@flowselections/pick-schermen-kwekers 1.0.64 → 1.0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/pick/PickScherm.d.ts +3 -1
- package/dist-lib/components/pick/PickScherm.d.ts.map +1 -1
- package/dist-lib/components/pick/PickScherm.js +18 -8
- package/dist-lib/components/pick/StickerReprintButton.d.ts.map +1 -1
- package/dist-lib/components/pick/StickerReprintButton.js +2 -1
- package/dist-lib/components/pick/StickerState.d.ts.map +1 -1
- package/dist-lib/components/pick/StickerState.js +21 -10
- package/dist-lib/hooks/useCartStickerStates.d.ts +8 -0
- package/dist-lib/hooks/useCartStickerStates.d.ts.map +1 -0
- package/dist-lib/hooks/useCartStickerStates.js +42 -0
- package/dist-lib/integrations/supabase/types.d.ts +328 -120
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/__tests__/pick167.test.d.ts +2 -0
- package/dist-lib/lib/__tests__/pick167.test.d.ts.map +1 -0
- package/dist-lib/lib/__tests__/pick167.test.js +25 -0
- package/dist-lib/lib/__tests__/pickStickerBundle.test.d.ts +2 -0
- package/dist-lib/lib/__tests__/pickStickerBundle.test.d.ts.map +1 -0
- package/dist-lib/lib/__tests__/pickStickerBundle.test.js +27 -0
- package/dist-lib/lib/pick159.js +1 -1
- package/dist-lib/lib/pick161.d.ts +15 -0
- package/dist-lib/lib/pick161.d.ts.map +1 -1
- package/dist-lib/lib/pick161.js +51 -0
- package/dist-lib/lib/pickStickerBundle.d.ts +20 -0
- package/dist-lib/lib/pickStickerBundle.d.ts.map +1 -0
- package/dist-lib/lib/pickStickerBundle.js +40 -0
- package/package.json +7 -2
- package/schema/pickschermen.sql +5332 -0
|
@@ -3,10 +3,12 @@ interface Props {
|
|
|
3
3
|
station: PickStation;
|
|
4
4
|
onBack?: () => void;
|
|
5
5
|
}
|
|
6
|
+
/** Taal per station op dit apparaat. */
|
|
7
|
+
export declare const langStorageKey: (stationId: string) => string;
|
|
6
8
|
/**
|
|
7
9
|
* Pickscherm. De Logistiek Engine bepaalt welke documenten zichtbaar zijn en
|
|
8
10
|
* in welke volgorde; dit scherm toont uitsluitend wat de wachtrij teruggeeft.
|
|
9
11
|
*/
|
|
10
|
-
export declare function PickScherm({ station, onBack }: Props): import("react").JSX.Element;
|
|
12
|
+
export declare function PickScherm({ station, onBack }: Props): import("react").JSX.Element | null;
|
|
11
13
|
export {};
|
|
12
14
|
//# sourceMappingURL=PickScherm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PickScherm.d.ts","sourceRoot":"","sources":["../../../src/components/pick/PickScherm.tsx"],"names":[],"mappings":"AA0DA,OAAO,EAaL,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"PickScherm.d.ts","sourceRoot":"","sources":["../../../src/components/pick/PickScherm.tsx"],"names":[],"mappings":"AA0DA,OAAO,EAaL,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AA8D7B,UAAU,KAAK;IACb,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAGD,wCAAwC;AACxC,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,WAAuC,CAAC;AAsBxF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,sCAosEpD"}
|
|
@@ -22,6 +22,7 @@ import { friendlyPickError, getPickUiTexts } from "../../lib/pickUiText.js";
|
|
|
22
22
|
import { getPrintJobTexts } from "../../lib/pickPrintJobText.js";
|
|
23
23
|
import { defaultFilters, usePickDays, usePickHeartbeat, usePickQueue, } from "../../hooks/usePickQueue.js";
|
|
24
24
|
import { usePickPrintStatus } from "../../hooks/usePickPrintStatus.js";
|
|
25
|
+
import { useCartStickerStates } from "../../hooks/useCartStickerStates.js";
|
|
25
26
|
import { activeDeviceKey } from "../../lib/pick159.js";
|
|
26
27
|
import { usePickDocumentTypes, usePickStatuses, useStationPrintPlek, } from "../../hooks/usePickConfig.js";
|
|
27
28
|
import { usePrintBatch, usePrintJob } from "../../hooks/usePrintJob.js";
|
|
@@ -35,6 +36,8 @@ import { isPrintBlocked } from "../../lib/pick156.js";
|
|
|
35
36
|
import { DocumentChoiceMelding, useDocumentChoice } from "./DocumentChoiceMelding.js";
|
|
36
37
|
import { isWaitingShippingNote, shippingNoteMessage, shippingNoteSourceLabel, } from "../../lib/shippingNoteStatus.js";
|
|
37
38
|
const LANG_STORAGE_KEY = "pick.language";
|
|
39
|
+
/** Taal per station op dit apparaat. */
|
|
40
|
+
export const langStorageKey = (stationId) => `${LANG_STORAGE_KEY}.${stationId}`;
|
|
38
41
|
/** Melding als de planning voor deze order geen karren heeft vastgelegd. */
|
|
39
42
|
/** Papier is geprint, maar de PDF-kopie op de werkplek is niet opgeslagen. */
|
|
40
43
|
const PDF_SAVE_NOTICE = "De pakbon is geprint, maar de PDF is niet op de werkplek opgeslagen. Geef de PDF-map in Layout maker opnieuw vrij.";
|
|
@@ -56,6 +59,7 @@ const NOT_READY_NOTICE = "Deze pakbon is nog niet printklaar. Klik op \"Pakbon o
|
|
|
56
59
|
export function PickScherm({ station, onBack }) {
|
|
57
60
|
const sessionId = getSessionId();
|
|
58
61
|
const [lang, setLang] = useState(null);
|
|
62
|
+
const [langLoaded, setLangLoaded] = useState(false);
|
|
59
63
|
const [filters, setFilters] = useState(defaultFilters);
|
|
60
64
|
const [chosenDay, setChosenDay] = useState(null);
|
|
61
65
|
const [loadingDay, setLoadingDay] = useState(false);
|
|
@@ -204,15 +208,16 @@ export function PickScherm({ station, onBack }) {
|
|
|
204
208
|
useEffect(() => {
|
|
205
209
|
if (typeof window === "undefined")
|
|
206
210
|
return;
|
|
207
|
-
const stored = window.localStorage.getItem(LANG_STORAGE_KEY);
|
|
211
|
+
const stored = window.localStorage.getItem(langStorageKey(station.id)) ?? window.localStorage.getItem(LANG_STORAGE_KEY);
|
|
208
212
|
if (stored)
|
|
209
213
|
setLang(stored);
|
|
210
|
-
|
|
214
|
+
setLangLoaded(true);
|
|
215
|
+
}, [station.id]);
|
|
211
216
|
const chooseLang = useCallback((code) => {
|
|
212
217
|
setLang(code);
|
|
213
218
|
if (typeof window !== "undefined")
|
|
214
|
-
window.localStorage.setItem(
|
|
215
|
-
}, []);
|
|
219
|
+
window.localStorage.setItem(langStorageKey(station.id), code);
|
|
220
|
+
}, [station.id]);
|
|
216
221
|
/** Zoeken pas na een korte pauze, zodat typen geen query per toets afvuurt. */
|
|
217
222
|
useEffect(() => {
|
|
218
223
|
const timer = setTimeout(() => {
|
|
@@ -232,6 +237,9 @@ export function PickScherm({ station, onBack }) {
|
|
|
232
237
|
const { result: printStatus, loading: printStatusLoading, inPrint, } = usePickPrintStatus(printStatusIds, activeDeviceKey() ? station.slug ?? null : null, lang !== null);
|
|
233
238
|
const inPrintRef = useRef(inPrint);
|
|
234
239
|
inPrintRef.current = inPrint;
|
|
240
|
+
// 1.0.65: stickerstand van alle karren van de order in één aanroep (openbaar station).
|
|
241
|
+
const stickerCartIds = useMemo(() => (Array.isArray(cartPlan?.carts) ? cartPlan.carts.map((c) => c.cartId).filter((x) => !!x) : []), [cartPlan]);
|
|
242
|
+
useCartStickerStates(stickerCartIds, station.slug ?? null);
|
|
235
243
|
/** Geprint maar nog niet gescand, van een eerdere pickdag (blijft open tot de scan). */
|
|
236
244
|
const viewDay = chosenDay ?? pickDay ?? null;
|
|
237
245
|
const { data: earlierRaw, refetch: refetchEarlier } = useQuery({
|
|
@@ -951,16 +959,16 @@ export function PickScherm({ station, onBack }) {
|
|
|
951
959
|
targets.push(item);
|
|
952
960
|
}
|
|
953
961
|
if (targets.length === 0) {
|
|
954
|
-
toast.warning("Er is geen enkele kar printklaar.");
|
|
962
|
+
toast.warning("Er is geen enkele kar printklaar.", { id: "pick-none-ready" });
|
|
955
963
|
for (const s of skipped.slice(0, 5))
|
|
956
|
-
toast.warning(`${s.title}: ${s.reason}`);
|
|
964
|
+
toast.warning(`${s.title}: ${s.reason}`, { id: `pick-skip-${s.title}` });
|
|
957
965
|
return;
|
|
958
966
|
}
|
|
959
967
|
if (targets.length < cartsPerPrint) {
|
|
960
|
-
toast.info(`Er zijn maar ${targets.length} van de ${cartsPerPrint} karren printklaar; alleen die worden geprint
|
|
968
|
+
toast.info(`Er zijn maar ${targets.length} van de ${cartsPerPrint} karren printklaar; alleen die worden geprint.`, { id: "pick-some-ready" });
|
|
961
969
|
}
|
|
962
970
|
for (const s of skipped.slice(0, 5))
|
|
963
|
-
toast.warning(`${s.title}: ${s.reason}`);
|
|
971
|
+
toast.warning(`${s.title}: ${s.reason}`, { id: `pick-skip-${s.title}` });
|
|
964
972
|
const doneUnits = new Set();
|
|
965
973
|
for (const item of targets) {
|
|
966
974
|
const unitKey = `${item.document_type_id ?? "-"}|${unitRefOf(item)}`;
|
|
@@ -1352,6 +1360,8 @@ export function PickScherm({ station, onBack }) {
|
|
|
1352
1360
|
autoFetched.current = false;
|
|
1353
1361
|
}, [pendingCount]);
|
|
1354
1362
|
// Stap 1 — taalselectie
|
|
1363
|
+
if (!langLoaded)
|
|
1364
|
+
return null;
|
|
1355
1365
|
if (lang === null) {
|
|
1356
1366
|
return (_jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 sm:flex sm:flex-wrap sm:justify-between", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h2", { className: "truncate text-xl font-bold text-foreground sm:text-2xl", children: station.name }), _jsx("p", { className: "text-sm text-muted-foreground", children: t("chooseLanguageHint") })] }), onBack && (_jsxs(Button, { variant: "outline", className: "shrink-0", onClick: onBack, children: [_jsx(ArrowLeft, { className: "mr-2 h-4 w-4" }), " ", t("back")] }))] }), _jsx(LanguageTiles, { onSelect: chooseLang })] }));
|
|
1357
1367
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StickerReprintButton.d.ts","sourceRoot":"","sources":["../../../src/components/pick/StickerReprintButton.tsx"],"names":[],"mappings":"AAMA,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"StickerReprintButton.d.ts","sourceRoot":"","sources":["../../../src/components/pick/StickerReprintButton.tsx"],"names":[],"mappings":"AAMA,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,sCAsE7F"}
|
|
@@ -17,7 +17,7 @@ export function StickerReprintButton({ cartId, slug }) {
|
|
|
17
17
|
refetchInterval: 15000,
|
|
18
18
|
placeholderData: (prev) => prev,
|
|
19
19
|
retry: 1,
|
|
20
|
-
enabled:
|
|
20
|
+
enabled: false, // gevuld door useCartStickerStates
|
|
21
21
|
});
|
|
22
22
|
if (!slug || !hasPrintedSticker(q.data))
|
|
23
23
|
return null;
|
|
@@ -41,6 +41,7 @@ export function StickerReprintButton({ cartId, slug }) {
|
|
|
41
41
|
finally {
|
|
42
42
|
setBusy(false);
|
|
43
43
|
qc.invalidateQueries({ queryKey: ["pick", "sticker-state", cartId] });
|
|
44
|
+
qc.invalidateQueries({ queryKey: ["pick", "sticker-bundle"] });
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
return (_jsxs("div", { className: "mt-3", children: [_jsx("button", { type: "button", onClick: () => setOpen(true), className: "rounded-md border bg-background px-3 py-2 text-sm font-medium text-foreground hover:bg-muted", children: "Stickers opnieuw printen" }), open && (_jsx("div", { role: "dialog", "aria-modal": "true", className: "fixed inset-0 z-50 flex items-center justify-center bg-foreground/40 p-4", children: _jsxs("div", { className: "w-full max-w-sm rounded-lg border bg-background p-4 shadow-lg", children: [_jsx("p", { className: "font-medium text-foreground", children: "Stickers van deze kar opnieuw printen?" }), _jsxs("label", { className: "mt-3 block text-sm text-muted-foreground", children: ["Reden (optioneel)", _jsx("input", { value: reden, onChange: (e) => setReden(e.target.value), disabled: busy, className: "mt-1 w-full rounded-md border bg-background px-2 py-1.5 text-sm text-foreground" })] }), detail && (_jsxs("details", { className: "mt-2 text-xs text-muted-foreground", children: [_jsx("summary", { className: "cursor-pointer", children: "Details voor beheer" }), _jsx("p", { children: detail })] })), _jsxs("div", { className: "mt-4 flex justify-end gap-2", children: [_jsx("button", { type: "button", disabled: busy, onClick: () => setOpen(false), className: "rounded-md border px-3 py-1.5 text-sm text-foreground", children: "Annuleren" }), _jsx("button", { type: "button", disabled: busy, onClick: run, className: "rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground disabled:opacity-60", children: busy ? "Bezig…" : "Opnieuw printen" })] })] }) }))] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StickerState.d.ts","sourceRoot":"","sources":["../../../src/components/pick/StickerState.tsx"],"names":[],"mappings":"AAcA,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"StickerState.d.ts","sourceRoot":"","sources":["../../../src/components/pick/StickerState.tsx"],"names":[],"mappings":"AAcA,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,sCAwC5F;AAED,6EAA6E;AAC7E,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,sCAoBvG;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,sCAuDzF;AAED,6HAA6H;AAC7H,wBAAgB,yBAAyB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,sCAiBpF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { fetchCartStickerState, fetchOrderStickerMeldingen, STICKER_UNKNOWN, stickerStatusLabel, } from "../../lib/pickStickers.js";
|
|
4
|
-
import {
|
|
4
|
+
import { stickerLineWithJobs } from "../../lib/pick161.js";
|
|
5
5
|
import { fetchUitwijk, fetchVroegeWaarschuwing, vroegeWaarschuwingText } from "../../lib/pickUitwijk.js";
|
|
6
6
|
import { fetchStickerFit, STICKER_FIT_UNKNOWN, stickerFitTone } from "../../lib/pick150.js";
|
|
7
7
|
const POLL = 15000;
|
|
@@ -10,11 +10,12 @@ export function StickerFitMeldingen({ cartId, slug }) {
|
|
|
10
10
|
const q = useQuery({
|
|
11
11
|
queryKey: ["pick", "sticker-fit", cartId, slug],
|
|
12
12
|
queryFn: () => fetchStickerFit(cartId, slug),
|
|
13
|
+
enabled: !slug, // openbaar station: gevuld door useCartStickerStates
|
|
13
14
|
refetchInterval: POLL,
|
|
14
15
|
placeholderData: (prev) => prev,
|
|
15
16
|
retry: 1,
|
|
16
17
|
});
|
|
17
|
-
if (q.
|
|
18
|
+
if (q.data === undefined && !q.isError)
|
|
18
19
|
return null;
|
|
19
20
|
if (q.isError || q.data == null) {
|
|
20
21
|
return _jsx("p", { className: "mt-3 text-xs text-muted-foreground", children: STICKER_FIT_UNKNOWN });
|
|
@@ -37,12 +38,12 @@ export function OrderStickerMeldingen({ orderId, slug }) {
|
|
|
37
38
|
const q = useQuery({
|
|
38
39
|
queryKey: ["pick", "sticker-meldingen", orderId, slug],
|
|
39
40
|
queryFn: () => fetchOrderStickerMeldingen(orderId, slug),
|
|
40
|
-
enabled: !!orderId,
|
|
41
|
+
enabled: !!orderId && !slug,
|
|
41
42
|
refetchInterval: POLL,
|
|
42
43
|
placeholderData: (prev) => prev,
|
|
43
44
|
retry: 1,
|
|
44
45
|
});
|
|
45
|
-
if (!orderId || q.
|
|
46
|
+
if (!orderId || (q.data === undefined && !q.isError))
|
|
46
47
|
return null;
|
|
47
48
|
if (q.isError || q.data == null) {
|
|
48
49
|
return _jsxs("p", { className: "mb-3 text-xs text-muted-foreground", children: ["Stickermeldingen: ", STICKER_UNKNOWN] });
|
|
@@ -57,6 +58,7 @@ export function CartStickerState({ cartId, slug }) {
|
|
|
57
58
|
const q = useQuery({
|
|
58
59
|
queryKey: ["pick", "sticker-state", cartId, slug],
|
|
59
60
|
queryFn: () => fetchCartStickerState(cartId, slug),
|
|
61
|
+
enabled: !slug,
|
|
60
62
|
refetchInterval: POLL,
|
|
61
63
|
placeholderData: (prev) => prev,
|
|
62
64
|
retry: 1,
|
|
@@ -65,20 +67,29 @@ export function CartStickerState({ cartId, slug }) {
|
|
|
65
67
|
const u = useQuery({
|
|
66
68
|
queryKey: ["pick", "uitwijk", jobIds.join(",")],
|
|
67
69
|
queryFn: () => fetchUitwijk(jobIds),
|
|
68
|
-
enabled: jobIds.length > 0,
|
|
70
|
+
enabled: !slug && jobIds.length > 0,
|
|
69
71
|
refetchInterval: POLL,
|
|
70
72
|
placeholderData: (prev) => prev,
|
|
71
73
|
retry: 1,
|
|
72
74
|
});
|
|
73
|
-
|
|
75
|
+
const jobs = useQuery({
|
|
76
|
+
queryKey: ["pick", "sticker-jobs", cartId, slug],
|
|
77
|
+
queryFn: () => null,
|
|
78
|
+
enabled: false, // gevuld door useCartStickerStates
|
|
79
|
+
});
|
|
80
|
+
const opdrachten = jobs.data?.opdrachten ?? null;
|
|
81
|
+
const hasJobs = Array.isArray(opdrachten) && opdrachten.length > 0;
|
|
82
|
+
if (q.data === undefined && !q.isError && !hasJobs)
|
|
74
83
|
return null;
|
|
75
|
-
if (q.isError || !q.data) {
|
|
84
|
+
if ((q.isError || !q.data) && !hasJobs) {
|
|
76
85
|
return _jsx("p", { className: "mt-3 text-xs text-muted-foreground", children: STICKER_UNKNOWN });
|
|
77
86
|
}
|
|
78
|
-
const s = q.data;
|
|
79
|
-
const line =
|
|
87
|
+
const s = q.data ?? null;
|
|
88
|
+
const line = stickerLineWithJobs(s, opdrachten, jobs.data?.tijdzone ?? null, u.data);
|
|
89
|
+
if (!s)
|
|
90
|
+
return _jsx("p", { className: "mt-3 text-sm text-foreground", children: line });
|
|
80
91
|
const regels = Array.isArray(s.regels) ? s.regels : [];
|
|
81
|
-
if (s.totaal === 0)
|
|
92
|
+
if (s.totaal === 0 || hasJobs)
|
|
82
93
|
return _jsx("p", { className: "mt-3 text-sm text-muted-foreground", children: line });
|
|
83
94
|
return (_jsxs("details", { className: "mt-3 rounded-md border bg-background p-3 text-sm", children: [_jsxs("summary", { className: "cursor-pointer font-medium text-foreground", children: ["Stickers: ", line] }), _jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "In de printwachtrij betekent nog niet fysiek geprint." }), _jsx("ul", { className: "mt-2 divide-y", children: regels.map((r, i) => (_jsxs("li", { className: "flex flex-wrap justify-between gap-2 py-1.5 text-xs", children: [_jsxs("span", { className: "text-foreground", children: [r.soort ?? "sticker", " \u00B7 ", r.kopieen ?? "—", "x", r.breedteMm && r.hoogteMm ? ` · ${r.breedteMm}x${r.hoogteMm} mm` : ""] }), _jsxs("span", { className: "text-muted-foreground", children: [stickerStatusLabel(r.status), r.reden ? ` — ${r.reden}` : ""] })] }, r.stickerId ?? i))) })] }));
|
|
84
95
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const STICKER_POLL = 15000;
|
|
2
|
+
/**
|
|
3
|
+
* Openbaar pickstation: stickerstand, controle, meldingen en uitwijk voor alle
|
|
4
|
+
* karren van de order in één aanroep. Vult de cache van de losse onderdelen,
|
|
5
|
+
* die met een slug zelf niet meer opvragen.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useCartStickerStates(cartIds: string[], slug: string | null): import("@tanstack/react-query").UseQueryResult<import("../lib/pickStickerBundle.js").CartStickerBundleItem[], Error>;
|
|
8
|
+
//# sourceMappingURL=useCartStickerStates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCartStickerStates.d.ts","sourceRoot":"","sources":["../../src/hooks/useCartStickerStates.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,QAAS,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,qHA2B1E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
|
2
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { supabase } from "@flowselections/core";
|
|
4
|
+
import { keyedRpc } from "../lib/pick159.js";
|
|
5
|
+
import { parseCartStickerBundle } from "../lib/pickStickerBundle.js";
|
|
6
|
+
import { pickMeasure } from "../lib/pickPerf.js";
|
|
7
|
+
const db = keyedRpc(supabase);
|
|
8
|
+
export const STICKER_POLL = 15000;
|
|
9
|
+
/**
|
|
10
|
+
* Openbaar pickstation: stickerstand, controle, meldingen en uitwijk voor alle
|
|
11
|
+
* karren van de order in één aanroep. Vult de cache van de losse onderdelen,
|
|
12
|
+
* die met een slug zelf niet meer opvragen.
|
|
13
|
+
*/
|
|
14
|
+
export function useCartStickerStates(cartIds, slug) {
|
|
15
|
+
const qc = useQueryClient();
|
|
16
|
+
const ids = useMemo(() => Array.from(new Set(cartIds.filter(Boolean))).sort(), [cartIds]);
|
|
17
|
+
const q = useQuery({
|
|
18
|
+
queryKey: ["pick", "sticker-bundle", slug, ids.join(",")],
|
|
19
|
+
enabled: !!slug && ids.length > 0,
|
|
20
|
+
refetchInterval: STICKER_POLL,
|
|
21
|
+
retry: 1,
|
|
22
|
+
queryFn: async () => {
|
|
23
|
+
const { data, error } = await pickMeasure("stickerstand", () => db.rpc("pickstation_cart_sticker_states", { p_slug: slug, p_cart_ids: ids }));
|
|
24
|
+
if (error)
|
|
25
|
+
throw new Error(error.message);
|
|
26
|
+
return parseCartStickerBundle(data);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!q.data)
|
|
31
|
+
return;
|
|
32
|
+
for (const k of q.data) {
|
|
33
|
+
qc.setQueryData(["pick", "sticker-state", k.cartId, slug], k.stand);
|
|
34
|
+
qc.setQueryData(["pick", "sticker-fit", k.cartId, slug], k.controle);
|
|
35
|
+
if (k.orderId)
|
|
36
|
+
qc.setQueryData(["pick", "sticker-meldingen", k.orderId, slug], k.meldingen);
|
|
37
|
+
qc.setQueryData(["pick", "uitwijk", k.jobIds.join(",")], k.uitwijk);
|
|
38
|
+
qc.setQueryData(["pick", "sticker-jobs", k.cartId, slug], { opdrachten: k.opdrachten, tijdzone: k.tijdzone });
|
|
39
|
+
}
|
|
40
|
+
}, [q.data, qc, slug]);
|
|
41
|
+
return q;
|
|
42
|
+
}
|