@flowselections/floriday-voorraad 1.0.26 → 1.0.28

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.
Files changed (104) hide show
  1. package/dist-lib/components/TemplatePage.d.ts +1 -1
  2. package/dist-lib/components/TemplatePage.d.ts.map +1 -1
  3. package/dist-lib/components/voorraad/AdditionalPackagingDialog.d.ts +1 -1
  4. package/dist-lib/components/voorraad/AdditionalPackagingDialog.d.ts.map +1 -1
  5. package/dist-lib/components/voorraad/ArtikelCompositionCard.d.ts +1 -1
  6. package/dist-lib/components/voorraad/ArtikelCompositionCard.d.ts.map +1 -1
  7. package/dist-lib/components/voorraad/ArtikelWizard.d.ts +1 -1
  8. package/dist-lib/components/voorraad/ArtikelWizard.d.ts.map +1 -1
  9. package/dist-lib/components/voorraad/ArtikelWizard.js +21 -8
  10. package/dist-lib/components/voorraad/ConnectionBadge.d.ts +1 -1
  11. package/dist-lib/components/voorraad/ConnectionBadge.d.ts.map +1 -1
  12. package/dist-lib/components/voorraad/EditArtikelPage.d.ts +1 -1
  13. package/dist-lib/components/voorraad/EditArtikelPage.d.ts.map +1 -1
  14. package/dist-lib/components/voorraad/EditArtikelPage.js +3 -2
  15. package/dist-lib/components/voorraad/ExcelExportButton.d.ts +1 -1
  16. package/dist-lib/components/voorraad/ExcelExportButton.d.ts.map +1 -1
  17. package/dist-lib/components/voorraad/FloridayInfoCard.d.ts +1 -1
  18. package/dist-lib/components/voorraad/FloridayInfoCard.d.ts.map +1 -1
  19. package/dist-lib/components/voorraad/FloridayStatusBadge.d.ts +1 -1
  20. package/dist-lib/components/voorraad/FloridayStatusBadge.d.ts.map +1 -1
  21. package/dist-lib/components/voorraad/NieuwArtikelPage.d.ts +1 -1
  22. package/dist-lib/components/voorraad/NieuwArtikelPage.d.ts.map +1 -1
  23. package/dist-lib/components/voorraad/OrderHistoryCard.d.ts +1 -1
  24. package/dist-lib/components/voorraad/OrderHistoryCard.d.ts.map +1 -1
  25. package/dist-lib/components/voorraad/PriceStatusBadge.d.ts +1 -1
  26. package/dist-lib/components/voorraad/PriceStatusBadge.d.ts.map +1 -1
  27. package/dist-lib/components/voorraad/ProductCustomFieldsCard.d.ts +5 -0
  28. package/dist-lib/components/voorraad/ProductCustomFieldsCard.d.ts.map +1 -0
  29. package/dist-lib/components/voorraad/ProductCustomFieldsCard.js +65 -0
  30. package/dist-lib/components/voorraad/ProductLinkCard.d.ts +1 -1
  31. package/dist-lib/components/voorraad/ProductLinkCard.d.ts.map +1 -1
  32. package/dist-lib/components/voorraad/StepSamenstelling.d.ts +1 -1
  33. package/dist-lib/components/voorraad/StepSamenstelling.d.ts.map +1 -1
  34. package/dist-lib/components/voorraad/StockBulkButtons.d.ts +1 -1
  35. package/dist-lib/components/voorraad/StockBulkButtons.d.ts.map +1 -1
  36. package/dist-lib/components/voorraad/StockBulkButtons.js +65 -2
  37. package/dist-lib/components/voorraad/ValidationOverviewTable.d.ts +1 -1
  38. package/dist-lib/components/voorraad/ValidationOverviewTable.d.ts.map +1 -1
  39. package/dist-lib/components/voorraad/ValidationOverviewTable.js +8 -2
  40. package/dist-lib/components/voorraad/ValidationPage.d.ts +1 -1
  41. package/dist-lib/components/voorraad/ValidationPage.d.ts.map +1 -1
  42. package/dist-lib/components/voorraad/VoorraadDashboard.d.ts +1 -1
  43. package/dist-lib/components/voorraad/VoorraadDashboard.d.ts.map +1 -1
  44. package/dist-lib/components/voorraad/VoorraadDashboard.js +4 -1
  45. package/dist-lib/components/voorraad/VoorraadPage.d.ts +1 -1
  46. package/dist-lib/components/voorraad/VoorraadPage.d.ts.map +1 -1
  47. package/dist-lib/components/voorraad/VoorraadPagination.d.ts +1 -1
  48. package/dist-lib/components/voorraad/VoorraadPagination.d.ts.map +1 -1
  49. package/dist-lib/components/voorraad/VoorraadStockCard.d.ts +1 -1
  50. package/dist-lib/components/voorraad/VoorraadStockCard.d.ts.map +1 -1
  51. package/dist-lib/components/voorraad/VoorraadTable.d.ts +1 -1
  52. package/dist-lib/components/voorraad/VoorraadTable.d.ts.map +1 -1
  53. package/dist-lib/components/voorraad/VoorraadTable.js +10 -2
  54. package/dist-lib/components/voorraad/VoorraadVeldenCard.d.ts +2 -0
  55. package/dist-lib/components/voorraad/VoorraadVeldenCard.d.ts.map +1 -0
  56. package/dist-lib/components/voorraad/VoorraadVeldenCard.js +97 -0
  57. package/dist-lib/hooks/useFloriday.d.ts +6 -6
  58. package/dist-lib/hooks/useFloriday.d.ts.map +1 -1
  59. package/dist-lib/hooks/useFloridayVbnRequired.d.ts +2 -2
  60. package/dist-lib/hooks/useFloridayVbnRequired.d.ts.map +1 -1
  61. package/dist-lib/hooks/useLocalTradeItems.d.ts +4 -4
  62. package/dist-lib/hooks/useLocalTradeItems.d.ts.map +1 -1
  63. package/dist-lib/hooks/useLocalTradeItems.js +59 -35
  64. package/dist-lib/hooks/useTradeItemSupplyLine.d.ts +1 -1
  65. package/dist-lib/hooks/useTradeItemSupplyLine.d.ts.map +1 -1
  66. package/dist-lib/hooks/useVbnRegulatoryFeatures.d.ts +1 -1
  67. package/dist-lib/hooks/useVbnRegulatoryFeatures.d.ts.map +1 -1
  68. package/dist-lib/hooks/useVoorraadCustomFields.d.ts +9 -0
  69. package/dist-lib/hooks/useVoorraadCustomFields.d.ts.map +1 -0
  70. package/dist-lib/hooks/useVoorraadCustomFields.js +26 -0
  71. package/dist-lib/index.d.ts +2 -0
  72. package/dist-lib/index.d.ts.map +1 -1
  73. package/dist-lib/index.js +4 -1
  74. package/dist-lib/integrations/supabase/auth-middleware.d.ts +2358 -177
  75. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  76. package/dist-lib/integrations/supabase/client.d.ts +2358 -177
  77. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  78. package/dist-lib/integrations/supabase/client.server.d.ts +2358 -177
  79. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  80. package/dist-lib/integrations/supabase/types.d.ts +2428 -174
  81. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  82. package/dist-lib/integrations/supabase/types.js +49 -0
  83. package/dist-lib/lib/floricode-required-features.functions.d.ts +2373 -198
  84. package/dist-lib/lib/floricode-required-features.functions.d.ts.map +1 -1
  85. package/dist-lib/lib/floriday-customer-offer.functions.d.ts +2375 -192
  86. package/dist-lib/lib/floriday-customer-offer.functions.d.ts.map +1 -1
  87. package/dist-lib/lib/floriday-gateway.functions.d.ts +49617 -38712
  88. package/dist-lib/lib/floriday-gateway.functions.d.ts.map +1 -1
  89. package/dist-lib/lib/floriday-vbn-required.functions.d.ts +13843 -9481
  90. package/dist-lib/lib/floriday-vbn-required.functions.d.ts.map +1 -1
  91. package/dist-lib/lib/floriday-warehouse.functions.d.ts +25719 -19176
  92. package/dist-lib/lib/floriday-warehouse.functions.d.ts.map +1 -1
  93. package/dist-lib/lib/floriday-writes.functions.d.ts +13826 -9464
  94. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
  95. package/dist-lib/lib/voorraad-custom-fields.d.ts +22 -0
  96. package/dist-lib/lib/voorraad-custom-fields.d.ts.map +1 -0
  97. package/dist-lib/lib/voorraad-custom-fields.js +71 -0
  98. package/package.json +1 -1
  99. package/dist-lib/components/settings/VoorraadSettingsCard.d.ts +0 -2
  100. package/dist-lib/components/settings/VoorraadSettingsCard.d.ts.map +0 -1
  101. package/dist-lib/components/settings/VoorraadSettingsCard.js +0 -39
  102. package/dist-lib/components/voorraad/ConnectionPicker.d.ts +0 -8
  103. package/dist-lib/components/voorraad/ConnectionPicker.d.ts.map +0 -1
  104. package/dist-lib/components/voorraad/ConnectionPicker.js +0 -8
