fix(pos2): wait for branch before fetching menu + add left category sidebar
CI/CD / CI · API (dotnet build + test) (push) Failing after 3m20s
CI/CD / CI · Admin API (dotnet build) (push) Failing after 3m19s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m5s
CI/CD / CI · Admin Web (tsc) (push) Successful in 41s
CI/CD / CI · Website (tsc) (push) Successful in 44s
CI/CD / CI · Koja (tsc) (push) Successful in 52s
CI/CD / Deploy · all services (push) Has been cancelled
CI/CD / CI · API (dotnet build + test) (push) Failing after 3m20s
CI/CD / CI · Admin API (dotnet build) (push) Failing after 3m19s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m5s
CI/CD / CI · Admin Web (tsc) (push) Successful in 41s
CI/CD / CI · Website (tsc) (push) Successful in 44s
CI/CD / CI · Koja (tsc) (push) Successful in 52s
CI/CD / Deploy · all services (push) Has been cancelled
Race fix: orderBranchId now returns `undefined` (not null) while the /branches query is in flight. usePos2Menu treats undefined as "not yet determined" and skips the fetch, preventing getBranchMenu(cafeId, null) → empty array. Once branchesFetched=true, orderBranchId resolves to the correct branchId (or null for café-wide fallback). Layout: desktop order screen now shows a left vertical category sidebar (116 px, md+) instead of horizontal chips, giving the classic POS sidebar feel. Horizontal chips kept for mobile (<md). Menu grid columns adjusted. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,13 @@ export function usePos2Categories(cafeId?: string | null) {
|
||||
}
|
||||
|
||||
/** Branch-scoped menu (effective prices) when a branch is selected; otherwise the
|
||||
* café-wide menu. Both normalize to MenuItem so the cart store can consume them. */
|
||||
* café-wide menu. Both normalize to MenuItem so the cart store can consume them.
|
||||
*
|
||||
* Pass `branchId = undefined` (not null) while still determining which branch to
|
||||
* use — the query will pause until branchId is resolved. Once resolved:
|
||||
* • string → branch-scoped menu via getBranchMenu
|
||||
* • null → café-wide fallback via /menu/items
|
||||
*/
|
||||
export function usePos2Menu(cafeId?: string | null, branchId?: string | null) {
|
||||
return useQuery({
|
||||
queryKey: ["pos2-menu", cafeId, branchId ?? "cafe"],
|
||||
@@ -33,7 +39,8 @@ export function usePos2Menu(cafeId?: string | null, branchId?: string | null) {
|
||||
}
|
||||
return apiGet<MenuItem[]>(`/api/cafes/${cafeId}/menu/items`);
|
||||
},
|
||||
enabled: !!cafeId,
|
||||
// branchId === undefined means "still determining" — don't fire yet
|
||||
enabled: !!cafeId && branchId !== undefined,
|
||||
staleTime: 30_000,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user