mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 14:04:08 +01:00
feat: enhance status display in inventory table with conditional styling
This commit is contained in:
parent
e004c62941
commit
0df2d8241e
@ -59,6 +59,7 @@ export default function InventoryPage() {
|
|||||||
queryFn: fetchInventoryItems,
|
queryFn: fetchInventoryItems,
|
||||||
staleTime: 60 * 1000,
|
staleTime: 60 * 1000,
|
||||||
});
|
});
|
||||||
|
// console.table(inventoryItems);
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
const handleSearch = () => {
|
const handleSearch = () => {
|
||||||
// update search state when user clicks or presses enter
|
// update search state when user clicks or presses enter
|
||||||
@ -79,29 +80,23 @@ export default function InventoryPage() {
|
|||||||
{
|
{
|
||||||
accessorKey: "status",
|
accessorKey: "status",
|
||||||
header: "Status",
|
header: "Status",
|
||||||
cell: (info: {
|
cell: (info: { getValue: () => string }) => {
|
||||||
getValue: () =>
|
const status = info.getValue();
|
||||||
| string
|
|
||||||
| number
|
let statusClass = ""; // default status class
|
||||||
| bigint
|
|
||||||
| boolean
|
if (status === "Low Stock") {
|
||||||
| ReactElement<unknown, string | JSXElementConstructor<any>>
|
statusClass = "bg-yellow-300"; // yellow for low stock
|
||||||
| Iterable<ReactNode>
|
} else if (status === "Out of Stock") {
|
||||||
| ReactPortal
|
statusClass = "bg-red-500 text-white"; // red for out of stock
|
||||||
| Promise<
|
}
|
||||||
| string
|
|
||||||
| number
|
return (
|
||||||
| bigint
|
<Badge className={`py-1 px-2 rounded-md ${statusClass}`}>
|
||||||
| boolean
|
{status}
|
||||||
| ReactPortal
|
</Badge>
|
||||||
| ReactElement<unknown, string | JSXElementConstructor<any>>
|
);
|
||||||
| Iterable<ReactNode>
|
},
|
||||||
| null
|
|
||||||
| undefined
|
|
||||||
>
|
|
||||||
| null
|
|
||||||
| undefined;
|
|
||||||
}) => <Badge>{info.getValue()}</Badge>,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "edit",
|
accessorKey: "edit",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user