@feedmepos/mf-inventory-portal 0.0.22-dev.47 → 0.0.22-dev.49

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