Skip to content

feat(admin): migrate resource pages to shadcn DataTable/Dialog + toasts (#77)#83

Merged
ismetcahangirov merged 9 commits into
mainfrom
feat/m77-admin-datatable
Jul 9, 2026
Merged

feat(admin): migrate resource pages to shadcn DataTable/Dialog + toasts (#77)#83
ismetcahangirov merged 9 commits into
mainfrom
feat/m77-admin-datatable

Conversation

@ismetcahangirov

Copy link
Copy Markdown
Owner

Closes #77.

Migrates all seven admin resource pages onto a shared, TanStack-based DataTable with the shadcn/Base UI shell primitives, replacing bespoke tables/modals/native inputs. No backend changes — all existing data hooks are used as-is.

Foundation

  • Add @tanstack/react-table; build reusable components/admin/data-table/DataTable (server pagination via { page, pages, total, limit }, client-side sort, column visibility, toolbar search + filter slot + reset, skeleton/empty/error states, optional row selection), DataTableColumnHeader, DataTableViewOptions, DataTableFilterSelect, and a createSelectionColumn helper.
  • Mount the Sonner <Toaster> in the admin shell.
  • Add AdminConfirmDialog on the Base UI Dialog primitive (replaces the Modal-based confirm; supports an embedded note field).

Migrated pages

Page Highlights
Reviews status filter, approve/reject + delete via row dropdown, toasts
Users debounced search, role/status filters, admin-toggle guard preserved
Vendors status-transition dropdown, moderation-note dialog
Coupons Dialog form with Select (type) + Switch (isActive), client filtering
Orders search/status/payment/date toolbar, detail Dialog + status-update Select
Categories tree indentation + parent-cycle guard, image upload, SEO section
Products 5-tab Dialog (basic/pricing/images/attributes/seo), image queue, low-stock badges

All success/error feedback now uses parseApiError + Sonner toasts.

i18n

  • Reuse existing namespaces; add the missing DataTable/dialog keys and the new admin_coupons & admin_categories namespaces across az/en/ru (124 keys/locale).

Tests & checks

  • Rewrote the 4 existing admin page tests for the new structure; added DataTable unit tests.
  • lint ✅ · client test ✅ (58 files / 414 tests) · next build ✅.
  • Verified locally against the running backend (Playwright): all seven pages render with live data; create/edit dialogs, row-action dropdowns, filters, tree indentation, and toasts work; coupon edit → PUT 200 + success toast.

🤖 Generated with Claude Code

ismatjahangirov and others added 8 commits July 9, 2026 21:45
- Add @tanstack/react-table; build components/admin/data-table (DataTable,
  column header, view options, filter select) driving server pagination via
  existing { page, pages, total, limit }.
- Mount Sonner <Toaster> in the admin shell.
- Add AdminConfirmDialog on the Base UI Dialog primitive.
- Migrate reviews + users pages to DataTable + Select filters + row-action
  dropdowns + parseApiError toasts, preserving all filters/search/guards.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Vendors: DataTable + status-filter Select + row-action dropdown of allowed
  transitions; AdminConfirmDialog with moderation-note Textarea; toasts.
- Coupons: DataTable (client-side search/filter) + shadcn Dialog form with
  Select (type) and Switch (isActive); introduce admin_coupons i18n usage;
  AdminConfirmDialog delete; toasts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Orders list on DataTable with toolbar (search, status + payment Selects,
  date-range inputs, reset). Detail Modal -> shadcn Dialog; status-update
  native select -> Select, textarea -> Textarea; inline alerts -> toasts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Categories tree on DataTable (preserving indentation + parent-cycle guard);
  shadcn Dialog form with parent Select, image upload, SEO section, Switch;
  AdminConfirmDialog delete; toasts; introduce admin_categories i18n usage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Products list on DataTable with toolbar (debounced search, category/status/
  stock Selects). Modal -> shadcn Dialog with Tabs (basic/pricing/images/
  attributes/seo); native selects -> Select, checkboxes -> Switch, textareas ->
  Textarea; AdminConfirmDialog delete; parseApiError toasts. Preserves image
  upload queue, attribute/tag editors and low-stock warnings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…able tests (#77)

- Rewrite reviews/users/vendors/orders page tests against the new DataTable/
  Select/Dialog structure using lightweight mocks for the Base UI portal
  primitives; preserve all behavioral assertions (filters, search debounce,
  status transitions, admin guard, order status update + tracking).
- Add components/admin/data-table/data-table.test.tsx (render/loading/empty/
  error/search/pagination/sort).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-shopflow Ready Ready Preview, Comment Jul 9, 2026 6:59pm
shopflow Ready Ready Preview, Comment Jul 9, 2026 6:59pm

CI enforces 80% global coverage (v8). The DataTable-mock page tests exercised
column cells but not headers, dropping function coverage. Cover column header
render fns via the test double, add AdminConfirmDialog + fuller DataTable
(toolbar/selection/row-click) tests, and add data-variation cases (vendor
REJECTED/SUSPENDED, review/user fallbacks, order detail branches).

Coverage: statements 86.4%, branches 81.3%, functions 84.3%, lines 87.8%.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ismetcahangirov
ismetcahangirov merged commit 63e8abe into main Jul 9, 2026
9 checks passed
@ismetcahangirov
ismetcahangirov deleted the feat/m77-admin-datatable branch July 9, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(admin): Migrate resource pages to shadcn DataTable/Dialog + toasts

2 participants