@feedmepos/mf-inventory-portal 0.0.22-dev.6 → 0.0.22-dev.8

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/{ApprovalView-C3pfc3dI.js → ApprovalView-BNeTV3TV.js} +4 -4
  2. package/dist/{BindingsDialog-B5Wslo-f.js → BindingsDialog-pBelBtiH.js} +1 -1
  3. package/dist/{BindingsPicker-DvI3H5lb.js → BindingsPicker-VHr76FFM.js} +19 -19
  4. package/dist/{BindingsTable-B6yXjwVZ.js → BindingsTable-CgIp6DKB.js} +1 -1
  5. package/dist/ClosingTemplateView-FleQasJi.js +1065 -0
  6. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BTw7Szfi.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BYfojQsH.js} +1 -1
  7. package/dist/{IngredientsView-J-HwciIj.js → IngredientsView-BEW8_MJ0.js} +3 -3
  8. package/dist/{IntegrationView-CJgc6NQo.js → IntegrationView-NnpJ8nYO.js} +2 -2
  9. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CzCVf08r.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CJMb1aR1.js} +1 -1
  10. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BJHZI0SZ.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DWSq3JsJ.js} +1 -1
  11. package/dist/{PurchaseOrderPrintPreview-DQlHM7ar.js → PurchaseOrderPrintPreview-BZ5uhyRy.js} +1 -1
  12. package/dist/{ReceiveRequestView-l-agN7yj.js → ReceiveRequestView-DN9u5HLn.js} +6 -6
  13. package/dist/{RecipeView-Bo85tc7w.js → RecipeView-DM20cOk3.js} +3 -3
  14. package/dist/{StockView-CqORznbJ.js → StockView-LppKR-nM.js} +6 -6
  15. package/dist/{SupplierView-BSc10_7O.js → SupplierView-DHh6MhoI.js} +37 -37
  16. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-KHwccWdi.js +754 -0
  17. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-2QZK3Iu5.js +1485 -0
  18. package/dist/TransferTemplateView-CUQSQR8U.js +1278 -0
  19. package/dist/{UnitView-C4Ynhnes.js → UnitView-D8XJca7H.js} +4 -4
  20. package/dist/{WarehouseView-CXhsdB6L.js → WarehouseView-DTnx3-Fi.js} +2 -2
  21. package/dist/api/inventory.d.ts +1 -0
  22. package/dist/api/netsuite.d.ts +40 -0
  23. package/dist/api/purchase-order-template.d.ts +0 -4
  24. package/dist/{app-CEx_CAFE.js → app-Cn0UYdAW.js} +8183 -7946
  25. package/dist/app.d.ts +6 -0
  26. package/dist/app.js +3 -3
  27. package/dist/{decimal-c4am8-9x.js → decimal-BiLgcnqq.js} +1 -1
  28. package/dist/{defineDeepModel-DstjIWV3.js → defineDeepModel-CXCb8GcR.js} +4 -4
  29. package/dist/{format-time-from-id-C7eIbCJx.js → format-time-from-id-5QzQNKlI.js} +1 -1
  30. package/dist/{id-to-date-BvvYzy9E.js → id-to-date-C-LYuoim.js} +1 -1
  31. package/dist/purchase-order-transaction-type-BV80Rx9h.js +676 -0
  32. package/dist/stores/api.d.ts +1 -0
  33. package/dist/stores/helper/core-store-proxy.d.ts +27 -0
  34. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  35. package/dist/stores/netsuite.d.ts +49 -0
  36. package/dist/style.css +1 -1
  37. package/dist/{supplier-Buou9AeW.js → supplier-Bg9MjX_y.js} +1 -1
  38. package/dist/tsconfig.app.tsbuildinfo +1 -1
  39. package/dist/use-template-enabled-locations-2-CzY-UFrc.js +85 -0
  40. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +14 -0
  41. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +42 -0
  42. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +42 -0
  43. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
  44. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +2 -2
  45. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +84 -0
  46. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +28 -986
  47. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +7 -0
  48. package/dist/{xlsx-_u-mXW67.js → xlsx-BsdfXPiA.js} +1 -1
  49. package/dist/{xlsx.util-C_mH9WMn.js → xlsx.util-B_ynXZ3Q.js} +2 -2
  50. package/package.json +5 -5
  51. package/dist/ClosingTemplateView-YW5Sw9M5.js +0 -1030
  52. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-qfnlbLSa.js +0 -740
  53. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-CW4b6og_.js +0 -1409
  54. package/dist/TransferTemplateView-Djn47L76.js +0 -1230
  55. package/dist/purchase-order-transaction-type-DpJe0L78.js +0 -702
  56. package/dist/use-template-enabled-locations-BPap1ER6.js +0 -57
