@feedmepos/mf-inventory-portal 1.2.12-dev.2 → 1.2.12

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 (74) hide show
  1. package/dist/{App-T4sL7Sy4.js → App-CP0Qx_82.js} +40 -44
  2. package/dist/{ApprovalView-CfmNwkYs.js → ApprovalView-D8_PzEpZ.js} +30 -30
  3. package/dist/{BindingsDialog-DDYAQsNs.js → BindingsDialog-BbpKhb0L.js} +2 -2
  4. package/dist/{BindingsPicker-CXZhlZ4b.js → BindingsPicker-DzDxisHj.js} +1 -1
  5. package/dist/{BindingsTable-LQ59h-NA.js → BindingsTable-DCXXSY8e.js} +1 -1
  6. package/dist/{ClosingDraftView-B1J4RCvY.js → ClosingDraftView-CkF-9An8.js} +129 -129
  7. package/dist/{ClosingTemplateView-6NoqcDMF.js → ClosingTemplateView-Ce1l7n0x.js} +28 -28
  8. package/dist/{DeliveryOrderPrintPreview--XMB1yg_.js → DeliveryOrderPrintPreview-CFzsECiK.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BXxGymbF.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-ZSERZzyn.js} +3 -3
  10. package/dist/{FmMultiselectDialog-DPPNjHO8.js → FmMultiselectDialog-DP992D0Q.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CSgYZv-j.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CzUvuj_c.js} +45 -45
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-tUefDFh2.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DsYwSn0d.js} +1 -1
  13. package/dist/{IngredientGroupView-BjtjeGay.js → IngredientGroupView-DUiKKpvF.js} +32 -31
  14. package/dist/IngredientsView-C3ozIXV8.js +2475 -0
  15. package/dist/{IntegrationView-D8HiAM5K.js → IntegrationView-CydpIwrf.js} +57 -57
  16. package/dist/{InventoryBindingForm-DCtBdWkM.js → InventoryBindingForm-BVd2FzOW.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-RxoPehX0.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CYp_JSBb.js} +31 -31
  18. package/dist/{InventoryBindingSummary-DGLMoDKd.js → InventoryBindingSummary-Dthool-6.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-D0ElZcnn.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DR0_Qtyc.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BNm3V8o4.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BLfGb7mm.js} +1 -1
  21. package/dist/{PublishView-DQcrQkVJ.js → PublishView-BE_aIhZ6.js} +15 -15
  22. package/dist/{PurchaseOrderPrintPreview-1NMEozJD.js → PurchaseOrderPrintPreview-CGeqqFg-.js} +1 -1
  23. package/dist/{ReceiveRequestView-BFs8VYre.js → ReceiveRequestView-Bul9Esf1.js} +63 -62
  24. package/dist/RecipeView-B9AGELV7.js +621 -0
  25. package/dist/{StockView-B80E0r1r.js → StockView-fpJrx4Bd.js} +166 -165
  26. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CFFDw9Mj.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DeOEgJ1N.js} +1 -1
  27. package/dist/{SupplierView-E_fX8cgQ.js → SupplierView-cfZTJqef.js} +492 -490
  28. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-m5o77oG-.js +3057 -0
  29. package/dist/{TransferTemplateView-B-uBdQgp.js → TransferTemplateView-PZ8Mad4D.js} +48 -48
  30. package/dist/UnitView-C3gJq1Mt.js +667 -0
  31. package/dist/{WarehouseView-DZSetx-S.js → WarehouseView-CWGQjwJm.js} +32 -32
  32. package/dist/api/inventory.d.ts +0 -306
  33. package/dist/api/purchase-order.d.ts +0 -1
  34. package/dist/{app-CLG8lnmY.js → app-D5PlbdVa.js} +8475 -8810
  35. package/dist/app.d.ts +0 -169
  36. package/dist/app.js +1 -1
  37. package/dist/array-Ca8T3f_G.js +44 -0
  38. package/dist/{closing-template-CHz79DOu.js → closing-template-C4FizLUw.js} +1 -1
  39. package/dist/{decimal-BNFgzHyV.js → decimal-Cv7FZ14q.js} +1 -1
  40. package/dist/{format-unit-display-DYY0F6KV.js → format-unit-display-B0NO6FLh.js} +25 -25
  41. package/dist/helper/number.d.ts +0 -1
  42. package/dist/{index-Bu7FmfHi.js → index-BCo2jtpG.js} +1 -1
  43. package/dist/{index-DiYSFnk1.js → index-DaJ92t7D.js} +1 -1
  44. package/dist/{purchase-order-template-DtfKTZLV.js → purchase-order-template-DLkR7Mva.js} +1 -1
  45. package/dist/router/name.d.ts +0 -1
  46. package/dist/{stock-RE6RExO9.js → stock-AUSAF9Ij.js} +1 -1
  47. package/dist/stores/feature.d.ts +0 -2
  48. package/dist/stores/inventory.d.ts +199 -26
  49. package/dist/{supplier-DkLAGLl7.js → supplier-DBXoP2UX.js} +1 -1
  50. package/dist/tsconfig.app.tsbuildinfo +1 -1
  51. package/dist/{use-ingredient-select-dialog-Bg_kT9z-.js → use-ingredient-select-dialog-DZQR6jfi.js} +1 -1
  52. package/dist/{use-inventory-binding-dialog-CpS4GfwM.js → use-inventory-binding-dialog-8PZ37vLV.js} +1 -1
  53. package/dist/views/ingredients/helper/import-export.helper.d.ts +1 -3
  54. package/dist/views/recipe/RecipeView.vue.d.ts +0 -1
  55. package/dist/views/unit/UnitView.vue.d.ts +0 -1
  56. package/package.json +1 -1
  57. package/dist/ImportView-ClHIcxRw.js +0 -1195
  58. package/dist/IngredientsView-BA6Y-uhX.js +0 -2240
  59. package/dist/RecipeView-DgF_kShy.js +0 -636
  60. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-Bxl2Gege.js +0 -3221
  61. package/dist/UnitView-DOIy_8oz.js +0 -674
  62. package/dist/import-export.helper-uZNU9S1q.js +0 -243
  63. package/dist/views/import/ImportView.vue.d.ts +0 -3
  64. package/dist/views/import/components/ImportDialog.vue.d.ts +0 -2
  65. package/dist/views/import/helper/import-export.helper.d.ts +0 -4
  66. package/dist/views/receive-request/components/delivery-order-form/SystemTrailDialog.vue.d.ts +0 -17
  67. package/dist/views/recipe/components/import-recipes/ImportRecipeItem.vue.d.ts +0 -16
  68. package/dist/views/recipe/components/import-recipes/ImportRecipes.vue.d.ts +0 -2
  69. package/dist/views/recipe/helper/import-recipe.d.ts +0 -48
  70. package/dist/views/unit/components/import-units/ImportUnitItem.vue.d.ts +0 -12
  71. package/dist/views/unit/components/import-units/ImportUnitItemProps.d.ts +0 -6
  72. package/dist/views/unit/components/import-units/ImportUnits.vue.d.ts +0 -9
  73. package/dist/views/unit/components/import-units/ImportUnitsProps.d.ts +0 -5
  74. package/dist/views/unit/helper/import-export.helper.d.ts +0 -40
