FastAPI backend (Python 3.11, MSSQL ODBC for SambaPOS, Azure DI OCR),
kitchen_db on central PG. React/TS/Vite frontend with navy sidebar layout.
Backend: auth.py (APP_SLUG=kitchen, SimpleNamespace — archive routes use
.kitchen_id/.is_admin without modification), main.py (51 migrations, scheduler,
internal router for KDS bookings feed), api/internal.py, full archive API
(31 routers: invoices, recipes, menus, sambapos, resos, newbook, disputes,
purchase_orders, etc.), models, migrations, OCR pipeline.
kitchen_id pinned to 1 (B1 — single hotel).
Frontend: AuthGate (app=kitchen, token shim for archive compat — B5b pending),
Layout (navy sidebar, 6 sections, Lucide icons, teal --app-primary),
App.tsx (Outlet pattern, UploadApp outside Layout), index.css (full :root block).
strict: false — archive components have type issues; build clean.
Note: 45 archive components call fetch('/api/...') without /kitchen/ prefix
(B5b). Runtime 404s; deferred until after initial testing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
107 lines
No EOL
3.3 KiB
JavaScript
107 lines
No EOL
3.3 KiB
JavaScript
"use client";
|
|
|
|
// src/useQueries.ts
|
|
import * as React from "react";
|
|
import {
|
|
QueriesObserver,
|
|
QueryObserver,
|
|
noop,
|
|
notifyManager
|
|
} from "@tanstack/query-core";
|
|
import { useQueryClient } from "./QueryClientProvider.js";
|
|
import { useIsRestoring } from "./IsRestoringProvider.js";
|
|
import { useQueryErrorResetBoundary } from "./QueryErrorResetBoundary.js";
|
|
import {
|
|
ensurePreventErrorBoundaryRetry,
|
|
getHasError,
|
|
useClearResetErrorBoundary
|
|
} from "./errorBoundaryUtils.js";
|
|
import {
|
|
ensureSuspenseTimers,
|
|
fetchOptimistic,
|
|
shouldSuspend
|
|
} from "./suspense.js";
|
|
function useQueries({
|
|
queries,
|
|
...options
|
|
}, queryClient) {
|
|
const client = useQueryClient(queryClient);
|
|
const isRestoring = useIsRestoring();
|
|
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
const defaultedQueries = React.useMemo(
|
|
() => queries.map((opts) => {
|
|
const defaultedOptions = client.defaultQueryOptions(
|
|
opts
|
|
);
|
|
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
return defaultedOptions;
|
|
}),
|
|
[queries, client, isRestoring]
|
|
);
|
|
defaultedQueries.forEach((queryOptions) => {
|
|
ensureSuspenseTimers(queryOptions);
|
|
const query = client.getQueryCache().get(queryOptions.queryHash);
|
|
ensurePreventErrorBoundaryRetry(queryOptions, errorResetBoundary, query);
|
|
});
|
|
useClearResetErrorBoundary(errorResetBoundary);
|
|
const [observer] = React.useState(
|
|
() => new QueriesObserver(
|
|
client,
|
|
defaultedQueries,
|
|
options
|
|
)
|
|
);
|
|
const [optimisticResult, getCombinedResult, trackResult] = observer.getOptimisticResult(
|
|
defaultedQueries,
|
|
options.combine
|
|
);
|
|
const shouldSubscribe = !isRestoring && options.subscribed !== false;
|
|
React.useSyncExternalStore(
|
|
React.useCallback(
|
|
(onStoreChange) => shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop,
|
|
[observer, shouldSubscribe]
|
|
),
|
|
() => observer.getCurrentResult(),
|
|
() => observer.getCurrentResult()
|
|
);
|
|
React.useEffect(() => {
|
|
observer.setQueries(
|
|
defaultedQueries,
|
|
options
|
|
);
|
|
}, [defaultedQueries, options, observer]);
|
|
const shouldAtLeastOneSuspend = optimisticResult.some(
|
|
(result, index) => shouldSuspend(defaultedQueries[index], result)
|
|
);
|
|
const suspensePromises = shouldAtLeastOneSuspend ? optimisticResult.flatMap((result, index) => {
|
|
const opts = defaultedQueries[index];
|
|
if (opts && shouldSuspend(opts, result)) {
|
|
const queryObserver = new QueryObserver(client, opts);
|
|
return fetchOptimistic(opts, queryObserver, errorResetBoundary);
|
|
}
|
|
return [];
|
|
}) : [];
|
|
if (suspensePromises.length > 0) {
|
|
throw Promise.all(suspensePromises);
|
|
}
|
|
const firstSingleResultWhichShouldThrow = optimisticResult.find(
|
|
(result, index) => {
|
|
const query = defaultedQueries[index];
|
|
return query && getHasError({
|
|
result,
|
|
errorResetBoundary,
|
|
throwOnError: query.throwOnError,
|
|
query: client.getQueryCache().get(query.queryHash),
|
|
suspense: query.suspense
|
|
});
|
|
}
|
|
);
|
|
if (firstSingleResultWhichShouldThrow == null ? void 0 : firstSingleResultWhichShouldThrow.error) {
|
|
throw firstSingleResultWhichShouldThrow.error;
|
|
}
|
|
return getCombinedResult(trackResult());
|
|
}
|
|
export {
|
|
useQueries
|
|
};
|
|
//# sourceMappingURL=useQueries.js.map
|