fix: product and inventory

This commit is contained in:
ferdiansyah783
2025-08-13 23:53:03 +07:00
parent ea6205cfa7
commit ba7911d04b
28 changed files with 435 additions and 204 deletions
@@ -103,11 +103,13 @@ const StockListTable = () => {
const [currentPage, setCurrentPage] = useState(1)
const [pageSize, setPageSize] = useState(10)
const [addInventoryOpen, setAddInventoryOpen] = useState(false)
const [search, setSearch] = useState('')
// Fetch products with pagination and search
const { data, isLoading, error, isFetching } = useInventories({
page: currentPage,
limit: pageSize
limit: pageSize,
search
})
const inventories = data?.inventory ?? []
@@ -150,7 +152,7 @@ const StockListTable = () => {
},
columnHelper.accessor('product_id', {
header: 'Product',
cell: ({ row }) => <Typography>{row.original.product_id}</Typography>
cell: ({ row }) => <Typography>{row.original.product?.name}</Typography>
}),
columnHelper.accessor('quantity', {
header: 'Quantity',
@@ -171,32 +173,6 @@ const StockListTable = () => {
/>
)
})
// columnHelper.accessor('actions', {
// header: 'Actions',
// cell: ({ row }) => (
// <div className='flex items-center'>
// <OptionMenu
// iconButtonProps={{ size: 'medium' }}
// iconClassName='text-textSecondary'
// options={[
// { text: 'Download', icon: 'tabler-download' },
// {
// text: 'Delete',
// icon: 'tabler-trash',
// menuItemProps: {
// onClick: () => {
// setOpenConfirm(true)
// setProductId(row.original.id)
// }
// }
// },
// { text: 'Duplicate', icon: 'tabler-copy' }
// ]}
// />
// </div>
// ),
// enableSorting: false
// })
],
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
@@ -226,13 +202,13 @@ const StockListTable = () => {
return (
<>
<Card>
<CardHeader title='Filters' />
{/* <CardHeader title='Filters' /> */}
{/* <TableFilters setData={() => {}} productData={[]} /> */}
<Divider />
{/* <Divider /> */}
<div className='flex flex-wrap justify-between gap-4 p-6'>
<DebouncedInput
value={'search'}
onChange={value => console.log(value)}
value={search}
onChange={value => setSearch(String(value))}
placeholder='Search Product'
className='max-sm:is-full'
/>
@@ -261,7 +237,7 @@ const StockListTable = () => {
onClick={() => setAddInventoryOpen(!addInventoryOpen)}
startIcon={<i className='tabler-plus' />}
>
Adjust Inventory
Adjust Stock
</Button>
</div>
</div>
@@ -107,11 +107,13 @@ const StockListTable = () => {
const [openConfirm, setOpenConfirm] = useState(false)
const [productId, setProductId] = useState('')
const [addInventoryOpen, setAddInventoryOpen] = useState(false)
const [search, setSearch] = useState('')
// Fetch products with pagination and search
const { data, isLoading, error, isFetching } = useInventories({
page: currentPage,
limit: pageSize
limit: pageSize,
search
})
const { mutate: deleteInventory, isPending: isDeleting } = useInventoriesMutation().deleteInventory
@@ -162,7 +164,7 @@ const StockListTable = () => {
},
columnHelper.accessor('product_id', {
header: 'Product',
cell: ({ row }) => <Typography>{row.original.product_id}</Typography>
cell: ({ row }) => <Typography>{row.original.product?.name}</Typography>
}),
columnHelper.accessor('is_low_stock', {
header: 'Status',
@@ -241,8 +243,8 @@ const StockListTable = () => {
<Divider />
<div className='flex flex-wrap justify-between gap-4 p-6'>
<DebouncedInput
value={'search'}
onChange={value => console.log(value)}
value={search}
onChange={value => setSearch(value as string)}
placeholder='Search Product'
className='max-sm:is-full'
/>
@@ -271,7 +273,7 @@ const StockListTable = () => {
onClick={() => setAddInventoryOpen(!addInventoryOpen)}
startIcon={<i className='tabler-plus' />}
>
Add Inventory
Add Stock
</Button>
</div>
</div>