@feedmepos/mf-inventory-portal 1.0.37-dev.3 → 1.0.38

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 (81) hide show
  1. package/dist/{App-Dmd2G8R5.js → App-Bh_jIWxm.js} +1 -1
  2. package/dist/{ApprovalView-Dp3k5vDw.js → ApprovalView-U-Jo7wyv.js} +19 -19
  3. package/dist/{BindingsDialog-D80Yhk4v.js → BindingsDialog-CC0wt6a_.js} +4 -4
  4. package/dist/{BindingsPicker-BYRH73Mx.js → BindingsPicker-WL_1lOdc.js} +1 -1
  5. package/dist/{BindingsTable-CvblcQnI.js → BindingsTable-DJf1WJou.js} +4 -4
  6. package/dist/{ClosingDraftView-DiUIrHnf.js → ClosingDraftView-BI19VIT_.js} +26 -26
  7. package/dist/ClosingTemplateView-B6p83fs1.js +1804 -0
  8. package/dist/{DeliveryOrderPrintPreview-7DmbPXg9.js → DeliveryOrderPrintPreview-LANZdQE7.js} +4 -4
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C_QmBqHi.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Bhz1nVO6.js} +11 -11
  10. package/dist/{FmMultiselectDialog-m2Wih5ZC.js → FmMultiselectDialog-B16LNSaK.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-C0Ky06__.js → FmUnitInput.vue_vue_type_script_setup_true_lang-pAmapm7v.js} +21 -21
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DLfxc861.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-D7wM9EQ2.js} +1 -1
  13. package/dist/{IngredientGroupView-Um-bP1SR.js → IngredientGroupView-Bi8657CZ.js} +2 -2
  14. package/dist/IngredientsView-CGEQ-GvW.js +1838 -0
  15. package/dist/{IntegrationView-DfBOpvo1.js → IntegrationView-mYS_UJlk.js} +76 -77
  16. package/dist/{InventoryBindingForm-sbgSzNep.js → InventoryBindingForm-D-Y-IDFl.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CYpXwzuu.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-ByFJ6s6U.js} +24 -24
  18. package/dist/{InventoryBindingSummary-BWdagbGS.js → InventoryBindingSummary-z6XljZ_R.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BvdA5Qfu.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-ihrVnPMe.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CBH7oYpv.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DhoXg0vX.js} +10 -10
  21. package/dist/{PublishView-CjX1ZmFe.js → PublishView-DB7j7FkK.js} +17 -17
  22. package/dist/{PurchaseOrderPrintPreview-M20PXH1Z.js → PurchaseOrderPrintPreview-CTQIzDKp.js} +12 -12
  23. package/dist/{ReceiveRequestView-CF9p1j-M.js → ReceiveRequestView-B2UDO9o9.js} +782 -797
  24. package/dist/{RecipeView-kVgJAZ9d.js → RecipeView-BIDDh0V9.js} +3 -3
  25. package/dist/{StockView-B9bSTjY4.js → StockView-BgzAJBdL.js} +6 -6
  26. package/dist/{SupplierView-uaW913cH.js → SupplierView-zS3HDy59.js} +3 -3
  27. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Bwiv5v2m.js → TransferDetails.vue_vue_type_script_setup_true_lang-DhnPjxXG.js} +696 -691
  28. package/dist/{TransferTemplateView-BuHT8mNT.js → TransferTemplateView-DLS9QAGY.js} +83 -83
  29. package/dist/{UnitView-Db_ETZrB.js → UnitView-B8mfgqXO.js} +3 -3
  30. package/dist/{WarehouseView-2SJNm6XK.js → WarehouseView-D4yYBRSM.js} +1 -1
  31. package/dist/api/inventory.d.ts +0 -4
  32. package/dist/api/netsuite.d.ts +0 -7
  33. package/dist/{app-CoEB-VoH.js → app-BLo-E2P1.js} +61427 -61936
  34. package/dist/app.d.ts +0 -9
  35. package/dist/app.js +1 -1
  36. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +0 -1
  37. package/dist/components/row-action.enum.d.ts +1 -2
  38. package/dist/components/shell/inventory/binding-ui.vue.d.ts +0 -1
  39. package/dist/{decimal-B7itxUWP.js → decimal-u4mLA_2Z.js} +1 -1
  40. package/dist/format-unit-display-g_Tq_sk7.js +1230 -0
  41. package/dist/{index-YGLKr3WK.js → index-BbBtmjWx.js} +1 -1
  42. package/dist/{index-DfWaG7Tl.js → index-Bu2R1xRv.js} +1 -1
  43. package/dist/{stock-CCQ352Hu.js → stock-BxIuAFed.js} +1 -1
  44. package/dist/stores/integration/netsuite.d.ts +1 -7
  45. package/dist/stores/inventory.d.ts +0 -9
  46. package/dist/{supplier-BCwA2FHM.js → supplier-CQftkZPG.js} +1 -1
  47. package/dist/tsconfig.app.tsbuildinfo +1 -1
  48. package/dist/{use-ingredient-select-dialog-DOONV-IL.js → use-ingredient-select-dialog-C9I7bja9.js} +1 -1
  49. package/dist/{use-inventory-binding-dialog-BPM-7FrW.js → use-inventory-binding-dialog-s8nyBhfo.js} +1 -1
  50. package/dist/views/adjustment-template/wastage-template/actions.d.ts +1 -4
  51. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +0 -8
  52. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +0 -24
  53. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +0 -1
  54. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +1 -16
  55. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +0 -12
  56. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +0 -2
  57. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +0 -1
  58. package/dist/views/integration/components/netsuite/InventoryTransferIngredientTable.vue.d.ts +0 -2
  59. package/dist/views/integration/components/netsuite/business/BusinessNetSuiteSideSheet.vue.d.ts +0 -4
  60. package/dist/views/receive-request/components/netsuite/NetSuiteLog.vue.d.ts +2 -2
  61. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +0 -17
  62. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +0 -2
  63. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +0 -4
  64. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +0 -1
  65. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +0 -4
  66. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +0 -24
  67. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +0 -24
  68. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +0 -2
  69. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +0 -2
  70. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +0 -2
  71. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +0 -2
  72. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +0 -1
  73. package/dist/views/transfer-template/composables/use-netsuite-custom-field.d.ts +0 -3
  74. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1 -16
  75. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +0 -12
  76. package/dist/{vue-i18n-DZAYeut-.js → vue-i18n-C3CYm8Dg.js} +352 -352
  77. package/package.json +1 -1
  78. package/dist/ClosingTemplateView-BGyaxOv_.js +0 -1849
  79. package/dist/IngredientsView-BOYvD0VL.js +0 -1858
  80. package/dist/api/duplicate-template.d.ts +0 -5
  81. package/dist/format-unit-display-DswmXjqB.js +0 -1275
