feat(contacts): sortable columns on the contacts table#52
Merged
Conversation
Click any column header on /contacts to sort; click again to reverse (▲/▼ indicator). Sort is server-side over the whole filtered set — not just the loaded page — so contacts that were emailed (imported long ago) surface to the top when sorting by "Last contacted" or "Status". - clients.ts: listClients accepts sort/dir, built from a column whitelist with ASC|DESC NULLS LAST (no user input in SQL). - api.ts: pass through sort/dir query params. - index.html: clickable headers, refetch sorted, i18n hint (EN/UA). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Клик по заголовку любой колонки на
/contactsсортирует таблицу; повторный клик — реверс (индикатор ▲/▼). Специально просили «Останній контакт» и «Статус».Why server-side
Сортировка выполняется на сервере по всей отфильтрованной выборке, а не только по загруженным 100 строкам. Иначе контакты, которым уже писали (импортированы давно), не всплывали бы наверх при сортировке по дате/статусу.
Changes
core/clients.ts—listClientsпринимаетsort/dir,ORDER BYстроится из whitelist колонок (name/email/org/region/segment/status/last) +ASC|DESC NULLS LAST. Пользовательский ввод в SQL не попадает.web/api.ts— пробросsort/dirиз query.web/public/index.html— кликабельные заголовки, refetch с сортировкой, i18n-подсказка (EN/UA).Verify
tsc --noEmit— clean.ORDER BY last_contacted_at DESC NULLS LASTна прод-данных: сверху корректно оказываются те, кому писали (mspcorporate, Inly, Intelex…).🤖 Generated with Claude Code