diff --git a/src/components/pages/inventory/product/InventoryProductTable.tsx b/src/components/pages/inventory/product/InventoryProductTable.tsx index 316bd103..cfbc284a 100644 --- a/src/components/pages/inventory/product/InventoryProductTable.tsx +++ b/src/components/pages/inventory/product/InventoryProductTable.tsx @@ -2,13 +2,8 @@ import Button from '@/components/Button'; import DebouncedTextInput from '@/components/input/DebouncedTextInput'; -import SelectInput, { OptionType } from '@/components/input/SelectInput'; import Table from '@/components/Table'; -import RowCollapseOptions from '@/components/table/RowCollapseOptions'; -import RowDropdownOptions from '@/components/table/RowDropdownOptions'; -import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RequirePermission from '@/components/helper/RequirePermission'; -import { ROWS_OPTIONS } from '@/config/constant'; import { isResponseSuccess } from '@/lib/api-helper'; import { cn, formatCurrency, formatNumber } from '@/lib/helper'; import { InventoryProductApi } from '@/services/api/inventory'; @@ -18,28 +13,59 @@ import { Icon } from '@iconify/react'; import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table'; import { ChangeEventHandler, useMemo, useState } from 'react'; import useSWR from 'swr'; +import PopoverButton from '@/components/popover/PopoverButton'; +import PopoverContent from '@/components/popover/PopoverContent'; const RowOptionsMenu = ({ - type = 'dropdown', + popoverPosition = 'bottom', props, }: { - type: 'dropdown' | 'collapse'; + popoverPosition: 'bottom' | 'top'; props: CellContext; -}) => ( - - - - - -); + + + + +
+ + + +
+
+ + ); +}; const InventoryProductTable = () => { const { @@ -69,16 +95,10 @@ const InventoryProductTable = () => { updateFilter('search', e.target.value); }; - const pageSizeChangeHandler = (val: OptionType | OptionType[] | null) => { - const newVal = val as OptionType; - setPageSize(newVal.value as number); - setPage(1); - }; - const columns: ColumnDef[] = useMemo( () => [ { - header: '#', + header: 'No', cell: (props) => tableFilterState.pageSize * (tableFilterState.page - 1) + props.row.index + @@ -125,7 +145,7 @@ const InventoryProductTable = () => { }, { header: 'Aksi', - cell: (props) => { + cell: (props: CellContext) => { const currentPageSize = props.table.getPaginationRowModel().rows.length; const currentPageRows = props.table.getPaginationRowModel().flatRows; @@ -135,58 +155,57 @@ const InventoryProductTable = () => { const isLast2Rows = currentRowRelativeIndex > currentPageSize - 2; return ( - <> - {currentPageSize > 2 && ( - - - - )} - - {currentPageSize <= 2 && ( - - - - )} - + ); }, }, ], - [] + [tableFilterState.pageSize, tableFilterState.page] ); return ( - <> -
-
-
-
-
- -
- - -
+
+ {/* Header Section */} +
+ {/* Action Buttons */} +
+ + +
+ {/* Search */} +
+ + } + className={{ + wrapper: 'w-full min-w-24 max-w-3xs', + inputWrapper: 'rounded-xl! shadow-button-soft', + input: + 'placeholder:font-semibold placeholder:text-base-content/50', + }} + /> +
+
+ + {/* Table Section */} +
data={ isResponseSuccess(inventoryProducts) ? inventoryProducts?.data : [] @@ -204,27 +223,21 @@ const InventoryProductTable = () => { : 0 } onPageChange={setPage} + onPageSizeChange={setPageSize} isLoading={isLoading} sorting={sorting} setSorting={setSorting} className={{ - containerClassName: cn({ - 'mb-20': + containerClassName: cn('p-3 mb-0', { + 'w-full': isResponseSuccess(inventoryProducts) && inventoryProducts?.data?.length === 0, }), - tableWrapperClassName: 'overflow-x-auto min-h-full!', - tableClassName: 'font-inter w-full table-auto min-h-full!', - headerRowClassName: 'border-b border-b-gray-200', - headerColumnClassName: - 'px-6 py-3 text-xs font-semibold text-gray-500 last:flex last:flex-row last:justify-end', - bodyRowClassName: 'border-b border-b-gray-200', - bodyColumnClassName: - 'px-6 py-3 last:flex last:flex-row last:justify-end', + headerColumnClassName: 'text-nowrap', }} />
- +
); };