@@ -0,0 +1,1804 @@
1
+ import { ref as D, h as F, defineComponent as j, resolveComponent as R, openBlock as T, createElementBlock as I, createElementVNode as _, normalizeClass as Y, createTextVNode as Fe, toDisplayString as C, unref as v, createCommentVNode as G, createVNode as $, withCtx as P, Fragment as H, renderList as J, computed as E, watch as Re, createSlots as Pe, createBlock as V, isRef as Oe, normalizeStyle as Ye, Teleport as Ke, normalizeProps as Ge, guardReactiveProps as Je, mergeProps as We } from "vue";
2
+ import { a3 as qe, u as le, af as Qe, D as Se, i as N, h as Xe, f as Ae, ag as oe, s as Ze, ah as Ee, v as Ue, a as ae, b as et, w as tt, x as Ve, y as nt, z as ot, e as z, G as O, K as st, ai as lt, m as at, E as Ne, A as rt, aj as it, ak as ne, B as ct, _ as mt, C as ut } from "./app-BLo-E2P1.js";
3
+ import { useCoreStore as re, useI18n as B } from "@feedmepos/mf-common";
4
+ import { useDialogChild as dt, useSnackbar as Z, useDialog as ie, FmButtonVariant as De, components as L, useProxiedModel as pt, useBreakpoints as ft } from "@feedmepos/ui-library";
5
+ import { defineStore as Be, storeToRefs as Le } from "pinia";
6
+ import { u as vt } from "./use-ingredient-select-dialog-C9I7bja9.js";
7
+ const ee = qe((i, o) => {
8
+ function s() {
9
+ var t;
10
+ return `business_${((t = re().currentBusiness.value) == null ? void 0 : t._id) ?? ""}`;
11
+ }
12
+ return {
13
+ async getRecentPublishingJob() {
14
+ const l = s(), e = `${i.inventoryBackendUrl}/${l}/closing-template/publish/recent`;
15
+ return o.get(e);
16
+ },
17
+ async startNewPublish() {
18
+ const l = s(), e = `${i.inventoryBackendUrl}/${l}/closing-template/publish`;
19
+ return o.post(e);
20
+ },
21
+ async getTemplate(l) {
22
+ const e = s(), t = `${i.inventoryBackendUrl}/${e}/closing-template/${l}`;
23
+ return o.get(t);
24
+ },
25
+ async readTemplates() {
26
+ const l = s(), e = `${i.inventoryBackendUrl}/${l}/closing-template`;
27
+ return o.get(e);
28
+ },
29
+ async createTemplate(l) {
30
+ const e = s(), t = `${i.inventoryBackendUrl}/${e}/closing-template`;
31
+ return o.post(t, l);
32
+ },
33
+ async updateTemplate(l) {
34
+ const e = s(), t = `${i.inventoryBackendUrl}/${e}/closing-template`;
35
+ return o.put(t, l);
36
+ },
37
+ async deleteTemplate(l) {
38
+ const e = s(), t = `${i.inventoryBackendUrl}/${e}/closing-template`;
39
+ return o.delete(t, { _id: l._id, _rev: l._rev });
40
+ },
41
+ async importTemplates(l) {
42
+ const e = s(), t = `${i.inventoryBackendUrl}/${e}/closing-template/import`;
43
+ return o.post(t, l);
44
+ }
45
+ };
46
+ }), te = Be(
47
+ "closingTemplateTable",
48
+ function() {
49
+ const { t: o } = B(), s = se(), l = D({}), e = D(new Array()), t = D(!1), f = le(), g = ee();
50
+ async function p() {
51
+ if (e.value = [], !!f._currentLocation) {
52
+ t.value = !0;
53
+ try {
54
+ const [y, b] = await Promise.all([
55
+ g.readTemplates(),
56
+ g.getRecentPublishingJob()
57
+ ]).delayed(1e3);
58
+ e.value = y, l.value = b;
59
+ } catch (y) {
60
+ console.log("Something went wrong when fetching templates:", y);
61
+ } finally {
62
+ t.value = !1;
63
+ }
64
+ }
65
+ }
66
+ async function r(y) {
67
+ if (!e.value.find((b) => b._id) && f._currentLocation) {
68
+ t.value = !0;
69
+ try {
70
+ const [b] = await Promise.all([
71
+ g.getTemplate(y),
72
+ new Promise((u) => setTimeout(u, 1e3))
73
+ ]);
74
+ e.value = [b];
75
+ } catch (b) {
76
+ console.log("Something went wrong when fetching templates:", b);
77
+ } finally {
78
+ t.value = !1;
79
+ }
80
+ }
81
+ }
82
+ function m(y, b) {
83
+ switch (b = Ae(b), y) {
84
+ case N.Details:
85
+ return s.viewTemplate(b);
86
+ case N.Edit:
87
+ return s.updateTemplate(b);
88
+ case N.Delete:
89
+ return s.deleteTemplate(b, t, p);
90
+ }
91
+ }
92
+ return {
93
+ columnDefs: [
94
+ {
95
+ id: "_id",
96
+ accessorKey: "_id",
97
+ header: () => o("inventory.closing.table.createdAt"),
98
+ cell(y) {
99
+ return Qe(`${y.getValue()}`);
100
+ },
101
+ enableSorting: !0
102
+ },
103
+ {
104
+ id: "name",
105
+ accessorKey: "name",
106
+ header: () => o("inventory.closing.table.name"),
107
+ enableSorting: !0,
108
+ size: 200
109
+ },
110
+ {
111
+ id: "noOfItems",
112
+ accessorKey: "items.length",
113
+ header: () => o("inventory.closing.table.noOfItems"),
114
+ enableSorting: !1,
115
+ meta: {
116
+ width: "10rem",
117
+ textAlign: "right"
118
+ }
119
+ },
120
+ {
121
+ id: "enabledLocations",
122
+ accessorKey: "locations.length",
123
+ header: () => o("inventory.closing.table.enabledOutlets"),
124
+ cell(y) {
125
+ var u;
126
+ const b = (u = y.row.original.locations) == null ? void 0 : u.length;
127
+ return b ? `${b}` : "All";
128
+ },
129
+ enableSorting: !1,
130
+ meta: {
131
+ width: "10rem",
132
+ textAlign: "right"
133
+ }
134
+ },
135
+ {
136
+ id: "ref",
137
+ accessorKey: "ref",
138
+ header: () => o("inventory.closing.table.reference"),
139
+ enableSorting: !1,
140
+ size: "auto"
141
+ },
142
+ {
143
+ id: "status",
144
+ header: () => o("inventory.closing.table.status"),
145
+ enableSorting: !1,
146
+ cell(y) {
147
+ var k;
148
+ const b = y.row.original, u = b._rev, n = (k = l.value.publishedRevs) == null ? void 0 : k[b._id], a = u === n;
149
+ return F(
150
+ "div",
151
+ {
152
+ class: "flex"
153
+ },
154
+ F(
155
+ "div",
156
+ {
157
+ class: [
158
+ "fm-status-badge",
159
+ a ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
160
+ ]
161
+ },
162
+ a ? "Published" : "Unpublished"
163
+ )
164
+ );
165
+ }
166
+ },
167
+ {
168
+ id: "action",
169
+ cell(y) {
170
+ const b = y.row.original, u = [
171
+ Se[N.Edit],
172
+ Se[N.Delete]
173
+ ];
174
+ return Xe(u, (n) => m(n, b));
175
+ },
176
+ enableSorting: !1,
177
+ size: 40,
178
+ meta: {
179
+ cellClass: "",
180
+ headerClass: ""
181
+ }
182
+ }
183
+ ],
184
+ recentPublish: l,
185
+ templates: e,
186
+ loading: t,
187
+ fetchTemplates: p,
188
+ loadTemplate: r
189
+ };
190
+ }
191
+ );
192
+ var ce = /* @__PURE__ */ ((i) => (i.Ingredients = "Ingredients", i))(ce || {});
193
+ function ze(i) {
194
+ const o = i.sku, s = new Set(i.disabledMeasurements);
195
+ return [
196
+ {
197
+ code: o.code,
198
+ name: o.name,
199
+ unit: o.unit.abbrev,
200
+ enabled: !s.has(o.unit._id)
201
+ },
202
+ ...o.unit.measurements.map((t) => ({
203
+ unit: t.abbrev,
204
+ enabled: !s.has(t.id)
205
+ }))
206
+ ];
207
+ }
208
+ function He() {
209
+ return [
210
+ {
211
+ id: "code",
212
+ name: "Code"
213
+ },
214
+ {
215
+ id: "name",
216
+ name: "Name"
217
+ },
218
+ {
219
+ id: "unit",
220
+ name: "Unit"
221
+ },
222
+ {
223
+ id: "enabled",
224
+ name: "Enabled"
225
+ }
226
+ ];
227
+ }
228
+ function gt(i) {
229
+ var g;
230
+ const s = re().currentBusiness.value, e = (g = i.map((p) => {
231
+ var u;
232
+ const r = p.items.flatMap(ze), m = He(), d = [
233
+ ["Template ID", p._id],
234
+ ["Template name", p.name],
235
+ ["Business name", s == null ? void 0 : s.name],
236
+ ["Business ID", s == null ? void 0 : s._id],
237
+ ["Menu version", s == null ? void 0 : s.menuVersion],
238
+ [
239
+ "Locations",
240
+ ...(u = p.locations) != null && u.length ? p.locations.map((n) => `${n.name} (${n.dbName})`) : ["All"]
241
+ ],
242
+ ["Reference", p.ref ?? ""],
243
+ [],
244
+ m.map((n) => n.name),
245
+ ...r.map((n) => m.map((a) => n[a.id]))
246
+ ], y = m.map((n) => `system:${n.id}`), b = oe(d, y);
247
+ return { name: p.name, sheet: b };
248
+ }).reduce(
249
+ (p, r) => {
250
+ var d;
251
+ const m = r.name.slice(0, 12);
252
+ return (d = p.sheetOccurence)[m] ?? (d[m] = 0), p.sheetOccurence[m] += 1, p.sheets[`${m} (${p.sheetOccurence[m]})`] = r.sheet, p;
253
+ },
254
+ {
255
+ sheets: {},
256
+ sheetOccurence: {}
257
+ }
258
+ )) == null ? void 0 : g.sheets, t = `${s == null ? void 0 : s.name} closing templates (${Ze(/* @__PURE__ */ new Date())}).xlsx`, f = Ee(e);
259
+ return Ue(f, t), t;
260
+ }
261
+ function yt() {
262
+ const i = re(), o = ae(), s = et(), l = ze({
263
+ sku: {
264
+ unit: {
265
+ _id: "",
266
+ name: "Unit",
267
+ abbrev: "Unit",
268
+ precision: 0,
269
+ measurements: []
270
+ },
271
+ code: "ING001",
272
+ _id: "",
273
+ name: "Sugar"
274
+ }
275
+ })[0], e = i.currentBusiness.value, t = He(), f = [
276
+ ["Template ID (leave empty to create new)", ""],
277
+ ["Template Name", "New template"],
278
+ ["Business name", e == null ? void 0 : e.name],
279
+ ["Business ID", e == null ? void 0 : e._id],
280
+ ["Menu version", e == null ? void 0 : e.menuVersion],
281
+ [
282
+ "Location codes (leave empty to enable all)",
283
+ "Example outlet (restaurant_xxx)",
284
+ "Example outlet 2 (restaurant_xxx)"
285
+ ],
286
+ ["Reference:"],
287
+ [],
288
+ t.map((u) => u.name),
289
+ t.map((u) => l[u.id])
290
+ ], g = t.map((u) => `system:${u.id}`), p = oe(f, g), r = s.isEnabled ? s.state.setting.childItems ?? [] : [], m = r.reduce(
291
+ (u, n) => {
292
+ var h, x;
293
+ const a = (h = s.netSuiteItemIdToSkuId.get(n.parentNetSuiteId)) == null ? void 0 : h[0], k = (x = s.netSuiteMeasurementIdToMeasurementId.get(
294
+ n.unitOfMeasureId
295
+ )) == null ? void 0 : x[0];
296
+ if (!n.externalId)
297
+ return u;
298
+ if (!a)
299
+ return console.error(`Item ${n.externalId} cannot be mapped to parent FdoInventorySku.`, n), u;
300
+ const c = o.skuById[a], w = c.unit.measurements.find((A) => A.id === k);
301
+ return w ? (u[n.externalId] = {
302
+ sku: c,
303
+ measurement: w
304
+ }, u) : (console.error(
305
+ `Item ${n.externalId} found parent FdoInventorySku of ${c.code} ${c.name} but the measurement of netsuite id ${n.unitOfMeasureId} cannot be found.`,
306
+ n
307
+ ), u);
308
+ },
309
+ {}
310
+ ), d = oe(
311
+ [
312
+ ...o.skus.flatMap((u) => [
313
+ [u.code, u.name, u.unit.abbrev, !0],
314
+ ...u.unit.measurements.map((a) => [
315
+ "",
316
+ "",
317
+ a.abbrev,
318
+ !a.abbrev.toLocaleLowerCase("en-us").includes("inactive")
319
+ ])
320
+ ]),
321
+ ...Object.entries(m).map(([u, { sku: n, measurement: a }]) => [
322
+ n.code,
323
+ n.name,
324
+ a.abbrev,
325
+ !a.abbrev.toLocaleLowerCase("en-us").includes("inactive"),
326
+ u
327
+ ])
328
+ ],
329
+ [
330
+ "Code",
331
+ "Name",
332
+ "Units",
333
+ "Enabled (true/false)",
334
+ ...r.length ? ["Netsuite Parent"] : []
335
+ ]
336
+ ), y = Ee({
337
+ Template: p,
338
+ Ingredients: d
339
+ }), b = `${e == null ? void 0 : e.name} transfer templates import.xlsx`;
340
+ return Ue(y, b), b;
341
+ }
342
+ function ht(i) {
343
+ if (!i.length || `${i[0]}`.toLocaleLowerCase() === "all")
344
+ return [];
345
+ const o = /(.*) \(((warehouse_|restaurant_).{24,})\)/, l = le().locationByDbName;
346
+ return i.map((e) => {
347
+ const t = new Array(), f = e.trim(), g = o.exec(f);
348
+ if (!g)
349
+ return t.push(`Enabled location value of ${f} cannot be read.`), {
350
+ errors: t
351
+ };
352
+ const p = g[1], r = g[2], m = l[r];
353
+ return m ? (p !== m.name && t.push(
354
+ `Location id ${r} has non-matching name. Found ${p} but expected ${m.name}`
355
+ ), {
356
+ errors: t,
357
+ location: m
358
+ }) : (t.push(`Location (${p}) of id ${r} is not found.`), {
359
+ errors: t
360
+ });
361
+ });
362
+ }
363
+ function bt(i) {
364
+ const [
365
+ o,
366
+ s,
367
+ l,
368
+ e,
369
+ t,
370
+ f,
371
+ g,
372
+ p
373
+ ] = Ve(i);
374
+ return {
375
+ id: `${s[1] ?? ""}`.trim(),
376
+ name: `${l[1] ?? ""}`.trim(),
377
+ locations: g.slice(1).map((r) => `${r}`.trim()).filter((r) => r),
378
+ reference: `${p[1] ?? ""}`.trim()
379
+ };
380
+ }
381
+ function _t(i) {
382
+ const [
383
+ o,
384
+ s,
385
+ l,
386
+ e,
387
+ t,
388
+ f,
389
+ g,
390
+ p,
391
+ r,
392
+ m,
393
+ ...d
394
+ ] = Ve(i);
395
+ if (!o || !o.length || o.some((a) => a.length && !a.startsWith("system:")))
396
+ throw new Error("Missing meta header. Excel file does not come from the template.");
397
+ const y = o.map((a) => a.split(":")[1]), u = ["code", "name", "unit", "enabled"].filter((a) => !y.includes(a));
398
+ if (u.length)
399
+ throw new Error(
400
+ `Missing meta headers (${u.join()}). Excel file does not come from the template.`
401
+ );
402
+ return d.map((a, k) => {
403
+ const c = {};
404
+ for (const w in y) {
405
+ const h = y[w];
406
+ Object.assign(c, { [h]: a[w] });
407
+ }
408
+ return {
409
+ index: k,
410
+ data: c
411
+ };
412
+ });
413
+ }
414
+ function xt(i) {
415
+ return i.reduce(
416
+ (o, s) => {
417
+ var t;
418
+ const l = s.data, e = s.index;
419
+ return l.unit && (l.code ? o.result.push({ parent: s, children: [] }) : o.result.length ? (t = o.result.at(-1)) == null || t.children.push(s) : o.errors.push(`Cannot find parent for row ${e + 9}`)), o;
420
+ },
421
+ { result: new Array(), errors: new Array() }
422
+ );
423
+ }
424
+ function wt(i) {
425
+ const o = i.parent.data, s = new Array(), e = ae().skuByCode[o.code ?? ""];
426
+ if (!e)
427
+ return s.push(`Cannot find ingredient of code ${o.code} ${o.name}`), { errors: s };
428
+ const t = {
429
+ sku: e
430
+ }, f = /* @__PURE__ */ new Set([e.unit._id, ...e.unit.measurements.map((p) => p.id)]), g = e.unit.measurements.find((p) => p.abbrev === o.unit);
431
+ o.unit !== e.unit.abbrev && !g ? s.push(
432
+ `Cannot find measurement unit of ${o.unit} for (${o.code}) ${o.name}.`
433
+ ) : (o.enabled === !0 || `${o.enabled}`.toLocaleLowerCase() === "true") && f.delete(e.unit._id);
434
+ for (const p of i.children) {
435
+ const r = p.data, m = r.unit === e.unit.abbrev ? e.unit : void 0, d = e.unit.measurements.find((y) => y.abbrev === r.unit);
436
+ if (!d && !m) {
437
+ s.push(
438
+ `Cannot find measurement unit of ${r.unit} for (${o.code}) ${o.name}.`
439
+ );
440
+ continue;
441
+ }
442
+ (r.enabled === !0 || `${r.enabled}`.toLocaleLowerCase() === "true") && f.delete((d == null ? void 0 : d.id) ?? (m == null ? void 0 : m._id) ?? "");
443
+ }
444
+ return f.has(e.unit._id) && t.sku.unit.measurements.every((p) => f.has(p.id)) && s.push(`Ingredient ${e.code} - ${e.name} must have at least one unit enabled.`), t.disabledMeasurements = [...f], { errors: s, templateItem: t };
445
+ }
446
+ function kt(i) {
447
+ const o = i.SheetNames.filter(
448
+ (t) => !Object.values(ce).map(String).includes(t)
449
+ ), l = te().templates, e = tt(l, "_id");
450
+ try {
451
+ return o.reduce(
452
+ (t, f) => {
453
+ const g = new Array(), p = i.Sheets[f], r = bt(p), m = ht(r.locations), d = m.filter((c) => c.location).map((c) => c.location);
454
+ g.push(...m.flatMap((c) => c.errors));
455
+ const y = _t(p).filter(
456
+ (c) => c.data.code || c.data.unit
457
+ ), b = xt(y);
458
+ g.push(...b.errors);
459
+ const u = b.result.map(
460
+ (c) => wt(c)
461
+ );
462
+ g.push(...u.flatMap((c) => c.errors));
463
+ const n = u.filter((c) => c.templateItem).map((c) => c.templateItem);
464
+ if (r.id) {
465
+ const c = e[r.id];
466
+ if (!c) {
467
+ const h = {
468
+ _id: r.id,
469
+ _rev: "",
470
+ name: r.name || `(unnamed from sheet ${f || "<unnamed sheet>"})`,
471
+ items: []
472
+ };
473
+ return g.push(`Template ID ${r.id} is not found.`), t.importUpdateResult.push({
474
+ type: "update",
475
+ original: h,
476
+ template: h,
477
+ excelSheetName: f,
478
+ errors: g
479
+ }), t;
480
+ }
481
+ const w = {
482
+ type: "update",
483
+ original: c,
484
+ template: {
485
+ ...c,
486
+ name: r.name,
487
+ locations: d.length ? d : null,
488
+ ref: r.reference,
489
+ items: n
490
+ },
491
+ excelSheetName: f,
492
+ errors: g
493
+ };
494
+ return t.importUpdateResult.push(w), t;
495
+ }
496
+ const k = {
497
+ type: "create",
498
+ template: {
499
+ name: r.name,
500
+ locations: d.length ? d : null,
501
+ ref: r.reference,
502
+ items: n
503
+ },
504
+ excelSheetName: f,
505
+ errors: g
506
+ };
507
+ return t.importCreateResult.push(k), t;
508
+ },
509
+ {
510
+ invalidExcel: !1,
511
+ importCreateResult: new Array(),
512
+ importUpdateResult: new Array()
513
+ }
514
+ );
515
+ } catch (t) {
516
+ return {
517
+ invalidExcel: !0,
518
+ invalidExcelMessage: (t == null ? void 0 : t.message) ?? "Invalid excel",
519
+ importCreateResult: [],
520
+ importUpdateResult: []
521
+ };
522
+ }
523
+ }
524
+ const Tt = { class: "flex items-center gap-12 pl-8" }, $t = { class: "flex flex-col" }, Ct = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, It = {
525
+ key: 0,
526
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
527
+ }, St = { key: 0 }, Me = /* @__PURE__ */ j({
528
+ __name: "ClosingTemplateImportItem",
529
+ props: {
530
+ type: {},
531
+ name: {},
532
+ locations: {},
533
+ items: {},
534
+ errors: {}
535
+ },
536
+ setup(i) {
537
+ const { t: o } = B();
538
+ return (s, l) => {
539
+ var f, g, p;
540
+ const e = R("FmIcon"), t = R("FmTooltip");
541
+ return T(), I("div", Tt, [
542
+ l[0] || (l[0] = _("div", null, "•", -1)),
543
+ _("div", $t, [
544
+ _("div", Ct, [
545
+ _("div", {
546
+ class: Y({
547
+ "text-fm-color-system-error-300": s.errors.length
548
+ })
549
+ }, [
550
+ Fe(C(s.name) + " ", 1),
551
+ s.type === "create" ? (T(), I("span", It, "(" + C(v(o)("inventory.closing.template.import.new")) + ")", 1)) : G("", !0)
552
+ ], 2),
553
+ s.errors.length ? (T(), I("div", St, [
554
+ $(t, { "z-index": 50 }, {
555
+ content: P(() => [
556
+ _("ol", null, [
557
+ (T(!0), I(H, null, J(s.errors, (r, m) => (T(), I("li", { key: m }, C(r), 1))), 128))
558
+ ])
559
+ ]),
560
+ default: P(() => [
561
+ $(e, {
562
+ name: "error",
563
+ size: "sm",
564
+ color: "system-error-300"
565
+ })
566
+ ]),
567
+ _: 1
568
+ })
569
+ ])) : G("", !0)
570
+ ]),
571
+ _("div", {
572
+ class: Y([
573
+ "fm-typo-en-body-sm-400",
574
+ {
575
+ "text-fm-color-system-error-200": s.errors.length,
576
+ "text-fm-color-typo-secondary": !s.errors.length
577
+ }
578
+ ])
579
+ }, C((f = s.locations) != null && f.length ? v(o)("inventory.closing.template.import.nLocations", { count: (g = s.locations) == null ? void 0 : g.length }) : v(o)("inventory.closing.template.import.allLocations")) + ", " + C(v(o)("inventory.closing.template.import.nItems", { count: (p = s.items) == null ? void 0 : p.length })), 3)
580
+ ])
581
+ ]);
582
+ };
583
+ }
584
+ }), Dt = { class: "flex flex-col gap-24" }, Mt = { class: "fm-typo-en-body-md-400" }, Ft = {
585
+ key: 0,
586
+ class: "flex items-center gap-8"
587
+ }, Rt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pt = { class: "flex flex-col gap-8" }, At = { class: "line-clamp-2 text-ellipsis break-all" }, Et = {
588
+ key: 2,
589
+ class: "shrink-0"
590
+ }, Ut = {
591
+ key: 0,
592
+ class: "flex flex-col"
593
+ }, Vt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Nt = {
594
+ key: 0,
595
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
596
+ }, Bt = { class: "fm-typo-en-body-lg-600" }, Lt = /* @__PURE__ */ j({
597
+ __name: "ClosingTemplateImport",
598
+ setup(i) {
599
+ const o = D(null), s = dt(), l = Z(), e = D(!1), t = D(!1), f = D(new Array()), g = D([]), p = D([]), r = E(
600
+ () => !!f.value.length || g.value.some((b) => b.errors.length) || p.value.some((b) => b.errors.length)
601
+ ), m = E(
602
+ () => !!g.value.length || !!p.value.length
603
+ ), { t: d } = B();
604
+ async function y(b) {
605
+ f.value = [], g.value = [], p.value = [];
606
+ try {
607
+ e.value = !0;
608
+ const [u] = await Promise.all([
609
+ ot(b),
610
+ // fake buffer
611
+ new Promise((c) => setTimeout(c, 1e3))
612
+ ]);
613
+ if (!u.SheetNames.filter(
614
+ (c) => !Object.values(ce).map(String).includes(c)
615
+ ).find((c) => c)) {
616
+ f.value.push(d("inventory.ingredient.import.fileError.noSheet"));
617
+ return;
618
+ }
619
+ const k = kt(u);
620
+ if (k.invalidExcel) {
621
+ f.value.push(
622
+ k.invalidExcelMessage ?? d("inventory.ingredient.import.fileError.invalidExcel")
623
+ );
624
+ return;
625
+ }
626
+ if (g.value = k.importCreateResult, p.value = k.importUpdateResult, !g.value.length && !p.value.length) {
627
+ f.value.push(d("inventory.ingredient.import.fileError.noData"));
628
+ return;
629
+ }
630
+ s.emitData(k);
631
+ } catch (u) {
632
+ l.open({
633
+ title: d("inventory.ingredient.import.fileError.unableToRead"),
634
+ message: u == null ? void 0 : u.message,
635
+ type: "error"
636
+ }), console.error("Error in reading file", u);
637
+ } finally {
638
+ f.value.length && l.open({
639
+ title: d("inventory.ingredient.import.fileError.invalidExcel"),
640
+ type: "error"
641
+ }), e.value = !1;
642
+ }
643
+ }
644
+ return Re(o, (b) => {
645
+ b && y(b);
646
+ }), (b, u) => {
647
+ const n = R("FmCircularProgress"), a = R("FmIcon"), k = R("FmButton");
648
+ return T(), I("div", Dt, [
649
+ _("div", Mt, C(v(d)("inventory.closing.template.import.message")), 1),
650
+ t.value ? (T(), I("div", Ft, [
651
+ _("div", null, [
652
+ $(n, {
653
+ size: "md",
654
+ color: "neutral-gray-200"
655
+ })
656
+ ]),
657
+ _("div", Rt, C(v(d)("inventory.formField.loading")), 1)
658
+ ])) : (T(), I(H, { key: 1 }, [
659
+ $(nt, {
660
+ class: Y({
661
+ "w-full": !0,
662
+ "h-[200px]": !o.value
663
+ }),
664
+ accept: ".xlsx",
665
+ onFileUpload: u[0] || (u[0] = (c) => o.value = c),
666
+ label: v(d)("inventory.ingredient.import.uploadTemplate"),
667
+ "button-label": v(d)("inventory.ingredient.import.selectFile")
668
+ }, Pe({ _: 2 }, [
669
+ o.value ? {
670
+ name: "default",
671
+ fn: P(({ openFileDialog: c }) => [
672
+ _("div", Pt, [
673
+ _("div", {
674
+ class: Y([
675
+ "fm-corner-radius-md p-16 flex items-center gap-16",
676
+ {
677
+ "border border-fm-color-neutral-gray-100": e.value,
678
+ "border border-fm-color-neutral-gray-200": !e.value && !r.value,
679
+ "border border-fm-color-system-error-200": r.value
680
+ }
681
+ ])
682
+ }, [
683
+ e.value ? (T(), V(n, {
684
+ key: 0,
685
+ size: "md",
686
+ color: "neutral-gray-200"
687
+ })) : (T(), V(a, {
688
+ key: 1,
689
+ name: r.value ? "error" : "attach_file",
690
+ outline: "",
691
+ color: r.value ? "system-error-300" : void 0
692
+ }, null, 8, ["name", "color"])),
693
+ _("div", {
694
+ class: Y([
695
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
696
+ {
697
+ "text-fm-color-typo-disabled": e.value,
698
+ "text-fm-color-typo-primary": !e.value
699
+ }
700
+ ])
701
+ }, [
702
+ _("div", At, C(o.value.name), 1)
703
+ ], 2),
704
+ e.value ? G("", !0) : (T(), I("div", Et, [
705
+ $(k, {
706
+ label: v(d)("inventory.ingredient.import.replaceFile"),
707
+ variant: r.value ? "destructive" : "secondary",
708
+ "prepend-icon": r.value ? void 0 : "autorenew",
709
+ onClick: c
710
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
711
+ ]))
712
+ ], 2),
713
+ f.value.length ? (T(), I("div", Ut, [
714
+ (T(!0), I(H, null, J(f.value, (w, h) => (T(), I("div", {
715
+ key: h,
716
+ class: "flex gap-8 items-center"
717
+ }, [
718
+ $(a, {
719
+ name: "error",
720
+ size: "sm",
721
+ color: "system-error-300"
722
+ }),
723
+ _("div", Vt, C(w), 1)
724
+ ]))), 128))
725
+ ])) : G("", !0)
726
+ ])
727
+ ]),
728
+ key: "0"
729
+ } : void 0
730
+ ]), 1032, ["class", "label", "button-label"]),
731
+ m.value ? (T(), I("div", Nt, [
732
+ _("div", Bt, C(v(d)("inventory.ingredient.import.summary")), 1),
733
+ (T(!0), I(H, null, J(g.value, (c, w) => (T(), V(Me, {
734
+ key: w,
735
+ name: c.template.name,
736
+ locations: c.template.locations,
737
+ items: c.template.items,
738
+ errors: c.errors,
739
+ type: "create"
740
+ }, null, 8, ["name", "locations", "items", "errors"]))), 128)),
741
+ (T(!0), I(H, null, J(p.value, (c) => (T(), V(Me, {
742
+ key: c.template._id,
743
+ name: c.template.name,
744
+ locations: c.template.locations,
745
+ items: c.template.items,
746
+ errors: c.errors,
747
+ type: "update"
748
+ }, null, 8, ["name", "locations", "items", "errors"]))), 128))
749
+ ])) : G("", !0)
750
+ ], 64))
751
+ ]);
752
+ };
753
+ }
754
+ }), se = Be("closingTemplateActions", () => {
755
+ const { t: i } = B(), o = ie(), s = Z(), l = ee(), e = te(), { loading: t } = Le(e), f = D({});
756
+ function g() {
757
+ f.value = {
758
+ mode: z.CREATE,
759
+ show: !0,
760
+ "onUpdate:show"(n) {
761
+ f.value.show = n;
762
+ }
763
+ };
764
+ }
765
+ function p(n) {
766
+ f.value = {
767
+ mode: z.UPDATE,
768
+ modelValue: n,
769
+ show: !0,
770
+ "onUpdate:show"(a) {
771
+ f.value.show = a;
772
+ }
773
+ };
774
+ }
775
+ function r(n, a, k) {
776
+ o.open({
777
+ title: `Confirm deleting template ${n.name}?`,
778
+ message: "Deleted template can no longer be retrieved",
779
+ primaryActions: {
780
+ text: "Delete",
781
+ variant: De.Destructive,
782
+ close: !0
783
+ },
784
+ secondaryActions: {
785
+ text: "Cancel",
786
+ variant: De.Plain,
787
+ close: !0
788
+ }
789
+ }).onPrimary(async () => {
790
+ s.open({
791
+ title: `Deleting ${n.name}`,
792
+ type: "info"
793
+ });
794
+ try {
795
+ a.value = !0;
796
+ const [c] = await Promise.allSettled([
797
+ l.deleteTemplate(n),
798
+ new Promise((w) => setTimeout(w, 1e3))
799
+ ]);
800
+ if (c.status === "rejected") throw c.reason;
801
+ s.open({
802
+ title: `Deleted ${n.name}`,
803
+ type: "success"
804
+ });
805
+ } catch (c) {
806
+ s.open({
807
+ title: `Unable to delete ${n.name}`,
808
+ message: `See error from server: ${c}`,
809
+ type: "error"
810
+ }), console.error("error on deleting closing template", c);
811
+ } finally {
812
+ a.value = !1, k();
813
+ }
814
+ });
815
+ }
816
+ const m = D({});
817
+ function d(n) {
818
+ m.value = {
819
+ template: n,
820
+ show: !0,
821
+ "onUpdate:show"(a) {
822
+ m.value.show = a;
823
+ },
824
+ "onAction:edit"() {
825
+ m.value.show = !1, p(Ae(n));
826
+ }
827
+ };
828
+ }
829
+ function y() {
830
+ if (!e.templates.length) {
831
+ s.open({
832
+ title: "No data to export",
833
+ type: "error"
834
+ });
835
+ return;
836
+ }
837
+ const n = gt(e.templates);
838
+ s.open({
839
+ title: i("inventory.ingredient.export.success"),
840
+ message: i("inventory.ingredient.export.filename", [n]),
841
+ type: "success"
842
+ });
843
+ }
844
+ function b() {
845
+ e.loading || o.open({
846
+ title: i("inventory.ingredient.import.title"),
847
+ contentComponent: Lt,
848
+ overlay: !0,
849
+ closeButton: !0,
850
+ primaryActions: {
851
+ text: i("common.import"),
852
+ close: !1
853
+ },
854
+ secondaryActions: {
855
+ text: i("common.close"),
856
+ close: !0
857
+ },
858
+ tertiaryActions: {
859
+ text: i("inventory.ingredient.import.actions.downloadTemplate"),
860
+ close: !1,
861
+ variant: "plain"
862
+ }
863
+ }).onPrimary((n) => {
864
+ if (!n) {
865
+ s.open({
866
+ title: i("inventory.ingredient.import.error.noData"),
867
+ type: "error"
868
+ });
869
+ return;
870
+ }
871
+ if (!n.importCreateResult.length && !n.importUpdateResult.length) {
872
+ s.open({
873
+ title: i("inventory.ingredient.import.error.invalidContent"),
874
+ message: i("inventory.ingredient.import.error.noImportData"),
875
+ type: "error"
876
+ });
877
+ return;
878
+ }
879
+ if (n.importCreateResult.some((a) => a.errors.length) || n.importUpdateResult.some((a) => a.errors.length)) {
880
+ s.open({
881
+ title: i("inventory.ingredient.import.error.invalidContent"),
882
+ message: i("inventory.ingredient.import.error.hasErrors"),
883
+ type: "error"
884
+ });
885
+ return;
886
+ }
887
+ o.close(), u(n);
888
+ }).onTertiary(yt);
889
+ }
890
+ async function u(n) {
891
+ t.value = !0;
892
+ try {
893
+ const a = [
894
+ ...n.importCreateResult.map(
895
+ (h) => h.template
896
+ ),
897
+ ...n.importUpdateResult.map(
898
+ (h) => h.template
899
+ )
900
+ ], k = 100;
901
+ let c = 0;
902
+ const w = () => {
903
+ c += k, s.open({
904
+ title: i("inventory.ingredient.import.progress", [
905
+ Math.min(c, a.length),
906
+ a.length
907
+ ])
908
+ });
909
+ };
910
+ for (const h of a.chunk(100))
911
+ w(), await l.importTemplates(h);
912
+ s.open({
913
+ title: i("inventory.ingredient.import.success"),
914
+ type: "success"
915
+ });
916
+ } catch (a) {
917
+ s.open({
918
+ title: i("inventory.ingredient.import.error.failed"),
919
+ message: i("inventory.ingredient.import.error.systemMessage", [a == null ? void 0 : a.message]),
920
+ type: "error"
921
+ }), console.error("Error in importing skus", n, a);
922
+ } finally {
923
+ t.value = !1, e.fetchTemplates();
924
+ }
925
+ }
926
+ return {
927
+ createTemplate: g,
928
+ viewTemplate: d,
929
+ updateTemplate: p,
930
+ deleteTemplate: r,
931
+ exportTemplates: y,
932
+ importTemplates: b,
933
+ templateDialogProps: f,
934
+ templateDetailsProps: m
935
+ };
936
+ });
937
+ var K = /* @__PURE__ */ ((i) => (i.Name = "Name", i.Unit = "Unit", i.Delete = "Delete", i))(K || {});
938
+ function zt(i) {
939
+ return {
940
+ columnDefs: E(() => {
941
+ const s = i.items.map((e) => e.sku.unit.measurements.length).reduce((e, t) => Math.max(e, t), 0);
942
+ return [
943
+ {
944
+ id: "Name",
945
+ header: () => "Name",
946
+ enableSorting: !1,
947
+ size: 400,
948
+ minSize: 400,
949
+ accessorFn: (e) => `${e.sku.name} ${e.sku.code}`,
950
+ cell(e) {
951
+ const t = e.row.original;
952
+ return F(
953
+ "div",
954
+ {
955
+ class: "flex flex-col",
956
+ style: { minWidth: "400px" }
957
+ },
958
+ [
959
+ F(
960
+ "span",
961
+ { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1" },
962
+ t.sku.name
963
+ ),
964
+ F(
965
+ "span",
966
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
967
+ t.sku.code
968
+ )
969
+ ]
970
+ );
971
+ }
972
+ },
973
+ {
974
+ id: "Unit",
975
+ header: () => "Enable unit",
976
+ enableSorting: !1,
977
+ minSize: 200,
978
+ maxSize: 400,
979
+ cell(e) {
980
+ var f, g, p;
981
+ const t = e.row.original;
982
+ return F("div", { class: "flex items-center gap-32" }, [
983
+ F(
984
+ L.FmFormGroup,
985
+ {
986
+ value: t.sku.unit._id,
987
+ modelValue: !((f = t.disabledMeasurements) != null && f.includes(t.sku.unit._id))
988
+ },
989
+ F(
990
+ "div",
991
+ {
992
+ class: "flex items-center gap-4",
993
+ style: { width: "120px" }
994
+ },
995
+ [
996
+ F(L.FmCheckbox, {
997
+ value: t.sku.unit._id,
998
+ modelValue: !((g = t.disabledMeasurements) != null && g.includes(t.sku.unit._id)),
999
+ disabled: i.disabled || !((p = t.disabledMeasurements) != null && p.includes(t.sku.unit._id)) && t.sku.unit.measurements.every(
1000
+ (r) => {
1001
+ var m;
1002
+ return (m = t.disabledMeasurements) == null ? void 0 : m.includes(r.id);
1003
+ }
1004
+ ),
1005
+ "onUpdate:modelValue"(r) {
1006
+ var m;
1007
+ if (r)
1008
+ i.updateItem({
1009
+ ...t,
1010
+ disabledMeasurements: (m = t.disabledMeasurements) == null ? void 0 : m.filter(
1011
+ (d) => d !== t.sku.unit._id
1012
+ )
1013
+ });
1014
+ else {
1015
+ const d = t.disabledMeasurements ?? [];
1016
+ i.updateItem({
1017
+ ...t,
1018
+ disabledMeasurements: [...d, t.sku.unit._id]
1019
+ });
1020
+ }
1021
+ }
1022
+ }),
1023
+ F(
1024
+ L.FmTooltip,
1025
+ { zIndex: 51 },
1026
+ {
1027
+ content() {
1028
+ return t.sku.unit.abbrev;
1029
+ },
1030
+ default() {
1031
+ return F(
1032
+ "div",
1033
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
1034
+ t.sku.unit.abbrev
1035
+ );
1036
+ }
1037
+ }
1038
+ )
1039
+ ]
1040
+ )
1041
+ ),
1042
+ ...Array.from({ length: Math.max(s, 0) }).map((r, m) => {
1043
+ var b, u, n, a;
1044
+ const d = e.row.original, y = d.sku.unit.measurements[m];
1045
+ return y ? F(
1046
+ L.FmFormGroup,
1047
+ {
1048
+ modelValue: !((b = d.disabledMeasurements) != null && b.includes(y.id)),
1049
+ value: y.id
1050
+ },
1051
+ F(
1052
+ "div",
1053
+ {
1054
+ class: "flex items-center gap-4",
1055
+ style: { width: "120px" }
1056
+ },
1057
+ [
1058
+ F(L.FmCheckbox, {
1059
+ value: y.id,
1060
+ modelValue: !((u = d.disabledMeasurements) != null && u.includes(y.id)),
1061
+ disabled: i.disabled || !((n = d.disabledMeasurements) != null && n.includes(y.id)) && ((a = d.disabledMeasurements) == null ? void 0 : a.includes(d.sku.unit._id)) && d.sku.unit.measurements.filter((k) => k.id != y.id).every((k) => {
1062
+ var c;
1063
+ return (c = d.disabledMeasurements) == null ? void 0 : c.includes(k.id);
1064
+ }),
1065
+ "onUpdate:modelValue"(k) {
1066
+ var c;
1067
+ if (k)
1068
+ i.updateItem({
1069
+ ...d,
1070
+ disabledMeasurements: (c = d.disabledMeasurements) == null ? void 0 : c.filter(
1071
+ (w) => w !== y.id
1072
+ )
1073
+ });
1074
+ else {
1075
+ const w = d.disabledMeasurements ?? [];
1076
+ i.updateItem({
1077
+ ...d,
1078
+ disabledMeasurements: [...w, y.id]
1079
+ });
1080
+ }
1081
+ }
1082
+ }),
1083
+ F(
1084
+ L.FmTooltip,
1085
+ { zIndex: 51 },
1086
+ {
1087
+ content() {
1088
+ return y.abbrev;
1089
+ },
1090
+ default() {
1091
+ return F(
1092
+ "div",
1093
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
1094
+ y.abbrev
1095
+ );
1096
+ }
1097
+ }
1098
+ )
1099
+ ]
1100
+ )
1101
+ ) : null;
1102
+ })
1103
+ ]);
1104
+ }
1105
+ },
1106
+ {
1107
+ id: "Delete",
1108
+ header: "",
1109
+ cell(e) {
1110
+ const t = e.row.original;
1111
+ return F(
1112
+ "div",
1113
+ { class: "w-full flex justify-end" },
1114
+ F(L.FmButton, {
1115
+ class: "delete-button",
1116
+ key: t.sku._id,
1117
+ type: "button",
1118
+ icon: "delete",
1119
+ variant: "tertiary",
1120
+ size: "md",
1121
+ disabled: i.disabled,
1122
+ onClick: () => {
1123
+ i.deleteItem(t);
1124
+ }
1125
+ })
1126
+ );
1127
+ },
1128
+ enableSorting: !1,
1129
+ size: 40,
1130
+ meta: {
1131
+ cellClass: "",
1132
+ headerClass: ""
1133
+ }
1134
+ }
1135
+ ];
1136
+ })
1137
+ };
1138
+ }
1139
+ const Ht = { class: "flex flex-col gap-16 py-12" }, jt = { class: "flex" }, Ot = { class: "flex-1 flex flex-col" }, Yt = { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, Kt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Gt = { class: "flex flex-col gap-4" }, Jt = /* @__PURE__ */ j({
1140
+ __name: "ClosingTemplateItem",
1141
+ props: {
1142
+ cellByColId: {},
1143
+ row: {}
1144
+ },
1145
+ setup(i) {
1146
+ const o = i, s = E(() => o.row), l = E(
1147
+ () => s.value.getVisibleCells().filter((e) => e.column.id !== K.Name && e.column.id !== K.Delete)
1148
+ );
1149
+ return (e, t) => {
1150
+ var f, g, p, r, m;
1151
+ return T(), I("div", Ht, [
1152
+ _("div", jt, [
1153
+ _("div", Ot, [
1154
+ _("div", Yt, C(s.value.original.sku.name), 1),
1155
+ _("div", Kt, C(s.value.original.sku.code), 1)
1156
+ ]),
1157
+ _("div", null, [
1158
+ $(v(O), {
1159
+ render: (p = (g = (f = e.cellByColId[v(K).Delete]) == null ? void 0 : f.column) == null ? void 0 : g.columnDef) == null ? void 0 : p.cell,
1160
+ props: (m = (r = e.cellByColId[v(K).Delete]) == null ? void 0 : r.getContext) == null ? void 0 : m.call(r)
1161
+ }, null, 8, ["render", "props"])
1162
+ ])
1163
+ ]),
1164
+ _("div", Gt, [
1165
+ t[0] || (t[0] = _("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, null, -1)),
1166
+ (T(!0), I(H, null, J(l.value, (d) => {
1167
+ var y, b, u;
1168
+ return T(), I("div", {
1169
+ key: d.id
1170
+ }, [
1171
+ $(v(O), {
1172
+ render: (b = (y = d.column) == null ? void 0 : y.columnDef) == null ? void 0 : b.cell,
1173
+ props: (u = d.getContext) == null ? void 0 : u.call(d)
1174
+ }, null, 8, ["render", "props"])
1175
+ ]);
1176
+ }), 128))
1177
+ ])
1178
+ ]);
1179
+ };
1180
+ }
1181
+ }), Wt = { class: "flex flex-col gap-16" }, qt = { class: "flex flex-col gap-24" }, Qt = { class: "flex flex-col gap-16" }, Xt = { class: "flex items-center" }, Zt = { class: "flex-1 fm-typo-en-title-sm-600" }, en = { class: "flex flex-col gap-16" }, tn = { class: "flex items-center" }, nn = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, on = /* @__PURE__ */ j({
1182
+ __name: "ClosingTemplateForm",
1183
+ props: {
1184
+ modelValue: {},
1185
+ disabled: { type: Boolean }
1186
+ },
1187
+ setup(i, { expose: o }) {
1188
+ const s = i, l = st(), { t: e } = B(), t = ae();
1189
+ ie();
1190
+ const {
1191
+ promptSelectLocations: f,
1192
+ columnDefs: g,
1193
+ rowData: p
1194
+ } = lt({
1195
+ getLocations() {
1196
+ return l.locations;
1197
+ },
1198
+ setLocations(n) {
1199
+ l.locations = n;
1200
+ }
1201
+ }), r = D(), m = D("");
1202
+ o({
1203
+ validateInputs: () => {
1204
+ var n, a;
1205
+ (a = (n = r.value) == null ? void 0 : n.validateInputs) == null || a.call(n);
1206
+ },
1207
+ resetInputsValidation: () => {
1208
+ var n, a;
1209
+ (a = (n = r.value) == null ? void 0 : n.resetInputsValidation) == null || a.call(n);
1210
+ },
1211
+ resetInputs: () => {
1212
+ var n, a;
1213
+ (a = (n = r.value) == null ? void 0 : n.resetInputs) == null || a.call(n);
1214
+ }
1215
+ });
1216
+ const d = zt({
1217
+ updateItem: (n) => {
1218
+ l.items = l.items.map((a) => a.sku._id !== n.sku._id ? a : n);
1219
+ },
1220
+ deleteItem: (n) => {
1221
+ l.items = l.items.filter((a) => a.sku._id !== n.sku._id);
1222
+ },
1223
+ get items() {
1224
+ return l.items;
1225
+ },
1226
+ get disabled() {
1227
+ return s.disabled;
1228
+ }
1229
+ }), y = E(() => d.columnDefs.value), { promptSelectIngredients: b } = vt();
1230
+ async function u() {
1231
+ const a = t.skus.map((w) => ({
1232
+ label: w.name,
1233
+ sublabel: w.code,
1234
+ value: w
1235
+ })).filter((w) => {
1236
+ var h;
1237
+ return (h = l.items) == null ? void 0 : h.find((x) => x.sku._id === w.value._id);
1238
+ }).map((w) => w.value), k = l.items ?? [], c = await b(
1239
+ a.map((w) => w._id),
1240
+ (w) => {
1241
+ const h = t.skuById[w], x = k.find((M) => M.sku._id === h._id);
1242
+ return x || {
1243
+ sku: h
1244
+ };
1245
+ }
1246
+ );
1247
+ c && (c.sort((w, h) => w.sku.code.localeCompare(h.sku.code)), l.items = c);
1248
+ }
1249
+ return (n, a) => {
1250
+ const k = R("FmTextField"), c = R("FmButton"), w = R("FmTable"), h = R("FmIcon"), x = R("FmFormGroup"), A = R("FmForm");
1251
+ return T(), V(A, {
1252
+ ref_key: "formRef",
1253
+ ref: r,
1254
+ class: "flex flex-col gap-32",
1255
+ disabled: n.disabled
1256
+ }, {
1257
+ default: P(() => [
1258
+ _("div", Wt, [
1259
+ _("div", qt, [
1260
+ $(k, {
1261
+ label: v(e)("inventory.closing.form.name"),
1262
+ "label-mark": "required",
1263
+ modelValue: v(l).name,
1264
+ "onUpdate:modelValue": a[0] || (a[0] = (M) => v(l).name = M),
1265
+ rules: [v(at)()]
1266
+ }, null, 8, ["label", "modelValue", "rules"]),
1267
+ $(k, {
1268
+ label: v(e)("inventory.closing.form.reference"),
1269
+ "label-mark": "optional",
1270
+ modelValue: v(l).ref,
1271
+ "onUpdate:modelValue": a[1] || (a[1] = (M) => v(l).ref = M)
1272
+ }, null, 8, ["label", "modelValue"])
1273
+ ])
1274
+ ]),
1275
+ _("div", Qt, [
1276
+ _("div", Xt, [
1277
+ _("div", Zt, C(v(e)("inventory.closing.form.locations")), 1),
1278
+ $(c, {
1279
+ disabled: n.disabled,
1280
+ label: v(e)("inventory.closing.form.selectLocation"),
1281
+ "prepend-icon": "add",
1282
+ variant: "plain",
1283
+ class: "border-2 rounded-lg border-fm-color-primary",
1284
+ onClick: v(f)
1285
+ }, null, 8, ["disabled", "label", "onClick"])
1286
+ ]),
1287
+ $(w, {
1288
+ "column-defs": v(g),
1289
+ "row-data": v(p),
1290
+ "shrink-at": 9999,
1291
+ onRowClick: v(f),
1292
+ "hide-footer": ""
1293
+ }, null, 8, ["column-defs", "row-data", "onRowClick"])
1294
+ ]),
1295
+ _("div", en, [
1296
+ _("div", tn, [
1297
+ _("div", nn, C(v(e)("inventory.closing.form.items.title")), 1),
1298
+ $(c, {
1299
+ disabled: n.disabled,
1300
+ label: v(e)("inventory.closing.form.items.addItem"),
1301
+ "prepend-icon": "add",
1302
+ variant: "plain",
1303
+ class: "border-2 rounded-lg border-fm-color-primary",
1304
+ onClick: a[2] || (a[2] = (M) => u()),
1305
+ size: "md"
1306
+ }, null, 8, ["disabled", "label"])
1307
+ ]),
1308
+ $(k, {
1309
+ placeholder: "Filter items",
1310
+ modelValue: m.value,
1311
+ "onUpdate:modelValue": a[4] || (a[4] = (M) => m.value = M)
1312
+ }, Pe({ _: 2 }, [
1313
+ m.value ? {
1314
+ name: "append",
1315
+ fn: P(() => [
1316
+ $(h, {
1317
+ name: "close",
1318
+ onClick: a[3] || (a[3] = (M) => m.value = ""),
1319
+ class: "cursor-pointer"
1320
+ })
1321
+ ]),
1322
+ key: "0"
1323
+ } : void 0
1324
+ ]), 1032, ["modelValue"]),
1325
+ (T(), V(w, {
1326
+ "search-value": m.value,
1327
+ "column-defs": y.value,
1328
+ "row-data": v(l).items,
1329
+ key: v(l).items.map((M) => M.sku._id).join("."),
1330
+ "hide-footer": v(l).items.length <= 10,
1331
+ "page-size": Math.min(10, v(l).items.length)
1332
+ }, {
1333
+ "list-row": P((M) => [
1334
+ (T(), V(Ne, {
1335
+ row: M,
1336
+ key: v(l).items.map((S) => S.sku._id).join(".")
1337
+ }, {
1338
+ default: P((S) => [
1339
+ $(Jt, {
1340
+ row: M,
1341
+ "cell-by-col-id": S
1342
+ }, null, 8, ["row", "cell-by-col-id"])
1343
+ ]),
1344
+ _: 2
1345
+ }, 1032, ["row"]))
1346
+ ]),
1347
+ _: 1
1348
+ }, 8, ["search-value", "column-defs", "row-data", "hide-footer", "page-size"])),
1349
+ $(x, {
1350
+ "model-value": v(l).items.length,
1351
+ rules: [v(rt)(1)]
1352
+ }, null, 8, ["model-value", "rules"])
1353
+ ])
1354
+ ]),
1355
+ _: 1
1356
+ }, 8, ["disabled"]);
1357
+ };
1358
+ }
1359
+ }), sn = { class: "flex items-center" }, ln = { class: "fm-typo-en-title-md-600" }, an = { class: "flex gap-4" }, rn = /* @__PURE__ */ j({
1360
+ __name: "ClosingTemplateDialog",
1361
+ props: {
1362
+ mode: {},
1363
+ modelValue: {},
1364
+ show: { type: Boolean }
1365
+ },
1366
+ emits: ["update:show", "submitted"],
1367
+ setup(i, { expose: o, emit: s }) {
1368
+ var w;
1369
+ const l = i, e = s, t = ee(), f = Z(), { t: g } = B(), p = pt(l, "show");
1370
+ function r() {
1371
+ return {
1372
+ _id: "",
1373
+ name: "",
1374
+ items: []
1375
+ };
1376
+ }
1377
+ const m = D(l.modelValue ?? r()), d = D(((w = l.modelValue) == null ? void 0 : w._id) ?? `${Math.random()}`);
1378
+ Re(
1379
+ () => l.show,
1380
+ (h) => {
1381
+ var x;
1382
+ h && (m.value = l.modelValue ?? r(), d.value = ((x = l.modelValue) == null ? void 0 : x._id) ?? `${Math.random()}`);
1383
+ }
1384
+ );
1385
+ const y = D(!1), b = E(() => {
1386
+ switch (l.mode) {
1387
+ case z.READ:
1388
+ return "";
1389
+ case z.CREATE:
1390
+ return g("inventory.closing.template.create.title");
1391
+ case z.UPDATE:
1392
+ return g("inventory.closing.template.update.title");
1393
+ }
1394
+ return "";
1395
+ }), u = D();
1396
+ o({
1397
+ validateInputs: () => {
1398
+ var h, x;
1399
+ (x = (h = u.value) == null ? void 0 : h.validateInputs) == null || x.call(h);
1400
+ },
1401
+ resetInputsValidation: () => {
1402
+ var h, x;
1403
+ (x = (h = u.value) == null ? void 0 : h.resetInputsValidation) == null || x.call(h);
1404
+ },
1405
+ resetInputs: () => {
1406
+ var h, x;
1407
+ (x = (h = u.value) == null ? void 0 : h.resetInputs) == null || x.call(h);
1408
+ }
1409
+ });
1410
+ async function n() {
1411
+ const h = m.value;
1412
+ if (h) {
1413
+ y.value = !0;
1414
+ try {
1415
+ await t.createTemplate(h), await new Promise((x) => setTimeout(x, 1e3)), f.open({
1416
+ title: g("inventory.closing.template.create.success"),
1417
+ message: g("inventory.closing.template.create.successMessage"),
1418
+ type: "success"
1419
+ }), e("update:show", !1), e("submitted");
1420
+ } catch (x) {
1421
+ f.open({
1422
+ title: g("inventory.closing.template.create.error"),
1423
+ message: g("inventory.closing.template.create.errorMessage"),
1424
+ type: "error"
1425
+ }), console.error("Error in creating closing template", x);
1426
+ } finally {
1427
+ y.value = !1;
1428
+ }
1429
+ }
1430
+ }
1431
+ async function a() {
1432
+ const h = m.value;
1433
+ if (h) {
1434
+ y.value = !0;
1435
+ try {
1436
+ await t.updateTemplate({
1437
+ ...h,
1438
+ _rev: h._rev ?? ""
1439
+ }), await new Promise((x) => setTimeout(x, 1e3)), f.open({
1440
+ title: g("inventory.closing.template.update.success"),
1441
+ message: g("inventory.closing.template.update.successMessage"),
1442
+ type: "success"
1443
+ }), e("update:show", !1), e("submitted");
1444
+ } catch (x) {
1445
+ f.open({
1446
+ title: g("inventory.closing.template.update.error"),
1447
+ message: g("inventory.closing.template.update.errorMessage"),
1448
+ type: "error"
1449
+ }), console.error("Error in updating closing template", x);
1450
+ } finally {
1451
+ y.value = !1;
1452
+ }
1453
+ }
1454
+ }
1455
+ function k() {
1456
+ switch (l.mode) {
1457
+ case z.CREATE:
1458
+ return n();
1459
+ case z.UPDATE:
1460
+ return a();
1461
+ }
1462
+ }
1463
+ function c() {
1464
+ var h, x;
1465
+ (x = (h = u.value) == null ? void 0 : h.validateInputs) == null || x.call(h);
1466
+ }
1467
+ return (h, x) => {
1468
+ const A = R("FmButton"), M = R("FmSideSheet");
1469
+ return T(), V(M, {
1470
+ modelValue: v(p),
1471
+ "onUpdate:modelValue": x[2] || (x[2] = (S) => Oe(p) ? p.value = S : null),
1472
+ "dismiss-away": "",
1473
+ "close-button": "",
1474
+ "max-width": 800
1475
+ }, {
1476
+ "side-sheet-header": P(() => [
1477
+ _("div", sn, [
1478
+ _("div", ln, C(b.value), 1)
1479
+ ])
1480
+ ]),
1481
+ default: P(() => [
1482
+ (T(), V(on, {
1483
+ class: "w-full",
1484
+ ref_key: "formRef",
1485
+ ref: u,
1486
+ onValidationSuccess: k,
1487
+ "model-value": m.value,
1488
+ "onUpdate:modelValue": x[0] || (x[0] = (S) => m.value = S),
1489
+ disabled: y.value,
1490
+ key: d.value
1491
+ }, null, 8, ["model-value", "disabled"]))
1492
+ ]),
1493
+ "side-sheet-footer": P(() => [
1494
+ _("div", an, [
1495
+ $(A, {
1496
+ loading: y.value,
1497
+ label: v(g)("common.save"),
1498
+ onClick: c
1499
+ }, null, 8, ["loading", "label"]),
1500
+ $(A, {
1501
+ disabled: y.value,
1502
+ variant: "tertiary",
1503
+ label: v(g)("common.close"),
1504
+ onClick: x[1] || (x[1] = (S) => e("update:show", !1))
1505
+ }, null, 8, ["disabled", "label"])
1506
+ ])
1507
+ ]),
1508
+ _: 1
1509
+ }, 8, ["modelValue"]);
1510
+ };
1511
+ }
1512
+ }), cn = {};
1513
+ function mn(i, o) {
1514
+ return T(), I("div");
1515
+ }
1516
+ const un = /* @__PURE__ */ it(cn, [["render", mn]]), dn = { class: "flex flex-col gap-40" }, pn = { key: 0 }, fn = {
1517
+ key: 1,
1518
+ class: "flex gap-8 items-center"
1519
+ }, vn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" }, gn = {
1520
+ key: 2,
1521
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary"
1522
+ }, yn = {
1523
+ key: 3,
1524
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary flex flex-col gap-12"
1525
+ }, hn = { class: "fm-typo-en-body-md-600" }, bn = { class: "fm-typo-en-body-md-600" }, _n = { key: 4 }, xn = { class: "fm-typo-en-body-md-600" }, wn = { class: "fm-typo-en-body-md-600" }, kn = { class: "flex sm:flex-col xs:flex-col justify-end gap-8 w-full mb-16" }, Tn = /* @__PURE__ */ j({
1526
+ __name: "ClosingTemplatePublish",
1527
+ emits: ["close"],
1528
+ setup(i, { emit: o }) {
1529
+ const s = D(!1), l = Z(), e = ee(), t = te(), { t: f } = B(), g = o;
1530
+ async function p() {
1531
+ s.value = !0;
1532
+ try {
1533
+ await e.startNewPublish().delayed(1e3), l.open({
1534
+ title: "Success",
1535
+ message: "You may refresh after a while to review publish status",
1536
+ type: "success"
1537
+ }), d();
1538
+ } catch (y) {
1539
+ l.open({
1540
+ title: "Something went wrong",
1541
+ message: "Please try again",
1542
+ type: "error"
1543
+ }), console.error("error on creating publish task", y);
1544
+ } finally {
1545
+ s.value = !1;
1546
+ }
1547
+ }
1548
+ const r = E(() => t.recentPublish.recentJob), m = E(
1549
+ () => t.templates.length && (!r.value || r.value.outlets.length === r.value.completed.length)
1550
+ );
1551
+ function d() {
1552
+ g("close");
1553
+ }
1554
+ return (y, b) => {
1555
+ const u = R("FmCircularProgress"), n = R("i18n-t"), a = R("FmButton");
1556
+ return T(), I("div", dn, [
1557
+ v(t).templates.length ? s.value ? (T(), I("div", fn, [
1558
+ _("div", null, [
1559
+ $(u, {
1560
+ size: "md",
1561
+ color: "neutral-gray-300"
1562
+ })
1563
+ ]),
1564
+ _("div", vn, [
1565
+ _("span", null, C(v(f)("inventory.closing.template.publish.publishing")), 1)
1566
+ ])
1567
+ ])) : r.value ? r.value.outlets.length === r.value.completed.length ? (T(), I("div", yn, [
1568
+ $(n, {
1569
+ keypath: "inventory.closing.template.publish.recentlyPublishedAt",
1570
+ tag: "p"
1571
+ }, {
1572
+ started: P(() => [
1573
+ _("span", hn, C(v(ne)(new Date(r.value.createdAt))), 1)
1574
+ ]),
1575
+ finished: P(() => [
1576
+ _("span", bn, C(v(ne)(new Date(r.value.updatedAt))), 1)
1577
+ ]),
1578
+ _: 1
1579
+ }),
1580
+ _("p", null, C(v(f)("inventory.closing.template.publish.message")), 1)
1581
+ ])) : (T(), I("div", _n, [
1582
+ $(n, {
1583
+ keypath: "inventory.closing.template.publish.stillPublishing",
1584
+ tag: "p"
1585
+ }, {
1586
+ started: P(() => [
1587
+ _("span", xn, C(v(ne)(new Date(r.value.createdAt))), 1)
1588
+ ]),
1589
+ progress: P(() => [
1590
+ _("span", wn, " (" + C(r.value.completed.length) + "/" + C(r.value.outlets.length) + " completed) ", 1)
1591
+ ]),
1592
+ _: 1
1593
+ }),
1594
+ Fe(" Your recent publishing task is still pending (" + C(r.value.completed.length) + " / " + C(r.value.outlets.length) + "). Please wait until all publishing task has completed. ", 1)
1595
+ ])) : (T(), I("div", gn, [
1596
+ _("p", null, C(v(f)("inventory.closing.template.publish.noRecentActivity")), 1),
1597
+ _("p", null, C(v(f)("inventory.closing.template.publish.message")), 1)
1598
+ ])) : (T(), I("div", pn, [
1599
+ _("p", null, C(v(f)("inventory.closing.template.publish.nothingToPublish")), 1)
1600
+ ])),
1601
+ _("div", kn, [
1602
+ $(a, {
1603
+ disabled: !m.value,
1604
+ loading: s.value,
1605
+ label: "Publish to all outlets",
1606
+ onClick: p
1607
+ }, null, 8, ["disabled", "loading"]),
1608
+ $(a, {
1609
+ variant: "tertiary",
1610
+ label: "Close",
1611
+ onClick: d
1612
+ })
1613
+ ])
1614
+ ]);
1615
+ };
1616
+ }
1617
+ }), $n = { class: "flex-1 flex flex-col gap-8" }, Cn = { class: "flex flex-col" }, In = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Sn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Dn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Mn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Vn = /* @__PURE__ */ j({
1618
+ __name: "ClosingTemplateView",
1619
+ setup(i) {
1620
+ const { t: o } = B(), { createTemplate: s, updateTemplate: l, exportTemplates: e, importTemplates: t } = se(), { templateDialogProps: f, templateDetailsProps: g } = Le(se()), p = le(), r = ie(), m = te(), d = ct(), { breakpoints: y } = ft();
1621
+ p.watchLocation(m.fetchTemplates);
1622
+ const b = E(() => m.loading), u = D(""), n = E(() => y.value.xs || y.value.sm), a = E(() => n.value ? 10 : 20);
1623
+ function k(x) {
1624
+ switch (x) {
1625
+ case N.Add:
1626
+ return s();
1627
+ case "publish":
1628
+ return c();
1629
+ case "import":
1630
+ return t();
1631
+ case "export":
1632
+ return e();
1633
+ case "refresh":
1634
+ return m.fetchTemplates();
1635
+ }
1636
+ }
1637
+ function c() {
1638
+ r.open({
1639
+ title: "Publish closing templates",
1640
+ contentComponent: Tn,
1641
+ contentComponentProps: {
1642
+ onClose() {
1643
+ r.close();
1644
+ }
1645
+ }
1646
+ });
1647
+ }
1648
+ function w(x) {
1649
+ return x;
1650
+ }
1651
+ const h = E(() => n.value ? [
1652
+ {
1653
+ label: o("inventory.closing.template.create.title"),
1654
+ value: N.Add,
1655
+ isPrimary: !0,
1656
+ prependIcon: "add"
1657
+ },
1658
+ {
1659
+ label: o("inventory.common.refresh"),
1660
+ value: "refresh",
1661
+ isPrimary: !1
1662
+ },
1663
+ {
1664
+ label: o("inventory.common.publish"),
1665
+ value: "publish",
1666
+ isPrimary: !1
1667
+ },
1668
+ {
1669
+ label: o("inventory.common.import"),
1670
+ value: "import",
1671
+ isPrimary: !1
1672
+ },
1673
+ {
1674
+ label: o("inventory.common.export"),
1675
+ value: "export",
1676
+ isPrimary: !1
1677
+ }
1678
+ ] : [
1679
+ {
1680
+ label: o("inventory.closing.template.create.title"),
1681
+ value: N.Add,
1682
+ isPrimary: !0,
1683
+ prependIcon: "add"
1684
+ },
1685
+ {
1686
+ label: o("inventory.common.publish"),
1687
+ value: "publish",
1688
+ isPrimary: !1
1689
+ },
1690
+ {
1691
+ label: o("inventory.common.import"),
1692
+ value: "import",
1693
+ isPrimary: !1
1694
+ },
1695
+ {
1696
+ label: o("inventory.common.refresh"),
1697
+ value: "refresh",
1698
+ isPrimary: !1
1699
+ },
1700
+ {
1701
+ label: o("inventory.common.export"),
1702
+ value: "export",
1703
+ isPrimary: !1
1704
+ }
1705
+ ]);
1706
+ return (x, A) => {
1707
+ const M = R("FmTable");
1708
+ return T(), I(H, null, [
1709
+ $(mt, {
1710
+ title: v(o)("inventory.closing.template.title"),
1711
+ actions: h.value,
1712
+ "onClick:action": k
1713
+ }, {
1714
+ default: P(() => [
1715
+ _("div", {
1716
+ class: Y([
1717
+ "flex flex-col gap-8 max-h-full",
1718
+ {
1719
+ "p-0": n.value,
1720
+ "px-24 ": !n.value
1721
+ }
1722
+ ])
1723
+ }, [
1724
+ $(ut, {
1725
+ searchable: "",
1726
+ search: u.value,
1727
+ "onUpdate:search": A[0] || (A[0] = (S) => u.value = S)
1728
+ }, null, 8, ["search"]),
1729
+ $(M, {
1730
+ style: Ye(v(d).tableHeight),
1731
+ "column-defs": v(m).columnDefs,
1732
+ "row-data": v(m).templates,
1733
+ "search-value": u.value,
1734
+ loading: b.value,
1735
+ onRowClick: A[1] || (A[1] = (S) => v(l)(S.original)),
1736
+ "page-size": a.value
1737
+ }, {
1738
+ "list-row": P((S) => [
1739
+ $(Ne, {
1740
+ row: S,
1741
+ onRowClick: (U) => v(l)(U)
1742
+ }, {
1743
+ default: P((U) => {
1744
+ var me, ue, de, W, pe, fe, ve, ge, q, ye, he, be, _e, xe, we, Q, ke, Te, $e, Ce, X, Ie;
1745
+ return [
1746
+ _("div", $n, [
1747
+ _("div", Cn, [
1748
+ _("div", In, [
1749
+ $(v(O), {
1750
+ render: (de = (ue = (me = U._id) == null ? void 0 : me.column) == null ? void 0 : ue.columnDef) == null ? void 0 : de.cell,
1751
+ props: (pe = (W = U._id) == null ? void 0 : W.getContext) == null ? void 0 : pe.call(W)
1752
+ }, null, 8, ["render", "props"])
1753
+ ]),
1754
+ _("div", Sn, [
1755
+ $(v(O), {
1756
+ render: (ge = (ve = (fe = U.name) == null ? void 0 : fe.column) == null ? void 0 : ve.columnDef) == null ? void 0 : ge.cell,
1757
+ props: (ye = (q = U.name) == null ? void 0 : q.getContext) == null ? void 0 : ye.call(q)
1758
+ }, null, 8, ["render", "props"])
1759
+ ]),
1760
+ _("div", null, C((he = S.original.locations) != null && he.length ? v(o)("inventory.closing.table.enabledForN", {
1761
+ count: ((be = S.original.locations) == null ? void 0 : be.length) ?? 0
1762
+ }) : v(o)("inventory.closing.table.enabledForAll")), 1),
1763
+ _("div", Dn, C([
1764
+ ...S.original.items.slice(0, 3).map((je) => je.sku.name),
1765
+ ...S.original.items.length >= 3 ? [`and ${S.original.items.length - 3} more items`] : []
1766
+ ].join(", ")), 1),
1767
+ _("div", Mn, [
1768
+ $(v(O), {
1769
+ render: (we = (xe = (_e = U.ref) == null ? void 0 : _e.column) == null ? void 0 : xe.columnDef) == null ? void 0 : we.cell,
1770
+ props: (ke = (Q = U.ref) == null ? void 0 : Q.getContext) == null ? void 0 : ke.call(Q)
1771
+ }, null, 8, ["render", "props"])
1772
+ ])
1773
+ ]),
1774
+ _("div", null, [
1775
+ $(v(O), {
1776
+ render: (Ce = ($e = (Te = U.status) == null ? void 0 : Te.column) == null ? void 0 : $e.columnDef) == null ? void 0 : Ce.cell,
1777
+ props: (Ie = (X = U.status) == null ? void 0 : X.getContext) == null ? void 0 : Ie.call(X)
1778
+ }, null, 8, ["render", "props"])
1779
+ ])
1780
+ ])
1781
+ ];
1782
+ }),
1783
+ _: 2
1784
+ }, 1032, ["row", "onRowClick"])
1785
+ ]),
1786
+ _: 1
1787
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1788
+ ], 2)
1789
+ ]),
1790
+ _: 1
1791
+ }, 8, ["title", "actions"]),
1792
+ (T(), V(Ke, { to: "body" }, [
1793
+ $(un, Ge(Je(v(g))), null, 16),
1794
+ $(rn, We(v(f), {
1795
+ onSubmitted: A[2] || (A[2] = (S) => v(m).fetchTemplates())
1796
+ }), null, 16)
1797
+ ]))
1798
+ ], 64);
1799
+ };
1800
+ }
1801
+ });
1802
+ export {
1803
+ Vn as default
1804
+ };