@flowselections/mailbox-orders 1.0.4 → 1.0.6
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/MailboxProposalsPage.d.ts.map +1 -1
- package/dist-lib/components/MailboxProposalsPage.js +66 -39
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +771 -3
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +771 -3
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +771 -3
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.js +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +781 -3
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/mailbox-template.functions.d.ts +4746 -138
- package/dist-lib/lib/mailbox-template.functions.d.ts.map +1 -1
- package/dist-lib/lib/mailbox.functions.d.ts +13889 -832
- package/dist-lib/lib/mailbox.functions.d.ts.map +1 -1
- package/dist-lib/lib/mailbox.functions.js +43 -8
- package/package.json +1 -1
|
@@ -464,14 +464,32 @@ export const listCustomersForPicker = createServerFn({ method: "GET" })
|
|
|
464
464
|
.from("customers").select("id, company_name, email").eq("is_active", true).order("company_name").range(0, 4999);
|
|
465
465
|
return { items: data ?? [] };
|
|
466
466
|
});
|
|
467
|
+
// Producten voor de picker — alleen items met beschikbare voorraad volgens de
|
|
468
|
+
// Floriday Voorraad Module (`trade_item_stock`). Beschikbaar = physical - reserved.
|
|
469
|
+
// De koppeling loopt via `products.custom_fields.floriday_id` = `trade_item_stock.trade_item_key`.
|
|
467
470
|
export const listProductsForPicker = createServerFn({ method: "GET" })
|
|
468
471
|
.middleware([requireSupabaseAuth])
|
|
469
472
|
.handler(async ({ context }) => {
|
|
473
|
+
const { data: stockRows } = await context.supabase
|
|
474
|
+
.from("trade_item_stock")
|
|
475
|
+
.select("trade_item_key, physical_stock, reserved_stock");
|
|
476
|
+
const availableKeys = new Set();
|
|
477
|
+
for (const s of Array.isArray(stockRows) ? stockRows : []) {
|
|
478
|
+
const avail = Number(s.physical_stock ?? 0) - Number(s.reserved_stock ?? 0);
|
|
479
|
+
if (avail > 0 && typeof s.trade_item_key === "string")
|
|
480
|
+
availableKeys.add(s.trade_item_key);
|
|
481
|
+
}
|
|
482
|
+
if (availableKeys.size === 0)
|
|
483
|
+
return { items: [] };
|
|
470
484
|
const { data } = await context.supabase
|
|
471
485
|
.from("products")
|
|
472
|
-
.select("id, product, unit, plants_per_crate, crates_per_layer, layers_per_cart")
|
|
486
|
+
.select("id, product, unit, plants_per_crate, crates_per_layer, layers_per_cart, custom_fields")
|
|
473
487
|
.order("product").range(0, 4999);
|
|
474
|
-
|
|
488
|
+
const items = (Array.isArray(data) ? data : []).filter((p) => {
|
|
489
|
+
const fid = p?.custom_fields?.floriday_id;
|
|
490
|
+
return typeof fid === "string" && availableKeys.has(fid);
|
|
491
|
+
});
|
|
492
|
+
return { items };
|
|
475
493
|
});
|
|
476
494
|
export const planAndSaveAutoCarts = createServerFn({ method: "POST" })
|
|
477
495
|
.middleware([requireSupabaseAuth])
|
|
@@ -654,16 +672,33 @@ export const listDeliveryLocationsForCustomer = createServerFn({ method: "POST"
|
|
|
654
672
|
.order("name");
|
|
655
673
|
return { items: Array.isArray(rows) ? rows : [] };
|
|
656
674
|
});
|
|
657
|
-
// Onze eigen bedrijfslocaties (tuinen / afhaallocaties)
|
|
675
|
+
// Onze eigen bedrijfslocaties (tuinen / afhaallocaties) — bron: Floriday warehouses cache.
|
|
676
|
+
// Filter op onze eigen warehouses: hasAccess=true en isExternal=false (dus geen KLOK/veiling
|
|
677
|
+
// locaties). Naam valt terug op het adres wanneer het name-veld leeg is (bv. "Zijdeweg 6A").
|
|
658
678
|
export const listPickupLocations = createServerFn({ method: "GET" })
|
|
659
679
|
.middleware([requireSupabaseAuth])
|
|
660
680
|
.handler(async ({ context }) => {
|
|
661
681
|
const { data } = await context.supabase
|
|
662
|
-
.from("
|
|
663
|
-
.select("
|
|
664
|
-
.
|
|
665
|
-
|
|
666
|
-
|
|
682
|
+
.from("floriday_warehouses_cache")
|
|
683
|
+
.select("floriday_id, name, data")
|
|
684
|
+
.eq("is_deleted", false);
|
|
685
|
+
const rows = Array.isArray(data) ? data : [];
|
|
686
|
+
const items = rows
|
|
687
|
+
.filter((r) => {
|
|
688
|
+
const d = r?.data ?? {};
|
|
689
|
+
return d?.hasAccess === true && d?.isExternal === false;
|
|
690
|
+
})
|
|
691
|
+
.map((r) => {
|
|
692
|
+
const addr = r?.data?.location?.address?.addressLine;
|
|
693
|
+
const city = r?.data?.location?.address?.city;
|
|
694
|
+
const nameRaw = typeof r.name === "string" ? r.name.trim() : "";
|
|
695
|
+
const label = nameRaw.length > 0
|
|
696
|
+
? nameRaw
|
|
697
|
+
: [addr, city].filter(Boolean).join(", ") || "(naamloos)";
|
|
698
|
+
return { id: r.floriday_id, name: label, sort_order: 0 };
|
|
699
|
+
})
|
|
700
|
+
.sort((a, b) => a.name.localeCompare(b.name, "nl"));
|
|
701
|
+
return { items };
|
|
667
702
|
});
|
|
668
703
|
export const listCarriersForPicker = createServerFn({ method: "GET" })
|
|
669
704
|
.middleware([requireSupabaseAuth])
|