stock request
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
FIESTA_APPLOCATION_ID,
|
||||
FIESTA_PRIMARY_LOCATION_ID,
|
||||
getOrderSummary,
|
||||
getSalesSummary,
|
||||
getRevenueSummary,
|
||||
getTimeSeries,
|
||||
getLocationSummary,
|
||||
@@ -61,6 +62,7 @@ import {
|
||||
CreateTenantLocationInput,
|
||||
updateTenantLocation,
|
||||
UpdateTenantLocationInput,
|
||||
deleteLocation,
|
||||
createProductLocation,
|
||||
createStockRequest,
|
||||
getStockRequests,
|
||||
@@ -73,6 +75,8 @@ import {
|
||||
export const fiestaKeys = {
|
||||
orderSummary: (tenantid: number, fromdate: string, todate: string, locationid?: number) =>
|
||||
['fiesta', 'orderSummary', tenantid, fromdate, todate, locationid ?? 0] as const,
|
||||
salesSummary: (tenantid: number, locationid: number | undefined, fromdate: string, todate: string) =>
|
||||
['fiesta', 'salesSummary', tenantid, locationid, fromdate, todate] as const,
|
||||
revenueSummary: (params: Record<string, unknown>) => ['fiesta', 'revenueSummary', params] as const,
|
||||
timeSeries: (params: Record<string, unknown>) => ['fiesta', 'timeSeries', params] as const,
|
||||
locationSummary: (tenantid: number) => ['fiesta', 'locationSummary', tenantid] as const,
|
||||
@@ -143,6 +147,19 @@ export function useFiestaTimeSeries(opts: {
|
||||
});
|
||||
}
|
||||
|
||||
export function useFiestaSalesSummary(opts: {
|
||||
tenantid: number;
|
||||
locationid?: number;
|
||||
fromdate: string;
|
||||
todate: string;
|
||||
}) {
|
||||
return useQuery({
|
||||
queryKey: fiestaKeys.salesSummary(opts.tenantid, opts.locationid, opts.fromdate, opts.todate),
|
||||
queryFn: () => getSalesSummary(opts),
|
||||
enabled: Boolean(opts.tenantid && opts.fromdate && opts.todate),
|
||||
});
|
||||
}
|
||||
|
||||
export function useFiestaLocationSummary(tenantid: number = FIESTA_TENANT_ID) {
|
||||
return useQuery({
|
||||
queryKey: fiestaKeys.locationSummary(tenantid),
|
||||
@@ -848,4 +865,15 @@ export function useLogin() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useFiestaDeleteLocation() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (input: { tenantid: number; locationid: number }) => deleteLocation(input),
|
||||
onSuccess: (_, variables) => {
|
||||
qc.invalidateQueries({ queryKey: fiestaKeys.tenantLocations(variables.tenantid) });
|
||||
qc.invalidateQueries({ queryKey: fiestaKeys.locationSummary(variables.tenantid) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export { FIESTA_TENANT_ID, FIESTA_APPLOCATION_ID, FIESTA_PRIMARY_LOCATION_ID };
|
||||
|
||||
Reference in New Issue
Block a user