@feedmepos/mf-inventory-portal 0.0.25-dev.9 → 0.0.26-dev.1

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 (116) hide show
  1. package/dist/{App-9zSE_swt.js → App-CipfIdtR.js} +71 -72
  2. package/dist/ApprovalView-IC33yBg7.js +143 -0
  3. package/dist/{BindingsDialog-eGbOIQkw.js → BindingsDialog-EN6Kbnu7.js} +2 -2
  4. package/dist/{BindingsPicker-CVXrd29s.js → BindingsPicker-DQ_LEoqq.js} +3 -3
  5. package/dist/BindingsTable-DGXpAyM4.js +120 -0
  6. package/dist/ClosingDraftView-DR9xsW9I.js +1348 -0
  7. package/dist/ClosingTemplateView-CC1T7ovX.js +1804 -0
  8. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C9un0wCK.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CovzlB-s.js} +43 -43
  9. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BRSABJnM.js → FmUnitInput.vue_vue_type_script_setup_true_lang-BxEtsFXp.js} +29 -29
  10. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DeRvrF7O.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-B8H6vFJ5.js} +1 -1
  11. package/dist/{IngredientGroupView-ZWCOAljO.js → IngredientGroupView-DRPbXH8d.js} +24 -24
  12. package/dist/IngredientsView-DSHcH30X.js +1731 -0
  13. package/dist/{IntegrationView-DO3Ambro.js → IntegrationView-BgACk-jP.js} +605 -669
  14. package/dist/{InventoryBindingForm-BjtFP29c.js → InventoryBindingForm-Fs-CHoT-.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CFMZ4VsK.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DVHQjAEC.js} +63 -63
  16. package/dist/{InventoryBindingSummary-C6DkVX-B.js → InventoryBindingSummary-CHWMtGtk.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-nb1t6u2V.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Cu9V-8Cf.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BcMAXo4F.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CyVRCAqv.js} +12 -12
  19. package/dist/PublishView-CI7o5a0F.js +222 -0
  20. package/dist/{PurchaseOrderPrintPreview-_MCAsdw9.js → PurchaseOrderPrintPreview-CO4a811o.js} +1 -1
  21. package/dist/ReceiveRequestView-KH5wY5BA.js +2562 -0
  22. package/dist/{RecipeView-dmmjklwh.js → RecipeView-DxVbUxOG.js} +47 -47
  23. package/dist/StockView-CiHPAaYh.js +1840 -0
  24. package/dist/{SupplierView-CO5460uC.js → SupplierView-DPj87kld.js} +448 -461
  25. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CfPPCFh8.js +1566 -0
  26. package/dist/TransferTemplateView-3W29v8hd.js +1420 -0
  27. package/dist/{UnitView-DbYzxCXF.js → UnitView-WCtNQFf8.js} +23 -23
  28. package/dist/{WarehouseView-BII4SEVC.js → WarehouseView-tgFFbQY7.js} +40 -40
  29. package/dist/api/bill.d.ts +12 -2
  30. package/dist/api/closing-draft.d.ts +1 -0
  31. package/dist/api/inventory.d.ts +8 -7
  32. package/dist/api/netsuite.d.ts +22 -5
  33. package/dist/api/purchase-order.d.ts +6 -1
  34. package/dist/api/stock.d.ts +1 -0
  35. package/dist/{app-IM1yJnE8.js → app-Ba80HxT3.js} +38448 -34777
  36. package/dist/app.d.ts +965 -120
  37. package/dist/app.js +1 -1
  38. package/dist/components/FmDroppableField.vue.d.ts +1 -1
  39. package/dist/components/FmMultiselectDialog.d.ts +23 -0
  40. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -1
  41. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -1
  42. package/dist/{decimal-DQUpCN-B.js → decimal-DFqusYHB.js} +1 -1
  43. package/dist/{format-unit-display-COuIZISg.js → format-unit-display-Bsod5Ra6.js} +232 -238
  44. package/dist/helper/country.d.ts +1 -0
  45. package/dist/helper/fuzzy.d.ts +1 -1
  46. package/dist/helper/number.d.ts +1 -1
  47. package/dist/index-0ekVGPtB.js +12197 -0
  48. package/dist/index-ZAEVHtfa.js +84 -0
  49. package/dist/{stock-BJUTiXXk.js → stock-Cn6EQvTz.js} +29 -25
  50. package/dist/stores/feature.d.ts +11 -6
  51. package/dist/stores/helper/generate-backend-urls.d.ts +0 -1
  52. package/dist/stores/integration/index.d.ts +2 -0
  53. package/dist/stores/integration/netsuite.d.ts +22 -5
  54. package/dist/stores/inventory.d.ts +141 -8
  55. package/dist/stores/location.d.ts +0 -9
  56. package/dist/stores/stock.d.ts +5 -0
  57. package/dist/stores/warehouse.d.ts +4 -7
  58. package/dist/style.css +1 -1
  59. package/dist/{supplier-CM-qQVyI.js → supplier-P1gi71dg.js} +4 -4
  60. package/dist/tsconfig.app.tsbuildinfo +1 -1
  61. package/dist/{use-ingredient-select-dialog-Cn79xFNg.js → use-ingredient-select-dialog-BW5imbB5.js} +1 -1
  62. package/dist/{use-inventory-binding-dialog-zwOG19YV.js → use-inventory-binding-dialog-BYxb8nXg.js} +1 -1
  63. package/dist/views/adjustment-template/wastage-template/actions.d.ts +0 -24
  64. package/dist/views/adjustment-template/wastage-template/table.d.ts +0 -24
  65. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +92 -8
  66. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +4 -1
  67. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +552 -48
  68. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +1 -1
  69. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -1
  70. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +12 -36
  71. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +12 -36
  72. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +3 -3
  73. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -2
  74. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -1
  75. package/dist/views/receive-request/components/netsuite/NetSuiteProps.d.ts +2 -0
  76. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +4 -1
  77. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +2 -0
  78. package/dist/views/receive-request/components/transfer-form/SparkIcon.vue.d.ts +1 -1
  79. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +529 -489
  80. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +8 -4
  81. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +382 -2
  82. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +5 -2
  83. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +1238 -972
  84. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +1080 -1003
  85. package/dist/views/receive-request/import/XilnexImportDialog.vue.d.ts +22 -0
  86. package/dist/views/receive-request/import/XilnexImportForm.vue.d.ts +17 -0
  87. package/dist/views/receive-request/import/XilnexResult.vue.d.ts +17 -0
  88. package/dist/views/receive-request/import/export.d.ts +14 -0
  89. package/dist/views/receive-request/import/props.d.ts +7 -0
  90. package/dist/views/stock/components/StockRecordCard.vue.d.ts +6 -1
  91. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +6 -4
  92. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +220 -0
  93. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +0 -8
  94. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +0 -1
  95. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +7 -2
  96. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +530 -530
  97. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +530 -530
  98. package/dist/views/transfer-template/composables/useTransferTemplateHelper.d.ts +305 -0
  99. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -14
  100. package/dist/vue-i18n-CjtRsQMl.js +2365 -0
  101. package/package.json +7 -7
  102. package/dist/ApprovalView-C2tg-wsm.js +0 -138
  103. package/dist/BindingsTable-CCsQEFnu.js +0 -145
  104. package/dist/ClosingDraftView-BI8b3CJ9.js +0 -1225
  105. package/dist/ClosingTemplateView-miJnC-ML.js +0 -1859
  106. package/dist/IngredientsView-5-pSX6y_.js +0 -1718
  107. package/dist/PublishView-DOMQdIJ7.js +0 -192
  108. package/dist/ReceiveRequestView-902hWGtz.js +0 -1877
  109. package/dist/StockView-C4lEYLXU.js +0 -7847
  110. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-D6sZDCEY.js +0 -1328
  111. package/dist/TransferTemplateView-C9UwNTnY.js +0 -1371
  112. package/dist/components/FmAutocompleteTextField.vue.d.ts +0 -31
  113. package/dist/feature-DMBVVBsQ.js +0 -1005
  114. package/dist/index-CIrsMt6f.js +0 -35546
  115. package/dist/views/dev/components/AutocompleteTextField.vue.d.ts +0 -2
  116. package/dist/vue-i18n-CzPFJ9JY.js +0 -2365
