@flowselections/floriday-verkoop-module 1.0.98 → 1.0.103
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/floriday/FlorydaySyncHealthBanner.d.ts +9 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts.map +1 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.js +26 -0
- package/dist-lib/components/karindeling/AfmetingenTab.d.ts +6 -0
- package/dist-lib/components/karindeling/AfmetingenTab.d.ts.map +1 -0
- package/dist-lib/components/karindeling/AfmetingenTab.js +128 -0
- package/dist-lib/components/karindeling/KarindelingPage.d.ts +2 -0
- package/dist-lib/components/karindeling/KarindelingPage.d.ts.map +1 -0
- package/dist-lib/components/karindeling/KarindelingPage.js +102 -0
- package/dist-lib/components/ui/dropdown-menu.d.ts +9 -0
- package/dist-lib/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist-lib/components/ui/dropdown-menu.js +14 -0
- package/dist-lib/components/verkoop/AnalyticsCards.d.ts +1 -1
- package/dist-lib/components/verkoop/AnalyticsCards.d.ts.map +1 -1
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts +4 -0
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts.map +1 -0
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.js +95 -0
- package/dist-lib/components/verkoop/CartAssignmentWizard.d.ts +1 -1
- package/dist-lib/components/verkoop/CartAssignmentWizard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CartLayersDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/CartLayersDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/ConfirmDialog.d.ts +11 -0
- package/dist-lib/components/verkoop/ConfirmDialog.d.ts.map +1 -0
- package/dist-lib/components/verkoop/ConfirmDialog.js +10 -0
- package/dist-lib/components/verkoop/CreateOrderDialog.d.ts +5 -0
- package/dist-lib/components/verkoop/CreateOrderDialog.d.ts.map +1 -0
- package/dist-lib/components/verkoop/CreateOrderDialog.js +33 -0
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.js +79 -15
- package/dist-lib/components/verkoop/DiagnoseConnectionDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/DiagnoseConnectionDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +11 -5
- package/dist-lib/components/verkoop/EngineBufferCard.d.ts +1 -1
- package/dist-lib/components/verkoop/EngineBufferCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/FloridayStageLine.d.ts +2 -2
- package/dist-lib/components/verkoop/FloridayStageLine.d.ts.map +1 -1
- package/dist-lib/components/verkoop/InvoiceTimingSettings.d.ts +1 -1
- package/dist-lib/components/verkoop/InvoiceTimingSettings.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderAfleverbrievenCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderAfleverbrievenCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.js +28 -2
- package/dist-lib/components/verkoop/OrderLinePackingCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderLinePackingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderLinePackingCard.js +1 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.js +16 -13
- package/dist-lib/components/verkoop/PlanCoverageBadge.d.ts +1 -1
- package/dist-lib/components/verkoop/PlanCoverageBadge.d.ts.map +1 -1
- package/dist-lib/components/verkoop/ProductDimensionsSettings.d.ts +1 -1
- package/dist-lib/components/verkoop/ProductDimensionsSettings.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +6 -6
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts +1 -2
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.d.ts +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.d.ts.map +1 -1
- package/dist-lib/components/verkoop/StockConsumptionAlertsBanner.d.ts +1 -1
- package/dist-lib/components/verkoop/StockConsumptionAlertsBanner.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/WeekCalendar.d.ts +1 -1
- package/dist-lib/components/verkoop/WeekCalendar.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.js +1 -1
- package/dist-lib/integrations/supabase/client.server.js +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +1055 -15
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.d.ts +20 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +129 -13
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts +4 -0
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts.map +1 -0
- package/dist-lib/lib/cron/mirror-floriday-orders.js +23 -0
- package/dist-lib/lib/cron/push-order-statuses.d.ts +4 -0
- package/dist-lib/lib/cron/push-order-statuses.d.ts.map +1 -0
- package/dist-lib/lib/cron/push-order-statuses.js +23 -0
- package/dist-lib/lib/customer-stickers.check.d.ts +2 -0
- package/dist-lib/lib/customer-stickers.check.d.ts.map +1 -0
- package/dist-lib/lib/customer-stickers.check.js +19 -0
- package/dist-lib/lib/customer-stickers.d.ts +14 -0
- package/dist-lib/lib/customer-stickers.d.ts.map +1 -0
- package/dist-lib/lib/customer-stickers.js +19 -0
- package/dist-lib/lib/departure-preview.check.js +24 -1
- package/dist-lib/lib/departure-preview.d.ts +25 -1
- package/dist-lib/lib/departure-preview.d.ts.map +1 -1
- package/dist-lib/lib/departure-preview.functions.d.ts +1 -0
- package/dist-lib/lib/departure-preview.functions.d.ts.map +1 -1
- package/dist-lib/lib/departure-preview.functions.js +1 -0
- package/dist-lib/lib/departure-preview.js +65 -2
- package/dist-lib/lib/departure-preview.server.d.ts +1 -0
- package/dist-lib/lib/departure-preview.server.d.ts.map +1 -1
- package/dist-lib/lib/departure-preview.server.js +3 -0
- package/dist-lib/lib/floriday/floriday.server.d.ts +14 -0
- package/dist-lib/lib/floriday/floriday.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday/floriday.server.js +92 -0
- package/dist-lib/lib/floriday/sales-orders.functions.d.ts +4736 -0
- package/dist-lib/lib/floriday/sales-orders.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday/sales-orders.functions.js +193 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +77581 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.js +65 -0
- package/dist-lib/lib/floriday-auto-fulfillment.server.d.ts +21 -0
- package/dist-lib/lib/floriday-auto-fulfillment.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-auto-fulfillment.server.js +352 -0
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.js +54 -1
- package/dist-lib/lib/floriday-status-sync.server.d.ts +14 -0
- package/dist-lib/lib/floriday-status-sync.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-status-sync.server.js +130 -0
- package/dist-lib/lib/invoice-timing.server.d.ts +3 -1
- package/dist-lib/lib/invoice-timing.server.d.ts.map +1 -1
- package/dist-lib/lib/invoice-timing.server.js +3 -2
- package/dist-lib/lib/module-version.d.ts +2 -0
- package/dist-lib/lib/module-version.d.ts.map +1 -0
- package/dist-lib/lib/module-version.js +3 -0
- package/dist-lib/lib/order-item-packing.functions.d.ts +2 -0
- package/dist-lib/lib/order-item-packing.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-item-packing.functions.js +2 -1
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +2 -1
- package/dist-lib/lib/salesorders-mapping.d.ts +2 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.js +4 -0
- package/dist-lib/lib/tradeitems.functions.d.ts +12 -1117
- package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
- package/dist-lib/lib/useBufferEvents.d.ts +2 -2
- package/dist-lib/lib/useBufferEvents.d.ts.map +1 -1
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts +2 -2
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrderDetailQuery.d.ts +1 -1
- package/dist-lib/lib/useSalesOrderDetailQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.d.ts +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.d.ts.map +1 -1
- package/package.json +9 -4
- package/schema/verkoop.sql +1939 -0
- package/dist-lib/lib/order-cart-count.server.d.ts +0 -8
- package/dist-lib/lib/order-cart-count.server.d.ts.map +0 -1
- package/dist-lib/lib/order-cart-count.server.js +0 -69
|
@@ -13,8 +13,9 @@ import { useServerFn } from "@tanstack/react-start";
|
|
|
13
13
|
import { SearchableSelect } from "./SearchableSelect.js";
|
|
14
14
|
import { toISODate } from "../../lib/carrier-availability.js";
|
|
15
15
|
import { getDeparturePreview } from "../../lib/departure-preview.functions.js";
|
|
16
|
-
import { decidePreview, momentLabel, LATE_CONFIRM } from "../../lib/departure-preview.js";
|
|
17
|
-
import {
|
|
16
|
+
import { decidePreview, momentLabel, firstDateText, LATE_CONFIRM } from "../../lib/departure-preview.js";
|
|
17
|
+
import { ConfirmDialog } from "./ConfirmDialog.js";
|
|
18
|
+
import { listCustomersForCreateOrder, ensureCustomerFromTwinfield, listProductsForCreateOrder, listCustomerStickerProducts, listDeliveryLocationsForCustomerCO, listPickupLocationsCO, listCarriersForCreateOrder, getOrderPickDaysCO, listBeladingOptionsForProducts, createManualOrder, getEffectivePrices, } from "../../lib/create-order.functions.js";
|
|
18
19
|
import { checkOrderStockAllowed } from "../../lib/logistics-stock.functions.js";
|
|
19
20
|
import { useAllowedLoadCarriers } from "../../lib/useAllowedLoadCarriers.js";
|
|
20
21
|
const beladingKey = (b) => `${b.plants_per_crate}x${b.crates_per_layer}x${b.layers_per_cart}`;
|
|
@@ -50,6 +51,7 @@ export function CreateOrderPage() {
|
|
|
50
51
|
const fetchPickDays = useServerFn(getOrderPickDaysCO);
|
|
51
52
|
const fetchBeladingen = useServerFn(listBeladingOptionsForProducts);
|
|
52
53
|
const fetchCreate = useServerFn(createManualOrder);
|
|
54
|
+
const fetchStickerProducts = useServerFn(listCustomerStickerProducts);
|
|
53
55
|
const loadCarriersEngine = useAllowedLoadCarriers();
|
|
54
56
|
const safe = async (fn) => {
|
|
55
57
|
try {
|
|
@@ -106,9 +108,47 @@ export function CreateOrderPage() {
|
|
|
106
108
|
// Ladingdrager — lijst en voorselectie komen uitsluitend van de Engine.
|
|
107
109
|
const [loadCarrierType, setLoadCarrierType] = useState(null);
|
|
108
110
|
const [notes, setNotes] = useState("");
|
|
111
|
+
const [customerReference, setCustomerReference] = useState("");
|
|
112
|
+
// Eigen vervoer / zelf afleveren: bewuste keuze, geen vervoerder.
|
|
113
|
+
const [ownTransport, setOwnTransport] = useState(false);
|
|
114
|
+
const [lateConfirmOpen, setLateConfirmOpen] = useState(false);
|
|
109
115
|
const [lines, setLines] = useState([
|
|
110
116
|
{ product_id: null, product_name: "", quantity: null, unit: "stuks", unit_price: null, belading: null },
|
|
111
117
|
]);
|
|
118
|
+
// Standaard stickervinkje: aan als er voor deze klant + dit product een
|
|
119
|
+
// vaste klantsticker bestaat. Een zelf gezet vinkje blijft staan.
|
|
120
|
+
const stickerProductKey = Array.from(new Set(lines.map((l) => l.product_id).filter((v) => !!v))).sort();
|
|
121
|
+
const stickerQ = useQuery({
|
|
122
|
+
queryKey: ["co-sticker-products", customerId, stickerProductKey],
|
|
123
|
+
enabled: !!customerId && stickerProductKey.length > 0,
|
|
124
|
+
staleTime: 60000,
|
|
125
|
+
queryFn: async () => {
|
|
126
|
+
try {
|
|
127
|
+
return await fetchStickerProducts({ data: { customerId: customerId, productIds: stickerProductKey } });
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return { productIds: [] };
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
const withSticker = new Set(customerId ? (stickerQ.data?.productIds ?? []) : []);
|
|
136
|
+
if (customerId && stickerQ.isFetching)
|
|
137
|
+
return;
|
|
138
|
+
let changed = false;
|
|
139
|
+
const next = lines.map((l) => {
|
|
140
|
+
if (!l.product_id || l.sticker_manual_for === l.product_id)
|
|
141
|
+
return l;
|
|
142
|
+
const want = withSticker.has(l.product_id);
|
|
143
|
+
if (!!l.needs_sticker === want)
|
|
144
|
+
return l;
|
|
145
|
+
changed = true;
|
|
146
|
+
return { ...l, needs_sticker: want };
|
|
147
|
+
});
|
|
148
|
+
if (changed)
|
|
149
|
+
setLines(next);
|
|
150
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
151
|
+
}, [customerId, stickerQ.data, stickerQ.isFetching, lines]);
|
|
112
152
|
// Beladingen die daadwerkelijk bij de gekozen producten horen.
|
|
113
153
|
const selectedProductIds = useMemo(() => Array.from(new Set(lines.map((l) => l.product_id).filter((v) => !!v))).sort(), [lines]);
|
|
114
154
|
const beladingQ = useQuery({
|
|
@@ -175,11 +215,19 @@ export function CreateOrderPage() {
|
|
|
175
215
|
});
|
|
176
216
|
const deliveryLocations = deliveryLocQ.data?.items ?? [];
|
|
177
217
|
const selectedLocation = deliveryLocations.find((l) => l.id === deliveryLocationId) ?? null;
|
|
178
|
-
// Reset delivery_location bij klantwissel
|
|
218
|
+
// Reset delivery_location bij klantwissel; daarna de vaste locatie (★,
|
|
219
|
+
// hooguit één per klant) standaard kiezen. Geen vaste locatie: niets kiezen.
|
|
220
|
+
const primaryPickedFor = useRef(null);
|
|
179
221
|
useEffect(() => {
|
|
180
222
|
if (deliveryLocationId && !deliveryLocations.some((l) => l.id === deliveryLocationId)) {
|
|
181
223
|
setDeliveryLocationId(null);
|
|
182
224
|
}
|
|
225
|
+
if (customerId && deliveryLocQ.data && primaryPickedFor.current !== customerId) {
|
|
226
|
+
primaryPickedFor.current = customerId;
|
|
227
|
+
const primaries = deliveryLocations.filter((l) => l.is_primary === true && (!l.customer_id || l.customer_id === customerId));
|
|
228
|
+
if (!deliveryLocationId && primaries.length === 1)
|
|
229
|
+
setDeliveryLocationId(primaries[0].id);
|
|
230
|
+
}
|
|
183
231
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
184
232
|
}, [customerId, deliveryLocQ.data]);
|
|
185
233
|
// Auto-fill vervoerder op basis van gekozen afleverlocatie (één keer per wissel)
|
|
@@ -214,9 +262,10 @@ export function CreateOrderPage() {
|
|
|
214
262
|
carrierId: carrierId ?? null,
|
|
215
263
|
deliveryLocation: deliveryLocationId,
|
|
216
264
|
deliveryDate: deliveryDate || toISODate(new Date()),
|
|
217
|
-
momentKey,
|
|
265
|
+
momentKey: ownTransport ? null : momentKey,
|
|
266
|
+
ownTransport,
|
|
218
267
|
}
|
|
219
|
-
: null, [canPickDate, isReservation, carrierId, deliveryLocationId, deliveryDate, momentKey]);
|
|
268
|
+
: null, [canPickDate, isReservation, carrierId, deliveryLocationId, deliveryDate, momentKey, ownTransport]);
|
|
220
269
|
const [debouncedInput, setDebouncedInput] = useState(previewInput);
|
|
221
270
|
useEffect(() => {
|
|
222
271
|
const t = setTimeout(() => setDebouncedInput(previewInput), 300);
|
|
@@ -288,7 +337,7 @@ export function CreateOrderPage() {
|
|
|
288
337
|
e.preventDefault();
|
|
289
338
|
};
|
|
290
339
|
const createMut = useMutation({
|
|
291
|
-
mutationFn: async () => {
|
|
340
|
+
mutationFn: async (opts) => {
|
|
292
341
|
if (!customerId)
|
|
293
342
|
throw new Error("Selecteer een klant");
|
|
294
343
|
if (!deliveryLocationId)
|
|
@@ -303,9 +352,13 @@ export function CreateOrderPage() {
|
|
|
303
352
|
throw new Error("Het ophaalmoment wordt nog opgehaald. Probeer het zo opnieuw.");
|
|
304
353
|
if (decision.kind === "blocked")
|
|
305
354
|
throw new Error(decision.reason);
|
|
355
|
+
if (decision.kind === "departed")
|
|
356
|
+
throw new Error(decision.reason);
|
|
306
357
|
if (decision.kind === "late") {
|
|
307
|
-
if (!
|
|
358
|
+
if (!opts?.lateConfirmed) {
|
|
359
|
+
setLateConfirmOpen(true);
|
|
308
360
|
throw new Error("__cancelled__");
|
|
361
|
+
}
|
|
309
362
|
acceptLateSignup = true;
|
|
310
363
|
}
|
|
311
364
|
}
|
|
@@ -344,8 +397,10 @@ export function CreateOrderPage() {
|
|
|
344
397
|
customerName: customer?.company_name ?? "Onbekende klant",
|
|
345
398
|
deliveryLocationId,
|
|
346
399
|
pickupLocationId,
|
|
347
|
-
carrierId: isReservation ? null : (carrierId ?? preview?.carrierId ?? null),
|
|
348
|
-
momentKey: isReservation ? null : momentKey,
|
|
400
|
+
carrierId: isReservation || ownTransport ? null : (carrierId ?? preview?.carrierId ?? null),
|
|
401
|
+
momentKey: isReservation || ownTransport ? null : momentKey,
|
|
402
|
+
ownTransport: !isReservation && ownTransport,
|
|
403
|
+
customerReference: customerReference.trim() ? customerReference.trim() : null,
|
|
349
404
|
acceptLateSignup,
|
|
350
405
|
deliveryDate: isReservation ? null : deliveryDate,
|
|
351
406
|
isReservation,
|
|
@@ -364,6 +419,7 @@ export function CreateOrderPage() {
|
|
|
364
419
|
crates_per_layer: l.belading?.crates_per_layer ?? p?.crates_per_layer ?? undefined,
|
|
365
420
|
layers_per_cart: l.belading?.layers_per_cart ?? p?.layers_per_cart ?? undefined,
|
|
366
421
|
article_code: p?.article_code ?? undefined,
|
|
422
|
+
needs_sticker: l.needs_sticker === true,
|
|
367
423
|
};
|
|
368
424
|
}),
|
|
369
425
|
};
|
|
@@ -373,6 +429,10 @@ export function CreateOrderPage() {
|
|
|
373
429
|
toast.success("Bestelling aangemaakt — karindeling is automatisch berekend");
|
|
374
430
|
qc.invalidateQueries({ queryKey: ["floriday", "salesorders-cache"] });
|
|
375
431
|
if (res?.orderId) {
|
|
432
|
+
try {
|
|
433
|
+
window.sessionStorage.setItem(`verkoop:just-created:${res.orderId}`, String(Date.now()));
|
|
434
|
+
}
|
|
435
|
+
catch { /* geen opslag */ }
|
|
376
436
|
navigate({
|
|
377
437
|
to: "/floriday-verkoop/verkooporders/$salesOrderId",
|
|
378
438
|
params: { salesOrderId: `local:${res.orderId}` },
|
|
@@ -413,7 +473,7 @@ export function CreateOrderPage() {
|
|
|
413
473
|
: "Wordt gekozen bij de afleverlocatie", disabled: !deliveryLocationId, allowClear: false, options: carriers.map((c) => ({
|
|
414
474
|
value: c.id,
|
|
415
475
|
label: c.name + (c.is_default ? " (standaard)" : ""),
|
|
416
|
-
})), onChange: (v) => { setCarrierId(v); setMomentKey(null); } }), selectedLocation?.carrier_id && carrierId && carrierId !== selectedLocation.carrier_id && (_jsx("div", { className: "text-xs text-muted-foreground", children: "Wijkt af van standaard vervoerder van deze locatie \u2014 geldt alleen voor deze bestelling." }))] })), _jsxs("div", { className: "space-y-1", children: [_jsxs(Label, { className: "flex items-center gap-2", children: ["Leverdatum ", !isReservation && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { type: "date", value: !isReservation && canPickDate ? deliveryDate : "", disabled: isReservation || !canPickDate, onChange: (e) => { setDeliveryDate(e.target.value || ""); setMomentKey(null); } }), _jsxs("label", { className: "mt-1 flex items-center gap-2 text-sm text-foreground", children: [_jsx("input", { type: "checkbox", checked: isReservation, onChange: (e) => setIsReservation(e.target.checked), className: "h-4 w-4 rounded border-input" }), "Reservering (nog geen vaste leverdatum)"] }), isReservation ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "De bestelling wordt als reservering aangemaakt zonder leverdatumvalidatie." })) : !canPickDate ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Selecteer eerst klant, afleverlocatie en afhaallocatie." })) : !decision ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Ophaalmoment ophalen\u2026" })) : decision.kind === "blocked" ? (_jsx("div", { className: "text-xs text-destructive", children: decision.reason })) : (_jsxs("div", { className: "space-y-2 text-xs", children: [preview && preview.moments.length > 0 && (_jsx("select", { className: "h-9 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground", value: momentKey ?? decision.momentKey ?? "", onChange: (e) => setMomentKey(e.target.value || null), "aria-label": "Ophaalmoment kiezen", children: preview.moments.map((m) => (_jsxs("option", { value: m.momentKey, disabled: !m.feasible, className: m.feasible ? "" : "text-muted-foreground", children: [momentLabel(m), m.feasible ? "" : " (niet haalbaar)"] }, m.momentKey))) })), decision.text && _jsx("div", { className: "text-foreground", children: decision.text }), decision.kind === "late" && (_jsxs("div", { className: "space-y-2 rounded-md border border-destructive/40 p-2", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), decision.firstReason && _jsx("div", { className: "text-muted-foreground", children: decision.firstReason }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: createMut.isPending, onClick: () =>
|
|
476
|
+
})), onChange: (v) => { setCarrierId(v); setMomentKey(null); } }), selectedLocation?.carrier_id && carrierId && carrierId !== selectedLocation.carrier_id && (_jsx("div", { className: "text-xs text-muted-foreground", children: "Wijkt af van standaard vervoerder van deze locatie \u2014 geldt alleen voor deze bestelling." }))] })), _jsxs("div", { className: "space-y-1", children: [_jsxs(Label, { className: "flex items-center gap-2", children: ["Leverdatum ", !isReservation && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { type: "date", value: !isReservation && canPickDate ? deliveryDate : "", disabled: isReservation || !canPickDate, onChange: (e) => { setDeliveryDate(e.target.value || ""); setMomentKey(null); } }), _jsxs("label", { className: "mt-1 flex items-center gap-2 text-sm text-foreground", children: [_jsx("input", { type: "checkbox", checked: isReservation, onChange: (e) => setIsReservation(e.target.checked), className: "h-4 w-4 rounded border-input" }), "Reservering (nog geen vaste leverdatum)"] }), !isReservation && (_jsxs("label", { className: "flex items-center gap-2 text-sm text-foreground", children: [_jsx("input", { type: "checkbox", checked: ownTransport, onChange: (e) => { setOwnTransport(e.target.checked); setMomentKey(null); }, className: "h-4 w-4 rounded border-input" }), "Eigen vervoer / zelf afleveren (geen vervoerder)"] })), isReservation ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "De bestelling wordt als reservering aangemaakt zonder leverdatumvalidatie." })) : !canPickDate ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Selecteer eerst klant, afleverlocatie en afhaallocatie." })) : !decision ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Ophaalmoment ophalen\u2026" })) : decision.kind === "blocked" ? (_jsx("div", { className: "text-xs text-destructive", children: decision.reason })) : decision.kind === "departed" ? (_jsxs("div", { className: "space-y-2 rounded-md border border-destructive/40 p-2 text-xs", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setOwnTransport(true); setMomentKey(null); }, children: "Eigen vervoer / zelf afleveren" })] })] })) : (_jsxs("div", { className: "space-y-2 text-xs", children: [!ownTransport && preview && preview.moments.length > 0 && (_jsx("select", { className: "h-9 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground", value: momentKey ?? decision.momentKey ?? "", onChange: (e) => setMomentKey(e.target.value || null), "aria-label": "Ophaalmoment kiezen", children: preview.moments.map((m) => (_jsxs("option", { value: m.momentKey, disabled: !m.feasible, className: m.feasible ? "" : "text-muted-foreground", children: [momentLabel(m), m.feasible ? "" : " (niet haalbaar)"] }, m.momentKey))) })), decision.text && _jsx("div", { className: "text-foreground", children: decision.text }), decision.kind === "late" && (_jsxs("div", { className: "space-y-2 rounded-md border border-destructive/40 p-2", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), (firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: createMut.isPending, onClick: () => setLateConfirmOpen(true), children: ["Toch aanmaken voor ", deliveryDate ? fmtDate(deliveryDate) : "de gekozen datum"] })] })] }))] }))] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { children: "Bestelregels" }), _jsxs("div", { className: "grid grid-cols-12 gap-2 text-xs text-muted-foreground px-1", children: [_jsx("div", { className: "col-span-3", children: "Product" }), _jsx("div", { className: "col-span-1 text-center", children: "Sticker" }), _jsx("div", { className: "col-span-3", children: "Belading" }), _jsx("div", { className: "col-span-2", children: "Fusten" }), _jsx("div", { className: "col-span-2", children: "Prijs" }), _jsx("div", { className: "col-span-1" })] }), lines.map((line, idx) => {
|
|
417
477
|
const product = line.product_id ? products.find((p) => p.id === line.product_id) : null;
|
|
418
478
|
const defaultBelading = completeBelading(product);
|
|
419
479
|
const effBelading = completeBelading(line.belading) ?? defaultBelading;
|
|
@@ -442,7 +502,7 @@ export function CreateOrderPage() {
|
|
|
442
502
|
const defaultKey = dbDefault
|
|
443
503
|
? beladingKey(dbDefault)
|
|
444
504
|
: defaultBelading ? beladingKey(defaultBelading) : null;
|
|
445
|
-
return (_jsxs("div", { className: "grid grid-cols-12 gap-2 items-start", children: [_jsxs("div", { className: "col-span-
|
|
505
|
+
return (_jsxs("div", { className: "grid grid-cols-12 gap-2 items-start", children: [_jsxs("div", { className: "col-span-3", children: [_jsx(SearchableSelect, { value: line.product_id, placeholder: "Kies product...", clearLabel: "\u2014 Handmatig \u2014", options: products.map((p) => {
|
|
446
506
|
const code = p.article_code ? `${p.article_code} · ` : "";
|
|
447
507
|
const label = p.in_stock
|
|
448
508
|
? `${code}${p.product}`
|
|
@@ -510,7 +570,11 @@ export function CreateOrderPage() {
|
|
|
510
570
|
} }), outOfStock && (_jsx("div", { className: "mt-1 text-xs text-amber-600", children: "Let op: dit product staat momenteel niet op voorraad." })), line.product_id && shortageByProduct.has(line.product_id) && (_jsx("div", { className: `mt-1 text-xs ${stockBlocked ? "text-destructive" : "text-amber-600"}`, children: (() => {
|
|
511
571
|
const s = shortageByProduct.get(line.product_id);
|
|
512
572
|
return `${s.product}: besteld ${s.wanted}, beschikbaar ${s.available}, tekort ${s.missing}`;
|
|
513
|
-
})() }))] }),
|
|
573
|
+
})() }))] }), _jsx("div", { className: "col-span-1 flex h-10 items-center justify-center", children: _jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary", "aria-label": "Sticker nodig", title: "Sticker nodig", checked: line.needs_sticker === true, disabled: !line.product_id, onChange: (e) => {
|
|
574
|
+
const next = [...lines];
|
|
575
|
+
next[idx] = { ...next[idx], needs_sticker: e.target.checked, sticker_manual_for: line.product_id };
|
|
576
|
+
setLines(next);
|
|
577
|
+
} }) }), _jsxs("div", { className: "col-span-3", children: [_jsx(SearchableSelect, { value: effBelading ? beladingKey(effBelading) : null, placeholder: !line.product_id ? "Kies eerst product"
|
|
514
578
|
: loadingBeladingen ? "Beladingen laden..."
|
|
515
579
|
: noBeladingen ? "Geen belading beschikbaar"
|
|
516
580
|
: "Kies belading...", disabled: !line.product_id || loadingBeladingen || noBeladingen, allowClear: false, emptyLabel: "Geen belading gekoppeld aan dit product", options: Array.from(optionMap.entries()).map(([key, b]) => ({
|
|
@@ -552,13 +616,13 @@ export function CreateOrderPage() {
|
|
|
552
616
|
next[idx] = { ...next[idx], unit_price: v };
|
|
553
617
|
setLines(next);
|
|
554
618
|
}, placeholder: "\u20AC prijs", "aria-invalid": !!line.product_id && !(Number(line.unit_price) > 0), title: !!line.product_id && !(Number(line.unit_price) > 0) ? "Geen prijs" : undefined }), _jsx(Button, { variant: "ghost", size: "icon", className: "col-span-1", onClick: () => setLines(lines.filter((_, i) => i !== idx)), "aria-label": "Regel verwijderen", children: _jsx(Trash2, { className: "h-4 w-4" }) })] }, idx));
|
|
555
|
-
}), lines.some((l) => l.product_id && !(Number(l.unit_price) > 0)) && (_jsxs("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: ["Geen prijs: ", lines.filter((l) => l.product_id && !(Number(l.unit_price) > 0)).length, " regel(s) zonder prijs. Er is geen prijs gevonden in prijsgroep of artikel; vul de prijs in."] })), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setLines([...lines, { product_id: null, product_name: "", quantity: null, unit: "stuks", unit_price: null, belading: null }]), children: [_jsx(Plus, { className: "h-3 w-3 mr-1" }), " Regel toevoegen"] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Opmerkingen" }), _jsx(Textarea, { value: notes, onChange: (e) => setNotes(e.target.value), placeholder: "Optionele notities bij deze bestelling", rows: 3 })] }), stockCheck && stockCheck.shortages.length > 0 && (_jsxs("div", { className: `rounded-md border p-3 text-sm ${stockBlocked
|
|
619
|
+
}), lines.some((l) => l.product_id && !(Number(l.unit_price) > 0)) && (_jsxs("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: ["Geen prijs: ", lines.filter((l) => l.product_id && !(Number(l.unit_price) > 0)).length, " regel(s) zonder prijs. Er is geen prijs gevonden in prijsgroep of artikel; vul de prijs in."] })), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setLines([...lines, { product_id: null, product_name: "", quantity: null, unit: "stuks", unit_price: null, belading: null }]), children: [_jsx(Plus, { className: "h-3 w-3 mr-1" }), " Regel toevoegen"] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Referentie klant" }), _jsx(Input, { value: customerReference, maxLength: 100, onChange: (e) => setCustomerReference(e.target.value), placeholder: "Optioneel, bijvoorbeeld het bestelnummer van je klant" })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Opmerkingen" }), _jsx(Textarea, { value: notes, onChange: (e) => setNotes(e.target.value), placeholder: "Optionele notities bij deze bestelling", rows: 3 })] }), stockCheck && stockCheck.shortages.length > 0 && (_jsxs("div", { className: `rounded-md border p-3 text-sm ${stockBlocked
|
|
556
620
|
? "border-destructive/40 bg-destructive/5 text-destructive"
|
|
557
621
|
: "border-amber-500/40 bg-amber-500/5 text-amber-700"}`, children: [_jsx("div", { className: "font-medium", children: stockBlocked
|
|
558
622
|
? "Bestelling geblokkeerd — onvoldoende voorraad"
|
|
559
|
-
: "Let op: tekorten (uitleveren zonder voorraad staat aan)" }), _jsx("ul", { className: "mt-1 space-y-0.5", children: stockCheck.shortages.map((s) => (_jsxs("li", { children: [s.product, ": besteld ", s.wanted, ", beschikbaar ", s.available, ", tekort ", s.missing] }, s.productId))) })] })), _jsxs("div", { className: "flex items-center justify-end gap-2 pt-2", children: [_jsx(Button, { variant: "outline", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders" }), disabled: createMut.isPending, children: "Annuleren" }), _jsx(Button, { onClick: () => createMut.mutate(), disabled: createMut.isPending || stockBlocked || stockQ.isFetching, title: stockBlocked ? "Onvoldoende voorraad; deze order kan zo niet worden aangemaakt. Pas de aantallen aan." : undefined, children: createMut.isPending
|
|
623
|
+
: "Let op: tekorten (uitleveren zonder voorraad staat aan)" }), _jsx("ul", { className: "mt-1 space-y-0.5", children: stockCheck.shortages.map((s) => (_jsxs("li", { children: [s.product, ": besteld ", s.wanted, ", beschikbaar ", s.available, ", tekort ", s.missing] }, s.productId))) })] })), _jsxs("div", { className: "flex items-center justify-end gap-2 pt-2", children: [_jsx(Button, { variant: "outline", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders" }), disabled: createMut.isPending, children: "Annuleren" }), _jsx(Button, { onClick: () => createMut.mutate(undefined), disabled: createMut.isPending || stockBlocked || stockQ.isFetching, title: stockBlocked ? "Onvoldoende voorraad; deze order kan zo niet worden aangemaakt. Pas de aantallen aan." : undefined, children: createMut.isPending
|
|
560
624
|
? "Bezig..."
|
|
561
625
|
: stockQ.isFetching
|
|
562
626
|
? "Voorraad controleren..."
|
|
563
|
-
: "Bestelling Aanmaken" })] })] })] })] }));
|
|
627
|
+
: "Bestelling Aanmaken" })] })] })] }), _jsx(ConfirmDialog, { open: lateConfirmOpen, onOpenChange: setLateConfirmOpen, title: "Toch aanmaken na de aanmeldtijd?", description: LATE_CONFIRM, confirmLabel: "Toch aanmaken", onConfirm: () => createMut.mutate({ lateConfirmed: true }) })] }));
|
|
564
628
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagnoseConnectionDialog.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/DiagnoseConnectionDialog.tsx"],"names":[],"mappings":"AAiBA,wBAAgB,wBAAwB,CAAC,EACvC,IAAI,EACJ,YAAY,GACb,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC
|
|
1
|
+
{"version":3,"file":"DiagnoseConnectionDialog.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/DiagnoseConnectionDialog.tsx"],"names":[],"mappings":"AAiBA,wBAAgB,wBAAwB,CAAC,EACvC,IAAI,EACJ,YAAY,GACb,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,2CAoMA"}
|
|
@@ -2,5 +2,5 @@ export declare function EditLocalOrderDialog({ orderId, open, onOpenChange, }: {
|
|
|
2
2
|
orderId: string;
|
|
3
3
|
open: boolean;
|
|
4
4
|
onOpenChange: (o: boolean) => void;
|
|
5
|
-
}): import("react").JSX.Element | null;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
6
6
|
//# sourceMappingURL=EditLocalOrderDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditLocalOrderDialog.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/EditLocalOrderDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditLocalOrderDialog.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/EditLocalOrderDialog.tsx"],"names":[],"mappings":"AA+CA,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,IAAI,EACJ,YAAY,GACb,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,kDAykBA"}
|
|
@@ -47,6 +47,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
47
47
|
quantity: it.quantity,
|
|
48
48
|
unit: it.unit,
|
|
49
49
|
plantsPerCrate: pos(it.plantsPerCrate),
|
|
50
|
+
needsSticker: it.needsSticker === true,
|
|
50
51
|
minQuantity: Number(it.minQuantity ?? 0),
|
|
51
52
|
shippedQuantity: Number(it.shippedQuantity ?? 0),
|
|
52
53
|
plannedQuantity: Number(it.plannedQuantity ?? 0),
|
|
@@ -104,6 +105,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
104
105
|
cratesPerLayer: cpl,
|
|
105
106
|
layersPerCart: lpc,
|
|
106
107
|
quantity: ppc,
|
|
108
|
+
needsSticker: false,
|
|
107
109
|
},
|
|
108
110
|
]);
|
|
109
111
|
};
|
|
@@ -216,8 +218,12 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
216
218
|
plantsPerCrate: n.plantsPerCrate,
|
|
217
219
|
cratesPerLayer: n.cratesPerLayer,
|
|
218
220
|
layersPerCart: n.layersPerCart,
|
|
221
|
+
needsSticker: n.needsSticker,
|
|
219
222
|
}))
|
|
220
223
|
: undefined,
|
|
224
|
+
stickers: items
|
|
225
|
+
.filter((i) => !removedIds.includes(i.id))
|
|
226
|
+
.map((i) => ({ itemId: i.id, needsSticker: i.needsSticker })),
|
|
221
227
|
},
|
|
222
228
|
});
|
|
223
229
|
toast.success("Bestelling bijgewerkt");
|
|
@@ -236,14 +242,14 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
236
242
|
setSaving(false);
|
|
237
243
|
}
|
|
238
244
|
};
|
|
239
|
-
return (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4", onClick: () => !saving && onOpenChange(false), children: _jsxs("div", { className: "flex w-full max-w-4xl max-h-[90vh] flex-col rounded-lg border border-border bg-card shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "shrink-0 p-6 pb-4", children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Bestelling bewerken" }), _jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Pas de leverdatum en het aantal planten of fusten per regel aan. Voorraad en karindeling worden automatisch bijgewerkt." })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-6 pb-4 min-h-0", children: [loading ? (_jsx("div", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })) : error ? (_jsx("div", { className: "rounded border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive", children: error })) : (_jsxs("div", { className: "space-y-4", children: [!isReservation && (_jsxs("div", { children: [_jsx("label", { className: "mb-1 block text-sm font-medium text-foreground", children: "Leverdatum" }), _jsx(Input, { type: "date", value: deliveryDate, onChange: (e) => setDeliveryDate(e.target.value) })] })), isReservation && (_jsx("div", { className: "rounded border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground", children: "Dit is een reservering \u2014 er is nog geen leverdatum. Voeg een bezorgmoment toe om (deels) uit te leveren." })), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Regels" }), _jsxs("div", { className: "grid grid-cols-12 gap-2 px-1 text-xs text-muted-foreground", children: [_jsx("div", { className: "col-span-
|
|
245
|
+
return (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4", onClick: () => !saving && onOpenChange(false), children: _jsxs("div", { className: "flex w-full max-w-4xl max-h-[90vh] flex-col rounded-lg border border-border bg-card shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "shrink-0 p-6 pb-4", children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Bestelling bewerken" }), _jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Pas de leverdatum en het aantal planten of fusten per regel aan. Voorraad en karindeling worden automatisch bijgewerkt." })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-6 pb-4 min-h-0", children: [loading ? (_jsx("div", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })) : error ? (_jsx("div", { className: "rounded border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive", children: error })) : (_jsxs("div", { className: "space-y-4", children: [!isReservation && (_jsxs("div", { children: [_jsx("label", { className: "mb-1 block text-sm font-medium text-foreground", children: "Leverdatum" }), _jsx(Input, { type: "date", value: deliveryDate, onChange: (e) => setDeliveryDate(e.target.value) })] })), isReservation && (_jsx("div", { className: "rounded border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground", children: "Dit is een reservering \u2014 er is nog geen leverdatum. Voeg een bezorgmoment toe om (deels) uit te leveren." })), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Regels" }), _jsxs("div", { className: "grid grid-cols-12 gap-2 px-1 text-xs text-muted-foreground", children: [_jsx("div", { className: "col-span-5", children: "Product" }), _jsx("div", { className: "col-span-1 text-center", children: "Sticker" }), _jsx("div", { className: "col-span-3", children: "Planten" }), _jsx("div", { className: "col-span-3", children: "Fusten" })] }), _jsxs("div", { className: "mt-1 space-y-2", children: [items.map((it, idx) => {
|
|
240
246
|
const ppc = it.plantsPerCrate;
|
|
241
247
|
const fusten = ppc !== null ? Math.ceil(it.quantity / ppc) : 0;
|
|
242
248
|
const removed = removedIds.includes(it.id);
|
|
243
|
-
return (_jsxs("div", { className: `grid grid-cols-12 items-start gap-2 rounded border border-border p-2 ${removed ? "opacity-50" : ""}`, children: [_jsxs("div", { className: "col-span-
|
|
249
|
+
return (_jsxs("div", { className: `grid grid-cols-12 items-start gap-2 rounded border border-border p-2 ${removed ? "opacity-50" : ""}`, children: [_jsxs("div", { className: "col-span-4 min-w-0 text-sm", children: [_jsx("div", { className: `truncate font-medium text-foreground ${removed ? "line-through" : ""}`, children: it.productName }), ppc === null ? (_jsx("div", { className: "text-xs text-destructive", children: "Belading onbekend \u2014 deze regel kan niet opgeslagen worden" })) : (_jsxs("div", { className: "text-xs text-muted-foreground", children: [ppc, " planten per fust"] })), it.minQuantity > 0 && (_jsxs("div", { className: "text-xs text-primary", children: ["min. ", it.minQuantity, " (reeds ", it.shippedQuantity, " geleverd, ", it.plannedQuantity, " gepland)"] })), it.productId && shortageByProduct.has(it.productId) && (_jsx("div", { className: `text-xs ${stockBlocked ? "text-destructive" : "text-amber-600"}`, children: (() => {
|
|
244
250
|
const s = shortageByProduct.get(it.productId);
|
|
245
251
|
return `${s.product}: besteld ${s.wanted}, beschikbaar ${s.available}, tekort ${s.missing}`;
|
|
246
|
-
})() }))] }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: ppc ?? 1, value: it.quantity, disabled: removed, onChange: (e) => setPlants(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: 1, value: ppc === null ? "" : fusten, disabled: removed || ppc === null, onChange: (e) => setFusten(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-1 flex justify-end", children: canEditProducts && (_jsx(Button, { variant: "ghost", size: "sm", title: removed ? "Verwijderen ongedaan maken" : "Regel verwijderen", onClick: () => setRemovedIds((prev) => prev.includes(it.id)
|
|
252
|
+
})() }))] }), _jsx("div", { className: "col-span-1 flex h-10 items-center justify-center", children: _jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary", "aria-label": "Sticker nodig", checked: it.needsSticker, disabled: removed, onChange: (e) => setItems((prev) => prev.map((p, i) => (i === idx ? { ...p, needsSticker: e.target.checked } : p))) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: ppc ?? 1, value: it.quantity, disabled: removed, onChange: (e) => setPlants(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: 1, value: ppc === null ? "" : fusten, disabled: removed || ppc === null, onChange: (e) => setFusten(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-1 flex justify-end", children: canEditProducts && (_jsx(Button, { variant: "ghost", size: "sm", title: removed ? "Verwijderen ongedaan maken" : "Regel verwijderen", onClick: () => setRemovedIds((prev) => prev.includes(it.id)
|
|
247
253
|
? prev.filter((x) => x !== it.id)
|
|
248
254
|
: [...prev, it.id]), children: _jsx(Trash2, { className: "h-4 w-4" }) })) })] }, it.id));
|
|
249
255
|
}), newItems.some((n) => !(Number(n.unitPrice) > 0)) && (_jsxs("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: ["Geen prijs: ", newItems.filter((n) => !(Number(n.unitPrice) > 0)).length, " nieuwe regel(s) zonder prijs in artikel of prijsgroep."] })), newItems.map((n, idx) => {
|
|
@@ -252,10 +258,10 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
252
258
|
const setNewQty = (plants) => setNewItems((prev) => prev.map((p, i) => i === idx
|
|
253
259
|
? { ...p, quantity: Number.isFinite(plants) ? Math.max(0, plants) : 0 }
|
|
254
260
|
: p));
|
|
255
|
-
return (_jsxs("div", { className: "grid grid-cols-12 items-start gap-2 rounded border border-primary/40 bg-primary/5 p-2", children: [_jsxs("div", { className: "col-span-
|
|
261
|
+
return (_jsxs("div", { className: "grid grid-cols-12 items-start gap-2 rounded border border-primary/40 bg-primary/5 p-2", children: [_jsxs("div", { className: "col-span-4 min-w-0 text-sm", children: [_jsx("div", { className: "truncate font-medium text-foreground", children: n.productName }), _jsxs("div", { className: "text-xs text-muted-foreground", children: ["nieuw \u00B7 ", ppc, " planten per fust"] }), shortageByProduct.has(n.productId) && (_jsx("div", { className: `text-xs ${stockBlocked ? "text-destructive" : "text-amber-600"}`, children: (() => {
|
|
256
262
|
const s = shortageByProduct.get(n.productId);
|
|
257
263
|
return `${s.product}: besteld ${s.wanted}, beschikbaar ${s.available}, tekort ${s.missing}`;
|
|
258
|
-
})() }))] }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: ppc, value: n.quantity, onChange: (e) => setNewQty(Number(e.target.value)) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: 1, value: fusten, onChange: (e) => setNewQty(Math.max(0, Number(e.target.value)) * ppc) }) }), _jsx("div", { className: "col-span-1 flex justify-end", children: _jsx(Button, { variant: "ghost", size: "sm", title: "Regel verwijderen", onClick: () => setNewItems((prev) => prev.filter((_, i) => i !== idx)), children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, n.key));
|
|
264
|
+
})() }))] }), _jsx("div", { className: "col-span-1 flex h-10 items-center justify-center", children: _jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary", "aria-label": "Sticker nodig", checked: n.needsSticker, onChange: (e) => setNewItems((prev) => prev.map((p, i) => (i === idx ? { ...p, needsSticker: e.target.checked } : p))) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: ppc, value: n.quantity, onChange: (e) => setNewQty(Number(e.target.value)) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: 1, value: fusten, onChange: (e) => setNewQty(Math.max(0, Number(e.target.value)) * ppc) }) }), _jsx("div", { className: "col-span-1 flex justify-end", children: _jsx(Button, { variant: "ghost", size: "sm", title: "Regel verwijderen", onClick: () => setNewItems((prev) => prev.filter((_, i) => i !== idx)), children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, n.key));
|
|
259
265
|
}), items.length === 0 && newItems.length === 0 && (_jsx("div", { className: "text-sm text-muted-foreground", children: "Geen regels op deze bestelling." }))] }), canEditProducts ? (_jsxs("div", { className: "mt-3", children: [_jsx("div", { className: "mb-1 text-xs text-muted-foreground", children: "Product toevoegen" }), _jsx(SearchableSelect, { value: null, options: productOptions, allowClear: false, placeholder: productsQ.isLoading ? "Producten laden…" : "Zoek een product…", onChange: addProduct, disabled: productsQ.isLoading })] })) : (_jsx("div", { className: "mt-3 rounded border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground", children: "Producten kunnen niet meer gewijzigd worden: deze bestelling is al geprint in het Pickstation. Aantallen aanpassen kan wel." }))] })] })), stockCheck && stockCheck.shortages.length > 0 && (_jsxs("div", { className: `mt-4 rounded-md border p-3 text-sm ${stockBlocked
|
|
260
266
|
? "border-destructive/40 bg-destructive/5 text-destructive"
|
|
261
267
|
: "border-amber-500/40 bg-amber-500/5 text-amber-700"}`, children: [_jsx("div", { className: "font-medium", children: stockBlocked
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineBufferCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/EngineBufferCard.tsx"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"EngineBufferCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/EngineBufferCard.tsx"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,kDAkJvE"}
|
|
@@ -8,8 +8,8 @@ export declare function FloridayStageLine({ status, stage, floridayFulfilled, is
|
|
|
8
8
|
isFloriday?: boolean;
|
|
9
9
|
notReportedCount?: number;
|
|
10
10
|
bufferSize?: number;
|
|
11
|
-
}): import("react").JSX.Element | null;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
12
12
|
export declare function MissingPriceBadge({ show }: {
|
|
13
13
|
show: boolean | undefined;
|
|
14
|
-
}): import("react").JSX.Element | null;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
15
15
|
//# sourceMappingURL=FloridayStageLine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloridayStageLine.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/FloridayStageLine.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA8D,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC/H,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,MAAM,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"FloridayStageLine.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/FloridayStageLine.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA8D,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC/H,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,MAAM,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,kDAwCA;AAED,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,kDAOxE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function InvoiceTimingSettingsCard(): import("react").JSX.Element;
|
|
1
|
+
export declare function InvoiceTimingSettingsCard(): import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export default InvoiceTimingSettingsCard;
|
|
3
3
|
//# sourceMappingURL=InvoiceTimingSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvoiceTimingSettings.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/InvoiceTimingSettings.tsx"],"names":[],"mappings":"AA+GA,wBAAgB,yBAAyB,
|
|
1
|
+
{"version":3,"file":"InvoiceTimingSettings.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/InvoiceTimingSettings.tsx"],"names":[],"mappings":"AA+GA,wBAAgB,yBAAyB,4CA2GxC;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -2,5 +2,5 @@ export declare function OrderAfleverbrievenCard({ salesOrderId, orderNumber, wer
|
|
|
2
2
|
salesOrderId: string;
|
|
3
3
|
orderNumber?: string;
|
|
4
4
|
werkplek?: string;
|
|
5
|
-
}): import("react").JSX.Element;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
//# sourceMappingURL=OrderAfleverbrievenCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderAfleverbrievenCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderAfleverbrievenCard.tsx"],"names":[],"mappings":"AAuCA,wBAAgB,uBAAuB,CAAC,EACtC,YAAY,EACZ,WAAW,EACX,QAAQ,GACT,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB
|
|
1
|
+
{"version":3,"file":"OrderAfleverbrievenCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderAfleverbrievenCard.tsx"],"names":[],"mappings":"AAuCA,wBAAgB,uBAAuB,CAAC,EACtC,YAAY,EACZ,WAAW,EACX,QAAQ,GACT,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,2CAwMA"}
|
|
@@ -9,5 +9,5 @@ export declare function OrderCarrierPicker({ orderId, applyToBuffer, compact, lo
|
|
|
9
9
|
applyToBuffer?: boolean;
|
|
10
10
|
compact?: boolean;
|
|
11
11
|
locked?: boolean;
|
|
12
|
-
}): import("react").JSX.Element;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
//# sourceMappingURL=OrderCarrierPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderCarrierPicker.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderCarrierPicker.tsx"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,aAAqB,EACrB,OAAe,EACf,MAAc,GACf,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB
|
|
1
|
+
{"version":3,"file":"OrderCarrierPicker.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderCarrierPicker.tsx"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,aAAqB,EACrB,OAAe,EACf,MAAc,GACf,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,2CA4EA"}
|
|
@@ -2,5 +2,5 @@ export declare function OrderControlStatusCard({ floridayId, isControlled, contr
|
|
|
2
2
|
floridayId: string;
|
|
3
3
|
isControlled: boolean;
|
|
4
4
|
controlledAt: string | null;
|
|
5
|
-
}): import("react").JSX.Element;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
//# sourceMappingURL=OrderControlStatusCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderControlStatusCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderControlStatusCard.tsx"],"names":[],"mappings":"AAsBA,wBAAgB,sBAAsB,CAAC,EACrC,UAAU,EACV,YAAY,EACZ,YAAY,GACb,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B
|
|
1
|
+
{"version":3,"file":"OrderControlStatusCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderControlStatusCard.tsx"],"names":[],"mappings":"AAsBA,wBAAgB,sBAAsB,CAAC,EACrC,UAAU,EACV,YAAY,EACZ,YAAY,GACb,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,2CA6DA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SalesOrderDTO } from "../../lib/salesorders-mapping.js";
|
|
2
2
|
export declare function OrderKarindelingCard({ order }: {
|
|
3
3
|
order: SalesOrderDTO;
|
|
4
|
-
}): import("react").JSX.Element;
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
//# sourceMappingURL=OrderKarindelingCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderKarindelingCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderKarindelingCard.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"OrderKarindelingCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderKarindelingCard.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAoB/D,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,2CAmMvE"}
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
// (logistics_order_plan_coverage). Deze kaart leest order_carts/
|
|
4
4
|
// order_cart_items niet zelf en berekent niets: alleen de regels van DEZE
|
|
5
5
|
// order, per kar, met of de kar gedeeld is met de buffer.
|
|
6
|
-
import { useState } from "react";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
7
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
8
8
|
import { useServerFn } from "@tanstack/react-start";
|
|
9
9
|
import { Badge, Button, Card, CardContent, CardHeader, CardTitle, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@flowselections/core";
|
|
@@ -20,6 +20,7 @@ const PICK_LABEL = {
|
|
|
20
20
|
bezig: "Bezig met picken",
|
|
21
21
|
gepickt: "Gepickt",
|
|
22
22
|
};
|
|
23
|
+
const JUST_CREATED_MS = 120000;
|
|
23
24
|
const fmt = (v) => (v ? new Date(v).toLocaleString("nl-NL") : null);
|
|
24
25
|
export function OrderKarindelingCard({ order }) {
|
|
25
26
|
// Lokale orders hebben een prefix in hun DTO-id; Floriday-orders hun
|
|
@@ -30,9 +31,27 @@ export function OrderKarindelingCard({ order }) {
|
|
|
30
31
|
const fetchCoverage = useServerFn(getOrderPlanCoverage);
|
|
31
32
|
const queryClient = useQueryClient();
|
|
32
33
|
const queryKey = ["order-plan-coverage", orderId];
|
|
34
|
+
// Net aangemaakt (in dit venster)? Dan maakt de planning de kar binnen enkele
|
|
35
|
+
// seconden: toon "Karindeling wordt gemaakt…" en lees elke 3 s opnieuw, max 2 min.
|
|
36
|
+
const [justCreatedAt, setJustCreatedAt] = useState(null);
|
|
37
|
+
const [now, setNow] = useState(() => Date.now());
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!orderId)
|
|
40
|
+
return;
|
|
41
|
+
try {
|
|
42
|
+
const v = Number(window.sessionStorage.getItem(`verkoop:just-created:${orderId}`));
|
|
43
|
+
if (Number.isFinite(v) && v > 0 && Date.now() - v < JUST_CREATED_MS)
|
|
44
|
+
setJustCreatedAt(v);
|
|
45
|
+
}
|
|
46
|
+
catch { /* geen opslag beschikbaar */ }
|
|
47
|
+
}, [orderId]);
|
|
33
48
|
const { data, isLoading, error, isFetching } = useQuery({
|
|
34
49
|
queryKey,
|
|
35
50
|
enabled: !!orderId,
|
|
51
|
+
refetchInterval: (q) => {
|
|
52
|
+
const st = q.state.data?.coverage?.state;
|
|
53
|
+
return justCreatedAt && st === "geen_indeling" && Date.now() - justCreatedAt < JUST_CREATED_MS ? 3000 : false;
|
|
54
|
+
},
|
|
36
55
|
staleTime: 30000,
|
|
37
56
|
retry: (failureCount, queryError) => /authorization|token|sessie/i.test(queryError.message) && failureCount < 5,
|
|
38
57
|
retryDelay: (attempt) => Math.min(500 * 2 ** attempt, 4000),
|
|
@@ -43,10 +62,17 @@ export function OrderKarindelingCard({ order }) {
|
|
|
43
62
|
},
|
|
44
63
|
});
|
|
45
64
|
const cov = data?.coverage ?? null;
|
|
65
|
+
const creating = !!justCreatedAt && cov?.state === "geen_indeling" && now - justCreatedAt < JUST_CREATED_MS;
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!justCreatedAt)
|
|
68
|
+
return;
|
|
69
|
+
const t = setInterval(() => setNow(Date.now()), 3000);
|
|
70
|
+
return () => clearInterval(t);
|
|
71
|
+
}, [justCreatedAt]);
|
|
46
72
|
const carts = Array.isArray(cov?.carts) ? cov.carts : [];
|
|
47
73
|
const pickRows = Array.isArray(cov?.pickRows) ? cov.pickRows : [];
|
|
48
74
|
const [layersFor, setLayersFor] = useState(null);
|
|
49
|
-
return (_jsxs(Card, { children: [_jsxs(CardHeader, { className: "grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2 sm:flex sm:flex-row sm:justify-between", children: [_jsx(CardTitle, { className: "truncate text-base", children: "Karindeling" }), _jsxs("div", { className: "flex items-center gap-2", children: [cov && cov.state !== "onbekend" && (_jsxs(Badge, { variant: "secondary", children: [carts.length, " kar(ren)"] })), _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Vernieuwen", title: "Vernieuwen", onClick: () => void queryClient.invalidateQueries({ queryKey }), children: _jsx(RefreshCw, { className: "h-4 w-4 " + (isFetching ? "animate-spin" : "") }) })] })] }), _jsx(CardContent, { className: "space-y-4", children: isLoading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Karindeling laden\u2026" })) : error ? (_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: "Indeling onbekend" }), _jsx("p", { className: "text-sm text-muted-foreground", children: error.message })] })) : cov ? (_jsxs(_Fragment, { children: [cov.externalFulfilled && !cov.externalFulfilled.full && (_jsxs("p", { className: "text-sm text-muted-foreground", children: [cov.externalFulfilled.salesOrderIds.length, " bestelling(en) afgehandeld in Floriday; de voortgang telt alleen de rest."] })), data?.externalEvent?.sendError ? (_jsxs("p", { className: "text-sm text-destructive", children: ["Het afronden in de planning lukte niet: de melding kon niet worden verstuurd (", data.externalEvent.sendError, ")."] })) : data?.externalEvent?.status === "failed" ? (_jsxs("p", { className: "text-sm text-destructive", children: ["Het afronden in de planning lukte niet: ", data.externalEvent.error ?? "geen reden opgegeven"] })) : data?.externalEvent && data.externalEvent.status && !["done", "processed", "completed", "applied", "skipped"].includes(data.externalEvent.status) ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "De planning verwerkt \"Afgehandeld in Floriday\" nog." })) : null, _jsxs("div", { className: "flex flex-wrap items-start gap-x-6 gap-y-2 text-sm", children: [_jsxs("div", { children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Indeling" }), _jsx(PlanCoverageBadge, { coverage: summarize(cov) })] }), _jsxs("div", { children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Pickstatus" }), _jsxs("div", { className: "mt-1", children: [cov.pickStatus ? PICK_LABEL[cov.pickStatus] : "—", cov.pickStatus === "gepickt" && cov.pickedAt ? ` · ${fmt(cov.pickedAt)}` : ""] })] }), pickRows.length > 0 && (_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Pickdocumenten" }), _jsx("div", { className: "mt-1 flex flex-wrap gap-1", children: pickRows.map((p, i) => (_jsxs(Badge, { variant: "outline", className: "text-[10px]", title: [
|
|
75
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { className: "grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2 sm:flex sm:flex-row sm:justify-between", children: [_jsx(CardTitle, { className: "truncate text-base", children: "Karindeling" }), _jsxs("div", { className: "flex items-center gap-2", children: [cov && cov.state !== "onbekend" && (_jsxs(Badge, { variant: "secondary", children: [carts.length, " kar(ren)"] })), _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Vernieuwen", title: "Vernieuwen", onClick: () => void queryClient.invalidateQueries({ queryKey }), children: _jsx(RefreshCw, { className: "h-4 w-4 " + (isFetching ? "animate-spin" : "") }) })] })] }), _jsx(CardContent, { className: "space-y-4", children: isLoading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Karindeling laden\u2026" })) : error ? (_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: "Indeling onbekend" }), _jsx("p", { className: "text-sm text-muted-foreground", children: error.message })] })) : cov ? (_jsxs(_Fragment, { children: [cov.externalFulfilled && !cov.externalFulfilled.full && (_jsxs("p", { className: "text-sm text-muted-foreground", children: [cov.externalFulfilled.salesOrderIds.length, " bestelling(en) afgehandeld in Floriday; de voortgang telt alleen de rest."] })), data?.externalEvent?.sendError ? (_jsxs("p", { className: "text-sm text-destructive", children: ["Het afronden in de planning lukte niet: de melding kon niet worden verstuurd (", data.externalEvent.sendError, ")."] })) : data?.externalEvent?.status === "failed" ? (_jsxs("p", { className: "text-sm text-destructive", children: ["Het afronden in de planning lukte niet: ", data.externalEvent.error ?? "geen reden opgegeven"] })) : data?.externalEvent && data.externalEvent.status && !["done", "processed", "completed", "applied", "skipped"].includes(data.externalEvent.status) ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "De planning verwerkt \"Afgehandeld in Floriday\" nog." })) : null, _jsxs("div", { className: "flex flex-wrap items-start gap-x-6 gap-y-2 text-sm", children: [_jsxs("div", { children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Indeling" }), creating ? (_jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Karindeling wordt gemaakt\u2026" })) : (_jsx(PlanCoverageBadge, { coverage: summarize(cov) }))] }), _jsxs("div", { children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Pickstatus" }), _jsxs("div", { className: "mt-1", children: [cov.pickStatus ? PICK_LABEL[cov.pickStatus] : "—", cov.pickStatus === "gepickt" && cov.pickedAt ? ` · ${fmt(cov.pickedAt)}` : ""] })] }), pickRows.length > 0 && (_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Pickdocumenten" }), _jsx("div", { className: "mt-1 flex flex-wrap gap-1", children: pickRows.map((p, i) => (_jsxs(Badge, { variant: "outline", className: "text-[10px]", title: [
|
|
50
76
|
p.printedAt ? `Geprint ${fmt(p.printedAt)}` : "Nog niet geprint",
|
|
51
77
|
p.completedAt ? `Afgerond ${fmt(p.completedAt)}` : null,
|
|
52
78
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderLinePackingCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderLinePackingCard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OrderLinePackingCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderLinePackingCard.tsx"],"names":[],"mappings":"AAoJA,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,kDA4CpE"}
|
|
@@ -59,7 +59,7 @@ function LineRow({ item, onChanged, }) {
|
|
|
59
59
|
onError: (e) => toast.error(e?.message ?? "Losmaken mislukt"),
|
|
60
60
|
});
|
|
61
61
|
const known = item.plantsPerCrate != null && item.cratesPerLayer != null && item.layersPerCart != null;
|
|
62
|
-
return (_jsxs("div", { className: "rounded-md border border-border p-3", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate text-sm font-medium text-foreground", children: item.productName }), _jsx("div", { className: "text-xs text-muted-foreground", children: known
|
|
62
|
+
return (_jsxs("div", { className: "rounded-md border border-border p-3", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate text-sm font-medium text-foreground", children: item.productName }), _jsxs("div", { className: "text-xs text-muted-foreground", children: ["Sticker: ", item.needsSticker ? "ja" : "nee"] }), _jsx("div", { className: "text-xs text-muted-foreground", children: known
|
|
63
63
|
? `${item.plantsPerCrate} planten/fust · ${item.cratesPerLayer} fusten/laag · ${item.layersPerCart} lagen/kar`
|
|
64
64
|
: "Belading onbekend — deze regel blokkeert de indeling tot er waarden staan" })] }), item.lockedAt ? (_jsxs(Badge, { variant: "outline", className: "gap-1 text-[11px]", children: [_jsx(Lock, { className: "h-3 w-3" }), "Handmatig vastgezet"] })) : null] }), item.lockedAt ? (_jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: ["Vastgezet door ", item.lockedByName ?? "onbekend", " op ", fmtWhen(item.lockedAt)] })) : null, editing ? (_jsxs("div", { className: "mt-3 flex flex-wrap items-end gap-2", children: [_jsxs("div", { children: [_jsx("div", { className: "mb-1 text-[11px] text-muted-foreground", children: "Planten/fust" }), _jsx(Input, { className: "w-28", value: ppc, onChange: (e) => setPpc(e.target.value), inputMode: "numeric" })] }), _jsxs("div", { children: [_jsx("div", { className: "mb-1 text-[11px] text-muted-foreground", children: "Fusten/laag" }), _jsx(Input, { className: "w-28", value: cpl, onChange: (e) => setCpl(e.target.value), inputMode: "numeric" })] }), _jsxs("div", { children: [_jsx("div", { className: "mb-1 text-[11px] text-muted-foreground", children: "Lagen/kar" }), _jsx(Input, { className: "w-28", value: lpc, onChange: (e) => setLpc(e.target.value), inputMode: "numeric" })] }), _jsx(Button, { size: "sm", onClick: () => lockM.mutate(), disabled: lockM.isPending, children: "Vastzetten" }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setEditing(false), disabled: lockM.isPending, children: "Annuleren" })] })) : (_jsxs("div", { className: "mt-3 flex flex-wrap gap-2", children: [_jsxs(Button, { size: "sm", variant: "outline", onClick: () => setEditing(true), children: [_jsx(Lock, { className: "mr-2 h-3.5 w-3.5" }), item.lockedAt ? "Vastgezette belading aanpassen" : "Belading handmatig vastzetten"] }), item.lockedAt ? (_jsxs(Button, { size: "sm", variant: "ghost", onClick: () => unlockM.mutate(), disabled: unlockM.isPending, children: [_jsx(LockOpen, { className: "mr-2 h-3.5 w-3.5" }), "Losmaken"] })) : null] }))] }));
|
|
65
65
|
}
|
|
@@ -6,5 +6,5 @@ export declare function OrderPickupMomentPicker({ orderId, readOnly, compact, }:
|
|
|
6
6
|
orderId: string;
|
|
7
7
|
readOnly?: boolean;
|
|
8
8
|
compact?: boolean;
|
|
9
|
-
}): import("react").JSX.Element;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
//# sourceMappingURL=OrderPickupMomentPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderPickupMomentPicker.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderPickupMomentPicker.tsx"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,OAAO,EACP,QAAgB,EAChB,OAAe,GAChB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB
|
|
1
|
+
{"version":3,"file":"OrderPickupMomentPicker.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderPickupMomentPicker.tsx"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,OAAO,EACP,QAAgB,EAChB,OAAe,GAChB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,2CA6EA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SalesOrderDTO } from "../../lib/salesorders-mapping.js";
|
|
2
2
|
export declare function OrderShipmentsCard({ order }: {
|
|
3
3
|
order: SalesOrderDTO;
|
|
4
|
-
}): import("react").JSX.Element | null;
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
5
5
|
//# sourceMappingURL=OrderShipmentsCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderShipmentsCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderShipmentsCard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OrderShipmentsCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderShipmentsCard.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AA+C/D,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,kDASrE"}
|