fix(FE): adjust data types for project flock and product stock inventory

This commit is contained in:
randy-ar
2025-12-04 16:13:47 +07:00
parent dc6b0eaec6
commit e0a8514814
5 changed files with 18 additions and 15 deletions
@@ -112,6 +112,15 @@ const InventoryProductTable = () => {
accessorFn: (row) => row.product_category.name,
header: 'Kategori',
},
{
accessorFn: (row) => row.total_stock,
header: 'Stok',
cell: (props) => {
return props.row.original.total_stock
? formatCurrency(props.row.original.total_stock)
: '-';
},
},
{
accessorFn: (row) => row.uom.name,
header: 'Satuan',
@@ -8,20 +8,9 @@ import { useMemo } from 'react';
const InventoryProductDetail = ({
inventoryProduct,
refresh,
}: {
inventoryProduct?: InventoryProduct;
refresh?: () => void;
}) => {
const totalStok = useMemo(() => {
return (
inventoryProduct?.product_warehouses?.reduce(
(total, warehouse) => total + (warehouse.current_stock || 0),
0
) || 0
);
}, [inventoryProduct]);
const stockLogs = useMemo(() => {
return (
inventoryProduct?.product_warehouses?.flatMap(
@@ -105,7 +94,11 @@ const InventoryProductDetail = ({
<tr>
<td className='font-semibold'>Total Stok</td>
<td>:</td>
<td>{formatNumber(totalStok)}</td>
<td>
{inventoryProduct?.total_stock
? formatNumber(inventoryProduct?.total_stock)
: '-'}
</td>
</tr>
</tbody>
</table>