mirror of
https://github.com/andwati/cymelle.git
synced 2026-11-24 00:48:46 +00:00
completed frontend v1
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import {getInventory, getLowStockInventory} from "#/api/inventory";
|
||||
import {useQuery} from "@tanstack/react-query";
|
||||
|
||||
export const inventoryQueryKeys = {
|
||||
all: ["inventory"] as const,
|
||||
list: () => [...inventoryQueryKeys.all, "list"] as const,
|
||||
lowStock: (threshold?: number) =>
|
||||
[...inventoryQueryKeys.all, "low-stock", threshold ?? "default"] as const,
|
||||
};
|
||||
|
||||
export function useInventory() {
|
||||
return useQuery({
|
||||
queryKey: inventoryQueryKeys.list(),
|
||||
queryFn: ({signal}) => getInventory(signal),
|
||||
});
|
||||
}
|
||||
|
||||
export function useLowStockInventory(threshold?: number) {
|
||||
return useQuery({
|
||||
queryKey: inventoryQueryKeys.lowStock(threshold),
|
||||
queryFn: ({signal}) => getLowStockInventory(threshold, signal),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user