Manager Console Fixes
Problem
Restaurant owners and clerks could not access the manager console. Multiple API routes had UUID vs numeric ID mismatches in authorization checks.
Fixes by Route
/api/admin/restaurants/route.ts
restaurantstable has nolegacy_numeric_idcolumn — replaced withidowner_user_idis UUID but was queried with numericlegacy_numeric_id— switched toauth.uid- Added
assignmentstable lookup so assigned restaurants (not just owned) are found
/api/admin/orders/route.ts
userHasAssignmentForRestaurantwas querying UUID column with numeric ID — fixed to useauth.uid- Owner check was comparing UUID with number — fixed to compare UUIDs
/api/admin/orders/[orderId]/route.ts
- Same UUID fix for assignment lookup in both GET and PATCH handlers
/api/order-detail/[orderId]/route.ts
- Response was missing
firestore_idon order object — addedfirestore_id: String(order.id) - Same UUID fix for assignment lookup
SWR Performance Fix
Page transitions were very slow due to aggressive SWR config in src/lib/swrConfig.ts:
| Setting | Before | After |
|---|---|---|
| revalidateOnFocus | true | false |
| dedupingInterval | 2000ms (2s) | 30000ms (30s) |
| keepPreviousData | not set | true |
This means navigating back to a previously visited page shows cached data instantly instead of a loading spinner, and switching browser tabs no longer triggers refetches.