@@ -1,1718 +0,0 @@
1
- import { ref as j, defineComponent as oe, computed as S, resolveComponent as C, openBlock as f, createBlock as B, withCtx as V, createVNode as p, unref as m, createElementBlock as A, Fragment as Q, createElementVNode as u, createCommentVNode as Y, renderSlot as ce, createTextVNode as Ie, toDisplayString as D, normalizeClass as X, onMounted as ot, watch as Oe, renderList as de, isRef as De, createSlots as qe, normalizeStyle as lt, Teleport as Pe, normalizeProps as at, guardReactiveProps as rt } from "vue";
2
- import { a as le, d as K, e as Ge, S as st, f as it, D as Be, h as fe, A as ge, b as Me, i as We, j as be, t as Ke, k as pe, l as xe, U as dt, m as ut, M as mt, n as Ne, C as ke, o as Le, p as Ze, q as ct, r as Je, s as pt, v as vt, I as ft, w as yt, x as gt, u as bt, y as ht, _ as _t, z as xt, B as kt, E as ze } from "./app-IM1yJnE8.js";
3
- import { useDialog as Qe, useSnackbar as he, useProxiedModel as He, useDialogChild as Vt, useBreakpoints as St } from "@feedmepos/ui-library";
4
- import { i as Ct, _ as wt } from "./is-linked-ingredient-error-fJ2TJb3z.js";
5
- import { useI18n as ae, useCoreStore as ve } from "@feedmepos/mf-common";
6
- import { defineStore as Ft, storeToRefs as It } from "pinia";
7
- import { g as Mt, _ as Ve, S as Se } from "./StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js";
8
- import { _ as $t } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-CFMZ4VsK.js";
9
- import { _ as Ce } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-DeRvrF7O.js";
10
- import { u as Xe } from "./feature-DMBVVBsQ.js";
11
- import { _ as we } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
12
- import { _ as Et } from "./FmCustomAttribute.vue_vue_type_script_setup_true_lang-D-IWRjRD.js";
13
- import "./array-hChJVZLE.js";
14
- const Fe = Ft("ingredientForm", function() {
15
- const o = Qe(), y = he(), s = le(), n = j(!1), { t: l } = ae(), i = j();
16
- function a() {
17
- const b = {
18
- unit: {},
19
- mode: K.CREATE,
20
- show: !0,
21
- "onUpdate:show"(r) {
22
- i.value.show = r;
23
- }
24
- };
25
- i.value = b;
26
- }
27
- async function h(b) {
28
- const r = {
29
- unit: Ge(b),
30
- mode: K.UPDATE,
31
- show: !0,
32
- "onUpdate:show"(_) {
33
- i.value.show = _;
34
- }
35
- };
36
- i.value = r;
37
- }
38
- async function k(b) {
39
- n.value = !0;
40
- try {
41
- await s.deleteSku(b), y.open({
42
- title: "Success",
43
- message: `Deleted ${b.name}`,
44
- type: "success"
45
- });
46
- } catch (r) {
47
- r instanceof st && Ct(r) ? o.open({
48
- title: "Cannot delete ingredient",
49
- contentComponent: wt,
50
- contentComponentProps: {
51
- subject: (b == null ? void 0 : b.name) ?? "",
52
- items: r.errorResponse.message
53
- },
54
- secondaryActions: {
55
- text: "Close",
56
- close: !0
57
- }
58
- }) : console.log("unable to delete ingredient", r), y.open({
59
- title: `Cannot delete ${b.name}`,
60
- message: "Please try again.",
61
- type: "error"
62
- }), console.error("failed to delete ingredient", r);
63
- } finally {
64
- n.value = !1;
65
- }
66
- }
67
- function g(b) {
68
- o.open({
69
- title: l("inventory.ingredient.delete.title", [(b == null ? void 0 : b.name) ?? ""]),
70
- closeButton: !1,
71
- message: l("inventory.ingredient.delete.message"),
72
- primaryActions: {
73
- text: l("common.delete"),
74
- close: !0,
75
- variant: "destructive"
76
- },
77
- secondaryActions: {
78
- text: l("common.cancel"),
79
- close: !0
80
- }
81
- }).onPrimary(() => k(b));
82
- }
83
- return {
84
- createIngredient: a,
85
- updateIngredient: h,
86
- deleteIngredient: g,
87
- ingredientDialogProps: i,
88
- ingredientViewLoading: n
89
- };
90
- });
91
- function Ut() {
92
- const { updateIngredient: d, deleteIngredient: o } = Fe(), { t: y } = ae();
93
- async function s(l, i) {
94
- const a = Ge(i);
95
- if (l === fe.Edit) {
96
- await d(a);
97
- return;
98
- }
99
- if (l === fe.Delete) {
100
- await o(a);
101
- return;
102
- }
103
- }
104
- return { columnDefs: [
105
- {
106
- accessorKey: "code",
107
- header: () => y("inventory.ingredient.code"),
108
- enableSorting: !0,
109
- size: 300
110
- },
111
- {
112
- accessorKey: "name",
113
- header: () => y("inventory.ingredient.name"),
114
- enableSorting: !0,
115
- size: 300
116
- },
117
- {
118
- id: "unit",
119
- header: () => y("inventory.ingredient.unit"),
120
- cell(l) {
121
- var a;
122
- const i = l.row.original;
123
- if (i.trackingMeasurement) {
124
- const h = (a = i.unit.measurements) == null ? void 0 : a.find(
125
- (k) => k.id === i.trackingMeasurement
126
- );
127
- if (h)
128
- return `${h.name} (${h.abbrev})`;
129
- }
130
- return `${i.unit.name} (${i.unit.abbrev})`;
131
- },
132
- enableSorting: !1,
133
- size: "auto"
134
- },
135
- {
136
- id: "action",
137
- header: "",
138
- cell(l) {
139
- return it(
140
- [Be[fe.Edit], Be[fe.Delete]],
141
- (i) => {
142
- s(i, l.row.original);
143
- }
144
- );
145
- },
146
- enableSorting: !1,
147
- size: 40,
148
- meta: {
149
- cellClass: "",
150
- headerClass: ""
151
- }
152
- }
153
- ] };
154
- }
155
- const Rt = /* @__PURE__ */ oe({
156
- __name: "ConvertForm",
157
- props: {
158
- modelValue: {},
159
- rootValue: {},
160
- disabled: { type: Boolean },
161
- readonly: { type: Boolean }
162
- },
163
- emits: ["update:modelValue"],
164
- setup(d, { emit: o }) {
165
- const y = d, s = S(() => {
166
- var r;
167
- return (r = y.rootValue) == null ? void 0 : r.unit;
168
- }), n = S(() => {
169
- var r;
170
- return (r = y.rootValue) == null ? void 0 : r._id;
171
- }), l = o, { t: i } = ae(), a = S({
172
- get() {
173
- return !!y.modelValue;
174
- },
175
- set(r) {
176
- r ? l("update:modelValue", {
177
- measurement: null,
178
- inventoryBindings: []
179
- }) : l("update:modelValue", null);
180
- }
181
- }), h = S(() => Mt(s.value));
182
- function k(r) {
183
- const _ = y.modelValue ?? {};
184
- _.measurement = r ? `${r}` : null, l("update:modelValue", _);
185
- }
186
- function g(r) {
187
- const _ = y.modelValue ?? {};
188
- _.inventoryBindings = r, l("update:modelValue", _);
189
- }
190
- const b = S(() => {
191
- if (!y.modelValue) return null;
192
- const r = y.modelValue;
193
- return r.measurement ? h.value.find((_) => _.value === r.measurement) ?? null : h.value.find((_) => _.value === null) ?? null;
194
- });
195
- return (r, _) => {
196
- const U = C("FmSwitch"), I = C("FmSelect"), N = C("FmCard");
197
- return f(), B(N, {
198
- variant: "outlined",
199
- class: "p-16 flex flex-col gap-16"
200
- }, {
201
- default: V(() => {
202
- var w, v;
203
- return [
204
- p(U, {
205
- value: "",
206
- "model-value": a.value,
207
- "onUpdate:modelValue": _[0] || (_[0] = (R) => a.value = R),
208
- label: m(i)("inventory.ingredient.convertible.title"),
209
- sublabel: m(i)("inventory.ingredient.convertible.subtitle"),
210
- labelPlacement: "right",
211
- disabled: r.readonly
212
- }, null, 8, ["model-value", "label", "sublabel", "disabled"]),
213
- a.value ? (f(), A(Q, { key: 0 }, [
214
- u("div", null, [
215
- p(I, {
216
- label: m(i)("inventory.ingredient.convertible.convertTo"),
217
- modelValue: (w = b.value) == null ? void 0 : w.value,
218
- "onUpdate:modelValue": k,
219
- items: h.value,
220
- disabled: r.readonly
221
- }, null, 8, ["label", "modelValue", "items", "disabled"])
222
- ]),
223
- p($t, {
224
- id: n.value,
225
- "model-value": ((v = r.modelValue) == null ? void 0 : v.inventoryBindings) ?? [],
226
- "onUpdate:modelValue": g,
227
- "exclude-binding-id": n.value,
228
- rules: [m(ge)(1)],
229
- readonly: r.readonly
230
- }, null, 8, ["id", "model-value", "exclude-binding-id", "rules", "readonly"])
231
- ], 64)) : Y("", !0)
232
- ];
233
- }),
234
- _: 1
235
- });
236
- };
237
- }
238
- });
239
- function ie() {
240
- return {
241
- low: 6,
242
- mid: 14
243
- };
244
- }
245
- const Tt = {
246
- key: 0,
247
- class: "flex flex-col gap-4"
248
- }, ye = /* @__PURE__ */ oe({
249
- __name: "FmLockableField",
250
- props: {
251
- locked: { type: Boolean },
252
- disabled: { type: Boolean },
253
- label: {},
254
- helperText: {},
255
- modelValue: {},
256
- tooltipMessage: {},
257
- tooltipPlacement: {},
258
- tooltipZIndex: {}
259
- },
260
- setup(d) {
261
- return (o, y) => {
262
- const s = C("FmLabel"), n = C("FmIcon"), l = C("FmTooltip"), i = C("FmField");
263
- return o.locked ? (f(), A("div", Tt, [
264
- ce(o.$slots, "label", {}, () => [
265
- p(s, {
266
- label: o.label,
267
- disabled: o.disabled
268
- }, null, 8, ["label", "disabled"])
269
- ]),
270
- ce(o.$slots, "field", {}, () => [
271
- p(i, { disabled: o.disabled }, {
272
- prepend: V(() => [
273
- o.tooltipMessage ? (f(), B(l, {
274
- key: 0,
275
- placement: o.tooltipPlacement,
276
- "z-index": o.tooltipZIndex
277
- }, {
278
- content: V(() => [
279
- Ie(D(o.tooltipMessage), 1)
280
- ]),
281
- default: V(() => [
282
- p(n, {
283
- name: "lock",
284
- color: "neutral-gray-400"
285
- })
286
- ]),
287
- _: 1
288
- }, 8, ["placement", "z-index"])) : (f(), B(n, {
289
- key: 1,
290
- name: "lock",
291
- color: "neutral-gray-400"
292
- }))
293
- ]),
294
- default: V(() => [
295
- ce(o.$slots, "modelValue", {}, () => [
296
- u("div", {
297
- class: X([
298
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary",
299
- "line-clamp-1 text-ellipsis break-all"
300
- ])
301
- }, D(o.modelValue), 3)
302
- ])
303
- ]),
304
- _: 3
305
- }, 8, ["disabled"])
306
- ]),
307
- ce(o.$slots, "helper-text", {}, () => [
308
- u("div", {
309
- class: X([
310
- "fm-typo-en-body-sm-400 line-clamp-1",
311
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
312
- ])
313
- }, D(o.helperText), 3)
314
- ])
315
- ])) : ce(o.$slots, "default", { key: 1 });
316
- };
317
- }
318
- }), At = { class: "flex gap-8" }, Dt = { class: "flex-1" }, Pt = { class: "flex-1" }, Bt = { class: "text-fm-color-typo-secondary" }, Nt = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, Lt = {
319
- key: 2,
320
- class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
321
- }, zt = { class: "flex flex-col gap-12" }, Ht = { class: "flex flex-col gap-4" }, Yt = { class: "fm-typo-en-title-sm-600" }, jt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ot = { class: "flex flex-col gap-4" }, qt = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, Gt = { class: "flex-1 p-12 flex flex-col gap-8" }, Wt = { class: "mx-auto" }, Kt = { class: "flex flex-col" }, Zt = { class: "fm-typo-en-body-sm-600 translate-y-4" }, Jt = { class: "flex-1 p-12 flex flex-col gap-8" }, Qt = { class: "mx-auto" }, Xt = { class: "flex flex-col" }, en = { class: "fm-typo-en-body-sm-600 translate-y-4" }, tn = { class: "flex-1 p-12 flex flex-col gap-8" }, nn = { class: "mx-auto" }, on = { class: "flex flex-col" }, ln = { class: "fm-typo-en-body-sm-600 translate-y-4" }, an = /* @__PURE__ */ oe({
322
- __name: "IngredientForm",
323
- props: {
324
- mode: {},
325
- modelValue: {},
326
- disabled: { type: Boolean }
327
- },
328
- emits: ["update:modelValue", "click:submit"],
329
- setup(d, { expose: o, emit: y }) {
330
- var me;
331
- const { t: s } = ae(), n = d, l = y, i = le(), a = ve(), h = Xe(), k = Me(), g = S(() => k.isEnabled);
332
- function b(e) {
333
- if (e.length === 0) return;
334
- const t = e[0], c = n.modelValue ?? {
335
- unit: i.units.find((x) => x)
336
- };
337
- c.unit || (c.unit = t, l("update:modelValue", c));
338
- }
339
- ot(() => {
340
- b(i.units);
341
- }), Oe([() => i.units], ([e]) => {
342
- b(e);
343
- });
344
- function r() {
345
- l("click:submit");
346
- }
347
- const _ = S({
348
- get() {
349
- var e;
350
- return ((e = n.modelValue) == null ? void 0 : e.code) ?? "";
351
- },
352
- set(e) {
353
- const t = n.modelValue ? {
354
- ...n.modelValue
355
- } : {};
356
- t.code = e, l("update:modelValue", t);
357
- }
358
- }), U = S({
359
- get() {
360
- var e;
361
- return ((e = n.modelValue) == null ? void 0 : e.name) ?? "";
362
- },
363
- set(e) {
364
- const t = n.modelValue ? {
365
- ...n.modelValue
366
- } : {};
367
- t.name = e, l("update:modelValue", t);
368
- }
369
- }), I = S({
370
- get() {
371
- var t, c;
372
- const e = (c = (t = n.modelValue) == null ? void 0 : t.defaultCost) == null ? void 0 : c.costPerUnit;
373
- return e ? +We(e) : 0;
374
- },
375
- set(e) {
376
- var c, x, E, F;
377
- const t = n.modelValue ? {
378
- ...n.modelValue
379
- } : {};
380
- t.defaultCost ?? (t.defaultCost = {
381
- costPerUnit: {
382
- amount: 0,
383
- precision: 2,
384
- currency: ((c = be(a.currentCountry.value)) == null ? void 0 : c.currency) ?? "MYR"
385
- },
386
- measurement: (F = (E = (x = n.modelValue) == null ? void 0 : x.unit) == null ? void 0 : E.measurements) == null ? void 0 : F.find(
387
- (G) => {
388
- var H;
389
- return G.id === ((H = n.modelValue) == null ? void 0 : H.trackingMeasurement);
390
- }
391
- )
392
- }), t.defaultCost.costPerUnit = {
393
- ...t.defaultCost.costPerUnit,
394
- ...Ke(+e, 4)
395
- }, l("update:modelValue", t);
396
- }
397
- }), N = S(() => {
398
- var t, c, x;
399
- const e = ((t = n.modelValue) == null ? void 0 : t.unit) ?? i.units.find((E) => E);
400
- return e ? {
401
- _id: e._id,
402
- measurement: (c = n.modelValue) == null ? void 0 : c.trackingMeasurement,
403
- name: ((x = e.measurements.find((E) => {
404
- var F;
405
- return E.id === ((F = n.modelValue) == null ? void 0 : F.trackingMeasurement);
406
- })) == null ? void 0 : x.name) ?? e.name
407
- } : null;
408
- }), w = S(
409
- () => i.units.flatMap(({ name: e, _id: t, abbrev: c, measurements: x }) => [
410
- {
411
- label: `${e}`,
412
- value: null,
413
- displayAsSection: !0
414
- },
415
- {
416
- label: `${e} (${c})`,
417
- value: { _id: t },
418
- displayAsSection: !1
419
- },
420
- ...x.map(({ id: E, name: F, abbrev: G }) => ({
421
- label: `${F} (${G})`,
422
- value: { _id: t, measurement: E },
423
- displayAsSection: !1
424
- }))
425
- ])
426
- );
427
- function v(e) {
428
- var t, c, x, E, F;
429
- return ((c = (t = n.modelValue) == null ? void 0 : t.unit) == null ? void 0 : c._id) === ((x = e.value) == null ? void 0 : x._id) && ((E = n.modelValue) == null ? void 0 : E.trackingMeasurement) === ((F = e.value) == null ? void 0 : F.measurement);
430
- }
431
- function R(e) {
432
- var G, H;
433
- if (!e) return;
434
- const { _id: t, measurement: c } = e, x = c || void 0, E = i.units.find((te) => te._id === t);
435
- if (!E)
436
- return;
437
- const F = n.modelValue ?? {};
438
- F.unit = E, F.trackingMeasurement = x, F.convert && (F.convert.measurement = x || null), h.enableTotalCost && (F.defaultCost = {
439
- measurement: E.measurements.find((te) => te.id === x),
440
- costPerUnit: {
441
- ...((G = F.defaultCost) == null ? void 0 : G.costPerUnit) ?? {
442
- amount: 0,
443
- precision: 2,
444
- currency: ((H = be(a.currentCountry.value)) == null ? void 0 : H.currency) ?? "MYR"
445
- }
446
- }
447
- }), l("update:modelValue", F);
448
- }
449
- const J = S({
450
- get() {
451
- var e;
452
- return ((e = n.modelValue) == null ? void 0 : e.convert) ?? null;
453
- },
454
- set(e) {
455
- const t = n.modelValue ? {
456
- ...n.modelValue
457
- } : {};
458
- e ? t.convert = e : t.convert = null, l("update:modelValue", t);
459
- }
460
- });
461
- S(() => pe.options.filter(
462
- (e) => e === pe.enum.FIFO || e === pe.enum.WAVG
463
- ).map((e) => ({
464
- label: s(`inventory.ingredient.valuationMethod.${e}`),
465
- value: e
466
- }))), S({
467
- get() {
468
- var e;
469
- return ((e = n.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
470
- },
471
- set(e) {
472
- const t = n.modelValue ? {
473
- ...n.modelValue
474
- } : {};
475
- t.valuation = e, l("update:modelValue", t);
476
- }
477
- });
478
- const Z = S({
479
- get() {
480
- var e;
481
- return ((e = n.modelValue) == null ? void 0 : e.customAttributes) ?? {};
482
- },
483
- set(e) {
484
- const t = n.modelValue ? {
485
- ...n.modelValue
486
- } : {};
487
- t.customAttributes = e, l("update:modelValue", t);
488
- }
489
- }), L = j();
490
- o({
491
- validateInputs: () => {
492
- var e, t;
493
- (t = (e = L.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
494
- },
495
- resetInputsValidation: () => {
496
- var e, t;
497
- (t = (e = L.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
498
- },
499
- resetInputs: () => {
500
- var e, t;
501
- (t = (e = L.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
502
- }
503
- });
504
- const z = j(!1), q = S(
505
- () => {
506
- var e, t, c;
507
- return (e = n.modelValue) != null && e._id ? ((c = i.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : c.filter(
508
- (x) => x.from === "INGREDIENT"
509
- )) ?? [] : [];
510
- }
511
- ), ne = S(
512
- () => {
513
- var e, t, c;
514
- return (e = n.modelValue) != null && e._id ? ((c = i.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : c.filter(
515
- (x) => x.from === "RECIPE"
516
- )) ?? [] : [];
517
- }
518
- ), ue = S(
519
- () => {
520
- var e, t, c;
521
- return (e = n.modelValue) != null && e._id ? ((c = i.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : c.filter((x) => x.from === "MENU")) ?? [] : [];
522
- }
523
- ), _e = S(
524
- () => i.skus.map((e) => ({ label: e.name, value: e.code }))
525
- ), P = j((me = n.modelValue) == null ? void 0 : me.code);
526
- function $(e) {
527
- var c;
528
- const t = e.el;
529
- t && ((c = t.querySelector("[x-should-scroll-into=true]")) == null || c.scrollIntoView());
530
- }
531
- function re(e) {
532
- switch (e) {
533
- case ke.MY:
534
- return "MYR";
535
- case ke.SG:
536
- return "SGD";
537
- case ke.ID:
538
- return "IDR";
539
- default:
540
- return "MYR";
541
- }
542
- }
543
- const se = S(
544
- () => {
545
- var e, t, c, x, E, F;
546
- return ((x = (c = (t = (e = n.modelValue) == null ? void 0 : e.unit) == null ? void 0 : t.measurements) == null ? void 0 : c.find(
547
- (G) => {
548
- var H;
549
- return G.id === ((H = n.modelValue) == null ? void 0 : H.trackingMeasurement);
550
- }
551
- )) == null ? void 0 : x.abbrev) ?? ((F = (E = n.modelValue) == null ? void 0 : E.unit) == null ? void 0 : F.abbrev);
552
- }
553
- ), ee = S({
554
- get() {
555
- var e, t;
556
- return ((t = (e = n.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.low) ?? ie().low;
557
- },
558
- set(e) {
559
- var x;
560
- const t = ((x = n.modelValue) == null ? void 0 : x.thresholds) ?? ie();
561
- t.low = e;
562
- const c = n.modelValue ? {
563
- ...n.modelValue
564
- } : {};
565
- c.thresholds = t, l("update:modelValue", c);
566
- }
567
- }), T = S({
568
- get() {
569
- var e, t;
570
- return ((t = (e = n.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.mid) ?? ie().mid;
571
- },
572
- set(e) {
573
- var x;
574
- const t = ((x = n.modelValue) == null ? void 0 : x.thresholds) ?? ie();
575
- t.mid = e;
576
- const c = n.modelValue ? {
577
- ...n.modelValue
578
- } : {};
579
- c.thresholds = t, l("update:modelValue", c);
580
- }
581
- });
582
- function O() {
583
- return function(t) {
584
- return typeof (t == null ? void 0 : t.low) != "number" || typeof (t == null ? void 0 : t.mid) != "number" ? "Required" : t.low >= t.mid ? "Days for red indicator should be less than yellow indicator." : !0;
585
- };
586
- }
587
- return (e, t) => {
588
- const c = C("FmTextField"), x = C("FmLabel"), E = C("FmField"), F = C("FmMenuHeader"), G = C("FmMenuDivider"), H = C("FmMenuItem"), te = C("FmMenu"), $e = C("FmFormGroup"), tt = C("FmSwitch"), Ee = C("FmStepperField"), nt = C("FmForm");
589
- return f(), B(nt, {
590
- disabled: e.disabled,
591
- ref_key: "formRef",
592
- ref: L,
593
- class: "flex flex-col gap-32",
594
- onValidationSuccess: r
595
- }, {
596
- default: V(() => {
597
- var Ue, Re, Te, Ae;
598
- return [
599
- u("div", At, [
600
- u("div", Dt, [
601
- p(ye, {
602
- "tooltip-message": "This field is managed by NetSuite",
603
- "tooltip-z-index": 50,
604
- label: m(s)("inventory.ingredient.code"),
605
- "model-value": _.value,
606
- "onUpdate:modelValue": t[1] || (t[1] = (M) => _.value = M),
607
- locked: g.value,
608
- disabled: e.disabled
609
- }, {
610
- default: V(() => [
611
- p(c, {
612
- label: m(s)("inventory.ingredient.code"),
613
- "model-value": _.value,
614
- "onUpdate:modelValue": t[0] || (t[0] = (M) => _.value = M),
615
- rules: [m(xe)(), m(dt)(_e.value, P.value)],
616
- "label-mark": "required"
617
- }, null, 8, ["label", "model-value", "rules"])
618
- ]),
619
- _: 1
620
- }, 8, ["label", "model-value", "locked", "disabled"])
621
- ]),
622
- u("div", Pt, [
623
- p(ye, {
624
- "tooltip-message": "This field is managed by NetSuite",
625
- "tooltip-z-index": 50,
626
- label: m(s)("inventory.ingredient.name"),
627
- "model-value": U.value,
628
- "onUpdate:modelValue": t[3] || (t[3] = (M) => U.value = M),
629
- locked: g.value,
630
- disabled: e.disabled
631
- }, {
632
- default: V(() => [
633
- p(c, {
634
- label: m(s)("inventory.ingredient.name"),
635
- "model-value": U.value,
636
- "onUpdate:modelValue": t[2] || (t[2] = (M) => U.value = M),
637
- rules: [m(xe)()],
638
- "label-mark": "required"
639
- }, null, 8, ["label", "model-value", "rules"])
640
- ]),
641
- _: 1
642
- }, 8, ["label", "model-value", "locked", "disabled"])
643
- ])
644
- ]),
645
- p(ye, {
646
- "tooltip-message": "This field is managed by NetSuite",
647
- "tooltip-z-index": 50,
648
- label: m(s)("inventory.ingredient.unit"),
649
- "helper-text": (Ue = e.modelValue) != null && Ue.trackingMeasurement ? `Base unit: ${(Te = (Re = e.modelValue) == null ? void 0 : Re.unit) == null ? void 0 : Te.name}` : void 0,
650
- "model-value": (Ae = N.value) == null ? void 0 : Ae.name,
651
- locked: g.value,
652
- disabled: e.disabled
653
- }, {
654
- default: V(() => [
655
- p($e, {
656
- "model-value": N.value,
657
- rules: [m(xe)()],
658
- "label-mark": "required"
659
- }, {
660
- label: V(() => [
661
- p(x, {
662
- label: m(s)("inventory.ingredient.unit")
663
- }, null, 8, ["label"])
664
- ]),
665
- default: V(({ invalid: M }) => [
666
- p(te, null, {
667
- "menu-button": V(() => [
668
- p(E, {
669
- class: X([
670
- "fm-typo-en-body-lg-400",
671
- {
672
- "text-fm-color-typo-primary": !e.disabled,
673
- "text-fm-color-typo-disabled": e.disabled
674
- }
675
- ]),
676
- invalid: M,
677
- "append-icon": "expand_more"
678
- }, {
679
- default: V(() => {
680
- var W;
681
- return [
682
- Ie(D((W = N.value) == null ? void 0 : W.name), 1)
683
- ];
684
- }),
685
- _: 2
686
- }, 1032, ["class", "invalid"])
687
- ]),
688
- default: V(() => [
689
- u("div", {
690
- class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
691
- onVnodeMounted: $
692
- }, [
693
- (f(!0), A(Q, null, de(w.value, (W) => (f(), A(Q, {
694
- key: W.label
695
- }, [
696
- W.displayAsSection ? (f(), A(Q, { key: 0 }, [
697
- p(F, {
698
- label: W.label
699
- }, null, 8, ["label"]),
700
- p(G)
701
- ], 64)) : (f(), B(H, {
702
- key: 1,
703
- label: W.label,
704
- "model-value": v(W),
705
- onClick: (zn) => R(W.value),
706
- "x-should-scroll-into": `${v(W)}`
707
- }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
708
- ], 64))), 128))
709
- ], 512)
710
- ]),
711
- _: 2
712
- }, 1024)
713
- ]),
714
- _: 1
715
- }, 8, ["model-value", "rules"])
716
- ]),
717
- _: 1
718
- }, 8, ["label", "helper-text", "model-value", "locked", "disabled"]),
719
- m(h).enableTotalCost ? (f(), B(ye, {
720
- key: 0,
721
- "tooltip-message": "This field is managed by NetSuite",
722
- "tooltip-z-index": 50,
723
- "model-value": `${m(ut)()} ${I.value}`,
724
- locked: g.value,
725
- disabled: e.disabled
726
- }, {
727
- label: V(() => [
728
- p(we, { "z-index": 50 }, {
729
- default: V(() => [
730
- p(x, {
731
- label: m(s)("inventory.ingredient.pricePerUnit")
732
- }, null, 8, ["label"])
733
- ]),
734
- _: 1
735
- })
736
- ]),
737
- default: V(() => [
738
- m(h).enableTotalCost ? (f(), B(c, {
739
- key: 0,
740
- "model-value": I.value,
741
- "onUpdate:modelValue": t[4] || (t[4] = (M) => I.value = M),
742
- rules: [m(ge)(0), m(mt)(4)]
743
- }, {
744
- label: V(() => [
745
- p(we, { "z-index": 50 }, {
746
- default: V(() => [
747
- p(x, {
748
- label: m(s)("inventory.ingredient.pricePerUnit")
749
- }, null, 8, ["label"])
750
- ]),
751
- _: 1
752
- })
753
- ]),
754
- prepend: V(() => {
755
- var M, W;
756
- return [
757
- u("div", Bt, D(re(((M = m(a).currentCountry) == null ? void 0 : M.value) ?? m(Ne)) === "MYR" ? "RM" : re(((W = m(a).currentCountry) == null ? void 0 : W.value) ?? m(Ne))), 1)
758
- ];
759
- }),
760
- append: V(() => [
761
- u("div", Nt, " / " + D(se.value), 1)
762
- ]),
763
- _: 1
764
- }, 8, ["model-value", "rules"])) : Y("", !0)
765
- ]),
766
- _: 1
767
- }, 8, ["model-value", "locked", "disabled"])) : Y("", !0),
768
- !g.value || J.value ? (f(), B(Rt, {
769
- key: 1,
770
- "model-value": J.value,
771
- "onUpdate:modelValue": t[5] || (t[5] = (M) => J.value = M),
772
- "root-value": e.modelValue,
773
- readonly: g.value
774
- }, null, 8, ["model-value", "root-value", "readonly"])) : Y("", !0),
775
- e.mode !== m(K).CREATE ? (f(), A("div", Lt, [
776
- u("div", null, [
777
- p(tt, {
778
- label: m(s)("inventory.ingredient.bindedItems.title"),
779
- modelValue: z.value,
780
- "onUpdate:modelValue": t[6] || (t[6] = (M) => z.value = M),
781
- "label-placement": "right"
782
- }, null, 8, ["label", "modelValue"])
783
- ]),
784
- z.value && q.value.length ? (f(), B(Ce, {
785
- key: 0,
786
- name: m(s)("inventory.ingredient.bindedItems.ingredient"),
787
- bindings: q.value
788
- }, null, 8, ["name", "bindings"])) : Y("", !0),
789
- z.value && ne.value.length ? (f(), B(Ce, {
790
- key: 1,
791
- name: m(s)("inventory.ingredient.bindedItems.recipe"),
792
- bindings: ne.value
793
- }, null, 8, ["name", "bindings"])) : Y("", !0),
794
- z.value && ue.value.length ? (f(), B(Ce, {
795
- key: 2,
796
- name: m(s)("inventory.ingredient.bindedItems.menu"),
797
- bindings: ue.value
798
- }, null, 8, ["name", "bindings"])) : Y("", !0)
799
- ])) : Y("", !0),
800
- u("div", zt, [
801
- u("div", Ht, [
802
- p(we, null, {
803
- default: V(() => [
804
- u("div", Yt, D(m(s)("inventory.ingredient.threshold.title")), 1)
805
- ]),
806
- _: 1
807
- }),
808
- u("div", jt, D(m(s)("inventory.ingredient.threshold.subtitle")), 1)
809
- ]),
810
- u("div", Ot, [
811
- p($e, {
812
- "model-value": { low: ee.value, mid: T.value },
813
- rules: [O()]
814
- }, null, 8, ["model-value", "rules"]),
815
- u("div", qt, [
816
- u("div", Gt, [
817
- u("div", Wt, [
818
- p(Ve, {
819
- days: ee.value,
820
- level: m(Se).low
821
- }, null, 8, ["days", "level"])
822
- ]),
823
- u("div", Kt, [
824
- u("div", Zt, D(m(s)("inventory.ingredient.threshold.whenRemaining")), 1),
825
- p(Ee, {
826
- modelValue: ee.value,
827
- "onUpdate:modelValue": t[7] || (t[7] = (M) => ee.value = M),
828
- rules: [m(ge)(0)]
829
- }, {
830
- append: V(() => t[10] || (t[10] = [
831
- u("div", {
832
- class: "text-fm-color-typo-secondary",
833
- style: { "padding-right": "32px" }
834
- }, "days", -1)
835
- ])),
836
- _: 1
837
- }, 8, ["modelValue", "rules"])
838
- ])
839
- ]),
840
- t[12] || (t[12] = u("div", {
841
- class: "h-full bg-fm-color-neutral-gray-200 relative",
842
- style: { width: "1px" }
843
- }, [
844
- u("div", {
845
- class: "absolute bg-white",
846
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
847
- }, " < ")
848
- ], -1)),
849
- u("div", Jt, [
850
- u("div", Qt, [
851
- p(Ve, {
852
- days: T.value,
853
- level: m(Se).mid
854
- }, null, 8, ["days", "level"])
855
- ]),
856
- u("div", Xt, [
857
- u("div", en, D(m(s)("inventory.ingredient.threshold.whenRemaining")), 1),
858
- p(Ee, {
859
- modelValue: T.value,
860
- "onUpdate:modelValue": t[8] || (t[8] = (M) => T.value = M),
861
- rules: [m(ge)(0)]
862
- }, {
863
- append: V(() => t[11] || (t[11] = [
864
- u("div", {
865
- class: "text-fm-color-typo-secondary",
866
- style: { "padding-right": "32px" }
867
- }, "days", -1)
868
- ])),
869
- _: 1
870
- }, 8, ["modelValue", "rules"])
871
- ])
872
- ]),
873
- t[13] || (t[13] = u("div", {
874
- class: "h-full bg-fm-color-neutral-gray-200 relative",
875
- style: { width: "1px" }
876
- }, [
877
- u("div", {
878
- class: "absolute bg-white",
879
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
880
- }, " < ")
881
- ], -1)),
882
- u("div", tn, [
883
- u("div", nn, [
884
- p(Ve, {
885
- days: T.value + 1,
886
- level: m(Se).high
887
- }, null, 8, ["days", "level"])
888
- ]),
889
- u("div", on, [
890
- u("div", ln, D(m(s)("inventory.ingredient.threshold.stockIsStaple")), 1)
891
- ])
892
- ])
893
- ])
894
- ])
895
- ]),
896
- u("div", null, [
897
- p(Et, {
898
- entity: "inventorySku",
899
- modelValue: Z.value,
900
- "onUpdate:modelValue": t[9] || (t[9] = (M) => Z.value = M)
901
- }, null, 8, ["modelValue"])
902
- ])
903
- ];
904
- }),
905
- _: 1
906
- }, 8, ["disabled"]);
907
- };
908
- }
909
- }), rn = { class: "flex flex-col gap-32" }, sn = {
910
- key: 0,
911
- class: "flex flex-col gap-12"
912
- }, dn = { class: "flex flex-col gap-4" }, un = { class: "flex-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, mn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, cn = { class: "flex gap-4" }, pn = /* @__PURE__ */ oe({
913
- __name: "IngredientDialog",
914
- props: {
915
- show: { type: Boolean },
916
- unit: {},
917
- mode: { default: K.READ }
918
- },
919
- emits: ["update:show"],
920
- setup(d) {
921
- const o = d, y = le(), s = Me(), n = he(), { t: l } = ae(), i = He(o, "show"), a = He(o, "unit"), h = S(
922
- () => {
923
- var v;
924
- return s.isEnabled && s.netSuiteItemBySkuId.has((v = o.unit) == null ? void 0 : v._id);
925
- }
926
- ), k = S(() => {
927
- switch (o.mode) {
928
- case K.READ:
929
- return "";
930
- case K.UPDATE:
931
- return l("inventory.ingredient.update.title");
932
- case K.CREATE:
933
- return l("inventory.ingredient.create.title");
934
- }
935
- return "";
936
- }), g = S(() => {
937
- switch (o.mode) {
938
- case K.READ:
939
- return "";
940
- case K.UPDATE:
941
- return l("common.save");
942
- case K.CREATE:
943
- return l("common.add");
944
- }
945
- return "";
946
- }), b = j(), r = j(!1);
947
- async function _() {
948
- r.value = !0;
949
- try {
950
- await y.createSku(a.value), i.value = !1, n.open({
951
- title: l("inventory.common.success"),
952
- message: l("inventory.ingredient.create.success", { name: a.value.name }),
953
- type: "success"
954
- });
955
- } catch (v) {
956
- v instanceof Le || n.open({
957
- title: l("inventory.ingredient.create.error.title"),
958
- message: l("inventory.ingredient.create.error.message"),
959
- type: "error"
960
- });
961
- } finally {
962
- r.value = !1;
963
- }
964
- }
965
- async function U() {
966
- r.value = !0;
967
- try {
968
- await y.updateSku(a.value), r.value = !1, i.value = !1, n.open({
969
- title: l("inventory.common.success"),
970
- message: l("inventory.ingredient.update.success", { name: a.value.name }),
971
- type: "success"
972
- });
973
- } catch (v) {
974
- v instanceof Le || n.open({
975
- title: l("inventory.ingredient.update.error.title"),
976
- message: l("inventory.ingredient.update.error.message"),
977
- type: "error"
978
- });
979
- } finally {
980
- r.value = !1;
981
- }
982
- }
983
- function I() {
984
- var v, R;
985
- (R = (v = b.value) == null ? void 0 : v.validateInputs) == null || R.call(v);
986
- }
987
- function N() {
988
- switch (o.mode) {
989
- case K.READ:
990
- return;
991
- case K.UPDATE:
992
- return U();
993
- case K.CREATE:
994
- return _();
995
- }
996
- }
997
- const w = S(() => {
998
- var J, Z;
999
- if (!s.isEnabled || !((J = o.unit) != null && J._id)) return null;
1000
- const v = (Z = s.netSuiteItemBySkuId.get(o.unit._id)) == null ? void 0 : Z[0];
1001
- return v ? s.state.setting.childItems.filter(
1002
- (L) => L.parentNetSuiteId === v.netSuiteId
1003
- ).map((L) => {
1004
- var q;
1005
- const z = (q = s.measurementByNetsuiteId.get(L.unitOfMeasureId)) == null ? void 0 : q[0];
1006
- return z ? {
1007
- externalId: L.externalId,
1008
- ...z
1009
- } : null;
1010
- }).filter((L) => L).map((L) => L) : null;
1011
- });
1012
- return (v, R) => {
1013
- const J = C("FmChip"), Z = C("FmButton"), L = C("FmSideSheet");
1014
- return f(), B(L, {
1015
- "model-value": m(i),
1016
- "onUpdate:modelValue": R[3] || (R[3] = (z) => De(i) ? i.value = z : null),
1017
- header: k.value,
1018
- "close-button": "",
1019
- "dismiss-away": "",
1020
- "max-width": 500
1021
- }, {
1022
- "side-sheet-footer": V(() => [
1023
- u("div", cn, [
1024
- p(Z, {
1025
- loading: r.value,
1026
- label: g.value,
1027
- onClick: I
1028
- }, null, 8, ["loading", "label"]),
1029
- p(Z, {
1030
- disabled: r.value,
1031
- label: m(l)("common.close"),
1032
- variant: "tertiary",
1033
- onClick: R[2] || (R[2] = (z) => i.value = !1)
1034
- }, null, 8, ["disabled", "label"])
1035
- ])
1036
- ]),
1037
- default: V(() => {
1038
- var z;
1039
- return [
1040
- u("div", rn, [
1041
- u("div", null, [
1042
- h.value ? (f(), B(J, {
1043
- key: 0,
1044
- label: "Netsuite",
1045
- compact: ""
1046
- })) : Y("", !0)
1047
- ]),
1048
- p(an, {
1049
- class: "w-full",
1050
- ref_key: "hasValidationExpose",
1051
- ref: b,
1052
- modelValue: m(a),
1053
- "onUpdate:modelValue": R[0] || (R[0] = (q) => De(a) ? a.value = q : null),
1054
- mode: v.mode,
1055
- disabled: r.value,
1056
- "onClick:submit": R[1] || (R[1] = (q) => N())
1057
- }, null, 8, ["modelValue", "mode", "disabled"]),
1058
- (z = w.value) != null && z.length ? (f(), A("div", sn, [
1059
- R[4] || (R[4] = u("div", { class: "fm-typo-en-title-sm-600" }, D("NetSuite info"), -1)),
1060
- u("div", dn, [
1061
- (f(!0), A(Q, null, de(w.value, (q, ne) => (f(), A("div", {
1062
- key: ne,
1063
- class: "flex items-center"
1064
- }, [
1065
- u("div", un, D(q.externalId), 1),
1066
- u("div", mn, D(q.abbrev), 1)
1067
- ]))), 128))
1068
- ])
1069
- ])) : Y("", !0)
1070
- ])
1071
- ];
1072
- }),
1073
- _: 1
1074
- }, 8, ["model-value", "header"]);
1075
- };
1076
- }
1077
- });
1078
- function* vn(d) {
1079
- for (; ; )
1080
- yield d[Math.floor(Math.random() * d.length)];
1081
- }
1082
- function fn(d = 4, o = vn("qwertyuiopasdfghjklzxcvbnm".split(""))) {
1083
- return Array.from({ length: d }).map(() => o.next().value).join("");
1084
- }
1085
- function yn() {
1086
- return `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${fn()}`;
1087
- }
1088
- const gn = {
1089
- _id: "",
1090
- name: "",
1091
- abbrev: "",
1092
- precision: 0,
1093
- measurements: []
1094
- };
1095
- function bn(d) {
1096
- var y, s, n, l, i;
1097
- return {
1098
- code: d.code,
1099
- name: d.name,
1100
- unit: ((y = d.unit.measurements.find((a) => a.id === d.trackingMeasurement)) == null ? void 0 : y.abbrev) ?? d.unit.abbrev,
1101
- baseUnit: d.unit.abbrev,
1102
- valuationMethod: d.valuation ?? "WAVG",
1103
- pricePerUnit: (s = d.defaultCost) != null && s.costPerUnit ? +We((n = d.defaultCost) == null ? void 0 : n.costPerUnit) : 0,
1104
- thresholdLow: ((l = d.thresholds) == null ? void 0 : l.low) ?? ie().low,
1105
- thresholdMid: ((i = d.thresholds) == null ? void 0 : i.mid) ?? ie().mid
1106
- };
1107
- }
1108
- function et() {
1109
- var n;
1110
- const d = [
1111
- {
1112
- id: "code",
1113
- name: "Code"
1114
- },
1115
- {
1116
- id: "name",
1117
- name: "Name"
1118
- },
1119
- {
1120
- id: "unit",
1121
- name: "Unit"
1122
- },
1123
- {
1124
- id: "baseUnit",
1125
- name: "Base unit"
1126
- }
1127
- ], o = Xe(), y = ve(), s = be(y.currentCountry.value);
1128
- return o.enableTotalCost && d.push(
1129
- {
1130
- id: "valuationMethod",
1131
- name: "Valuation method"
1132
- },
1133
- {
1134
- id: "pricePerUnit",
1135
- name: `Price per unit (${s == null ? void 0 : s.currency})`
1136
- }
1137
- ), ((n = y.currentBusiness.value) == null ? void 0 : n.menuVersion) === "v4" && d.push(
1138
- {
1139
- id: "thresholdLow",
1140
- name: "Show RED when remaining"
1141
- },
1142
- {
1143
- id: "thresholdMid",
1144
- name: "Show YELLOW when remaining"
1145
- }
1146
- ), d;
1147
- }
1148
- function hn() {
1149
- const o = le().skus.map(bn), s = ve().currentBusiness.value, n = et(), l = [
1150
- ["Business name:", s == null ? void 0 : s.name],
1151
- ["Business ID:", s == null ? void 0 : s._id],
1152
- ["Menu version", s == null ? void 0 : s.menuVersion],
1153
- [],
1154
- n.map((k) => k.name),
1155
- ...o.map((k) => n.map((g) => k[g.id]))
1156
- ], i = n.map((k) => `system:${k.id}`), a = Ze(l, i), h = `${s == null ? void 0 : s.name} ingredients (${ct(/* @__PURE__ */ new Date())}).xlsx`;
1157
- return Je(a, h), h;
1158
- }
1159
- function _n() {
1160
- const o = ve().currentBusiness.value, y = et(), s = [
1161
- ["Business name:", o == null ? void 0 : o.name],
1162
- ["Business ID:", o == null ? void 0 : o._id],
1163
- ["Menu version", o == null ? void 0 : o.menuVersion],
1164
- [],
1165
- y.map((a) => a.name)
1166
- ], n = y.map((a) => `system:${a.id}`), l = Ze(s, n), i = "FeedMe ingredients template.xlsx";
1167
- return Je(l, i), i;
1168
- }
1169
- function xn(d) {
1170
- const [
1171
- o,
1172
- y,
1173
- s,
1174
- n,
1175
- l,
1176
- i,
1177
- ...a
1178
- ] = vt(d);
1179
- if (!o || !o.length || o.some((r) => r.length && !r.startsWith("system:")))
1180
- throw new Error("Missing meta header. Excel file does not come from the template.");
1181
- const h = o.map((r) => r.split(":")[1]), g = ["code", "name", "unit", "baseUnit"].filter((r) => !h.includes(r));
1182
- if (g.length)
1183
- throw new Error(
1184
- `Missing meta headers (${g.join()}). Excel file does not come from the template.`
1185
- );
1186
- return a.map((r, _) => {
1187
- const U = {};
1188
- for (const I in h) {
1189
- const N = h[I];
1190
- Object.assign(U, { [N]: r[I] });
1191
- }
1192
- return {
1193
- index: _,
1194
- data: U
1195
- };
1196
- });
1197
- }
1198
- function Ye(d, o, y) {
1199
- var w;
1200
- const n = le().units, l = new Array(), i = y.filter((v) => v.data.code === d.code);
1201
- i.length > 1 && l.push(
1202
- `Code ${d.code} is already used in row ${i.map((v) => v.index + 6).join()}.`
1203
- );
1204
- const a = n.find((v) => v.abbrev === d.baseUnit), h = a == null ? void 0 : a.measurements.find((v) => v.abbrev === d.unit);
1205
- if (!a)
1206
- l.push(`Cannot find base unit of symbol ${d.baseUnit}.`);
1207
- else if (d.baseUnit !== d.unit && !h) {
1208
- const v = `Cannot find unit conversion for ${d.baseUnit} with symbol ${d.unit || "[empty]"}.`;
1209
- l.push(v);
1210
- }
1211
- const k = pe.options.find(
1212
- (v) => v === d.valuationMethod
1213
- );
1214
- d.valuationMethod && !k && l.push(
1215
- `Expected valuation method to be one of ${pe.options.join()} but got ${d.valuationMethod} instead.`
1216
- );
1217
- const b = ve().currentCountry.value, r = (v) => `${v}`.length && ft()(v) === !0, _ = r(`${d.pricePerUnit}`) === !0 ? {
1218
- costPerUnit: {
1219
- ...Ke(Number(d.pricePerUnit) || 0),
1220
- currency: ((w = be(b)) == null ? void 0 : w.currency) ?? "MYR"
1221
- },
1222
- measurement: h
1223
- } : void 0, U = r(`${d.thresholdLow}`) && r(`${d.thresholdMid}`) ? {
1224
- low: Number(d.thresholdLow) || 0,
1225
- mid: Number(d.thresholdMid) || 0
1226
- } : void 0;
1227
- return {
1228
- type: "create",
1229
- sku: {
1230
- _id: yn(),
1231
- code: d.code,
1232
- name: d.name,
1233
- unit: a ?? n.find((v) => v) ?? gn,
1234
- trackingMeasurement: h == null ? void 0 : h.id,
1235
- valuation: k,
1236
- defaultCost: _,
1237
- thresholds: U
1238
- },
1239
- errors: l,
1240
- excelRowNumber: o + 6
1241
- };
1242
- }
1243
- function kn(d) {
1244
- try {
1245
- const o = xn(d).filter((k) => k.data.code), s = le().skus, n = pt(s, "code"), l = o.filter((k) => !n[k.data.code]), i = o.filter((k) => n[k.data.code]), a = l.map(
1246
- (k) => Ye(k.data, k.index, o)
1247
- ), h = i.map((k) => {
1248
- const g = Ye(k.data, k.index, o), b = n[k.data.code];
1249
- return {
1250
- ...g,
1251
- type: "update",
1252
- original: b,
1253
- sku: {
1254
- // to maintain original props not in the import excel, e.g. inventory binding, etc...
1255
- ...b,
1256
- code: g.sku.code || b.code,
1257
- name: g.sku.name || b.name,
1258
- unit: g.sku.unit || b.unit,
1259
- trackingMeasurement: g.sku.trackingMeasurement || b.trackingMeasurement,
1260
- valuation: g.sku.valuation || b.valuation,
1261
- defaultCost: g.sku.defaultCost || b.defaultCost,
1262
- thresholds: g.sku.thresholds || b.thresholds
1263
- }
1264
- };
1265
- });
1266
- return {
1267
- invalidExcel: !1,
1268
- importCreateResult: a,
1269
- importUpdateResult: h
1270
- };
1271
- } catch (o) {
1272
- return {
1273
- invalidExcel: !0,
1274
- invalidExcelMessage: (o == null ? void 0 : o.message) ?? "Invalid excel",
1275
- importCreateResult: [],
1276
- importUpdateResult: []
1277
- };
1278
- }
1279
- }
1280
- const Vn = { class: "flex items-center gap-12 pl-8" }, Sn = { class: "flex flex-col" }, Cn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, wn = {
1281
- key: 0,
1282
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1283
- }, Fn = { key: 0 }, je = /* @__PURE__ */ oe({
1284
- __name: "ImportIngredientItem",
1285
- props: {
1286
- type: {},
1287
- code: {},
1288
- name: {},
1289
- errors: {}
1290
- },
1291
- setup(d) {
1292
- return (o, y) => {
1293
- const s = C("FmIcon"), n = C("FmTooltip");
1294
- return f(), A("div", Vn, [
1295
- y[0] || (y[0] = u("div", null, "•", -1)),
1296
- u("div", Sn, [
1297
- u("div", Cn, [
1298
- u("div", {
1299
- class: X({
1300
- "text-fm-color-system-error-300": o.errors.length
1301
- })
1302
- }, [
1303
- Ie(D(o.name) + " ", 1),
1304
- o.type === "create" ? (f(), A("span", wn, "(new)")) : Y("", !0)
1305
- ], 2),
1306
- o.errors.length ? (f(), A("div", Fn, [
1307
- p(n, { "z-index": 50 }, {
1308
- content: V(() => [
1309
- u("ol", null, [
1310
- (f(!0), A(Q, null, de(o.errors, (l, i) => (f(), A("li", { key: i }, D(l), 1))), 128))
1311
- ])
1312
- ]),
1313
- default: V(() => [
1314
- p(s, {
1315
- name: "error",
1316
- size: "sm",
1317
- color: "system-error-300"
1318
- })
1319
- ]),
1320
- _: 1
1321
- })
1322
- ])) : Y("", !0)
1323
- ]),
1324
- u("div", {
1325
- class: X([
1326
- "fm-typo-en-body-sm-400",
1327
- {
1328
- "text-fm-color-system-error-200": o.errors.length,
1329
- "text-fm-color-typo-secondary": !o.errors.length
1330
- }
1331
- ])
1332
- }, D(o.code), 3)
1333
- ])
1334
- ]);
1335
- };
1336
- }
1337
- }), In = { class: "flex flex-col gap-24" }, Mn = { class: "fm-typo-en-body-md-400" }, $n = { class: "flex flex-col gap-8" }, En = { class: "line-clamp-2 text-ellipsis break-all" }, Un = {
1338
- key: 2,
1339
- class: "shrink-0"
1340
- }, Rn = {
1341
- key: 0,
1342
- class: "flex flex-col"
1343
- }, Tn = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, An = {
1344
- key: 0,
1345
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1346
- }, Dn = { class: "fm-typo-en-body-lg-600" }, Pn = /* @__PURE__ */ oe({
1347
- __name: "ImportIngredients",
1348
- setup(d) {
1349
- const o = j(null), y = Vt(), s = he(), n = j(!1), l = j(new Array()), i = j([]), a = j([]), h = S(
1350
- () => !!l.value.length || i.value.some((r) => r.errors.length) || a.value.some((r) => r.errors.length)
1351
- ), k = S(
1352
- () => !!i.value.length || !!a.value.length
1353
- ), { t: g } = ae();
1354
- async function b(r) {
1355
- l.value = [], i.value = [], a.value = [];
1356
- try {
1357
- n.value = !0;
1358
- const [_] = await Promise.all([
1359
- gt(r),
1360
- // fake buffer
1361
- new Promise((N) => setTimeout(N, 1e3))
1362
- ]), U = _.SheetNames.find((N) => N);
1363
- if (!U) {
1364
- l.value.push(g("inventory.ingredient.import.fileError.noSheet"));
1365
- return;
1366
- }
1367
- const I = kn(_.Sheets[U]);
1368
- if (I.invalidExcel) {
1369
- l.value.push(I.invalidExcelMessage ?? g("inventory.ingredient.import.fileError.invalidExcel"));
1370
- return;
1371
- }
1372
- if (i.value = I.importCreateResult, a.value = I.importUpdateResult, !i.value.length && !a.value.length) {
1373
- l.value.push(g("inventory.ingredient.import.fileError.noData"));
1374
- return;
1375
- }
1376
- y.emitData(I);
1377
- } catch (_) {
1378
- s.open({
1379
- title: g("inventory.ingredient.import.fileError.unableToRead"),
1380
- message: _ == null ? void 0 : _.message,
1381
- type: "error"
1382
- }), console.error("Error in reading file", _);
1383
- } finally {
1384
- l.value.length && s.open({
1385
- title: g("inventory.ingredient.import.fileError.invalidExcel"),
1386
- type: "error"
1387
- }), n.value = !1;
1388
- }
1389
- }
1390
- return Oe(o, (r) => {
1391
- r && b(r);
1392
- }), (r, _) => {
1393
- const U = C("FmCircularProgress"), I = C("FmIcon"), N = C("FmButton");
1394
- return f(), A("div", In, [
1395
- u("div", Mn, D(m(g)("inventory.ingredient.import.uploadDescription")), 1),
1396
- p(yt, {
1397
- class: X({
1398
- "w-full": !0,
1399
- "h-[200px]": !o.value
1400
- }),
1401
- accept: ".xlsx",
1402
- onFileUpload: _[0] || (_[0] = (w) => o.value = w),
1403
- label: m(g)("inventory.ingredient.import.uploadTemplate"),
1404
- "button-label": m(g)("inventory.ingredient.import.selectFile")
1405
- }, qe({ _: 2 }, [
1406
- o.value ? {
1407
- name: "default",
1408
- fn: V(({ openFileDialog: w }) => [
1409
- u("div", $n, [
1410
- u("div", {
1411
- class: X([
1412
- "fm-corner-radius-md p-16 flex items-center gap-16",
1413
- {
1414
- "border border-fm-color-neutral-gray-100": n.value,
1415
- "border border-fm-color-neutral-gray-200": !n.value && !h.value,
1416
- "border border-fm-color-system-error-200": h.value
1417
- }
1418
- ])
1419
- }, [
1420
- n.value ? (f(), B(U, {
1421
- key: 0,
1422
- size: "md",
1423
- color: "neutral-gray-200"
1424
- })) : (f(), B(I, {
1425
- key: 1,
1426
- name: h.value ? "error" : "attach_file",
1427
- outline: "",
1428
- color: h.value ? "system-error-300" : void 0
1429
- }, null, 8, ["name", "color"])),
1430
- u("div", {
1431
- class: X([
1432
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1433
- {
1434
- "text-fm-color-typo-disabled": n.value,
1435
- "text-fm-color-typo-primary": !n.value
1436
- }
1437
- ])
1438
- }, [
1439
- u("div", En, D(o.value.name), 1)
1440
- ], 2),
1441
- n.value ? Y("", !0) : (f(), A("div", Un, [
1442
- p(N, {
1443
- label: m(g)("inventory.ingredient.import.replaceFile"),
1444
- variant: h.value ? "destructive" : "secondary",
1445
- "prepend-icon": h.value ? void 0 : "autorenew",
1446
- onClick: w
1447
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
1448
- ]))
1449
- ], 2),
1450
- l.value.length ? (f(), A("div", Rn, [
1451
- (f(!0), A(Q, null, de(l.value, (v, R) => (f(), A("div", {
1452
- key: R,
1453
- class: "flex gap-8 items-center"
1454
- }, [
1455
- p(I, {
1456
- name: "error",
1457
- size: "sm",
1458
- color: "system-error-300"
1459
- }),
1460
- u("div", Tn, D(v), 1)
1461
- ]))), 128))
1462
- ])) : Y("", !0)
1463
- ])
1464
- ]),
1465
- key: "0"
1466
- } : void 0
1467
- ]), 1032, ["class", "label", "button-label"]),
1468
- k.value ? (f(), A("div", An, [
1469
- u("div", Dn, D(m(g)("inventory.ingredient.import.summary")), 1),
1470
- (f(!0), A(Q, null, de(i.value, (w) => (f(), B(je, {
1471
- key: w.sku._id,
1472
- code: w.sku.code,
1473
- name: w.sku.name,
1474
- errors: w.errors,
1475
- type: "create"
1476
- }, null, 8, ["code", "name", "errors"]))), 128)),
1477
- (f(!0), A(Q, null, de(a.value, (w) => (f(), B(je, {
1478
- key: w.sku._id,
1479
- code: w.sku.code,
1480
- name: w.sku.name,
1481
- errors: w.errors,
1482
- type: "update"
1483
- }, null, 8, ["code", "name", "errors"]))), 128))
1484
- ])) : Y("", !0)
1485
- ]);
1486
- };
1487
- }
1488
- }), Bn = { class: "flex flex-col py-8" }, Nn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ln = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, to = /* @__PURE__ */ oe({
1489
- __name: "IngredientsView",
1490
- setup(d) {
1491
- const o = le(), y = S(() => o.skus), s = bt(), n = Qe(), l = he(), i = Me(), { t: a } = ae(), { createIngredient: h, updateIngredient: k } = Fe(), { ingredientDialogProps: g, ingredientViewLoading: b } = It(Fe()), { columnDefs: r } = Ut();
1492
- function _(P) {
1493
- switch (P) {
1494
- case "add":
1495
- return i.isEnabled ? void 0 : h();
1496
- case "import":
1497
- return ue();
1498
- case "export":
1499
- return ne();
1500
- }
1501
- }
1502
- const U = j(""), I = j(!1), N = S(() => I.value || b.value), { breakpoints: w } = St(), v = S(() => w.value.xs || w.value.sm), R = S(() => v.value ? 10 : 20), J = ht(), Z = j(!1), L = [
1503
- {
1504
- value: "import",
1505
- label: a("common.import")
1506
- },
1507
- {
1508
- value: "export",
1509
- label: a("common.export")
1510
- }
1511
- ];
1512
- function z(P) {
1513
- switch (Z.value = !1, P) {
1514
- case "import":
1515
- return ue();
1516
- case "export":
1517
- return ne();
1518
- }
1519
- }
1520
- const q = S(() => [
1521
- ...i.isEnabled ? [] : [
1522
- {
1523
- label: a("inventory.ingredient.create.title"),
1524
- value: "add",
1525
- isPrimary: !0,
1526
- prependIcon: "add"
1527
- },
1528
- { label: a("common.import"), value: "import" }
1529
- ],
1530
- { label: a("common.export"), value: "export" }
1531
- ]);
1532
- function ne() {
1533
- const P = hn();
1534
- l.open({
1535
- title: a("inventory.ingredient.export.success"),
1536
- message: a("inventory.ingredient.export.filename", [P]),
1537
- type: "success"
1538
- });
1539
- }
1540
- function ue() {
1541
- n.open({
1542
- title: a("inventory.ingredient.import.title"),
1543
- contentComponent: Pn,
1544
- overlay: !0,
1545
- closeButton: !0,
1546
- primaryActions: {
1547
- text: a("common.import"),
1548
- close: !1
1549
- },
1550
- secondaryActions: {
1551
- text: a("common.close"),
1552
- close: !0
1553
- },
1554
- tertiaryActions: {
1555
- text: a("inventory.ingredient.import.actions.downloadTemplate"),
1556
- close: !1,
1557
- variant: "plain"
1558
- }
1559
- }).onPrimary((P) => {
1560
- if (!P) {
1561
- l.open({
1562
- title: a("inventory.ingredient.import.error.noData"),
1563
- type: "error"
1564
- });
1565
- return;
1566
- }
1567
- if (!P.importCreateResult.length && !P.importUpdateResult.length) {
1568
- l.open({
1569
- title: a("inventory.ingredient.import.error.invalidContent"),
1570
- message: a("inventory.ingredient.import.error.noImportData"),
1571
- type: "error"
1572
- });
1573
- return;
1574
- }
1575
- if (P.importCreateResult.some(($) => $.errors.length) || P.importUpdateResult.some(($) => $.errors.length)) {
1576
- l.open({
1577
- title: a("inventory.ingredient.import.error.invalidContent"),
1578
- message: a("inventory.ingredient.import.error.hasErrors"),
1579
- type: "error"
1580
- });
1581
- return;
1582
- }
1583
- n.close(), _e(P);
1584
- }).onTertiary(_n);
1585
- }
1586
- async function _e(P) {
1587
- I.value = !0;
1588
- try {
1589
- const $ = [
1590
- ...P.importCreateResult.map(({ sku: T }) => ({ type: "create", sku: T })),
1591
- ...P.importUpdateResult.map(({ sku: T }) => ({ type: "update", sku: T }))
1592
- ], re = 100;
1593
- let se = 0;
1594
- const ee = () => {
1595
- se += re, l.open({
1596
- title: a("inventory.ingredient.import.progress", [
1597
- Math.min(se, $.length),
1598
- $.length
1599
- ])
1600
- });
1601
- };
1602
- for (const T of $.chunk(100))
1603
- ee(), await o.importSkus({
1604
- create: T.filter((O) => O.type === "create").map((O) => O.sku),
1605
- update: T.filter((O) => O.type === "update").map((O) => O.sku)
1606
- });
1607
- l.open({
1608
- title: a("inventory.ingredient.import.success"),
1609
- type: "success"
1610
- });
1611
- } catch ($) {
1612
- l.open({
1613
- title: a("inventory.ingredient.import.error.failed"),
1614
- message: a("inventory.ingredient.import.error.systemMessage", [$ == null ? void 0 : $.message]),
1615
- type: "error"
1616
- }), console.error("Error in importing skus", P, $);
1617
- } finally {
1618
- I.value = !1;
1619
- }
1620
- }
1621
- return (P, $) => {
1622
- const re = C("FmTable"), se = C("FmCollapsibleTabs"), ee = C("FmBottomSheet");
1623
- return f(), B(_t, {
1624
- title: m(a)("inventory.ingredient.title"),
1625
- actions: q.value,
1626
- "onClick:action": _
1627
- }, {
1628
- default: V(() => [
1629
- u("div", {
1630
- class: X([
1631
- "flex flex-col gap-8 max-h-full",
1632
- {
1633
- "p-0": v.value,
1634
- "px-24 ": !v.value
1635
- }
1636
- ])
1637
- }, [
1638
- p(xt, {
1639
- searchable: "",
1640
- search: U.value,
1641
- "onUpdate:search": $[0] || ($[0] = (T) => U.value = T)
1642
- }, null, 8, ["search"]),
1643
- p(re, {
1644
- style: lt(m(J).tableHeight),
1645
- "column-defs": m(r),
1646
- "row-data": y.value,
1647
- "search-value": U.value,
1648
- loading: !m(s)._currentLocation || N.value,
1649
- "loading-text": "Loading",
1650
- onRowClick: $[1] || ($[1] = (T) => m(k)(T.original)),
1651
- "page-size": R.value
1652
- }, {
1653
- "list-row": V((T) => [
1654
- p(kt, {
1655
- row: T,
1656
- onRowClick: m(k)
1657
- }, qe({
1658
- default: V((O) => {
1659
- var me, e, t, c, x, E, F, G, H, te;
1660
- return [
1661
- u("div", Bn, [
1662
- u("div", Nn, [
1663
- p(m(ze), {
1664
- render: (t = (e = (me = O.code) == null ? void 0 : me.column) == null ? void 0 : e.columnDef) == null ? void 0 : t.cell,
1665
- props: (x = (c = O.code) == null ? void 0 : c.getContext) == null ? void 0 : x.call(c)
1666
- }, null, 8, ["render", "props"])
1667
- ]),
1668
- u("div", Ln, [
1669
- p(m(ze), {
1670
- render: (G = (F = (E = O.name) == null ? void 0 : E.column) == null ? void 0 : F.columnDef) == null ? void 0 : G.cell,
1671
- props: (te = (H = O.name) == null ? void 0 : H.getContext) == null ? void 0 : te.call(H)
1672
- }, null, 8, ["render", "props"])
1673
- ])
1674
- ])
1675
- ];
1676
- }),
1677
- _: 2
1678
- }, [
1679
- I.value ? {
1680
- name: "loading-text",
1681
- fn: V(() => [
1682
- u("div", null, D(m(a)("inventory.ingredient.table.importing")), 1)
1683
- ]),
1684
- key: "0"
1685
- } : void 0
1686
- ]), 1032, ["row", "onRowClick"])
1687
- ]),
1688
- _: 1
1689
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1690
- ], 2),
1691
- (f(), B(Pe, { to: "body" }, [
1692
- p(pn, at(rt(m(g))), null, 16)
1693
- ])),
1694
- (f(), B(Pe, { to: "body" }, [
1695
- p(ee, {
1696
- "dismiss-away": "",
1697
- modelValue: Z.value,
1698
- "onUpdate:modelValue": $[3] || ($[3] = (T) => Z.value = T)
1699
- }, {
1700
- default: V(() => [
1701
- p(se, {
1702
- class: "pb-8",
1703
- items: L,
1704
- "onUpdate:modelValue": $[2] || ($[2] = (T) => z(T))
1705
- })
1706
- ]),
1707
- _: 1
1708
- }, 8, ["modelValue"])
1709
- ]))
1710
- ]),
1711
- _: 1
1712
- }, 8, ["title", "actions"]);
1713
- };
1714
- }
1715
- });
1716
- export {
1717
- to as default
1718
- };