Skip to content

Commit

Permalink
added stock total
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardarhia committed Aug 23, 2024
1 parent a79aaad commit eec2d10
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/pages/products/ProductListsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "sonner";
import { usePermission } from "@/hooks/usePermission";
import { formatCurrency } from "@/helpers";

const ProductListsScreen = () => {
const { removeItemFromList } = useOptimisticUpdates();
Expand Down Expand Up @@ -90,12 +91,16 @@ const ProductListsScreen = () => {
const actionButton = !canCreateProducts
? undefined
: {
createButton: {
name: "Create Product",
onClick: () => navigate("/products/create"),
disabled: isFetching || !canCreateProducts
}
};
createButton: {
name: "Create Product",
onClick: () => navigate("/products/create"),
disabled: isFetching || !canCreateProducts
}
};
const products = data?.data || []
const stockTotal = products.reduce((prev, current) => {
return (current.totalProductPrice || 0) + prev;
}, 0)
return (
<DashboardLayout pageTitle="Products List" actionButton={actionButton}>
<Modal
Expand All @@ -105,9 +110,12 @@ const ProductListsScreen = () => {
actionButtons={modalData.actionButtons}
/>
<Container className="border border-gray-50">
<div className="flex items-end justify-end mb-5">
<p>Stock Total: <span className="font-medium text-sm">{formatCurrency({ value: stockTotal })}</span></p>
</div>
<Table
columns={productTableSchema}
data={data?.data || []}
data={products}
paginator={data?.paginator || null}
allowRowSelect
showSelectColumns
Expand Down

0 comments on commit eec2d10

Please sign in to comment.