@@ -2,5 +2,5 @@ import type { TradeItem } from "../../lib/floriday-client";
2
2
  export declare function VoorraadTable({ items, loading, }: {
3
3
  items: TradeItem[];
4
4
  loading: boolean;
5
- }): import("react/jsx-runtime").JSX.Element;
5
+ }): import("react").JSX.Element;
6
6
  //# sourceMappingURL=VoorraadTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VoorraadTable.d.ts","sourceRoot":"","sources":["../../../src/components/voorraad/VoorraadTable.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAY3D,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,OAAO,GACR,EAAE;IACD,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB,2CA6IA"}
1
+ {"version":3,"file":"VoorraadTable.d.ts","sourceRoot":"","sources":["../../../src/components/voorraad/VoorraadTable.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAmB3D,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,OAAO,GACR,EAAE;IACD,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB,+BAyJA"}
@@ -2,6 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useNavigate } from "@tanstack/react-router";
3
3
  import { Package } from "lucide-react";
4
4
  import { Badge } from "@flowselections/core";
5
+ import { useVoorraadCustomFields } from "../../hooks/useVoorraadCustomFields";
6
+ import { formatCustomValue } from "../../lib/voorraad-custom-fields";
5
7
  const columns = [
6
8
  { key: "quantity", label: "Liggend" },
7
9
  { key: "minQuantity", label: "Minimum" },
@@ -10,15 +12,21 @@ const columns = [
10
12
  { key: "incomingQuantity", label: "Inkomend" },
11
13
  { key: "economicQuantity", label: "Economisch" },
12
14
  ];
15
+ function customValue(item, key) {
16
+ const cf = item.raw?.custom_fields;
17
+ return cf && typeof cf === "object" ? cf[key] : undefined;
18
+ }
13
19
  export function VoorraadTable({ items, loading, }) {
14
20
  const navigate = useNavigate();
21
+ const { fields } = useVoorraadCustomFields();
22
+ const extraColumns = fields.filter((f) => f.show_in_columns);
15
23
  if (loading) {
16
24
  return _jsx("p", { className: "text-sm text-muted-foreground p-6", children: "Voorraad laden..." });
17
25
  }
18
26
  if (items.length === 0) {
19
27
  return (_jsx("p", { className: "text-sm text-muted-foreground p-6", children: "Geen producten gevonden voor deze connectie." }));
20
28
  }
21
- return (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-muted/50 text-left", children: _jsxs("tr", { children: [_jsx("th", { className: "p-3 w-14" }), _jsx("th", { className: "p-3", children: "Product" }), _jsx("th", { className: "p-3", children: "Type" }), _jsx("th", { className: "p-3", children: "Artikelnummer" }), columns.map((c) => (_jsx("th", { className: "p-3 text-right whitespace-nowrap", children: c.label }, c.key)))] }) }), _jsx("tbody", { children: items.map((item) => {
29
+ return (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-muted/50 text-left", children: _jsxs("tr", { children: [_jsx("th", { className: "p-3 w-14" }), _jsx("th", { className: "p-3", children: "Product" }), _jsx("th", { className: "p-3", children: "Type" }), _jsx("th", { className: "p-3", children: "Artikelnummer" }), columns.map((c) => (_jsx("th", { className: "p-3 text-right whitespace-nowrap", children: c.label }, c.key))), extraColumns.map((f) => (_jsx("th", { className: "p-3 whitespace-nowrap", children: f.field_label }, f.id)))] }) }), _jsx("tbody", { children: items.map((item) => {
22
30
  const low = item.minQuantity > 0 &&
23
31
  item.availableQuantity < item.minQuantity;
24
32
  const linkId = item.productId ?? item.localId ?? item.id;
@@ -41,6 +49,6 @@ export function VoorraadTable({ items, loading, }) {
41
49
  : "Niet online in Floriday", title: floriday
42
50
  ? "Online in Floriday"
43
51
  : "Niet online in Floriday", className: "inline-flex items-center gap-1.5 rounded-full border border-border bg-background px-2 py-0.5 text-[11px] font-medium leading-none text-muted-foreground", children: [_jsx("span", { className: "h-1.5 w-1.5 rounded-full " +
44
- (floriday ? "bg-emerald-500" : "bg-red-500"), "aria-hidden": true }), _jsx("span", { children: "Floriday" })] })] }), low && (_jsx("div", { className: "text-xs text-destructive", children: "onder minimumvoorraad" }))] }), _jsx("td", { className: "p-3", children: item.itemType === "productgroep" ? (_jsx(Badge, { className: "bg-indigo-500/15 text-indigo-700 border-indigo-500/30", children: "Productgroep" })) : item.itemType === "samenstelling" ? (_jsx(Badge, { className: "bg-emerald-500/15 text-emerald-700 border-emerald-500/30", children: "Samenstelling" })) : (_jsx(Badge, { variant: "secondary", children: "Artikel" })) }), _jsx("td", { className: "p-3 font-mono text-xs", children: item.articleNumber || "—" }), columns.map((c) => (_jsx("td", { className: "p-3 text-right tabular-nums text-muted-foreground", children: Number(item[c.key] ?? 0) }, c.key)))] }, item.id));
52
+ (floriday ? "bg-emerald-500" : "bg-red-500"), "aria-hidden": true }), _jsx("span", { children: "Floriday" })] })] }), low && (_jsx("div", { className: "text-xs text-destructive", children: "onder minimumvoorraad" }))] }), _jsx("td", { className: "p-3", children: item.itemType === "productgroep" ? (_jsx(Badge, { className: "bg-indigo-500/15 text-indigo-700 border-indigo-500/30", children: "Productgroep" })) : item.itemType === "samenstelling" ? (_jsx(Badge, { className: "bg-emerald-500/15 text-emerald-700 border-emerald-500/30", children: "Samenstelling" })) : (_jsx(Badge, { variant: "secondary", children: "Artikel" })) }), _jsx("td", { className: "p-3 font-mono text-xs", children: item.articleNumber || "—" }), columns.map((c) => (_jsx("td", { className: "p-3 text-right tabular-nums text-muted-foreground", children: Number(item[c.key] ?? 0) }, c.key))), extraColumns.map((f) => (_jsx("td", { className: "p-3 text-muted-foreground whitespace-nowrap", children: formatCustomValue(customValue(item, f.field_key)) }, f.id)))] }, item.id));
45
53
  }) })] }) }));
