@flowselections/floriday-voorraad 1.0.27 → 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.
- package/dist-lib/components/voorraad/ArtikelWizard.d.ts.map +1 -1
- package/dist-lib/components/voorraad/ArtikelWizard.js +21 -8
- package/dist-lib/components/voorraad/EditArtikelPage.d.ts.map +1 -1
- package/dist-lib/components/voorraad/EditArtikelPage.js +3 -2
- package/dist-lib/components/voorraad/ProductCustomFieldsCard.d.ts +5 -0
- package/dist-lib/components/voorraad/ProductCustomFieldsCard.d.ts.map +1 -0
- package/dist-lib/components/voorraad/ProductCustomFieldsCard.js +65 -0
- package/dist-lib/components/voorraad/StockBulkButtons.d.ts.map +1 -1
- package/dist-lib/components/voorraad/StockBulkButtons.js +65 -2
- package/dist-lib/components/voorraad/ValidationOverviewTable.d.ts.map +1 -1
- package/dist-lib/components/voorraad/ValidationOverviewTable.js +8 -2
- package/dist-lib/components/voorraad/VoorraadDashboard.d.ts.map +1 -1
- package/dist-lib/components/voorraad/VoorraadDashboard.js +4 -1
- package/dist-lib/components/voorraad/VoorraadTable.d.ts.map +1 -1
- package/dist-lib/components/voorraad/VoorraadTable.js +10 -2
- package/dist-lib/components/voorraad/VoorraadVeldenCard.d.ts +2 -0
- package/dist-lib/components/voorraad/VoorraadVeldenCard.d.ts.map +1 -0
- package/dist-lib/components/voorraad/VoorraadVeldenCard.js +97 -0
- package/dist-lib/hooks/useLocalTradeItems.d.ts +4 -4
- package/dist-lib/hooks/useLocalTradeItems.d.ts.map +1 -1
- package/dist-lib/hooks/useLocalTradeItems.js +59 -35
- package/dist-lib/hooks/useVoorraadCustomFields.d.ts +9 -0
- package/dist-lib/hooks/useVoorraadCustomFields.d.ts.map +1 -0
- package/dist-lib/hooks/useVoorraadCustomFields.js +26 -0
- package/dist-lib/index.d.ts +2 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +4 -1
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +2358 -177
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +2358 -177
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +2358 -177
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +2428 -174
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.js +49 -0
- package/dist-lib/lib/floricode-required-features.functions.d.ts +2358 -177
- package/dist-lib/lib/floricode-required-features.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-customer-offer.functions.d.ts +2358 -177
- package/dist-lib/lib/floriday-customer-offer.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-gateway.functions.d.ts +49617 -38712
- package/dist-lib/lib/floriday-gateway.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-vbn-required.functions.d.ts +13843 -9481
- package/dist-lib/lib/floriday-vbn-required.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-warehouse.functions.d.ts +25719 -19176
- package/dist-lib/lib/floriday-warehouse.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-writes.functions.d.ts +13826 -9464
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
- package/dist-lib/lib/voorraad-custom-fields.d.ts +22 -0
- package/dist-lib/lib/voorraad-custom-fields.d.ts.map +1 -0
- package/dist-lib/lib/voorraad-custom-fields.js +71 -0
- package/package.json +1 -1
|
@@ -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
|
|
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:
|
|
30
|
-
published:
|
|
31
|
-
linkStatus:
|
|
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
|
|
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,
|
|
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.
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
:
|
|
167
|
-
|
|
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 (`
|
|
178
|
-
* `
|
|
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.
|
|
186
|
-
|
|
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);
|
|
@@ -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
|
+
}
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -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
|
package/dist-lib/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
};
|