@feedmepos/mf-inventory-portal 1.1.6-dev.3 → 1.1.6

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