46
54
  }
@@ -0,0 +1,2 @@
1
+ export declare function VoorraadVeldenCard(): import("react").JSX.Element;
2
+ //# sourceMappingURL=VoorraadVeldenCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VoorraadVeldenCard.d.ts","sourceRoot":"","sources":["../../../src/components/voorraad/VoorraadVeldenCard.tsx"],"names":[],"mappings":"AAoCA,wBAAgB,kBAAkB,gCAqOjC"}
@@ -0,0 +1,97 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Checkbox, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, toast, } from "@flowselections/core";
4
+ import { Loader2, Plus, Trash2 } from "lucide-react";
5
+ import { useVoorraadCustomFields } from "../../hooks/useVoorraadCustomFields";
6
+ import { createVoorraadCustomField, deleteVoorraadCustomField, slugifyFieldKey, updateVoorraadCustomField, } from "../../lib/voorraad-custom-fields";
7
+ const TYPE_LABELS = {
8
+ text: "Tekst",
9
+ number: "Getal",
10
+ date: "Datum",
11
+ select: "Keuzelijst",
12
+ boolean: "Ja / nee",
13
+ };
14
+ export function VoorraadVeldenCard() {
15
+ const { fields, loading, reload } = useVoorraadCustomFields();
16
+ const [label, setLabel] = useState("");
17
+ const [type, setType] = useState("text");
18
+ const [options, setOptions] = useState("");
19
+ const [inTemplate, setInTemplate] = useState(false);
20
+ const [inColumns, setInColumns] = useState(false);
21
+ const [inDetail, setInDetail] = useState(true);
22
+ const [saving, setSaving] = useState(false);
23
+ const add = async () => {
24
+ const trimmed = label.trim();
25
+ if (!trimmed) {
26
+ toast.error("Geef het veld een naam");
27
+ return;
28
+ }
29
+ const key = slugifyFieldKey(trimmed);
30
+ if (!key) {
31
+ toast.error("Ongeldige veldnaam");
32
+ return;
33
+ }
34
+ if (fields.some((f) => f.field_key === key)) {
35
+ toast.error("Er bestaat al een veld met deze naam");
36
+ return;
37
+ }
38
+ setSaving(true);
39
+ try {
40
+ await createVoorraadCustomField({
41
+ field_key: key,
42
+ field_label: trimmed,
43
+ field_type: type,
44
+ options: type === "select"
45
+ ? options
46
+ .split(",")
47
+ .map((o) => o.trim())
48
+ .filter(Boolean)
49
+ : [],
50
+ show_in_template: inTemplate,
51
+ show_in_columns: inColumns,
52
+ show_in_detail: inDetail,
53
+ sort_order: fields.length,
54
+ });
55
+ setLabel("");
56
+ setOptions("");
57
+ setType("text");
58
+ setInTemplate(false);
59
+ setInColumns(false);
60
+ setInDetail(true);
61
+ await reload();
62
+ toast.success("Veld toegevoegd");
63
+ }
64
+ catch (e) {
65
+ toast.error(`Toevoegen mislukt: ${e.message}`);
66
+ }
67
+ finally {
68
+ setSaving(false);
69
+ }
70
+ };
71
+ const toggle = async (id, key, value) => {
72
+ try {
73
+ await updateVoorraadCustomField(id, { [key]: value });
74
+ await reload();
75
+ }
76
+ catch (e) {
77
+ toast.error(`Opslaan mislukt: ${e.message}`);
78
+ }
79
+ };
80
+ const remove = async (id, name) => {
81
+ if (!confirm(`Veld "${name}" verwijderen? Ingevulde waarden blijven bewaard.`))
82
+ return;
83
+ try {
84
+ await deleteVoorraadCustomField(id);
85
+ await reload();
86
+ toast.success("Veld verwijderd");
87
+ }
88
+ catch (e) {
89
+ toast.error(`Verwijderen mislukt: ${e.message}`);
90
+ }
91
+ };
92
+ return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Voorraadvelden" }), _jsx(CardDescription, { children: "Maak eigen velden aan en bepaal per veld waar het zichtbaar is: in de Excel-template, als kolom in de voorraadlijst, en/of op de productpagina." })] }), _jsxs(CardContent, { className: "space-y-6", children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-[1fr_180px] items-end", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "veld-naam", children: "Veldnaam" }), _jsx(Input, { id: "veld-naam", value: label, onChange: (e) => setLabel(e.target.value), placeholder: "Bijv. Kweeklocatie" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { children: "Type" }), _jsxs(Select, { value: type, onValueChange: (v) => setType(v), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: Object.keys(TYPE_LABELS).map((t) => (_jsx(SelectItem, { value: t, children: TYPE_LABELS[t] }, t))) })] })] })] }), type === "select" && (_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "veld-opties", children: "Keuzes (komma-gescheiden)" }), _jsx(Input, { id: "veld-opties", value: options, onChange: (e) => setOptions(e.target.value), placeholder: "Kas 1, Kas 2, Buiten" })] })), _jsxs("div", { className: "flex flex-wrap gap-6", children: [_jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { checked: inTemplate, onCheckedChange: (c) => setInTemplate(c === true) }), "In Excel-template"] }), _jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { checked: inColumns, onCheckedChange: (c) => setInColumns(c === true) }), "Als voorraadkolom"] }), _jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { checked: inDetail, onCheckedChange: (c) => setInDetail(c === true) }), "Op productpagina"] })] }), _jsxs(Button, { onClick: add, disabled: saving, children: [saving ? (_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" })) : (_jsx(Plus, { className: "mr-2 h-4 w-4" })), "Veld toevoegen"] }), _jsx("div", { className: "border-t pt-4", children: loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Velden laden\u2026" })) : fields.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Nog geen eigen voorraadvelden aangemaakt." })) : (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "text-left text-muted-foreground", children: _jsxs("tr", { children: [_jsx("th", { className: "py-2", children: "Veld" }), _jsx("th", { className: "py-2", children: "Type" }), _jsx("th", { className: "py-2 text-center", children: "Template" }), _jsx("th", { className: "py-2 text-center", children: "Kolom" }), _jsx("th", { className: "py-2 text-center", children: "Productpagina" }), _jsx("th", { className: "py-2" })] }) }), _jsx("tbody", { children: fields.map((f) => (_jsxs("tr", { className: "border-t", children: [_jsxs("td", { className: "py-2", children: [_jsx("div", { className: "font-medium text-foreground", children: f.field_label }), _jsx("div", { className: "font-mono text-xs text-muted-foreground", children: f.field_key })] }), _jsx("td", { className: "py-2", children: TYPE_LABELS[f.field_type] ?? f.field_type }), [
93
+ "show_in_template",
94
+ "show_in_columns",
95
+ "show_in_detail",
96
+ ].map((k) => (_jsx("td", { className: "py-2 text-center", children: _jsx(Checkbox, { checked: f[k], onCheckedChange: (c) => toggle(f.id, k, c === true), "aria-label": `${f.field_label} – ${k}` }) }, k))), _jsx("td", { className: "py-2 text-right", children: _jsx(Button, { variant: "ghost", size: "sm", onClick: () => remove(f.id, f.field_label), "aria-label": `Verwijder ${f.field_label}`, children: _jsx(Trash2, { className: "h-4 w-4 text-destructive" }) }) })] }, f.id))) })] }) })) })] })] }));
97
+ }
@@ -27,25 +27,25 @@ export interface FloridaySchema {
27
27
  payload?: unknown;
28
28
  }>>;