@@ -0,0 +1,1065 @@
1
+ import { ref as P, h as x, computed as M, defineComponent as Y, openBlock as k, createElementBlock as F, createElementVNode as f, toDisplayString as A, createVNode as w, unref as u, Fragment as _e, renderList as Ce, resolveComponent as I, createBlock as z, withCtx as R, watch as Me, isRef as Pe, createTextVNode as ve, normalizeClass as Se, normalizeStyle as Fe, Teleport as Ae, normalizeProps as Ve, guardReactiveProps as Ie, mergeProps as Re } from "vue";
2
+ import { u as Ue, _ as Ee, a as Ne } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BYfojQsH.js";
3
+ import { useCoreStore as Be, useI18n as q } from "@feedmepos/mf-common";
4
+ import { useDialog as Q, useSnackbar as W, FmButtonVariant as be, components as V, useProxiedModel as ze, useBreakpoints as Le } from "@feedmepos/ui-library";
5
+ import { defineStore as we, storeToRefs as Ye } from "pinia";
6
+ import { F as U, D as ye, R as E } from "./row-action.enum-PMKMRrZR.js";
7
+ import { n as je, c as xe, j as ke, u as Ke, R as He, y as Je, i as qe, Q as he } from "./app-Cn0UYdAW.js";
8
+ import { c as Ge, F as B, _ as Te } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
9
+ import { f as Oe } from "./format-time-from-id-5QzQNKlI.js";
10
+ import "vue-router";
11
+ import { d as Qe } from "./defineDeepModel-CXCb8GcR.js";
12
+ import { u as We } from "./use-template-enabled-locations-2-CzY-UFrc.js";
13
+ const G = je((m, g) => {
14
+ function v() {
15
+ var t;
16
+ return `business_${((t = Be().currentBusiness.value) == null ? void 0 : t._id) ?? ""}`;
17
+ }
18
+ return {
19
+ async getRecentPublishingJob() {
20
+ const s = v(), n = `${m.inventoryBackendUrl}/${s}/closing-template/publish/recent`;
21
+ return g.get(n);
22
+ },
23
+ async startNewPublish() {
24
+ const s = v(), n = `${m.inventoryBackendUrl}/${s}/closing-template/publish`;
25
+ return g.post(n);
26
+ },
27
+ async getTemplate(s) {
28
+ const n = v(), t = `${m.inventoryBackendUrl}/${n}/closing-template/${s}`;
29
+ return g.get(t);
30
+ },
31
+ async readTemplates() {
32
+ const s = v(), n = `${m.inventoryBackendUrl}/${s}/closing-template`;
33
+ return g.get(n);
34
+ },
35
+ async createTemplate(s) {
36
+ const n = v(), t = `${m.inventoryBackendUrl}/${n}/closing-template`;
37
+ return g.post(t, s);
38
+ },
39
+ async updateTemplate(s) {
40
+ const n = v(), t = `${m.inventoryBackendUrl}/${n}/closing-template`;
41
+ return g.put(t, s);
42
+ },
43
+ async deleteTemplate(s) {
44
+ const n = v(), t = `${m.inventoryBackendUrl}/${n}/closing-template`;
45
+ return g.delete(t, { _id: s._id, _rev: s._rev });
46
+ }
47
+ };
48
+ }), O = we("closingTemplateActions", () => {
49
+ const m = Q(), g = W(), v = G(), s = P({});
50
+ function n() {
51
+ s.value = {
52
+ mode: U.CREATE,
53
+ show: !0,
54
+ "onUpdate:show"(d) {
55
+ s.value.show = d;
56
+ }
57
+ };
58
+ }
59
+ function t(d) {
60
+ s.value = {
61
+ mode: U.UPDATE,
62
+ modelValue: d,
63
+ show: !0,
64
+ "onUpdate:show"(c) {
65
+ s.value.show = c;
66
+ }
67
+ };
68
+ }
69
+ function b(d, c, y) {
70
+ m.open({
71
+ title: `Confirm deleting template ${d.name}?`,
72
+ message: "Deleted template can no longer be retrieved",
73
+ primaryActions: {
74
+ text: "Delete",
75
+ variant: be.Destructive,
76
+ close: !0
77
+ },
78
+ secondaryActions: {
79
+ text: "Cancel",
80
+ variant: be.Plain,
81
+ close: !0
82
+ }
83
+ }).onPrimary(async () => {
84
+ g.open({
85
+ title: `Deleting ${d.name}`,
86
+ type: "info"
87
+ });
88
+ try {
89
+ c.value = !0;
90
+ const [p] = await Promise.allSettled([
91
+ v.deleteTemplate(d),
92
+ new Promise((_) => setTimeout(_, 1e3))
93
+ ]);
94
+ if (p.status === "rejected") throw p.reason;
95
+ g.open({
96
+ title: `Deleted ${d.name}`,
97
+ type: "success"
98
+ });
99
+ } catch (p) {
100
+ g.open({
101
+ title: `Unable to delete ${d.name}`,
102
+ message: `See error from server: ${p}`,
103
+ type: "error"
104
+ }), console.error("error on deleting closing template", p);
105
+ } finally {
106
+ c.value = !1, y();
107
+ }
108
+ });
109
+ }
110
+ const a = P({});
111
+ function i(d) {
112
+ a.value = {
113
+ template: d,
114
+ show: !0,
115
+ "onUpdate:show"(c) {
116
+ a.value.show = c;
117
+ },
118
+ "onAction:edit"() {
119
+ a.value.show = !1, t(xe(d));
120
+ }
121
+ };
122
+ }
123
+ return {
124
+ createTemplate: n,
125
+ viewTemplate: i,
126
+ updateTemplate: t,
127
+ deleteTemplate: b,
128
+ templateDialogProps: s,
129
+ templateDetailsProps: a
130
+ };
131
+ }), De = we(
132
+ "closingTable",
133
+ function() {
134
+ const { t: g } = q(), { viewTemplate: v, updateTemplate: s, deleteTemplate: n } = O(), t = P({}), b = P(new Array()), a = P(!1), i = ke(), d = G();
135
+ async function c() {
136
+ if (b.value = [], !!i._currentLocation) {
137
+ a.value = !0;
138
+ try {
139
+ const [e, o] = await Promise.all([
140
+ d.readTemplates(),
141
+ d.getRecentPublishingJob()
142
+ ]).delayed(1e3);
143
+ b.value = e, t.value = o;
144
+ } catch (e) {
145
+ console.log("Something went wrong when fetching templates:", e);
146
+ } finally {
147
+ a.value = !1;
148
+ }
149
+ }
150
+ }
151
+ async function y(e) {
152
+ if (!b.value.find((o) => o._id) && i._currentLocation) {
153
+ a.value = !0;
154
+ try {
155
+ const [o] = await Promise.all([
156
+ d.getTemplate(e),
157
+ new Promise((h) => setTimeout(h, 1e3))
158
+ ]);
159
+ b.value = [o];
160
+ } catch (o) {
161
+ console.log("Something went wrong when fetching templates:", o);
162
+ } finally {
163
+ a.value = !1;
164
+ }
165
+ }
166
+ }
167
+ function p(e, o) {
168
+ switch (o = xe(o), e) {
169
+ case E.Details:
170
+ return v(o);
171
+ case E.Edit:
172
+ return s(o);
173
+ case E.Delete:
174
+ return n(o, a, c);
175
+ }
176
+ }
177
+ return {
178
+ columnDefs: [
179
+ {
180
+ id: "_id",
181
+ accessorKey: "_id",
182
+ header: () => g("inventory.closing.table.createdAt"),
183
+ cell(e) {
184
+ return Oe(`${e.getValue()}`);
185
+ },
186
+ enableSorting: !0
187
+ },
188
+ {
189
+ id: "name",
190
+ accessorKey: "name",
191
+ header: () => g("inventory.closing.table.name"),
192
+ enableSorting: !0,
193
+ size: 200
194
+ },
195
+ {
196
+ id: "noOfItems",
197
+ accessorKey: "items.length",
198
+ header: () => g("inventory.closing.table.noOfItems"),
199
+ enableSorting: !1,
200
+ meta: {
201
+ width: "10rem",
202
+ textAlign: "right"
203
+ }
204
+ },
205
+ {
206
+ id: "enabledLocations",
207
+ accessorKey: "locations.length",
208
+ header: () => "Enabled outlets",
209
+ cell(e) {
210
+ var h;
211
+ const o = (h = e.row.original.locations) == null ? void 0 : h.length;
212
+ return o ? `${o}` : "All";
213
+ },
214
+ enableSorting: !1,
215
+ meta: {
216
+ width: "10rem",
217
+ textAlign: "right"
218
+ }
219
+ },
220
+ {
221
+ id: "ref",
222
+ accessorKey: "ref",
223
+ header: () => g("inventory.closing.table.reference"),
224
+ enableSorting: !1,
225
+ size: "auto"
226
+ },
227
+ {
228
+ id: "status",
229
+ header: () => "Status",
230
+ enableSorting: !1,
231
+ cell(e) {
232
+ var $;
233
+ const o = e.row.original, h = o._rev, D = ($ = t.value.publishedRevs) == null ? void 0 : $[o._id];
234
+ return h === D ? x(
235
+ V.FmChip,
236
+ {
237
+ class: "fm-chip-success-secondary",
238
+ compact: !0
239
+ },
240
+ "Published"
241
+ ) : x(
242
+ V.FmChip,
243
+ {
244
+ class: "fm-chip-info-secondary",
245
+ compact: !0
246
+ },
247
+ "Unpublished"
248
+ );
249
+ }
250
+ },
251
+ {
252
+ id: "action",
253
+ cell(e) {
254
+ const o = e.row.original, h = [
255
+ ye[E.Edit],
256
+ ye[E.Delete]
257
+ ];
258
+ return Ge(h, (D) => p(D, o));
259
+ },
260
+ enableSorting: !1,
261
+ size: 40,
262
+ meta: {
263
+ cellClass: "",
264
+ headerClass: ""
265
+ }
266
+ }
267
+ ],
268
+ recentPublish: t,
269
+ templates: b,
270
+ loading: a,
271
+ fetchTemplates: c,
272
+ loadTemplate: y
273
+ };
274
+ }
275
+ );
276
+ var L = /* @__PURE__ */ ((m) => (m.Name = "Name", m.Unit = "Unit", m.Delete = "Delete", m))(L || {});
277
+ function Xe(m) {
278
+ return {
279
+ columnDefs: M(() => {
280
+ const v = m.items.map((n) => n.sku.unit.measurements.length).reduce((n, t) => Math.max(n, t), 0);
281
+ return [
282
+ {
283
+ id: "Name",
284
+ header: () => "Name",
285
+ enableSorting: !1,
286
+ size: 400,
287
+ cell(n) {
288
+ const t = n.row.original;
289
+ return x(
290
+ "div",
291
+ {
292
+ class: "flex flex-col"
293
+ },
294
+ [
295
+ x(
296
+ "span",
297
+ { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1" },
298
+ t.sku.name
299
+ ),
300
+ x(
301
+ "span",
302
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
303
+ t.sku.code
304
+ )
305
+ ]
306
+ );
307
+ }
308
+ },
309
+ {
310
+ id: "Unit",
311
+ header: () => "Enable unit",
312
+ enableSorting: !1,
313
+ size: "auto",
314
+ cell(n) {
315
+ var b, a, i;
316
+ const t = n.row.original;
317
+ return x(
318
+ V.FmFormGroup,
319
+ {
320
+ value: t.sku.unit._id,
321
+ modelValue: !((b = t.disabledMeasurements) != null && b.includes(t.sku.unit._id))
322
+ },
323
+ x(
324
+ "div",
325
+ {
326
+ class: "flex items-center gap-4"
327
+ },
328
+ [
329
+ x(V.FmCheckbox, {
330
+ value: t.sku.unit._id,
331
+ modelValue: !((a = t.disabledMeasurements) != null && a.includes(t.sku.unit._id)),
332
+ disabled: m.disabled || !((i = t.disabledMeasurements) != null && i.includes(t.sku.unit._id)) && t.sku.unit.measurements.every(
333
+ (d) => {
334
+ var c;
335
+ return (c = t.disabledMeasurements) == null ? void 0 : c.includes(d.id);
336
+ }
337
+ ),
338
+ "onUpdate:modelValue"(d) {
339
+ var c;
340
+ if (d)
341
+ m.updateItem({
342
+ ...t,
343
+ disabledMeasurements: (c = t.disabledMeasurements) == null ? void 0 : c.filter(
344
+ (y) => y !== t.sku.unit._id
345
+ )
346
+ });
347
+ else {
348
+ const y = t.disabledMeasurements ?? [];
349
+ m.updateItem({
350
+ ...t,
351
+ disabledMeasurements: [...y, t.sku.unit._id]
352
+ });
353
+ }
354
+ }
355
+ }),
356
+ x(
357
+ V.FmTooltip,
358
+ { zIndex: 51 },
359
+ {
360
+ content() {
361
+ return t.sku.unit.abbrev;
362
+ },
363
+ default() {
364
+ return x(
365
+ "div",
366
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
367
+ t.sku.unit.abbrev
368
+ );
369
+ }
370
+ }
371
+ )
372
+ ]
373
+ )
374
+ );
375
+ }
376
+ },
377
+ ...Array.from({ length: Math.max(v, 0) }).map(
378
+ (n, t) => ({
379
+ id: `measurement${t}`,
380
+ header: () => "",
381
+ enableSorting: !1,
382
+ size: "auto",
383
+ cell(b) {
384
+ var d, c, y, p;
385
+ const a = b.row.original, i = a.sku.unit.measurements[t];
386
+ return i ? x(
387
+ V.FmFormGroup,
388
+ {
389
+ modelValue: !((d = a.disabledMeasurements) != null && d.includes(i.id)),
390
+ value: i.id
391
+ },
392
+ x(
393
+ "div",
394
+ {
395
+ class: "flex items-center gap-4"
396
+ },
397
+ [
398
+ x(V.FmCheckbox, {
399
+ value: i.id,
400
+ modelValue: !((c = a.disabledMeasurements) != null && c.includes(i.id)),
401
+ disabled: m.disabled || !((y = a.disabledMeasurements) != null && y.includes(i.id)) && ((p = a.disabledMeasurements) == null ? void 0 : p.includes(a.sku.unit._id)) && a.sku.unit.measurements.filter((_) => _.id != i.id).every((_) => {
402
+ var e;
403
+ return (e = a.disabledMeasurements) == null ? void 0 : e.includes(_.id);
404
+ }),
405
+ "onUpdate:modelValue"(_) {
406
+ var e;
407
+ if (_)
408
+ m.updateItem({
409
+ ...a,
410
+ disabledMeasurements: (e = a.disabledMeasurements) == null ? void 0 : e.filter(
411
+ (o) => o !== i.id
412
+ )
413
+ });
414
+ else {
415
+ const o = a.disabledMeasurements ?? [];
416
+ m.updateItem({
417
+ ...a,
418
+ disabledMeasurements: [...o, i.id]
419
+ });
420
+ }
421
+ }
422
+ }),
423
+ x(
424
+ V.FmTooltip,
425
+ { zIndex: 51 },
426
+ {
427
+ content() {
428
+ return i.abbrev;
429
+ },
430
+ default() {
431
+ return x(
432
+ "div",
433
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
434
+ i.abbrev
435
+ );
436
+ }
437
+ }
438
+ )
439
+ ]
440
+ )
441
+ ) : null;
442
+ }
443
+ })
444
+ ),
445
+ {
446
+ id: "Delete",
447
+ header: "",
448
+ cell(n) {
449
+ const t = n.row.original;
450
+ return x(
451
+ "div",
452
+ { class: "w-full flex justify-end" },
453
+ x(V.FmButton, {
454
+ class: "delete-button",
455
+ key: t.sku._id,
456
+ type: "button",
457
+ icon: "delete",
458
+ variant: "tertiary",
459
+ size: "md",
460
+ disabled: m.disabled,
461
+ onClick: () => {
462
+ m.deleteItem(t);
463
+ }
464
+ })
465
+ );
466
+ },
467
+ enableSorting: !1,
468
+ size: 40,
469
+ meta: {
470
+ cellClass: "",
471
+ headerClass: ""
472
+ }
473
+ }
474
+ ];
475
+ })
476
+ };
477
+ }
478
+ const Ze = { class: "flex flex-col gap-16 py-12" }, et = { class: "flex" }, tt = { class: "flex-1 flex flex-col" }, st = { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, lt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ot = { class: "flex flex-col gap-4" }, nt = /* @__PURE__ */ Y({
479
+ __name: "ClosingTemplateItem",
480
+ props: {
481
+ cellByColId: {},
482
+ row: {}
483
+ },
484
+ setup(m) {
485
+ const g = m, v = M(() => g.row), s = M(
486
+ () => v.value.getVisibleCells().filter((n) => n.column.id !== L.Name && n.column.id !== L.Delete)
487
+ );
488
+ return (n, t) => {
489
+ var b, a, i, d, c;
490
+ return k(), F("div", Ze, [
491
+ f("div", et, [
492
+ f("div", tt, [
493
+ f("div", st, A(v.value.original.sku.name), 1),
494
+ f("div", lt, A(v.value.original.sku.code), 1)
495
+ ]),
496
+ f("div", null, [
497
+ w(u(B), {
498
+ render: (i = (a = (b = n.cellByColId[u(L).Delete]) == null ? void 0 : b.column) == null ? void 0 : a.columnDef) == null ? void 0 : i.cell,
499
+ props: (c = (d = n.cellByColId[u(L).Delete]) == null ? void 0 : d.getContext) == null ? void 0 : c.call(d)
500
+ }, null, 8, ["render", "props"])
501
+ ])
502
+ ]),
503
+ f("div", ot, [
504
+ t[0] || (t[0] = f("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, "Enabled units", -1)),
505
+ (k(!0), F(_e, null, Ce(s.value, (y) => {
506
+ var p, _, e;
507
+ return k(), F("div", {
508
+ key: y.id
509
+ }, [
510
+ w(u(B), {
511
+ render: (_ = (p = y.column) == null ? void 0 : p.columnDef) == null ? void 0 : _.cell,
512
+ props: (e = y.getContext) == null ? void 0 : e.call(y)
513
+ }, null, 8, ["render", "props"])
514
+ ]);
515
+ }), 128))
516
+ ])
517
+ ]);
518
+ };
519
+ }
520
+ }), at = { class: "flex flex-col gap-16" }, it = { class: "flex flex-col gap-24" }, rt = { class: "flex flex-col gap-16" }, ct = { class: "flex items-center" }, ut = { class: "flex flex-col gap-16" }, dt = { class: "flex items-center" }, mt = { class: "flex-1 gap-8 fm-typo-en-title-sm-800" }, pt = /* @__PURE__ */ Y({
521
+ __name: "ClosingTemplateForm",
522
+ props: {
523
+ modelValue: {},
524
+ disabled: { type: Boolean }
525
+ },
526
+ setup(m, { expose: g }) {
527
+ const v = m, s = Qe(), { t: n } = q(), t = Ke(), b = Q(), {
528
+ promptSelectLocations: a,
529
+ columnDefs: i,
530
+ rowData: d
531
+ } = We({
532
+ getLocations() {
533
+ return s.locations;
534
+ },
535
+ setLocations(e) {
536
+ s.locations = e;
537
+ }
538
+ }), c = P();
539
+ g({
540
+ validateInputs: () => {
541
+ var e, o;
542
+ (o = (e = c.value) == null ? void 0 : e.validateInputs) == null || o.call(e);
543
+ },
544
+ resetInputsValidation: () => {
545
+ var e, o;
546
+ (o = (e = c.value) == null ? void 0 : e.resetInputsValidation) == null || o.call(e);
547
+ },
548
+ resetInputs: () => {
549
+ var e, o;
550
+ (o = (e = c.value) == null ? void 0 : e.resetInputs) == null || o.call(e);
551
+ }
552
+ });
553
+ const y = Xe({
554
+ updateItem: (e) => {
555
+ s.items = s.items.map((o) => o.sku._id !== e.sku._id ? o : e);
556
+ },
557
+ deleteItem: (e) => {
558
+ s.items = s.items.filter((o) => o.sku._id !== e.sku._id);
559
+ },
560
+ get items() {
561
+ return s.items;
562
+ },
563
+ get disabled() {
564
+ return v.disabled;
565
+ }
566
+ }), p = M(() => y.columnDefs.value);
567
+ function _() {
568
+ const e = t.skus.map((h) => ({
569
+ label: h.name,
570
+ sublabel: h.code,
571
+ value: h
572
+ })), o = e.filter((h) => {
573
+ var D;
574
+ return (D = s.items) == null ? void 0 : D.find(($) => $.sku._id === h.value._id);
575
+ }).map((h) => h.value);
576
+ b.open({
577
+ title: n("inventory.closing.form.items.selectItem"),
578
+ closeButton: !0,
579
+ contentComponent: Je,
580
+ contentComponentProps: {
581
+ modelValue: o,
582
+ items: e,
583
+ virtualScroll: !0
584
+ },
585
+ primaryActions: {
586
+ text: n("common.confirm"),
587
+ close: !0
588
+ },
589
+ secondaryActions: {
590
+ text: n("common.close"),
591
+ close: !0,
592
+ variant: "tertiary"
593
+ }
594
+ }).onPrimary((h) => {
595
+ const D = s.items ?? [], $ = h.map((S) => {
596
+ const l = D.find((N) => N.sku._id === S._id);
597
+ return l || {
598
+ sku: S
599
+ };
600
+ });
601
+ $.sort((S, l) => S.sku.code.localeCompare(l.sku.code)), s.items = $;
602
+ });
603
+ }
604
+ return (e, o) => {
605
+ const h = I("FmTextField"), D = I("FmButton"), $ = I("FmTable"), S = I("FmForm");
606
+ return k(), z(S, {
607
+ ref_key: "formRef",
608
+ ref: c,
609
+ class: "flex flex-col gap-32",
610
+ disabled: e.disabled
611
+ }, {
612
+ default: R(() => [
613
+ f("div", at, [
614
+ f("div", it, [
615
+ w(h, {
616
+ label: u(n)("inventory.closing.form.name"),
617
+ "label-mark": "required",
618
+ modelValue: u(s).name,
619
+ "onUpdate:modelValue": o[0] || (o[0] = (l) => u(s).name = l),
620
+ rules: [u(He)()]
621
+ }, null, 8, ["label", "modelValue", "rules"]),
622
+ w(h, {
623
+ label: u(n)("inventory.closing.form.reference"),
624
+ "label-mark": "optional",
625
+ modelValue: u(s).ref,
626
+ "onUpdate:modelValue": o[1] || (o[1] = (l) => u(s).ref = l)
627
+ }, null, 8, ["label", "modelValue"])
628
+ ])
629
+ ]),
630
+ f("div", rt, [
631
+ f("div", ct, [
632
+ o[3] || (o[3] = f("div", { class: "flex-1 fm-typo-en-title-sm-600" }, "Locations", -1)),
633
+ w(D, {
634
+ disabled: e.disabled,
635
+ label: "Select location",
636
+ "prepend-icon": "add",
637
+ variant: "plain",
638
+ class: "border-2 rounded-lg border-fm-color-primary",
639
+ onClick: u(a)
640
+ }, null, 8, ["disabled", "onClick"])
641
+ ]),
642
+ w($, {
643
+ "column-defs": u(i),
644
+ "row-data": u(d),
645
+ "shrink-at": 9999,
646
+ "hide-footer": ""
647
+ }, null, 8, ["column-defs", "row-data"])
648
+ ]),
649
+ f("div", ut, [
650
+ f("div", dt, [
651
+ f("div", mt, A(u(n)("inventory.closing.form.items.title")), 1),
652
+ w(D, {
653
+ disabled: e.disabled,
654
+ label: u(n)("inventory.closing.form.items.addItem"),
655
+ "prepend-icon": "add",
656
+ variant: "plain",
657
+ class: "border-2 rounded-lg border-fm-color-primary",
658
+ onClick: o[2] || (o[2] = (l) => _()),
659
+ size: "md"
660
+ }, null, 8, ["disabled", "label"])
661
+ ]),
662
+ (k(), z($, {
663
+ "column-defs": p.value,
664
+ "row-data": u(s).items,
665
+ key: u(s).items.map((l) => l.sku._id).join("."),
666
+ "hide-footer": ""
667
+ }, {
668
+ "list-row": R((l) => [
669
+ (k(), z(Te, {
670
+ row: l,
671
+ key: u(s).items.map((r) => r.sku._id).join(".")
672
+ }, {
673
+ default: R((r) => [
674
+ w(nt, {
675
+ row: l,
676
+ "cell-by-col-id": r
677
+ }, null, 8, ["row", "cell-by-col-id"])
678
+ ]),
679
+ _: 2
680
+ }, 1032, ["row"]))
681
+ ]),
682
+ _: 1
683
+ }, 8, ["column-defs", "row-data"]))
684
+ ])
685
+ ]),
686
+ _: 1
687
+ }, 8, ["disabled"]);
688
+ };
689
+ }
690
+ }), ft = { class: "flex items-center" }, gt = { class: "fm-typo-en-title-md-800" }, vt = { class: "flex gap-4" }, bt = /* @__PURE__ */ Y({
691
+ __name: "ClosingTemplateDialog",
692
+ props: {
693
+ mode: {},
694
+ modelValue: {},
695
+ show: { type: Boolean }
696
+ },
697
+ emits: ["update:show", "submitted"],
698
+ setup(m, { expose: g, emit: v }) {
699
+ var S;
700
+ const s = m, n = v, t = G(), b = W(), { t: a } = q(), i = ze(s, "show");
701
+ function d() {
702
+ return {
703
+ _id: "",
704
+ name: "",
705
+ items: []
706
+ };
707
+ }
708
+ const c = P(s.modelValue ?? d()), y = P(((S = s.modelValue) == null ? void 0 : S._id) ?? `${Math.random()}`);
709
+ Me(
710
+ () => s.show,
711
+ (l) => {
712
+ var r;
713
+ l && (c.value = s.modelValue ?? d(), y.value = ((r = s.modelValue) == null ? void 0 : r._id) ?? `${Math.random()}`);
714
+ }
715
+ );
716
+ const p = P(!1), _ = M(() => {
717
+ switch (s.mode) {
718
+ case U.READ:
719
+ return "";
720
+ case U.CREATE:
721
+ return a("inventory.closing.template.create.title");
722
+ case U.UPDATE:
723
+ return a("inventory.closing.template.update.title");
724
+ }
725
+ return "";
726
+ }), e = P();
727
+ g({
728
+ validateInputs: () => {
729
+ var l, r;
730
+ (r = (l = e.value) == null ? void 0 : l.validateInputs) == null || r.call(l);
731
+ },
732
+ resetInputsValidation: () => {
733
+ var l, r;
734
+ (r = (l = e.value) == null ? void 0 : l.resetInputsValidation) == null || r.call(l);
735
+ },
736
+ resetInputs: () => {
737
+ var l, r;
738
+ (r = (l = e.value) == null ? void 0 : l.resetInputs) == null || r.call(l);
739
+ }
740
+ });
741
+ async function o() {
742
+ const l = c.value;
743
+ if (l) {
744
+ p.value = !0;
745
+ try {
746
+ await t.createTemplate(l), await new Promise((r) => setTimeout(r, 1e3)), b.open({
747
+ title: a("inventory.closing.template.create.success"),
748
+ message: a("inventory.closing.template.create.successMessage"),
749
+ type: "success"
750
+ }), n("update:show", !1), n("submitted");
751
+ } catch (r) {
752
+ b.open({
753
+ title: a("inventory.closing.template.create.error"),
754
+ message: a("inventory.closing.template.create.errorMessage"),
755
+ type: "error"
756
+ }), console.error("Error in creating closing template", r);
757
+ } finally {
758
+ p.value = !1;
759
+ }
760
+ }
761
+ }
762
+ async function h() {
763
+ const l = c.value;
764
+ if (l) {
765
+ p.value = !0;
766
+ try {
767
+ await t.updateTemplate(l), await new Promise((r) => setTimeout(r, 1e3)), b.open({
768
+ title: a("inventory.closing.template.update.success"),
769
+ message: a("inventory.closing.template.update.successMessage"),
770
+ type: "success"
771
+ }), n("update:show", !1), n("submitted");
772
+ } catch (r) {
773
+ b.open({
774
+ title: a("inventory.closing.template.update.error"),
775
+ message: a("inventory.closing.template.update.errorMessage"),
776
+ type: "error"
777
+ }), console.error("Error in updating closing template", r);
778
+ } finally {
779
+ p.value = !1;
780
+ }
781
+ }
782
+ }
783
+ function D() {
784
+ switch (s.mode) {
785
+ case U.CREATE:
786
+ return o();
787
+ case U.UPDATE:
788
+ return h();
789
+ }
790
+ }
791
+ function $() {
792
+ var l, r;
793
+ (r = (l = e.value) == null ? void 0 : l.validateInputs) == null || r.call(l);
794
+ }
795
+ return (l, r) => {
796
+ const N = I("FmButton"), C = I("FmSideSheet");
797
+ return k(), z(C, {
798
+ modelValue: u(i),
799
+ "onUpdate:modelValue": r[2] || (r[2] = (T) => Pe(i) ? i.value = T : null),
800
+ "dismiss-away": "",
801
+ "close-button": "",
802
+ "max-width": 800
803
+ }, {
804
+ "side-sheet-header": R(() => [
805
+ f("div", ft, [
806
+ f("div", gt, A(_.value), 1)
807
+ ])
808
+ ]),
809
+ default: R(() => [
810
+ (k(), z(pt, {
811
+ class: "w-full",
812
+ ref_key: "formRef",
813
+ ref: e,
814
+ onValidationSuccess: D,
815
+ "model-value": c.value,
816
+ "onUpdate:modelValue": r[0] || (r[0] = (T) => c.value = T),
817
+ disabled: p.value,
818
+ key: y.value
819
+ }, null, 8, ["model-value", "disabled"]))
820
+ ]),
821
+ "side-sheet-footer": R(() => [
822
+ f("div", vt, [
823
+ w(N, {
824
+ loading: p.value,
825
+ label: u(a)("common.save"),
826
+ onClick: $
827
+ }, null, 8, ["loading", "label"]),
828
+ w(N, {
829
+ disabled: p.value,
830
+ variant: "tertiary",
831
+ label: u(a)("common.close"),
832
+ onClick: r[1] || (r[1] = (T) => n("update:show", !1))
833
+ }, null, 8, ["disabled", "label"])
834
+ ])
835
+ ]),
836
+ _: 1
837
+ }, 8, ["modelValue"]);
838
+ };
839
+ }
840
+ }), yt = {};
841
+ function ht(m, g) {
842
+ return k(), F("div");
843
+ }
844
+ const _t = /* @__PURE__ */ qe(yt, [["render", ht]]), wt = { class: "flex flex-col gap-40" }, xt = { key: 0 }, kt = {
845
+ key: 1,
846
+ class: "flex gap-8 items-center"
847
+ }, Tt = {
848
+ key: 2,
849
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary"
850
+ }, Dt = {
851
+ key: 3,
852
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary flex flex-col gap-12"
853
+ }, $t = { key: 4 }, Ct = { class: "flex sm:flex-col xs:flex-col justify-end gap-8 w-full mb-16" }, Mt = /* @__PURE__ */ Y({
854
+ __name: "ClosingTemplatePublish",
855
+ emits: ["close"],
856
+ setup(m, { emit: g }) {
857
+ const v = P(!1), s = W(), n = G(), t = De(), b = g;
858
+ async function a() {
859
+ v.value = !0;
860
+ try {
861
+ await n.startNewPublish().delayed(1e3), s.open({
862
+ title: "Success",
863
+ message: "You may refresh after a while to review publish status",
864
+ type: "success"
865
+ }), c();
866
+ } catch (y) {
867
+ s.open({
868
+ title: "Something went wrong",
869
+ message: "Please try again",
870
+ type: "error"
871
+ }), console.error("error on creating publish task", y);
872
+ } finally {
873
+ v.value = !1;
874
+ }
875
+ }
876
+ const i = M(() => t.recentPublish.recentJob), d = M(
877
+ () => t.templates.length && (!i.value || i.value.outlets.length === i.value.completed.length)
878
+ );
879
+ function c() {
880
+ b("close");
881
+ }
882
+ return (y, p) => {
883
+ const _ = I("FmCircularProgress"), e = I("FmButton");
884
+ return k(), F("div", wt, [
885
+ u(t).templates.length ? v.value ? (k(), F("div", kt, [
886
+ f("div", null, [
887
+ w(_, {
888
+ size: "md",
889
+ color: "neutral-gray-300"
890
+ })
891
+ ]),
892
+ p[0] || (p[0] = f("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" }, [
893
+ f("span", null, "Sending a task to publish templates to all outlets...")
894
+ ], -1))
895
+ ])) : i.value ? i.value.outlets.length === i.value.completed.length ? (k(), F("div", Dt, [
896
+ f("p", null, [
897
+ ve(" Your recent publishing task at " + A(u(he)(new Date(i.value.createdAt))) + " has ", 1),
898
+ p[1] || (p[1] = f("span", { class: "fm-typo-en-body-lg-600" }, "completed", -1)),
899
+ ve(" at " + A(u(he)(new Date(i.value.updatedAt))) + ". ", 1)
900
+ ]),
901
+ p[2] || (p[2] = f("p", null, "Do you want to publish to all outlets?", -1))
902
+ ])) : (k(), F("div", $t, " Your recent publishing task is still pending (" + A(i.value.completed.length) + " / " + A(i.value.outlets.length) + "). Please wait until all publishing task has completed. ", 1)) : (k(), F("div", Tt, " You have no recent publish activity. Do you want to publish to all outlets? ")) : (k(), F("div", xt, "You have no template to publish.")),
903
+ f("div", Ct, [
904
+ w(e, {
905
+ disabled: !d.value,
906
+ loading: v.value,
907
+ label: "Publish to all outlets",
908
+ onClick: a
909
+ }, null, 8, ["disabled", "loading"]),
910
+ w(e, {
911
+ variant: "tertiary",
912
+ label: "Close",
913
+ onClick: c
914
+ })
915
+ ])
916
+ ]);
917
+ };
918
+ }
919
+ }), Pt = { class: "flex-1 flex flex-col gap-8" }, St = { class: "flex flex-col" }, Ft = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, At = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Vt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, It = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, qt = /* @__PURE__ */ Y({
920
+ __name: "ClosingTemplateView",
921
+ setup(m) {
922
+ const { t: g } = q(), { createTemplate: v, updateTemplate: s } = O(), { templateDialogProps: n, templateDetailsProps: t } = Ye(O()), b = ke(), a = Q(), i = De(), d = Ue(), { breakpoints: c } = Le();
923
+ b.watchLocation(i.fetchTemplates);
924
+ const y = M(() => i.loading), p = P(""), _ = M(() => c.value.xs || c.value.sm), e = M(() => _.value ? 10 : 20);
925
+ function o(l) {
926
+ switch (l) {
927
+ case E.Add:
928
+ return v();
929
+ case "publish":
930
+ return h();
931
+ }
932
+ }
933
+ function h() {
934
+ a.open({
935
+ title: "Publish closing templates",
936
+ contentComponent: Mt,
937
+ contentComponentProps: {
938
+ onClose() {
939
+ a.close();
940
+ }
941
+ }
942
+ });
943
+ }
944
+ function D(l) {
945
+ return l;
946
+ }
947
+ const $ = M(() => {
948
+ const l = [
949
+ {
950
+ label: g("inventory.closing.template.create.title"),
951
+ value: E.Add,
952
+ isPrimary: !0,
953
+ prependIcon: "add"
954
+ }
955
+ ];
956
+ return _.value ? l : [
957
+ ...l,
958
+ {
959
+ label: "Publish",
960
+ value: "publish",
961
+ isPrimary: !1
962
+ }
963
+ ];
964
+ }), S = M(() => {
965
+ const l = [{ icon: "refresh", onClick: i.fetchTemplates }];
966
+ return _.value ? [{ icon: "publish", onClick: h }, ...l] : l;
967
+ });
968
+ return (l, r) => {
969
+ const N = I("FmTable");
970
+ return k(), F(_e, null, [
971
+ w(Ee, {
972
+ title: u(g)("inventory.closing.template.title"),
973
+ actions: $.value,
974
+ "onClick:action": o
975
+ }, {
976
+ default: R(() => [
977
+ f("div", {
978
+ class: Se([
979
+ "flex flex-col gap-8 max-h-full",
980
+ {
981
+ "p-0": _.value,
982
+ "px-24 ": !_.value
983
+ }
984
+ ])
985
+ }, [
986
+ w(Ne, {
987
+ searchable: "",
988
+ search: p.value,
989
+ "onUpdate:search": r[0] || (r[0] = (C) => p.value = C),
990
+ actions: S.value
991
+ }, null, 8, ["search", "actions"]),
992
+ w(N, {
993
+ style: Fe(u(d).tableHeight),
994
+ "column-defs": u(i).columnDefs,
995
+ "row-data": u(i).templates,
996
+ "search-value": p.value,
997
+ loading: y.value,
998
+ onRowClick: r[1] || (r[1] = (C) => u(s)(C.original)),
999
+ "page-size": e.value
1000
+ }, {
1001
+ "list-row": R((C) => [
1002
+ w(Te, {
1003
+ row: C,
1004
+ onRowClick: (T) => u(s)(T)
1005
+ }, {
1006
+ default: R((T) => {
1007
+ var X, Z, ee, j, te, se, le, oe, K, ne, ae, ie, re, ce, ue, H, de, me, pe, fe, J, ge;
1008
+ return [
1009
+ f("div", Pt, [
1010
+ f("div", St, [
1011
+ f("div", Ft, [
1012
+ w(u(B), {
1013
+ render: (ee = (Z = (X = T._id) == null ? void 0 : X.column) == null ? void 0 : Z.columnDef) == null ? void 0 : ee.cell,
1014
+ props: (te = (j = T._id) == null ? void 0 : j.getContext) == null ? void 0 : te.call(j)
1015
+ }, null, 8, ["render", "props"])
1016
+ ]),
1017
+ f("div", At, [
1018
+ w(u(B), {
1019
+ render: (oe = (le = (se = T.name) == null ? void 0 : se.column) == null ? void 0 : le.columnDef) == null ? void 0 : oe.cell,
1020
+ props: (ne = (K = T.name) == null ? void 0 : K.getContext) == null ? void 0 : ne.call(K)
1021
+ }, null, 8, ["render", "props"])
1022
+ ]),
1023
+ f("div", null, A((ae = C.original.locations) != null && ae.length ? `Enabled for ${(ie = C.original.locations) == null ? void 0 : ie.length} outlets` : "Enabled for all outlets"), 1),
1024
+ f("div", Vt, A([
1025
+ ...C.original.items.slice(0, 3).map(($e) => $e.sku.name),
1026
+ ...C.original.items.length >= 3 ? [`and ${C.original.items.length - 3} more items`] : []
1027
+ ].join(", ")), 1),
1028
+ f("div", It, [
1029
+ w(u(B), {
1030
+ render: (ue = (ce = (re = T.ref) == null ? void 0 : re.column) == null ? void 0 : ce.columnDef) == null ? void 0 : ue.cell,
1031
+ props: (de = (H = T.ref) == null ? void 0 : H.getContext) == null ? void 0 : de.call(H)
1032
+ }, null, 8, ["render", "props"])
1033
+ ])
1034
+ ]),
1035
+ f("div", null, [
1036
+ w(u(B), {
1037
+ render: (fe = (pe = (me = T.status) == null ? void 0 : me.column) == null ? void 0 : pe.columnDef) == null ? void 0 : fe.cell,
1038
+ props: (ge = (J = T.status) == null ? void 0 : J.getContext) == null ? void 0 : ge.call(J)
1039
+ }, null, 8, ["render", "props"])
1040
+ ])
1041
+ ])
1042
+ ];
1043
+ }),
1044
+ _: 2
1045
+ }, 1032, ["row", "onRowClick"])
1046
+ ]),
1047
+ _: 1
1048
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1049
+ ], 2)
1050
+ ]),
1051
+ _: 1
1052
+ }, 8, ["title", "actions"]),
1053
+ (k(), z(Ae, { to: "body" }, [
1054
+ w(_t, Ve(Ie(u(t))), null, 16),
1055
+ w(bt, Re(u(n), {
1056
+ onSubmitted: r[2] || (r[2] = (C) => u(i).fetchTemplates())
1057
+ }), null, 16)
1058
+ ]))
1059
+ ], 64);
1060
+ };
1061
+ }
1062
+ });
1063
+ export {
1064
+ qt as default
1065
+ };