shift fix

This commit is contained in:
2026-09-25 16:19:51 +05:30
parent 9314771aa8
commit 21818320a0
5 changed files with 287 additions and 88 deletions

View File

@@ -637,11 +637,23 @@ export function usePosRoles() {
});
}
export function useStaffShifts(tenantid: number | undefined, locationid: number | undefined) {
/**
* The shift windows this tenant's staff can be put on.
*
* Tenant-scoped, and the branch is optional. A shift is a fact about how a
* business runs — a tenant working 07:00–15:00 works those hours at every shop
* it owns — so requiring an outlet meant re-entering the same two windows per
* branch, which is how the third branch quietly ends up on 07:00–15:30.
*
* Passing a branch narrows the list to the tenant's shifts plus that branch's
* own, for the shops that genuinely differ. Omitting it returns everything the
* tenant has, which is what the pickers want.
*/
export function useStaffShifts(tenantid: number | undefined, locationid?: number) {
return useQuery({
queryKey: queryKeys.people.shifts(tenantid ?? 0, locationid ?? 0),
queryFn: () => posUsersApi.shifts(tenantid as number, locationid as number),
enabled: Boolean(tenantid) && Boolean(locationid),
queryFn: () => posUsersApi.shifts(tenantid as number, locationid),
enabled: Boolean(tenantid),
...stable,
});
}