29
29
  }
30
- export declare function useFloridaySchema(resource: string, params?: Record<string, string>): import("@tanstack/react-query").UseQueryResult<FloridaySchema, Error>;
31
- export declare function useTradeItemFormSchema(): import("@tanstack/react-query").UseQueryResult<FloridaySchema, Error>;
32
- export declare function useCodeList(listName: string | null | undefined): import("@tanstack/react-query").UseQueryResult<{
30
+ export declare function useFloridaySchema(resource: string, params?: Record<string, string>): import("@tanstack/react-query").UseQueryResult<NoInfer<FloridaySchema>, Error>;
31
+ export declare function useTradeItemFormSchema(): import("@tanstack/react-query").UseQueryResult<NoInfer<FloridaySchema>, Error>;
32
+ export declare function useCodeList(listName: string | null | undefined): import("@tanstack/react-query").UseQueryResult<NoInfer<{
33
33
  ok: boolean;
34
34
  listName: string;
35
35
  values: {
36
36
  code: string;
37
37
  description?: string;
38
38
  }[];
39
- }, Error>;
39
+ }>, Error>;
40
40
  import type { GatewayEntity } from "../lib/floriday-gateway-entities";
41
- export declare function useCachedList(entity: GatewayEntity | null | undefined, limit?: number): import("@tanstack/react-query").UseQueryResult<{
41
+ export declare function useCachedList(entity: GatewayEntity | null | undefined, limit?: number): import("@tanstack/react-query").UseQueryResult<NoInfer<{
42
42
  ok: boolean;
43
43
  entity: string;
44
44
  rows: {
45
45
  id: string;
46
46
  data: Record<string, any>;
47
47
  }[];
48
- }, Error>;
48
+ }>, Error>;
49
49
  /**
50
50
  * Invalideert alle floriday-* queries wanneer de actieve connectie
51
51
  * (en dus mogelijk de environment) wijzigt. Voorkomt cache-bleed
@@ -1 +1 @@
1
- {"version":3,"file":"useFloriday.d.ts","sourceRoot":"","sources":["../../src/hooks/useFloriday.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAChB,MAAM,EACN,KAAK,CAAC;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC,CACH,CAA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anstack/react-query").UseQueryResult<{
1
+ export declare function useFloridayVbnRequired(vbnCode: string | null | undefined): import("@tanstack/react-query").UseQueryResult<NoInfer<{
2
2
  vbnCode: string;
3
3
  requiredCodes: string[];
4
- }, Error>;
4
+ }>, Error>;
5
5
  //# sourceMappingURL=useFloridayVbnRequired.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFloridayVbnRequired.d.ts","sourceRoot":"","sources":["../../src/hooks/useFloridayVbnRequired.ts"],"names":[],"mappings":"AAOA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;;;UASxE"}
1
+ {"version":3,"file":"useFloridayVbnRequired.d.ts","sourceRoot":"","sources":["../../src/hooks/useFloridayVbnRequired.ts"],"names":[],"mappings":"AAOA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;;;WASxE"}
@@ -2,7 +2,7 @@ import type { WizardData } from "../lib/floriday-payload";
2
2
  import { type FloridayLinkStatus, type TradeItem } from "../lib/floriday-client";
3
3
  /**
4
4
  * Concept/Draft is verwijderd. Alle "lokale trade items" leven nu als volwaardige rijen in
5
- * `public.products` met de Floriday-velden in `floriday_payload`. Dit bestand behoudt de
5
+ * `public.products` met de Floriday-velden in `custom_fields.floriday_payload`. Dit bestand behoudt de
6
6
  * oorspronkelijke API-namen zodat bestaande callers blijven werken, maar leest en schrijft
7
7
  * uitsluitend op `products`. `trade_item_drafts` is read-only (trigger blokkeert writes).
8
8
  */
