From 94e7b997127ed0bbdc8a7c9fde828a9d04480941 Mon Sep 17 00:00:00 2001 From: Firman Ramdhani <33869609+firmanramdhani@users.noreply.github.com> Date: Thu, 23 Jul 2026 16:50:09 +0700 Subject: [PATCH] refactor: remove unused DataTable component and clean up filter logic in FullPagePageIndex --- .../presentation/components/data-table.tsx | 261 ------------------ .../components/filter-content.tsx | 16 +- .../pages/full-page.page.index.tsx | 17 -- .../core-i18n/src/languages/en/common.json | 2 +- .../core-i18n/src/languages/id/common.json | 2 +- .../components/data-table/index.tsx | 28 +- .../providers/detail-page.provider.tsx | 2 +- 7 files changed, 20 insertions(+), 308 deletions(-) delete mode 100644 apps/web/src/apps/modules/example/full-page/presentation/components/data-table.tsx diff --git a/apps/web/src/apps/modules/example/full-page/presentation/components/data-table.tsx b/apps/web/src/apps/modules/example/full-page/presentation/components/data-table.tsx deleted file mode 100644 index 4f88c99..0000000 --- a/apps/web/src/apps/modules/example/full-page/presentation/components/data-table.tsx +++ /dev/null @@ -1,261 +0,0 @@ -import { useState, useCallback } from 'react'; -import { - Table, - Box, - Paper, - Badge, - Text, - Group, - Button, - TextInput, - Pagination, - Select, - ScrollArea, -} from '@repo/ui/components'; -import { PageActions } from '@repo/ui/components'; -import { useEnterpriseModuleTranslationContext, useEnterpriseModuleNavigationContext } from '@repo/ui/foundations'; -import { FullPageEntity } from '../../domain/entities'; -import { Edit2, Eye, Copy, Trash2, Search, Filter, CheckCircle2, Ban } from 'lucide-react'; - -// TODO: Replace this mock data with real API data loaded from DataService via useEnterpriseModuleDataServiceContext -const MOCK_DATA: FullPageEntity[] = Array.from({ length: 50 }).map((_, i) => ({ - id: String(i + 1), - name: `Database Cluster ${i + 1}`, - code: `DB-PROD-${String(i + 1).padStart(3, '0')}`, - status: i % 7 === 0 ? 'MAINTENANCE' : i % 4 === 0 ? 'INACTIVE' : 'ACTIVE', - description: `Managed PostgreSQL cluster instance in region us-east-${(i % 3) + 1}`, -})); - -export function DataTable() { - const { t } = useEnterpriseModuleTranslationContext(); - const { navigateToDetail, navigateToEdit, navigateToDuplicate } = useEnterpriseModuleNavigationContext(); - - const [page, setPage] = useState(1); - const [pageSize, setPageSize] = useState(10); - - const totalRecords = MOCK_DATA.length; - const totalPages = Math.ceil(totalRecords / pageSize); - const paginatedData = MOCK_DATA.slice((page - 1) * pageSize, page * pageSize); - - const getRowActions = useCallback( - (row: FullPageEntity) => [ - { - key: 'view', - label: t('common:view'), - icon: , - onClick: () => navigateToDetail(row.id as string), - }, - { - key: 'edit', - label: t('common:edit'), - icon: , - onClick: () => navigateToEdit(row.id as string), - }, - { - key: 'duplicate', - label: t('common:duplicate'), - icon: , - onClick: () => navigateToDuplicate(row.id as string), - }, - { - type: 'divider' as const, - key: 'div-1', - }, - { - key: 'delete', - label: t('common:delete'), - icon: , - intent: 'destructive' as const, - onClick: () => { - // Mock delete action - alert(`Delete ${row.name}`); - }, - }, - ], - [t, navigateToDetail, navigateToEdit, navigateToDuplicate], - ); - - const rows = paginatedData.map((item) => ( - - - - {item.code} - - - - - {item.name} - - - - - {item.status} - - - - - {item.description} - - - - - - - )); - - return ( - - {/* --- TABLE TOOLBAR --- */} - - - - } - size="sm" - radius="md" - w={280} - /> - - - - - - - - - - - - - {/* --- END TABLE TOOLBAR --- */} - - - - - - - {t('fields.code')} - - - {t('fields.name')} - - - {t('fields.status')} - - - {t('fields.description')} - - - Actions - - - - {rows} -
-
- - {/* --- PAGINATION FOOTER --- */} - - - - Showing{' '} - - {(page - 1) * pageSize + 1} - {' '} - to{' '} - - {Math.min(page * pageSize, totalRecords)} - {' '} - of{' '} - - {totalRecords} - {' '} - entries - - - - - Rows per page: - -