@@ -1,1195 +0,0 @@
1
- import { defineComponent as $e, ref as B, computed as Z, watch as Ne, resolveComponent as q, openBlock as S, createElementBlock as P, createVNode as G, normalizeClass as ue, unref as F, createSlots as De, withCtx as J, createElementVNode as a, createBlock as se, toDisplayString as A, createCommentVNode as X, Fragment as Te, renderList as Me, shallowRef as be, h as ge, createTextVNode as he } from "vue";
2
- import { a as ae, aq as Fe, b5 as Se, ao as Ge, V as Pe, an as _e, l as He, z as Oe, B as je, C as ze, E as xe, c as Ve } from "./app-CLG8lnmY.js";
3
- import { useCoreStore as we, useI18n as Be } from "@feedmepos/mf-common";
4
- import { useDialogChild as Ke, useSnackbar as Ae, useDialog as Le, useBreakpoints as We } from "@feedmepos/ui-library";
5
- import { s as Je, g as qe, b as Xe, d as Ce } from "./import-export.helper-uZNU9S1q.js";
6
- import { r as Ee } from "./random-CSbEbElR.js";
7
- function Qe() {
8
- return `unit_${(/* @__PURE__ */ new Date()).toISOString()}_${Ee()}`;
9
- }
10
- function Ue() {
11
- return `measurement_${(/* @__PURE__ */ new Date()).toISOString()}_${Ee()}`;
12
- }
13
- function Ye(k) {
14
- const [
15
- e,
16
- E,
17
- g,
18
- h,
19
- x,
20
- b,
21
- ...t
22
- ] = Fe(k);
23
- if (!e || !e.length || e.some((l) => l.length && !l.startsWith("system:")))
24
- throw new Error("Missing meta header. Excel file does not come from the template.");
25
- const o = e.map((l) => l.split(":")[1]), p = ["name", "symbol", "precision"].filter((l) => !o.includes(l));
26
- if (p.length)
27
- throw new Error(
28
- `Missing meta headers (${p.join()}). Excel file does not come from the template.`
29
- );
30
- return t.map((l, f) => {
31
- const v = {};
32
- for (const d in o) {
33
- const i = o[d];
34
- Object.assign(v, { [i]: l[d] });
35
- }
36
- return {
37
- index: f,
38
- data: v
39
- };
40
- });
41
- }
42
- function Ze(k) {
43
- try {
44
- const e = Ye(k).filter((t) => {
45
- const { name: o, symbol: s, precision: p, measurement_name: u, measurement_symbol: l, measurement_conversion: f } = t.data;
46
- return o || s || p || u || l || f;
47
- }), g = ae().units, h = [], x = [];
48
- let b = {};
49
- for (const t of e)
50
- if (t.data.name && t.data.symbol)
51
- b[t.data.name] = {
52
- unit: {
53
- _id: Qe(),
54
- name: t.data.name,
55
- abbrev: t.data.symbol,
56
- precision: Math.max(0, Math.min(10, Math.floor(t.data.precision || 2))),
57
- measurements: []
58
- },
59
- rowNumber: t.index
60
- }, t.data.measurement_name && t.data.measurement_symbol && t.data.measurement_conversion && b[t.data.name].unit.measurements.push({
61
- id: Ue(),
62
- name: t.data.measurement_name,
63
- abbrev: t.data.measurement_symbol,
64
- conversion: {
65
- amount: Math.round(t.data.measurement_conversion * Math.pow(10, b[t.data.name].unit.precision)),
66
- precision: b[t.data.name].unit.precision
67
- }
68
- });
69
- else {
70
- const o = Object.keys(b)[Object.keys(b).length - 1];
71
- o && b[o] && t.data.measurement_name && t.data.measurement_symbol && t.data.measurement_conversion && b[o].unit.measurements.push({
72
- id: Ue(),
73
- name: t.data.measurement_name,
74
- abbrev: t.data.measurement_symbol,
75
- conversion: {
76
- amount: Math.round(t.data.measurement_conversion * Math.pow(10, b[o].unit.precision)),
77
- precision: b[o].unit.precision
78
- }
79
- });
80
- }
81
- for (const [t, { unit: o, rowNumber: s }] of Object.entries(b)) {
82
- const p = g.find((u) => {
83
- var l, f;
84
- return u.abbrev === o.abbrev && ((l = u.name) == null ? void 0 : l.trim()) === ((f = o.name) == null ? void 0 : f.trim());
85
- });
86
- p ? x.push({
87
- type: "update",
88
- original: p,
89
- unit: {
90
- ...p,
91
- name: o.name || p.name,
92
- abbrev: o.abbrev || p.abbrev,
93
- precision: o.precision !== void 0 ? o.precision : p.precision,
94
- measurements: o.measurements.map((u) => {
95
- const l = p.measurements.find((f) => f.name === u.name && f.abbrev === u.abbrev);
96
- return l ? { ...l, ...u, id: l.id } : u;
97
- })
98
- },
99
- errors: [],
100
- excelRowNumber: s
101
- }) : h.push({
102
- type: "create",
103
- unit: o,
104
- errors: [],
105
- excelRowNumber: s
106
- });
107
- }
108
- return {
109
- invalidExcel: !1,
110
- importCreateResult: h,
111
- importUpdateResult: x
112
- };
113
- } catch (e) {
114
- return {
115
- invalidExcel: !0,
116
- invalidExcelMessage: (e == null ? void 0 : e.message) ?? "Invalid excel",
117
- importCreateResult: [],
118
- importUpdateResult: []
119
- };
120
- }
121
- }
122
- function et() {
123
- return `recipe_${(/* @__PURE__ */ new Date()).toISOString()}_${Ee()}`;
124
- }
125
- function tt(k, { ignoreErrors: e = !1 } = {}) {
126
- var E, g, h;
127
- try {
128
- const x = ae(), b = x.skuByCode, t = x.recipeByName, o = x.skuGroupById, s = x.skuGroups, p = x.units, u = [];
129
- let l = {};
130
- for (const r of k) {
131
- const y = [];
132
- let R = "";
133
- if (r.data.type === "INGREDIENT") {
134
- const U = b[r.data.code];
135
- U ? R = U._id : y.push(`Ingredient with code '${r.data.code}' not found`);
136
- } else if (r.data.type === "RECIPE") {
137
- const U = t[r.data.name];
138
- U ? R = U._id : y.push(`Recipe with name '${r.data.name}' not found`);
139
- } else if (r.data.type === "SKU_GROUP") {
140
- const U = s.find(($) => $.ref === r.data.code || $.name === r.data.name);
141
- U ? R = U._id : y.push(`SKU Group with ref '${r.data.code}' or name '${r.data.name}' not found`);
142
- } else
143
- y.push(`Invalid type '${r.data.type}'. Must be 'INGREDIENT', 'RECIPE', or 'SKU_GROUP'`);
144
- (!r.data.amount || isNaN(parseFloat(r.data.amount))) && y.push(`Invalid amount '${r.data.amount}'. Must be a valid number`);
145
- let D;
146
- if ((r.data.unit || r.data.baseUnit) && r.data.type !== "RECIPE" && r.data.type !== "SKU_GROUP" && (D = p.find((U) => {
147
- var $, ee;
148
- return U.abbrev === r.data.baseUnit && (($ = U.name) == null ? void 0 : $.trim()) === ((ee = r.data.unit) == null ? void 0 : ee.trim());
149
- }), D || (r.data.baseUnit && r.data.unit ? y.push(`Cannot find unit with symbol '${r.data.baseUnit}' and name '${r.data.unit}'`) : r.data.baseUnit ? y.push(`Cannot find unit with symbol '${r.data.baseUnit}'`) : r.data.unit && y.push(`Cannot find unit with name '${r.data.unit}'`))), y.length > 0 && u.push(`Row ${r.index + 6}: ${y.join(", ")}`), e || y.length === 0) {
150
- let U;
151
- if (r.data.type === "RECIPE" || r.data.type === "SKU_GROUP" ? U = void 0 : U = (E = D == null ? void 0 : D.measurements) == null ? void 0 : E.find(($) => $.abbrev === r.data.measurementName), r.data.recipeName)
152
- l[r.data.recipeName] = {
153
- _id: et(),
154
- name: r.data.recipeName,
155
- customAttributes: r.data.customAttributes ? Je(r.data.customAttributes) : {},
156
- contains: [{
157
- type: r.data.type === "INGREDIENT" ? "SKU" : r.data.type,
158
- id: R,
159
- amount: {
160
- amount: parseFloat(r.data.amount) || 0,
161
- precision: Se(r.data.amount) === !0 && ((g = r.data.amount.split(".")[1]) == null ? void 0 : g.length) || 0
162
- },
163
- measurement: U || void 0
164
- }]
165
- }, u[r.data.recipeName] = y.length > 0 ? `Row ${r.index + 6}: ${y.join(", ")}` : [];
166
- else {
167
- const $ = Object.keys(l)[Object.keys(l).length - 1];
168
- $ && l[$] && (l[$] = {
169
- ...l[$],
170
- contains: [
171
- ...l[$].contains,
172
- {
173
- type: r.data.type === "INGREDIENT" ? "SKU" : r.data.type,
174
- id: R,
175
- amount: {
176
- amount: parseFloat(r.data.amount) || 0,
177
- precision: Se(r.data.amount) === !0 && ((h = r.data.amount.split(".")[1]) == null ? void 0 : h.length) || 0
178
- },
179
- measurement: U || void 0
180
- }
181
- ]
182
- }, u[$] = y.length > 0 ? u[$] ? `${u[$]}, Row ${r.index + 6}: ${y.join(", ")}` : `Row ${r.index + 6}: ${y.join(", ")}` : []);
183
- }
184
- }
185
- }
186
- const f = Object.values(l), v = f.filter((r) => !t[r.name]), d = f.filter((r) => t[r.name]), i = v.map((r, y) => ({
187
- type: "create",
188
- recipe: r,
189
- errors: u[r.name],
190
- excelRowNumber: y + 6
191
- // Assuming header rows
192
- })), C = d.map((r, y) => {
193
- const R = t[r.name];
194
- return {
195
- type: "update",
196
- original: R,
197
- recipe: {
198
- ...R,
199
- name: r.name || R.name,
200
- contains: r.contains.length > 0 ? r.contains : R.contains,
201
- customAttributes: r.customAttributes || R.customAttributes
202
- },
203
- errors: u[r.name],
204
- excelRowNumber: y + 6
205
- };
206
- });
207
- return {
208
- invalidExcel: u.length > 0,
209
- invalidExcelMessage: u.length > 0 ? `Import completed with ${u.length} error(s): ${u.join("; ")}` : void 0,
210
- importCreateResult: i,
211
- importUpdateResult: C
212
- };
213
- } catch (x) {
214
- return {
215
- invalidExcel: !0,
216
- invalidExcelMessage: x instanceof Error ? x.message : "Unknown error occurred",
217
- importCreateResult: [],
218
- importUpdateResult: []
219
- };
220
- }
221
- }
222
- function rt(k) {
223
- const [
224
- e,
225
- E,
226
- g,
227
- h,
228
- x,
229
- b,
230
- ...t
231
- ] = Fe(k);
232
- if (!e || !e.length || e.some((l) => l.length && !l.startsWith("system:")))
233
- throw new Error("Missing meta header. Excel file does not come from the template.");
234
- const o = e.map((l) => l.split(":")[1]), p = ["code", "recipeName", "unit", "baseUnit", "type", "amount"].filter((l) => !o.includes(l));
235
- if (p.length)
236
- throw new Error(
237
- `Missing meta headers (${p.join()}). Excel file does not come from the template.`
238
- );
239
- return t.map((l, f) => {
240
- const v = {};
241
- for (const d in o) {
242
- const i = o[d];
243
- Object.assign(v, { [i]: l[d] });
244
- }
245
- return {
246
- index: f,
247
- data: v
248
- };
249
- }).filter((l) => {
250
- const { recipeName: f, type: v, code: d, name: i, amount: C, unit: r, baseUnit: y, measurementName: R, customAttributes: D } = l.data;
251
- return f || v || d || i || C || r || y || R || D;
252
- });
253
- }
254
- function nt() {
255
- const e = we().currentBusiness.value, E = ae(), g = [
256
- { id: "name", name: "Unit Name" },
257
- { id: "symbol", name: "Symbol" },
258
- { id: "precision", name: "Precision" },
259
- { id: "measurement_name", name: "Measurement Name" },
260
- { id: "measurement_symbol", name: "Measurement Symbol" },
261
- { id: "measurement_conversion", name: "Measurement Conversion" }
262
- ];
263
- let h = [];
264
- E.units.length > 0 ? E.units.forEach((t) => {
265
- if (t.measurements.length === 0)
266
- h.push([
267
- t.name,
268
- t.abbrev,
269
- t.precision,
270
- "",
271
- "",
272
- ""
273
- ]);
274
- else {
275
- h.push([
276
- t.name,
277
- t.abbrev,
278
- t.precision,
279
- t.measurements[0].name,
280
- t.measurements[0].abbrev,
281
- t.measurements[0].conversion.amount
282
- ]);
283
- for (let o = 1; o < t.measurements.length; o++)
284
- h.push([
285
- "",
286
- "",
287
- "",
288
- t.measurements[o].name,
289
- t.measurements[o].abbrev,
290
- t.measurements[o].conversion.amount
291
- ]);
292
- }
293
- }) : h = [
294
- ["Length", "m", 2, "Meter", "m", 1],
295
- ["", "", "", "Centimeter", "cm", 0.01],
296
- ["", "", "", "Millimeter", "mm", 1e-3],
297
- ["Weight", "kg", 3, "Kilogram", "kg", 1],
298
- ["", "", "", "Gram", "g", 1e-3],
299
- ["", "", "", "Pound", "lb", 0.453592]
300
- ];
301
- const x = [
302
- ["Business name:", e == null ? void 0 : e.name],
303
- ["Business ID:", e == null ? void 0 : e._id],
304
- ["Menu version", e == null ? void 0 : e.menuVersion],
305
- [],
306
- g.map((t) => t.name),
307
- ...h
308
- ], b = g.map((t) => `system:${t.id}`);
309
- return _e(x, b);
310
- }
311
- function st() {
312
- const e = we().currentBusiness.value, E = ae(), g = Xe();
313
- let h = [];
314
- E.skus.length > 0 ? h = E.skus.map((t) => {
315
- var o, s, p, u, l, f, v, d;
316
- return [
317
- t.code,
318
- t.name,
319
- ((o = t.unit) == null ? void 0 : o.name) || "",
320
- ((s = t.unit) == null ? void 0 : s.abbrev) || "",
321
- ((u = (p = t.unit) == null ? void 0 : p.measurements.find((i) => i.id === t.trackingMeasurement)) == null ? void 0 : u.abbrev) ?? t.unit.abbrev,
322
- t.valuation || "WAVG",
323
- (l = t.defaultCost) != null && l.costPerUnit ? +He((f = t.defaultCost) == null ? void 0 : f.costPerUnit) : 0,
324
- ((v = t.thresholds) == null ? void 0 : v.low) ?? Ce().low,
325
- ((d = t.thresholds) == null ? void 0 : d.mid) ?? Ce().mid,
326
- t.customAttributes ? Object.entries(t.customAttributes).map(([i, C]) => `${i}:${C}`).join("|") : ""
327
- ];
328
- }) : h = [
329
- ["EXAMPLE_CODE", "Example Ingredient", "kg", "kg", "Unit Name", "WAVG", 10.5, 5, 10, ""]
330
- ];
331
- const x = [
332
- ["Business name:", e == null ? void 0 : e.name],
333
- ["Business ID:", e == null ? void 0 : e._id],
334
- ["Menu version", e == null ? void 0 : e.menuVersion],
335
- [],
336
- g.map((t) => t.name),
337
- ...h
338
- ], b = g.map((t) => `system:${t.id}`);
339
- return _e(x, b);
340
- }
341
- function at() {
342
- const e = we().currentBusiness.value, E = ae(), g = [
343
- { id: "recipeName", name: "Recipe Name" },
344
- { id: "type", name: "Type" },
345
- { id: "code", name: "Code" },
346
- { id: "name", name: "Item Name" },
347
- { id: "amount", name: "Amount" },
348
- { id: "unit", name: "Unit" },
349
- { id: "baseUnit", name: "Base Unit" },
350
- { id: "measurementName", name: "Measurement Name" },
351
- { id: "customAttributes", name: "Custom Attributes" }
352
- ];
353
- let h = [];
354
- if (E.recipes.length > 0) {
355
- const t = E.recipeById, o = E.skuById, s = E.skuGroupById;
356
- h = E.recipes.flatMap((p) => {
357
- var l;
358
- const u = p.customAttributes ? Object.entries(p.customAttributes).map(([f, v]) => `${f}:${v}`).join("|") : "";
359
- if ((l = p.contains) != null && l.length) {
360
- const f = p.contains.filter((i) => i.type === "RECIPE"), v = p.contains.filter((i) => i.type === "SKU"), d = p.contains.filter((i) => i.type === "SKU_GROUP");
361
- return [
362
- ...f.map((i, C) => {
363
- var r;
364
- return [
365
- C === 0 ? p.name : "",
366
- "RECIPE",
367
- "",
368
- ((r = t[i.id]) == null ? void 0 : r.name) || "",
369
- i.amount.amount,
370
- "",
371
- "unit",
372
- "Unit",
373
- C === 0 ? u : ""
374
- ];
375
- }),
376
- ...v.map((i, C) => {
377
- var r, y, R, D, U, $, ee, de, oe, ce, ie, me, pe, ve, fe, ye;
378
- return [
379
- !f.length && C === 0 ? p.name : "",
380
- "INGREDIENT",
381
- ((r = o[i.id]) == null ? void 0 : r.code) || "",
382
- ((y = o[i.id]) == null ? void 0 : y.name) || "",
383
- i.amount.amount,
384
- i.measurement ? ((D = (R = o[i.id]) == null ? void 0 : R.unit) == null ? void 0 : D.name) || "" : (($ = (U = o[i.id]) == null ? void 0 : U.unit) == null ? void 0 : $.name) || "",
385
- i.measurement ? ((de = (ee = o[i.id]) == null ? void 0 : ee.unit) == null ? void 0 : de.abbrev) || "" : ((ce = (oe = o[i.id]) == null ? void 0 : oe.unit) == null ? void 0 : ce.abbrev) || "",
386
- i.measurement ? i.measurement.abbrev : ((ve = (pe = (me = (ie = o[i.id]) == null ? void 0 : ie.unit) == null ? void 0 : me.measurements) == null ? void 0 : pe.find((m) => {
387
- var n;
388
- return m.id === ((n = o[i.id]) == null ? void 0 : n.trackingMeasurement);
389
- })) == null ? void 0 : ve.abbrev) || ((ye = (fe = o[i.id]) == null ? void 0 : fe.unit) == null ? void 0 : ye.abbrev) || "",
390
- !f.length && C === 0 ? u : ""
391
- ];
392
- }),
393
- ...d.map((i, C) => {
394
- var r, y;
395
- return [
396
- f.length === 0 && v.length === 0 && C === 0 ? p.name : "",
397
- "SKU_GROUP",
398
- ((r = s[i.id]) == null ? void 0 : r.ref) || "",
399
- ((y = s[i.id]) == null ? void 0 : y.name) || "",
400
- i.amount.amount,
401
- "",
402
- "unit",
403
- "Unit",
404
- f.length === 0 && v.length === 0 && C === 0 ? u : ""
405
- ];
406
- })
407
- ];
408
- }
409
- return [];
410
- });
411
- } else
412
- h = [
413
- ["Pizza Dough", "INGREDIENT", "FLOUR001", "Flour", "500", "Weight", "g", "Gram", "difficulty:easy, category:italian"],
414
- ["", "INGREDIENT", "WATER001", "Water", "300", "Volume", "ml", "Milliliter", ""],
415
- ["", "INGREDIENT", "SALT001", "Salt", "10", "Weight", "g", "Gram", ""]
416
- ];
417
- const x = [
418
- ["Business name:", e == null ? void 0 : e.name],
419
- ["Business ID:", e == null ? void 0 : e._id],
420
- ["Menu version", e == null ? void 0 : e.menuVersion],
421
- [],
422
- g.map((t) => t.name),
423
- ...h
424
- ], b = g.map((t) => `system:${t.id}`);
425
- return _e(x, b);
426
- }
427
- function ot() {
428
- const k = Ge({
429
- unit: nt(),
430
- ingredient: st(),
431
- recipe: at()
432
- }), e = "FeedMe comprehensive template.xlsx";
433
- return Pe(k, e), e;
434
- }
435
- async function it(k) {
436
- if (!k) return null;
437
- try {
438
- return Ze(k);
439
- } catch (e) {
440
- throw console.error("Error in processUnitsSheet:", e), e;
441
- }
442
- }
443
- async function lt(k) {
444
- if (!k) return null;
445
- try {
446
- return qe(k);
447
- } catch (e) {
448
- throw console.error("Error in processIngredientsSheet:", e), e;
449
- }
450
- }
451
- async function ut(k) {
452
- if (!k) return null;
453
- try {
454
- const e = rt(k);
455
- return tt(e, { ignoreErrors: !0 });
456
- } catch (e) {
457
- throw console.error("Error in processRecipesSheet:", e), e;
458
- }
459
- }
460
- const dt = { class: "flex flex-col gap-24" }, ct = { class: "flex flex-col gap-8" }, mt = { class: "flex flex-col flex-1 gap-4" }, pt = { class: "fm-typo-en-body-md-600" }, vt = {
461
- key: 2,
462
- class: "shrink-0"
463
- }, ft = {
464
- key: 0,
465
- class: "flex flex-col"
466
- }, yt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, gt = {
467
- key: 0,
468
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
469
- }, ht = { class: "fm-typo-en-body-lg-600" }, bt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, xt = /* @__PURE__ */ $e({
470
- __name: "ImportDialog",
471
- setup(k) {
472
- const e = B(null), E = Ke();
473
- Ae();
474
- const g = B(!1), h = B(new Array()), x = B(null), b = B([]), t = B([]), o = Z(() => !!h.value.length), s = Z(() => !!x.value && b.value.length > 0), { t: p } = Be();
475
- async function u(v) {
476
- h.value = [], x.value = null, b.value = [], t.value = [];
477
- try {
478
- g.value = !0;
479
- const [d] = await Promise.all([
480
- je(v),
481
- // fake buffer for UX
482
- new Promise((i) => setTimeout(i, 1e3))
483
- ]);
484
- x.value = d, l();
485
- } catch (d) {
486
- console.error("Error parsing Excel file:", d), h.value.push((d == null ? void 0 : d.message) || "Unknown error occurred");
487
- } finally {
488
- g.value = !1;
489
- }
490
- }
491
- function l() {
492
- if (h.value = [], !x.value) return;
493
- const d = ["unit", "ingredient", "recipe"].filter((i) => x.value.Sheets[i]);
494
- if (d.length === 0) {
495
- h.value.push("No valid sheets found. Expected sheets: unit, ingredient, or recipe");
496
- return;
497
- }
498
- b.value = d, E.emitData({ availableSheets: d, workbook: x.value });
499
- }
500
- Ne(e, (v) => {
501
- v && u(v);
502
- });
503
- function f() {
504
- if (!x.value || b.value.length === 0) return "";
505
- const v = [];
506
- return b.value.forEach((d) => {
507
- switch (d) {
508
- case "unit":
509
- v.push("Units sheet found");
510
- break;
511
- case "ingredient":
512
- v.push("Ingredients sheet found");
513
- break;
514
- case "recipe":
515
- v.push("Recipes sheet found");
516
- break;
517
- }
518
- }), v.length > 0 ? `Ready to process: ${v.join(", ")}. Processing will follow dependency order.` : "No valid sheets found";
519
- }
520
- return (v, d) => {
521
- const i = q("FmCircularProgress"), C = q("FmIcon"), r = q("FmButton");
522
- return S(), P("div", dt, [
523
- G(Oe, {
524
- class: ue({
525
- "w-full": !0,
526
- "h-[200px]": !e.value
527
- }),
528
- accept: ".xlsx,.xls",
529
- onFileUpload: d[0] || (d[0] = (y) => e.value = y),
530
- label: F(p)("inventory.ingredient.import.uploadTemplate"),
531
- "button-label": F(p)("inventory.ingredient.import.selectFile")
532
- }, De({ _: 2 }, [
533
- e.value ? {
534
- name: "default",
535
- fn: J(({ openFileDialog: y }) => [
536
- a("div", ct, [
537
- a("div", {
538
- class: ue([
539
- "fm-corner-radius-md p-16 flex items-center gap-16",
540
- {
541
- "border border-fm-color-neutral-gray-100": g.value,
542
- "border border-fm-color-neutral-gray-200": !g.value && !o.value,
543
- "border border-fm-color-system-error-200": o.value
544
- }
545
- ])
546
- }, [
547
- g.value ? (S(), se(i, {
548
- key: 0,
549
- size: "md",
550
- color: "neutral-gray-200"
551
- })) : (S(), se(C, {
552
- key: 1,
553
- name: o.value ? "error" : "check_circle",
554
- color: o.value ? "system-error-300" : "system-success-400",
555
- size: "lg"
556
- }, null, 8, ["name", "color"])),
557
- a("div", mt, [
558
- a("div", pt, A(e.value.name), 1),
559
- a("div", {
560
- class: ue([
561
- "fm-typo-en-body-sm-400",
562
- {
563
- "text-fm-color-system-error-300": o.value,
564
- "text-fm-color-typo-secondary": !o.value
565
- }
566
- ])
567
- }, A(o.value ? F(p)("inventory.ingredient.import.error.invalidContent") : "File valid"), 3)
568
- ]),
569
- g.value ? X("", !0) : (S(), P("div", vt, [
570
- G(r, {
571
- label: F(p)("inventory.ingredient.import.replaceFile"),
572
- variant: o.value ? "destructive" : "secondary",
573
- "prepend-icon": o.value ? void 0 : "autorenew",
574
- onClick: y
575
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
576
- ]))
577
- ], 2),
578
- h.value.length ? (S(), P("div", ft, [
579
- (S(!0), P(Te, null, Me(h.value, (R, D) => (S(), P("div", {
580
- key: D,
581
- class: "flex gap-8 items-center"
582
- }, [
583
- G(C, {
584
- name: "error",
585
- size: "sm",
586
- color: "system-error-300"
587
- }),
588
- a("div", yt, A(R), 1)
589
- ]))), 128))
590
- ])) : X("", !0)
591
- ])
592
- ]),
593
- key: "0"
594
- } : void 0
595
- ]), 1032, ["class", "label", "button-label"]),
596
- s.value ? (S(), P("div", gt, [
597
- a("div", ht, A(F(p)("inventory.ingredient.import.summary")), 1),
598
- a("div", bt, A(f()), 1)
599
- ])) : X("", !0)
600
- ]);
601
- };
602
- }
603
- }), _t = {
604
- key: 0,
605
- class: "bg-blue-50 border border-blue-200 rounded-lg p-16"
606
- }, wt = { class: "flex items-start gap-12" }, Et = { class: "flex flex-col gap-8" }, kt = { class: "fm-typo-en-body-md-400 text-blue-800" }, It = { class: "fm-typo-en-body-sm-400 text-blue-700" }, Rt = ["innerHTML"], St = ["innerHTML"], Ct = {
607
- key: 1,
608
- class: "bg-white rounded-lg shadow"
609
- }, Ut = { class: "flex items-center justify-between p-16 border-b" }, $t = { class: "fm-typo-en-body-sm-400 text-gray-600 mt-4" }, Nt = {
610
- key: 0,
611
- class: "text-red-600"
612
- }, Tt = {
613
- key: 1,
614
- class: "text-orange-600"
615
- }, Mt = {
616
- key: 2,
617
- class: "text-green-600"
618
- }, Ft = { class: "flex gap-8" }, Bt = { class: "p-16" }, At = {
619
- key: 2,
620
- class: "bg-white rounded-lg shadow"
621
- }, Dt = { class: "flex items-center justify-between p-16 border-b" }, Gt = { class: "fm-typo-en-body-sm-400 text-gray-600 mt-4" }, Pt = { class: "flex gap-8" }, Ht = { class: "p-16" }, Ot = {
622
- key: 0,
623
- class: "flex flex-col gap-16 p-16"
624
- }, jt = { class: "grid grid-cols-2 gap-12" }, zt = { class: "fm-typo-en-body-md-600" }, Vt = { key: 0 }, Kt = { class: "fm-typo-en-body-md-600" }, Lt = { class: "fm-typo-en-body-md-600" }, Wt = { class: "fm-typo-en-body-md-600" }, Jt = { class: "space-y-8" }, qt = { class: "fm-typo-en-body-md-400 text-red-800" }, Xt = { class: "bg-gray-50 p-12 rounded border overflow-auto" }, Qt = { class: "text-sm" }, Yt = { class: "flex gap-8" }, Zt = { class: "flex flex-col items-center justify-center h-64 gap-16" }, er = { class: "flex flex-col items-center justify-center h-64 gap-16" }, ir = /* @__PURE__ */ $e({
625
- __name: "ImportView",
626
- setup(k) {
627
- const { t: e } = Be(), E = Le(), g = Ae();
628
- ze();
629
- const h = Ve(), { breakpoints: x } = We(), b = ae(), t = B("");
630
- B(!1);
631
- const o = B(!1), s = B(null), p = B(!1), u = B(null), l = B(!1), f = B([]), v = B(null), d = B([]), i = B(!1), C = Z(() => x.value.xs || x.value.sm), r = Z(() => C.value ? 10 : 20), y = Z(() => s.value ? !!(s.value.units && [
632
- ...s.value.units.create || [],
633
- ...s.value.units.update || []
634
- ].some((n) => n.errors && n.errors.length > 0) || s.value.skus && [
635
- ...s.value.skus.create || [],
636
- ...s.value.skus.update || []
637
- ].some((n) => n.errors && n.errors.length > 0) || s.value.recipes && [
638
- ...s.value.recipes.create || [],
639
- ...s.value.recipes.update || []
640
- ].some((n) => n.errors && n.errors.length > 0)) : !1), R = Z(() => s.value ? !!s.value._invalidExcel : !1), D = be([]);
641
- Ne(
642
- s,
643
- (m) => {
644
- if (!m) {
645
- D.value = [];
646
- return;
647
- }
648
- const n = [], { units: I, skus: j, recipes: L, _invalidExcel: z, _invalidExcelMessage: W } = m, M = (_) => _.errors && _.errors.length > 0 ? _.errors || "Validation Failed" : z ? W || "Invalid Excel format" : "Ready to Import", V = (_, H) => {
649
- if (_) {
650
- if (_.create)
651
- for (const w of _.create)
652
- n.push({
653
- name: w.name || w.abbrev || w.code || "Unknown",
654
- type: H,
655
- operation: "Create",
656
- status: M(w),
657
- errors: w.errors || [],
658
- details: w
659
- });
660
- if (_.update)
661
- for (const w of _.update)
662
- n.push({
663
- name: w.name || w.abbrev || w.code || "Unknown",
664
- type: H,
665
- operation: "Update",
666
- status: M(w),
667
- errors: w.errors || [],
668
- details: w
669
- });
670
- }
671
- };
672
- V(I, "Unit"), V(j, "Ingredient"), V(L, "Recipe"), D.value = n;
673
- },
674
- { immediate: !0, deep: !0 }
675
- );
676
- const U = Z(() => !d.value || d.value.length === 0 ? [] : d.value.map((m, n) => {
677
- var I;
678
- return {
679
- id: n + 1,
680
- name: m.error.data.name || "Unknown",
681
- type: m.type || "General",
682
- message: ((I = m.error) == null ? void 0 : I.message) || JSON.stringify(m.error)
683
- };
684
- }));
685
- function $(m) {
686
- switch (m) {
687
- case "import":
688
- return ee();
689
- }
690
- }
691
- B(null);
692
- function ee() {
693
- E.open({
694
- title: e("common.import"),
695
- contentComponent: xt,
696
- overlay: !0,
697
- closeButton: !0,
698
- primaryActions: {
699
- text: e("common.next"),
700
- close: !1
701
- },
702
- secondaryActions: {
703
- text: e("common.close"),
704
- close: !0
705
- },
706
- tertiaryActions: {
707
- text: e("inventory.ingredient.import.actions.downloadTemplate"),
708
- close: !1,
709
- variant: "plain"
710
- }
711
- }).onPrimary(async (m) => {
712
- m && m.workbook && m.availableSheets && (await de(m), E.close()), f.value.length === 0 && E.close();
713
- }).onTertiary(() => {
714
- try {
715
- const m = ot();
716
- g.open({
717
- title: e("common.export") + " " + e("inventory.ingredient.import.actions.downloadTemplate"),
718
- message: `Template downloaded: ${m}`,
719
- type: "success"
720
- });
721
- } catch (m) {
722
- g.open({
723
- title: "Download Failed",
724
- message: "Failed to download template. Please try again.",
725
- type: "error"
726
- }), console.error("Error downloading template:", m);
727
- }
728
- });
729
- }
730
- async function de(m) {
731
- s.value || (s.value = {}), v.value = m.workbook, f.value = [...m.availableSheets], await oe();
732
- }
733
- async function oe() {
734
- var n, I, j, L, z, W;
735
- if (!v.value || f.value.length === 0) {
736
- p.value = !0;
737
- return;
738
- }
739
- const m = f.value[0];
740
- try {
741
- s.value || (s.value = {});
742
- const M = s.value;
743
- switch (m) {
744
- case "unit":
745
- const V = v.value.Sheets.unit, _ = await it(V);
746
- _ && (_.invalidExcel && (M._invalidExcel = !0, M._invalidExcelMessage = _.invalidExcelMessage || "Invalid Excel format for Units sheet"), (_.importCreateResult || _.importUpdateResult) && (M.units = {
747
- create: ((n = _.importCreateResult) == null ? void 0 : n.map((T) => ({ ...T.unit, errors: T.errors }))) || [],
748
- update: ((I = _.importUpdateResult) == null ? void 0 : I.map((T) => ({ ...T.unit, errors: T.errors }))) || []
749
- }));
750
- break;
751
- case "ingredient":
752
- const H = v.value.Sheets.ingredient, w = await lt(H);
753
- w && (w.invalidExcel && (M._invalidExcel = !0, M._invalidExcelMessage = w.invalidExcelMessage || "Invalid Excel format for Ingredients sheet"), (w.importCreateResult || w.importUpdateResult) && (M.skus = {
754
- create: ((j = w.importCreateResult) == null ? void 0 : j.map((T) => ({ ...T.sku, errors: T.errors }))) || [],
755
- update: ((L = w.importUpdateResult) == null ? void 0 : L.map((T) => ({ ...T.sku, errors: T.errors }))) || []
756
- }));
757
- break;
758
- case "recipe":
759
- const te = v.value.Sheets.recipe, O = await ut(te);
760
- O && (O.invalidExcel && (M._invalidExcel = !0, M._invalidExcelMessage = O.invalidExcelMessage || "Invalid Excel format for Recipes sheet"), (O.importCreateResult || O.importUpdateResult) && (M.recipes = {
761
- create: ((z = O.importCreateResult) == null ? void 0 : z.map((T) => ({ ...T.recipe, errors: T.errors }))) || [],
762
- update: ((W = O.importUpdateResult) == null ? void 0 : W.map((T) => ({ ...T.recipe, errors: T.errors }))) || []
763
- }));
764
- break;
765
- }
766
- f.value.shift(), p.value = !0;
767
- } catch (M) {
768
- console.error(`Error processing ${m} sheet:`, M), g.open({
769
- title: "Processing Error",
770
- message: `Failed to process ${m} sheet`,
771
- type: "error"
772
- });
773
- }
774
- }
775
- async function ce() {
776
- var m, n, I, j, L, z, W, M, V, _, H, w, te, O, T, ke, Ie, Re;
777
- if (s.value) {
778
- if (R.value) {
779
- g.open({
780
- title: "Invalid Excel Format",
781
- message: s.value._invalidExcelMessage || "Invalid Excel format detected",
782
- type: "error"
783
- });
784
- return;
785
- }
786
- if (y.value) {
787
- g.open({
788
- title: e("inventory.import.error.invalidContent"),
789
- message: e("inventory.ingredient.import.error.hasErrors"),
790
- type: "error"
791
- });
792
- return;
793
- }
794
- o.value = !0;
795
- try {
796
- let K = 0, re = "";
797
- if (s.value.units && ((m = s.value.units.create) != null && m.length || (n = s.value.units.update) != null && n.length)) {
798
- const N = {
799
- create: ((I = s.value.units.create) == null ? void 0 : I.filter((c) => !c.errors || c.errors.length === 0)) || [],
800
- update: ((j = s.value.units.update) == null ? void 0 : j.filter((c) => !c.errors || c.errors.length === 0)) || []
801
- };
802
- if (N.create.length || N.update.length) {
803
- const c = await b.importUnits(N);
804
- c && c.errors && c.errors.length > 0 && d.value.push(...c.errors.map((ne) => ({
805
- type: "units",
806
- error: ne
807
- })));
808
- const Q = N.create.length + N.update.length, Y = c && c.errors ? c.errors.length : 0;
809
- K = Q - Y, re = "units", s.value.units = null;
810
- }
811
- } else if (s.value.skus && ((L = s.value.skus.create) != null && L.length || (z = s.value.skus.update) != null && z.length)) {
812
- const N = {
813
- create: ((W = s.value.skus.create) == null ? void 0 : W.filter((c) => !c.errors || c.errors.length === 0)) || [],
814
- update: ((M = s.value.skus.update) == null ? void 0 : M.filter((c) => !c.errors || c.errors.length === 0)) || []
815
- };
816
- if (N.create.length || N.update.length) {
817
- const c = await b.importSkus(N);
818
- c && c.errors && c.errors.length > 0 && d.value.push(...c.errors.map((ne) => ({
819
- type: "ingredients",
820
- error: ne
821
- })));
822
- const Q = N.create.length + N.update.length, Y = c && c.errors ? c.errors.length : 0;
823
- K = Q - Y, re = "ingredients", s.value.skus = null;
824
- }
825
- } else if (s.value.recipes && ((V = s.value.recipes.create) != null && V.length || (_ = s.value.recipes.update) != null && _.length)) {
826
- const N = {
827
- create: ((H = s.value.recipes.create) == null ? void 0 : H.filter((c) => !c.errors || c.errors.length === 0)) || [],
828
- update: ((w = s.value.recipes.update) == null ? void 0 : w.filter((c) => !c.errors || c.errors.length === 0)) || []
829
- };
830
- if (N.create.length || N.update.length) {
831
- const c = await b.importRecipes(N);
832
- c && c.errors && c.errors.length > 0 && d.value.push(...c.errors.map((ne) => ({
833
- type: "recipes",
834
- error: ne
835
- })));
836
- const Q = N.create.length + N.update.length, Y = c && c.errors ? c.errors.length : 0;
837
- K = Q - Y, re = "recipes", s.value.recipes = null;
838
- }
839
- }
840
- if (K > 0) {
841
- const N = d.value.filter((c) => c.type === re);
842
- N.length > 0 ? g.open({
843
- title: "Import Completed with Issues",
844
- message: `Successfully imported ${K} ${re}, failed ${N.length} ${re}`,
845
- type: "warning"
846
- }) : g.open({
847
- title: e("inventory.ingredient.import.success"),
848
- message: `Successfully imported ${K} ${re}`,
849
- type: "success"
850
- });
851
- }
852
- if (f.value.length > 0)
853
- await oe();
854
- else if (!(s.value.units && (((te = s.value.units.create) == null ? void 0 : te.length) || ((O = s.value.units.update) == null ? void 0 : O.length)) || s.value.skus && (((T = s.value.skus.create) == null ? void 0 : T.length) || ((ke = s.value.skus.update) == null ? void 0 : ke.length)) || s.value.recipes && (((Ie = s.value.recipes.create) == null ? void 0 : Ie.length) || ((Re = s.value.recipes.update) == null ? void 0 : Re.length))))
855
- if (ie(), d.value.length > 0) {
856
- const c = d.value.filter((le) => le.type === "units").length, Q = d.value.filter((le) => le.type === "ingredients").length, Y = d.value.filter((le) => le.type === "recipes").length, ne = c + Q + Y;
857
- i.value = !0, g.open({
858
- title: "Import Completed with Issues",
859
- message: `Import finished with ${ne} failed items (${c} units, ${Q} ingredients, ${Y} recipes failed). Check the error details below.`,
860
- type: "warning"
861
- }), console.error("Import errors:", d.value);
862
- } else
863
- g.open({
864
- title: "Import Complete",
865
- message: "All data has been successfully imported!",
866
- type: "success"
867
- });
868
- } catch (K) {
869
- g.open({
870
- title: e("inventory.ingredient.import.error.failed"),
871
- message: (K == null ? void 0 : K.message) || "Unknown error occurred",
872
- type: "error"
873
- }), console.error("Error during import:", K);
874
- } finally {
875
- o.value = !1;
876
- }
877
- }
878
- }
879
- function ie() {
880
- p.value = !1, i.value = !1, s.value = null, f.value = [], v.value = null;
881
- }
882
- function me() {
883
- i.value = !1, d.value = [];
884
- }
885
- function pe() {
886
- l.value = !1, u.value = null;
887
- }
888
- const ve = Z(() => [
889
- {
890
- label: e("common.import"),
891
- value: "import",
892
- isPrimary: !1,
893
- prependIcon: "upload"
894
- }
895
- ]), fe = be([
896
- {
897
- id: "name",
898
- accessorKey: "name",
899
- header: () => "Name",
900
- size: 200
901
- },
902
- {
903
- id: "type",
904
- accessorKey: "type",
905
- header: () => "Type",
906
- size: 120
907
- },
908
- {
909
- id: "operation",
910
- accessorKey: "operation",
911
- header: () => "Operation",
912
- size: 100
913
- },
914
- {
915
- id: "status",
916
- accessorKey: "status",
917
- header: () => "Status",
918
- size: 120,
919
- cell: (m) => {
920
- const n = m.row.original.status;
921
- let I = "px-8 py-4 rounded";
922
- return n === "Ready to Import" ? I += " bg-blue-100 text-blue-800 border border-blue-200" : n === "Imported" || n === "Successfully Imported" ? I += " bg-green-100 text-green-800 border border-green-200" : n === "Failed" ? I += " bg-red-100 text-red-800 border border-red-200" : n === "Validation Failed" ? I += " bg-orange-100 text-orange-800 border border-orange-200" : (n.includes("Invalid Excel"), I += " bg-red-100 text-red-800 border border-red-200"), ge("div", { class: I, title: n }, n);
923
- }
924
- }
925
- ]), ye = be([
926
- {
927
- id: "name",
928
- accessorKey: "name",
929
- header: () => "Name",
930
- cell: (m) => ge("div", { class: "text-gray-800 text-sm py-2" }, m.row.original.name || "Unknown")
931
- },
932
- {
933
- id: "type",
934
- accessorKey: "type",
935
- header: () => "Error Type",
936
- cell: (m) => {
937
- const n = m.row.original.type;
938
- return ge("div", { class: "text-gray-800 text-sm py-2" }, n === "units" ? "Unit" : n === "ingredients" ? "Ingredient" : n === "recipes" ? "Recipe" : "Unknown");
939
- }
940
- },
941
- {
942
- id: "message",
943
- accessorKey: "message",
944
- header: () => "Error Message",
945
- cell: (m) => ge(
946
- "div",
947
- { class: "text-red-800 text-sm py-2", title: m.row.original.message },
948
- m.row.original.message
949
- )
950
- }
951
- ]);
952
- return (m, n) => {
953
- const I = q("FmIcon"), j = q("FmButton"), L = q("FmTable"), z = q("FmCard"), W = q("FmSideSheet"), M = q("FmSpinner");
954
- return F(h).isLoaded && F(h).enableBulkImport ? (S(), se(xe, {
955
- key: 0,
956
- title: F(e)("inventory.common.import"),
957
- actions: ve.value,
958
- "onClick:action": $
959
- }, {
960
- default: J(() => {
961
- var V;
962
- return [
963
- a("div", {
964
- class: ue([
965
- "flex flex-col gap-8 max-h-full",
966
- {
967
- "p-0": C.value,
968
- "px-24": !C.value
969
- }
970
- ])
971
- }, [
972
- p.value ? X("", !0) : (S(), P("div", _t, [
973
- a("div", wt, [
974
- G(I, {
975
- name: "info",
976
- class: "text-blue-600 mt-2"
977
- }),
978
- a("div", Et, [
979
- a("div", kt, A(F(e)("inventory.ingredient.import.multiUploadTemplateInstruction")), 1),
980
- a("div", It, [
981
- n[1] || (n[1] = he(" 1. ")),
982
- a("span", {
983
- innerHTML: F(e)("inventory.ingredient.import.importInstructions.step1")
984
- }, null, 8, Rt),
985
- n[2] || (n[2] = a("br", null, null, -1)),
986
- n[3] || (n[3] = he(" 2. ")),
987
- a("span", {
988
- innerHTML: F(e)("inventory.ingredient.import.importInstructions.step2")
989
- }, null, 8, St),
990
- n[4] || (n[4] = a("br", null, null, -1)),
991
- he(" 3. " + A(F(e)("inventory.ingredient.import.importInstructions.step3")), 1),
992
- n[5] || (n[5] = a("br", null, null, -1)),
993
- he(" 4. " + A(F(e)("inventory.ingredient.import.importInstructions.step4")), 1)
994
- ])
995
- ])
996
- ])
997
- ])),
998
- p.value ? (S(), P("div", Ct, [
999
- a("div", Ut, [
1000
- a("div", null, [
1001
- n[6] || (n[6] = a("div", { class: "fm-typo-en-title-md-600" }, "Import Preview", -1)),
1002
- a("div", $t, [
1003
- R.value ? (S(), P("span", Nt, " Error exist: " + A(s.value._invalidExcelMessage), 1)) : y.value ? (S(), P("span", Tt, " Some items have validation errors. Only valid items will be imported. ")) : (S(), P("span", Mt, " All items are valid and ready to import. "))
1004
- ])
1005
- ]),
1006
- a("div", Ft, [
1007
- G(j, {
1008
- variant: "secondary",
1009
- onClick: ie,
1010
- label: F(e)("common.cancel")
1011
- }, null, 8, ["label"]),
1012
- G(j, {
1013
- variant: "primary",
1014
- onClick: ce,
1015
- loading: o.value,
1016
- disabled: o.value || y.value || R.value,
1017
- label: F(e)("common.import")
1018
- }, null, 8, ["loading", "disabled", "label"])
1019
- ])
1020
- ]),
1021
- a("div", Bt, [
1022
- G(L, {
1023
- "column-defs": fe.value,
1024
- "row-data": D.value,
1025
- "page-size": r.value,
1026
- "search-value": t.value,
1027
- loading: !1,
1028
- "row-hover": ""
1029
- }, null, 8, ["column-defs", "row-data", "page-size", "search-value"])
1030
- ])
1031
- ])) : X("", !0),
1032
- i.value && d.value.length > 0 ? (S(), P("div", At, [
1033
- a("div", Dt, [
1034
- a("div", null, [
1035
- n[7] || (n[7] = a("div", { class: "fm-typo-en-title-md-600 text-red-800" }, "Import Errors", -1)),
1036
- a("div", Gt, A(d.value.length) + " items failed to import. Review the errors below: ", 1)
1037
- ]),
1038
- a("div", Pt, [
1039
- G(j, {
1040
- variant: "secondary",
1041
- onClick: me,
1042
- label: F(e)("common.close")
1043
- }, null, 8, ["label"])
1044
- ])
1045
- ]),
1046
- a("div", Ht, [
1047
- G(L, {
1048
- "column-defs": ye.value,
1049
- "row-data": U.value,
1050
- "page-size": r.value,
1051
- "search-value": t.value,
1052
- loading: !1,
1053
- "row-hover": ""
1054
- }, null, 8, ["column-defs", "row-data", "page-size", "search-value"])
1055
- ])
1056
- ])) : X("", !0)
1057
- ], 2),
1058
- G(W, {
1059
- "model-value": l.value,
1060
- "onUpdate:modelValue": n[0] || (n[0] = (_) => l.value = _),
1061
- header: `${(V = u.value) == null ? void 0 : V.type} Details`,
1062
- "max-width": 600,
1063
- "dismiss-away": ""
1064
- }, {
1065
- "side-sheet-footer": J(() => [
1066
- a("div", Yt, [
1067
- G(j, {
1068
- label: "Close",
1069
- variant: "tertiary",
1070
- onClick: pe
1071
- })
1072
- ])
1073
- ]),
1074
- default: J(() => [
1075
- u.value != null ? (S(), P("div", Ot, [
1076
- G(z, {
1077
- variant: "outlined",
1078
- class: "p-16"
1079
- }, {
1080
- default: J(() => {
1081
- var _, H, w, te, O;
1082
- return [
1083
- n[13] || (n[13] = a("div", { class: "fm-typo-en-title-sm-600 mb-12" }, "Basic Information", -1)),
1084
- a("div", jt, [
1085
- a("div", null, [
1086
- n[8] || (n[8] = a("div", { class: "fm-typo-en-body-sm-400 text-gray-600" }, "Name", -1)),
1087
- a("div", zt, A(((H = (_ = u.value) == null ? void 0 : _.details) == null ? void 0 : H.name) || ((w = u.value) == null ? void 0 : w.name)), 1)
1088
- ]),
1089
- (O = (te = u.value) == null ? void 0 : te.details) != null && O.code ? (S(), P("div", Vt, [
1090
- n[9] || (n[9] = a("div", { class: "fm-typo-en-body-sm-400 text-gray-600" }, "Code", -1)),
1091
- a("div", Kt, A(u.value.details.code), 1)
1092
- ])) : X("", !0),
1093
- a("div", null, [
1094
- n[10] || (n[10] = a("div", { class: "fm-typo-en-body-sm-400 text-gray-600" }, "Type", -1)),
1095
- a("div", Lt, A(u.value.type), 1)
1096
- ]),
1097
- a("div", null, [
1098
- n[11] || (n[11] = a("div", { class: "fm-typo-en-body-sm-400 text-gray-600" }, "Operation", -1)),
1099
- a("div", Wt, A(u.value.operation), 1)
1100
- ]),
1101
- a("div", null, [
1102
- n[12] || (n[12] = a("div", { class: "fm-typo-en-body-sm-400 text-gray-600" }, "Status", -1)),
1103
- a("div", {
1104
- class: ue([
1105
- "inline-block px-8 py-4 rounded text-sm",
1106
- u.value.status !== "Ready to Import" ? "bg-red-100 text-red-800 border border-red-200" : "bg-green-100 text-green-800 border border-green-200"
1107
- ])
1108
- }, A(u.value.status), 3)
1109
- ])
1110
- ])
1111
- ];
1112
- }),
1113
- _: 1
1114
- }),
1115
- u.value.errors && u.value.errors.length > 0 ? (S(), se(z, {
1116
- key: 0,
1117
- variant: "outlined",
1118
- class: "p-16"
1119
- }, {
1120
- default: J(() => [
1121
- n[14] || (n[14] = a("div", { class: "fm-typo-en-title-sm-600 mb-12 text-red-800" }, "Validation Errors", -1)),
1122
- a("div", Jt, [
1123
- (S(!0), P(Te, null, Me(u.value.errors, (_, H) => (S(), P("div", {
1124
- key: H,
1125
- class: "flex items-start gap-8 p-12 bg-red-50 border border-red-200 rounded"
1126
- }, [
1127
- G(I, {
1128
- name: "error",
1129
- class: "text-red-600 mt-2",
1130
- size: "sm"
1131
- }),
1132
- a("div", qt, A(_), 1)
1133
- ]))), 128))
1134
- ])
1135
- ]),
1136
- _: 1
1137
- })) : X("", !0),
1138
- G(z, {
1139
- variant: "outlined",
1140
- class: "p-16"
1141
- }, {
1142
- default: J(() => [
1143
- n[15] || (n[15] = a("div", { class: "fm-typo-en-title-sm-600 mb-12" }, "Raw Data", -1)),
1144
- a("div", Xt, [
1145
- a("pre", Qt, A(JSON.stringify(u.value.details, null, 2)), 1)
1146
- ])
1147
- ]),
1148
- _: 1
1149
- })
1150
- ])) : X("", !0)
1151
- ]),
1152
- _: 1
1153
- }, 8, ["model-value", "header"])
1154
- ];
1155
- }),
1156
- _: 1
1157
- }, 8, ["title", "actions"])) : F(h).isLoaded ? (S(), se(xe, {
1158
- key: 2,
1159
- title: F(e)("inventory.common.import")
1160
- }, {
1161
- default: J(() => [
1162
- a("div", er, [
1163
- G(I, {
1164
- name: "block",
1165
- class: "text-gray-400",
1166
- size: "xl"
1167
- }),
1168
- n[17] || (n[17] = a("div", { class: "text-center" }, [
1169
- a("div", { class: "fm-typo-en-title-md-600 text-gray-600 mb-8" }, "Feature Not Available"),
1170
- a("div", { class: "fm-typo-en-body-md-400 text-gray-500" }, " The bulk import feature is not enabled for your account. ")
1171
- ], -1))
1172
- ])
1173
- ]),
1174
- _: 1
1175
- }, 8, ["title"])) : (S(), se(xe, {
1176
- key: 1,
1177
- title: F(e)("inventory.common.import")
1178
- }, {
1179
- default: J(() => [
1180
- a("div", Zt, [
1181
- G(M, { size: "lg" }),
1182
- n[16] || (n[16] = a("div", { class: "text-center" }, [
1183
- a("div", { class: "fm-typo-en-title-md-600 text-gray-600 mb-8" }, "Loading..."),
1184
- a("div", { class: "fm-typo-en-body-md-400 text-gray-500" }, " Checking feature availability... ")
1185
- ], -1))
1186
- ])
1187
- ]),
1188
- _: 1
1189
- }, 8, ["title"]));
1190
- };
1191
- }
1192
- });
1193
- export {
1194
- ir as default
1195
- };