@@ -38,7 +38,7 @@ export interface DraftMeta {
38
38
  source?: "manual" | "excel_import";
39
39
  }
40
40
  /**
41
- * Slaat Floriday-velden op in `products.floriday_payload`. Als `id` ontbreekt maken we een
41
+ * Slaat Floriday-velden op in `products.custom_fields.floriday_payload`. Als `id` ontbreekt maken we een
42
42
  * nieuw product aan (met minimale ERP-velden uit de payload). Nooit een concept-rij.
43
43
  */
44
44
  export declare function upsertLocalTradeItem(params: {
@@ -48,8 +48,8 @@ export declare function upsertLocalTradeItem(params: {
48
48
  meta?: DraftMeta;
49
49
  }): Promise<string>;
50
50
  /**
51
- * Legacy API. Alleen meta-velden die vandaag nog op `products` bestaan (`floriday_active`,
52
- * `floriday_trade_item_id`) worden gepersisteerd; overige velden worden stilzwijgend genegeerd
51
+ * Legacy API. Alleen meta-velden die vandaag nog op `products` bestaan (`floriday_trade_item_id`
52
+ * en `custom_fields.floriday_id`) worden gepersisteerd; overige velden worden stilzwijgend genegeerd
53
53
  * omdat het draft-model verdwenen is.
54
54
  */
55
55
  export declare function updateDraftMeta(id: string, meta: DraftMeta): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalTradeItems.d.ts","sourceRoot":"","sources":["../../src/hooks/useLocalTradeItems.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAwB,KAAK,kBAAkB,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGvG;;;;;GAKG;AAEH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,kBAAkB,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,uBAAuB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1C,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AA2DD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;;;;EA0B9D;AAED,w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B,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpE"}
@@ -1,8 +1,19 @@
1
1
  import { useCallback, useEffect, useState } from "react";
2
2
  import { supabase } from "../integrations/supabase/client";
3
3
  import { derivePrimaryPacking } from "../lib/floriday-client";
4
+ function asRecord(value) {
5
+ return value && typeof value === "object" && !Array.isArray(value)
6
+ ? value
7
+ : {};
8
+ }
4
9
  function productToTradeItem(row) {
5
- const payload = (row.floriday_payload ?? {});
10
+ const cf = asRecord(row.custom_fields);
11
+ const payload = asRecord(cf.floriday_payload);
12
+ const floridayId = row.floriday_trade_item_id ||
13
+ (typeof cf.floriday_id === "string" ? cf.floriday_id : null) ||
14
+ (row.trade_item_key && !row.trade_item_key.startsWith("product:")
15
+ ? row.trade_item_key
16
+ : null);
6
17
  const firstImage = Array.isArray(payload.images) && payload.images.length > 0 ? payload.images[0] : null;
7
18
  const payloadImage = (firstImage && (firstImage.url || firstImage.previewUrl)) ?? null;
8
19
  const packingConfigurations = Array.isArray(payload.packingConfigurations)
@@ -14,7 +25,7 @@ function productToTradeItem(row) {
14
25
  id: row.id,
15
26
  productId: row.id,
16
27
  localId: row.id,
17
- tradeItemKey: `product:${row.id}`,
28
+ tradeItemKey: row.trade_item_key || `product:${row.id}`,
18
29
  source: "product",
19
30
  name,
20
31
  articleNumber,
@@ -26,18 +37,18 @@ function productToTradeItem(row) {
26
37
  incomingQuantity: 0,
27
38
  economicQuantity: 0,
28
39
  raw: row,
29
- floridayActive: row.floriday_active,
30
- published: row.floriday_active,
31
- linkStatus: row.floriday_active ? "published" : "linked",
40
+ floridayActive: Boolean(floridayId),
41
+ published: Boolean(floridayId),
42
+ linkStatus: floridayId ? "published" : "linked",
32
43
  missingFields: [],
33
44
  linkError: null,
34
45
  lastSyncAt: null,
35
- floridayId: row.floriday_trade_item_id,
46
+ floridayId,
36
47
  packingConfigurations,
37
48
  primaryPacking: derivePrimaryPacking(packingConfigurations),
38
49
  };
39
50
  }
40
- const SELECT_COLS = "id,product,article_number,barcode,image_url,floriday_active,floriday_trade_item_id,floriday_payload,updated_at,created_at";
51
+ const SELECT_COLS = "id,product,article_number,barcode,image_url,trade_item_key,floriday_trade_item_id,custom_fields,updated_at,created_at";
41
52
  /**
42
53
  * `connectionId` wordt vandaag genegeerd: producten zijn niet meer per Floriday-connectie gescoped.
43
54
  * De parameter blijft in de signatuur zodat bestaande callers zonder wijziging werken.
@@ -83,11 +94,16 @@ export async function getLocalTradeItem(id) {
83
94
  return {
84
95
  id: p.id,
85
96
  connection_id: null,
86
- data: (p.floriday_payload ?? {}),
97
+ data: (asRecord(p.custom_fields).floriday_payload ?? {
98
+ ...{},
99
+ name: p.product ?? "",
100
+ articleCode: p.article_number ?? "",
101
+ gtin: p.barcode ?? "",
102
+ }),
87
103
  updated_at: p.updated_at,
88
104
  created_at: p.created_at,
89
- floriday_id: p.floriday_trade_item_id,
90
- floriday_link_status: p.floriday_active ? "published" : "linked",
105
+ floriday_id: p.floriday_trade_item_id ?? asRecord(p.custom_fields).floriday_id ?? null,
106
+ floriday_link_status: p.floriday_trade_item_id || asRecord(p.custom_fields).floriday_id ? "published" : "linked",
91
107
  missing_required_fields: [],
92
108
  last_floriday_sync_at: null,
93
109
  floriday_link_error: null,
@@ -95,7 +111,7 @@ export async function getLocalTradeItem(id) {
95
111
  };
96
112
  }
97
113
  /**
98
- * Slaat Floriday-velden op in `products.floriday_payload`. Als `id` ontbreekt maken we een
114
+ * Slaat Floriday-velden op in `products.custom_fields.floriday_payload`. Als `id` ontbreekt maken we een
99
115
  * nieuw product aan (met minimale ERP-velden uit de payload). Nooit een concept-rij.
100
116
  */
101
117
  export async function upsertLocalTradeItem(params) {
@@ -109,15 +125,11 @@ export async function upsertLocalTradeItem(params) {
109
125
  : null;
110
126
  const targetId = params.id && params.id.length > 0 ? params.id : linkedProductId;
111
127
  const productPatch = {
112
- floriday_payload: payload,
113
128
  updated_at: new Date().toISOString(),
114
129
  };
115
130
  if (params.meta?.floridayId !== undefined) {
116
131
  productPatch.floriday_trade_item_id = params.meta.floridayId;
117
132
  }
118
- if (params.meta?.floridayLinkStatus === "published") {
119
- productPatch.floriday_active = true;
120
- }
121
133
  if (payload.name)
122
134
  productPatch.product = payload.name;
123
135
  if (payload.articleCode)
@@ -128,15 +140,21 @@ export async function upsertLocalTradeItem(params) {
128
140
  const firstImageUrl = firstImage?.url || firstImage?.previewUrl;
129
141
  if (firstImageUrl)
130
142
  productPatch.image_url = firstImageUrl;
131
- if (payload.vatRate !== undefined) {
132
- const v = payload.vatRate;
133
- productPatch.vat_rate = v === null || v === "" || Number.isNaN(Number(v)) ? null : Number(v);
134
- }
135
- if (payload.vatCode !== undefined) {
136
- const c = payload.vatCode;
137
- productPatch.vat_code = c && String(c).length > 0 ? String(c) : null;
138
- }
139
143
  if (targetId) {
144
+ const { data: existing } = await supabase
145
+ .from("products")
146
+ .select("custom_fields")
147
+ .eq("id", targetId)
148
+ .maybeSingle();
149
+ const currentCustomFields = asRecord(existing?.custom_fields);
150
+ productPatch.custom_fields = {
151
+ ...currentCustomFields,
152
+ articleCode: payload.articleCode || currentCustomFields.articleCode,
153
+ floriday_id: params.meta?.floridayId !== undefined
154
+ ? params.meta.floridayId
155
+ : currentCustomFields.floriday_id,
156
+ floriday_payload: payload,
157
+ };
140
158
  const { error } = await supabase
141
159
  .from("products")
142
160
  .update(productPatch)
@@ -158,15 +176,12 @@ export async function upsertLocalTradeItem(params) {
158
176
  image_url: firstImageUrl || null,
159
177
  product_type: "levend",
160
178
  trade_item_key: `product:${generatedId}`,
161
- floriday_payload: payload,
162
179
  floriday_trade_item_id: params.meta?.floridayId ?? null,
163
- floriday_active: params.meta?.floridayLinkStatus === "published",
164
- vat_rate: payload.vatRate !== null && payload.vatRate !== undefined && payload.vatRate !== ""
165
- ? Number(payload.vatRate)
166
- : null,
167
- vat_code: payload.vatCode && String(payload.vatCode).length > 0
168
- ? String(payload.vatCode)
169
- : null,
180
+ custom_fields: {
181
+ articleCode: payload.articleCode || null,
182
+ floriday_id: params.meta?.floridayId ?? null,
183
+ floriday_payload: payload,
184
+ },
170
185
  };
171
186
  const { error } = await supabase.from("products").insert(insertRow);
172
187
  if (error)
@@ -174,16 +189,25 @@ export async function upsertLocalTradeItem(params) {
174
189
  return generatedId;
175
190
  }
176
191
  /**
177
- * Legacy API. Alleen meta-velden die vandaag nog op `products` bestaan (`floriday_active`,
178
- * `floriday_trade_item_id`) worden gepersisteerd; overige velden worden stilzwijgend genegeerd
192
+ * Legacy API. Alleen meta-velden die vandaag nog op `products` bestaan (`floriday_trade_item_id`
193
+ * en `custom_fields.floriday_id`) worden gepersisteerd; overige velden worden stilzwijgend genegeerd
179
194
  * omdat het draft-model verdwenen is.
180
195
  */
181
196
  export async function updateDraftMeta(id, meta) {
182
197
  const patch = {};
183
198
  if (meta.floridayId !== undefined)
184
199
  patch.floriday_trade_item_id = meta.floridayId;
185
- if (meta.floridayLinkStatus === "published")
186
- patch.floriday_active = true;
200
+ if (meta.floridayId !== undefined) {
201
+ const { data } = await supabase
202
+ .from("products")
203
+ .select("custom_fields")
204
+ .eq("id", id)
205
+ .maybeSingle();
206
+ patch.custom_fields = {
207
+ ...asRecord(data?.custom_fields),
208
+ floriday_id: meta.floridayId,
209
+ };
210
+ }
187
211
  if (Object.keys(patch).length === 0)
188
212
  return;
189
213
  const { error } = await supabase.from("products").update(patch).eq("id", id);
@@ -17,5 +17,5 @@ export type TradeItemSupplyLine = {
17
17
  * Leest de meest recente supply-line voor een trade item en luistert realtime
18
18
  * op wijzigingen zodat de UI direct meebeweegt na een push naar Floriday.
19
19
  */
20
- export declare function useTradeItemSupplyLine(tradeItemId: string | null | undefined): import("@tanstack/react-query").UseQueryResult<TradeItemSupplyLine | null, Error>;
20
+ export declare function useTradeItemSupplyLine(tradeItemId: string | null | undefined): import("@tanstack/react-query").UseQueryResult<NoInfer<TradeItemSupplyLine | null>, Error>;
21
21
  //# sourceMappingURL=useTradeItemSupplyLine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTradeItemSupplyLine.d.ts","sourceRoot":"","sources":["../../src/hooks/useTradeItemSupplyLine.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,qFA+C5E"}
1
+ {"version":3,"file":"useTradeItemSupplyLine.d.ts","sourceRoot":"","sources":["../../src/hooks/useTradeItemSupplyLine.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,8FA+C5E"}
@@ -1,3 +1,3 @@
1
1
  import { type GetRequiredFeaturesResult } from "../lib/floricode-required-features.functions";
2
- export declare function useVbnRegulatoryFeatures(vbnCode: string | null | undefined): import("@tanstack/react-query").UseQueryResult<GetRequiredFeaturesResult, Error>;
2
+ export declare function useVbnRegulatoryFeatures(vbnCode: string | null | undefined): import("@tanstack/react-query").UseQueryResult<NoInfer<GetRequiredFeaturesResult>, Error>;
3
3
  //# sourceMappingURL=useVbnRegulatoryFeatures.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useVbnRegulatoryFeatures.d.ts","sourceRoot":"","sources":["../../src/hooks/useVbnRegulatoryFeatures.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,8CAA8C,CAAC;AAEtD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,oFAS1E"}
1
+ {"version":3,"file":"useVbnRegulatoryFeatures.d.ts","sourceRoot":"","sources":["../../src/hooks/useVbnRegulatoryFeatures.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,8CAA8C,CAAC;AAEtD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,6FAS1E"}
@@ -0,0 +1,9 @@
1
+ import { type VoorraadCustomField } from "../lib/voorraad-custom-fields";
2
+ /** Laadt de door de gebruiker gedefinieerde voorraadvelden. */
3
+ export declare function useVoorraadCustomFields(): {
4
+ fields: VoorraadCustomField[];
5
+ loading: boolean;
6
+ error: string | null;
7
+ reload: () => Promise<void>;
8
+ };
9
+ //# sourceMappingURL=useVoorraadCustomFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVoorraadCustomFields.d.ts","sourceRoot":"","sources":["../../src/hooks/useVoorraadCustomFields.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,+BAA+B,CAAC;AAEvC,+DAA+D;AAC/D,wBAAgB,uBAAuB;;;;;EAuBtC"}
@@ -0,0 +1,26 @@
1
+ import { useCallback, useEffect, useState } from "react";
2
+ import { fetchVoorraadCustomFields, } from "../lib/voorraad-custom-fields";
3
+ /** Laadt de door de gebruiker gedefinieerde voorraadvelden. */
4
+ export function useVoorraadCustomFields() {
5
+ const [fields, setFields] = useState([]);
6
+ const [loading, setLoading] = useState(true);
7
+ const [error, setError] = useState(null);
8
+ const reload = useCallback(async () => {
9
+ setLoading(true);
10
+ try {
11
+ setFields(await fetchVoorraadCustomFields());
12
+ setError(null);
13
+ }
14
+ catch (e) {
15
+ setFields([]);
16
+ setError(e.message);
17
+ }
18
+ finally {
19
+ setLoading(false);
20
+ }
21
+ }, []);
22
+ useEffect(() => {
23
+ void reload();
24
+ }, [reload]);
25
+ return { fields, loading, error, reload };
26
+ }
@@ -6,5 +6,7 @@ export { EditArtikelPage } from './components/voorraad/EditArtikelPage';
6
6
  export { ValidationPage } from './components/voorraad/ValidationPage';
7
7
  export { ArtikelWizard } from './components/voorraad/ArtikelWizard';
8
8
  export { ProductLinkCard } from './components/voorraad/ProductLinkCard';
9
+ export { VoorraadVeldenCard } from './components/voorraad/VoorraadVeldenCard';
10
+ export { ProductCustomFieldsCard } from './components/voorraad/ProductCustomFieldsCard';
9
11
  export declare const floridayVoorraadModule: FlowModule;
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,eAAO,MAAM,sBAAsB,EAAE,UAUpC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAIxF,eAAO,MAAM,sBAAsB,EAAE,UAUpC,CAAC"}
package/dist-lib/index.js CHANGED
@@ -9,6 +9,9 @@ export { EditArtikelPage } from './components/voorraad/EditArtikelPage';
9
9
  export { ValidationPage } from './components/voorraad/ValidationPage';
10
10
  export { ArtikelWizard } from './components/voorraad/ArtikelWizard';
11
11
  export { ProductLinkCard } from './components/voorraad/ProductLinkCard';
12
+ export { VoorraadVeldenCard } from './components/voorraad/VoorraadVeldenCard';
13
+ export { ProductCustomFieldsCard } from './components/voorraad/ProductCustomFieldsCard';
14
+ import { VoorraadVeldenCard } from './components/voorraad/VoorraadVeldenCard';
12
15
  export const floridayVoorraadModule = {
13
16
  id: "voorraad",
14
17
  name: "Voorraad",
@@ -18,5 +21,5 @@ export const floridayVoorraadModule = {
18
21
  href: "/voorraad",
19
22
  icon: Package,
20
23
  },
21
- settingsCards: [],
24
+ settingsCards: [{ component: VoorraadVeldenCard, order: 50 }],
22
25
  };