feat(tables): implement sortable columns across various table components

- Added TableSortProvider to manage sorting state in AdminsTable, CmsTable, CompaniesTable, CustomersTable, TendersTable, and CompanyCategoriesTable.
- Enhanced TableHead component to support sortable columns with visual indicators for sort direction.
- Introduced columnSortKeys and columnDefaultOrder mappings in respective table presenters to define sortable fields and default sorting behavior.
- Updated useCompanyListPresenter, useCmsTablePresenter, useCustomerListPresenter, useTenderListPresenter, and useCompanyCategoriesPresenter to handle sorting logic and state management.
- Improved user experience by allowing dynamic sorting of table data based on user interactions.
This commit is contained in:
AmirReza Jamali
2026-05-31 10:48:08 +03:30
parent 5ef0298840
commit 46ddc018a6
16 changed files with 971 additions and 54 deletions
+26 -5
View File
@@ -10,6 +10,7 @@ import {
TableHead,
TableHeader,
TableRow,
TableSortProvider,
} from "@/components/ui/table";
import IsVisible from "@/components/ui/IsVisible";
import ListHeader from "@/components/ui/ListHeader";
@@ -25,6 +26,11 @@ import useTenderListPresenter from "./useTenderListPresenter";
const TendersTable = () => {
const {
columns,
columnSortKeys,
columnDefaultOrder,
sortBy,
sortOrder,
handleSortChange,
filterRegister,
handleFilterSubmit,
search,
@@ -67,14 +73,28 @@ const TendersTable = () => {
onClearAll={clearAllFilters}
/>
<div ref={tableSectionRef}>
<TableSortProvider
sortKey={sortBy}
sortOrder={sortOrder}
onSortChange={handleSortChange}
>
<Table>
<TableHeader>
<TableRow className="border-none uppercase [&>th]:text-start">
{columns.map((column) => (
<TableHead key={column} colSpan={100}>
{column}
</TableHead>
))}
{columns.map((column) => {
const sortKey = columnSortKeys[column];
return (
<TableHead
key={column}
colSpan={100}
sortable={Boolean(sortKey)}
sortKey={sortKey}
defaultSortOrder={columnDefaultOrder[column]}
>
{column}
</TableHead>
);
})}
</TableRow>
</TableHeader>
@@ -153,6 +173,7 @@ const TendersTable = () => {
</TableBody>
)}
</Table>
</TableSortProvider>
</div>
<IsVisible condition={shouldShowPagination}>
<Pagination