@feedmepos/mf-inventory-portal 1.0.15-dev.2 → 1.0.15-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/{App-CgxrN-aD.js → App-3Zym4rob.js} +2 -2
  2. package/dist/ApprovalView-C4qLlZua.js +213 -0
  3. package/dist/{BindingsDialog-B_ZMDl-b.js → BindingsDialog-DHaF8DtC.js} +2 -2
  4. package/dist/{BindingsPicker-B84BG8zT.js → BindingsPicker-C04HnWZ-.js} +1 -1
  5. package/dist/{BindingsTable-DrvoykYc.js → BindingsTable-CnZUt7GU.js} +1 -1
  6. package/dist/{ClosingDraftView-Ds9sI2Eg.js → ClosingDraftView-DaMruAln.js} +41 -41
  7. package/dist/{ClosingTemplateView-BhZ1OXkD.js → ClosingTemplateView-B3lyKcz-.js} +2 -2
  8. package/dist/{DeliveryOrderPrintPreview-Yuxf-jCh.js → DeliveryOrderPrintPreview-CGPkYOfW.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-D6ktiUO5.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DFJNtwjV.js} +43 -43
  10. package/dist/{FmMultiselectDialog-4lVsA2Rn.js → FmMultiselectDialog-yR5Mo3U-.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-XmTRSHn_.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DoY67RWl.js} +57 -57
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-B3PvtR0j.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BSuFAwN3.js} +1 -1
  13. package/dist/IngredientGroupView-B-hyo-7W.js +898 -0
  14. package/dist/IngredientsView-Cod5ahQy.js +1778 -0
  15. package/dist/{IntegrationView-BnrCkjWt.js → IntegrationView-D9KZtPN3.js} +5 -5
  16. package/dist/{InventoryBindingForm-uyHh2TI_.js → InventoryBindingForm-CrRoablh.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CECDj9Pw.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-W9p7khOs.js} +46 -46
  18. package/dist/{InventoryBindingSummary-DyHCqgIe.js → InventoryBindingSummary-D88BG4ze.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Dx2lMf6h.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-VtM-wvuF.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BCX3vlmU.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Ccx9QvpN.js} +15 -15
  21. package/dist/{PublishView-BVGyY6nn.js → PublishView-DhE7YE-k.js} +13 -13
  22. package/dist/{PurchaseOrderPrintPreview-pbYIFiOG.js → PurchaseOrderPrintPreview-CF_VeOeU.js} +4 -4
  23. package/dist/ReceiveRequestView-Bx9-NHyn.js +2576 -0
  24. package/dist/{RecipeView-DcgoCf4g.js → RecipeView-JhM5Z4CP.js} +4 -4
  25. package/dist/{StockView-zO2uL662.js → StockView-u7jlKoO5.js} +108 -108
  26. package/dist/{SupplierView-I5bqiX_2.js → SupplierView-BDBBQnGy.js} +37 -37
  27. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BJiobEDM.js +2090 -0
  28. package/dist/{TransferTemplateView-BDOt17yc.js → TransferTemplateView-CNMHm8Gy.js} +149 -149
  29. package/dist/{UnitView-BVY5S6-3.js → UnitView-UVgn7ofI.js} +32 -32
  30. package/dist/{WarehouseView-m6MKrtYq.js → WarehouseView-CEw69mhn.js} +26 -26
  31. package/dist/{app-DtICLubM.js → app-cfPLYfcH.js} +33227 -25194
  32. package/dist/app.js +5 -5
  33. package/dist/components/FmInventoryTableToolbar.vue.d.ts +36 -0
  34. package/dist/{decimal-C1dAcCf3.js → decimal-BeCLbdwn.js} +1 -1
  35. package/dist/{feature-Y7qzvbl4.js → feature-dhG2tL_A.js} +79 -79
  36. package/dist/{format-unit-display-CPqfS4vp.js → format-unit-display-D3UdcFM6.js} +48 -48
  37. package/dist/{index-DIEdSG3y.js → index-BUou6R58.js} +1 -1
  38. package/dist/{index-0qsqwB0T.js → index-BkR-Qpc0.js} +4 -4
  39. package/dist/{stock-CowNp_xM.js → stock-DQPwSZX1.js} +1 -1
  40. package/dist/{supplier-JVTTlQNL.js → supplier-CAcd6PiU.js} +2 -2
  41. package/dist/tsconfig.app.tsbuildinfo +1 -1
  42. package/dist/{use-ingredient-select-dialog-Df59lld2.js → use-ingredient-select-dialog-E3qfQso7.js} +5 -5
  43. package/dist/{use-inventory-binding-dialog-Bxxb93Kz.js → use-inventory-binding-dialog-DRKy4nUx.js} +1 -1
  44. package/dist/{vue-i18n-DJOdRwc3.js → vue-i18n-DLrqHK28.js} +271 -271
  45. package/package.json +4 -4
  46. package/dist/ApprovalView-DNGhkVc9.js +0 -147
  47. package/dist/IngredientGroupView-usK9stxT.js +0 -8779
  48. package/dist/IngredientsView-DPx8Z2zo.js +0 -1749
  49. package/dist/ReceiveRequestView-DZAgH2_u.js +0 -2516
  50. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-NyQg_yR9.js +0 -2020
@@ -0,0 +1,898 @@
1
+ import { ref as V, computed as w, h as F, defineComponent as j, resolveComponent as h, openBlock as S, createElementBlock as B, createVNode as g, unref as o, createElementVNode as d, createBlock as T, withCtx as C, toDisplayString as A, Fragment as pe, renderList as fe, createTextVNode as ve, createCommentVNode as se, watch as ge, isRef as ye, normalizeClass as _e, normalizeStyle as be, createSlots as ke, Teleport as xe, normalizeProps as he, guardReactiveProps as we } from "vue";
2
+ import { a as P, d as I, e as z, f as Re, D as oe, h as q, G as re, J as Ie, N as Ge, l as ue, K as Se, p as ae, u as Fe, z as Ve, _ as Ce, B as De, C as $e, E as le } from "./app-cfPLYfcH.js";
3
+ import { useDialog as Ae, useSnackbar as J, components as K, useProxiedModel as Ee, useBreakpoints as Te } from "@feedmepos/ui-library";
4
+ import { useI18n as U, useCoreStore as Me } from "@feedmepos/mf-common";
5
+ import { defineStore as de, storeToRefs as ie } from "pinia";
6
+ import "./array-Ca8T3f_G.js";
7
+ import { u as Be } from "./FmMultiselectDialog-yR5Mo3U-.js";
8
+ import { r as ce } from "./random-CSbEbElR.js";
9
+ import { u as ze, R as Pe } from "./usePromise-CbVUCxhj.js";
10
+ const H = de(
11
+ "ingredientGroupactions",
12
+ function() {
13
+ const v = Ae(), f = J(), k = P(), { t: i } = U(), m = V();
14
+ function e() {
15
+ const c = {
16
+ modelValue: {},
17
+ mode: I.CREATE,
18
+ show: !0,
19
+ "onUpdate:show"(p) {
20
+ m.value.show = p;
21
+ }
22
+ };
23
+ m.value = c;
24
+ }
25
+ async function l(c) {
26
+ const p = {
27
+ modelValue: z(c),
28
+ mode: I.UPDATE,
29
+ show: !0,
30
+ "onUpdate:show"(r) {
31
+ m.value.show = r;
32
+ }
33
+ };
34
+ m.value = p;
35
+ }
36
+ async function n(c, p, r) {
37
+ p.value = !0;
38
+ try {
39
+ await k.deleteSkuGroup(c), f.open({
40
+ title: "Success",
41
+ message: `Deleted ${c.name}`,
42
+ type: "success"
43
+ });
44
+ } catch (y) {
45
+ f.open({
46
+ title: `Cannot delete ${c.name}`,
47
+ message: "Please try again.",
48
+ type: "error"
49
+ }), console.error("failed to delete ingredient", y);
50
+ } finally {
51
+ p.value = !1, r();
52
+ }
53
+ }
54
+ function s(c, p, r) {
55
+ v.open({
56
+ title: i("inventory.ingredient.delete.title", [(c == null ? void 0 : c.name) ?? ""]),
57
+ closeButton: !1,
58
+ message: i("inventory.ingredient.delete.message"),
59
+ primaryActions: {
60
+ text: i("common.delete"),
61
+ close: !0,
62
+ variant: "destructive"
63
+ },
64
+ secondaryActions: {
65
+ text: i("common.cancel"),
66
+ close: !0
67
+ }
68
+ }).onPrimary(() => n(c, p, r));
69
+ }
70
+ function t() {
71
+ }
72
+ function _() {
73
+ }
74
+ return {
75
+ createIngredientGroup: e,
76
+ updateIngredientGroup: l,
77
+ deleteIngredientGroup: s,
78
+ importIngredientGroups: t,
79
+ exportIngredientGroups: _,
80
+ ingredientGroupDialogProps: m
81
+ };
82
+ }
83
+ ), Ue = de(
84
+ "ingredientGroupTable",
85
+ function() {
86
+ const v = V(!1), f = J(), k = P(), i = H();
87
+ async function m() {
88
+ v.value = !0;
89
+ try {
90
+ await k.readInventory();
91
+ } catch (n) {
92
+ console.error("error on reading inventory", n), f.open({
93
+ title: "Error",
94
+ message: "Something went wrong, please try again.",
95
+ type: "error"
96
+ });
97
+ } finally {
98
+ v.value = !1;
99
+ }
100
+ }
101
+ function e(n, s) {
102
+ switch (s = z(s), n) {
103
+ case q.Edit:
104
+ return i.updateIngredientGroup(s);
105
+ case q.Delete:
106
+ return i.deleteIngredientGroup(
107
+ s,
108
+ v,
109
+ () => m()
110
+ );
111
+ }
112
+ }
113
+ const l = w(() => [
114
+ {
115
+ accessorKey: "name",
116
+ header: () => "Name"
117
+ },
118
+ {
119
+ accessorKey: "skuRefs.length",
120
+ header: () => "No. of items"
121
+ },
122
+ {
123
+ accessorKey: "ref",
124
+ header: () => "Reference"
125
+ },
126
+ {
127
+ id: "action",
128
+ header: "",
129
+ cell(n) {
130
+ return Re(
131
+ [oe[q.Edit], oe[q.Delete]],
132
+ (s) => {
133
+ e(s, n.row.original);
134
+ }
135
+ );
136
+ },
137
+ enableSorting: !1,
138
+ size: 40,
139
+ meta: {
140
+ cellClass: "",
141
+ headerClass: ""
142
+ }
143
+ }
144
+ ]);
145
+ return {
146
+ fetchIngredientGroups: m,
147
+ loading: v,
148
+ columnDefs: l
149
+ };
150
+ }
151
+ );
152
+ function Le(a) {
153
+ return {
154
+ addItem: () => {
155
+ const i = a.create();
156
+ a.items = [...a.items, i];
157
+ },
158
+ updateItem: (i) => {
159
+ i && (a.items = a.items.map(
160
+ (m) => a.id(m) === a.id(i) ? i : m
161
+ ));
162
+ },
163
+ removeItem: (i) => {
164
+ a.items = a.items.filter((m) => a.id(m) !== a.id(i));
165
+ }
166
+ };
167
+ }
168
+ function me(a) {
169
+ const v = Be(), f = P(), k = w(() => [
170
+ {
171
+ id: "delete",
172
+ header: "",
173
+ cell(e) {
174
+ const l = e.row.original;
175
+ return F(
176
+ "div",
177
+ { class: "w-full flex justify-end" },
178
+ F(K.FmButton, {
179
+ class: "delete-button",
180
+ key: l._id,
181
+ type: "button",
182
+ icon: "delete",
183
+ variant: "tertiary",
184
+ size: "md",
185
+ disabled: a.disabled ?? !1,
186
+ onClick: () => {
187
+ a.skuRefs = a.skuRefs.filter((n) => n._id !== l._id);
188
+ }
189
+ })
190
+ );
191
+ },
192
+ enableSorting: !1,
193
+ size: 40,
194
+ meta: {
195
+ cellClass: "",
196
+ headerClass: ""
197
+ }
198
+ },
199
+ {
200
+ id: "skuRef",
201
+ header: () => "Ingredient",
202
+ accessorFn: (e) => {
203
+ var l, n;
204
+ return `${((l = f.skuById[e._id]) == null ? void 0 : l.name) ?? ""} (${((n = f.skuById[e._id]) == null ? void 0 : n.code) ?? ""})`;
205
+ },
206
+ cell: ({ row: e }) => {
207
+ const l = f.skuById[e.original._id];
208
+ return F(
209
+ "div",
210
+ {
211
+ class: "w-full flex flex-col"
212
+ },
213
+ [
214
+ F("div", { class: "fm-typo-en-body-lg-400" }, l.name),
215
+ F("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, l.code)
216
+ ]
217
+ );
218
+ },
219
+ size: "auto",
220
+ enableSorting: !1
221
+ },
222
+ {
223
+ id: "unit",
224
+ header: () => "Unit",
225
+ accessorFn: (e) => {
226
+ const l = f.skuById[e._id];
227
+ return l.unit.measurements.computeFirst(
228
+ (n) => n.id === e.trackingMeasurement ? n.name : null
229
+ ) ?? l.unit.name;
230
+ },
231
+ enableSorting: !1
232
+ },
233
+ {
234
+ id: "unitOption",
235
+ header: () => "Unit",
236
+ accessorKey: "trackingMeasurement",
237
+ cell(e) {
238
+ const l = f.skuById[e.row.original._id];
239
+ if (!l) return null;
240
+ const n = [
241
+ {
242
+ label: l.unit.name,
243
+ sublabel: l.unit.abbrev,
244
+ value: null
245
+ },
246
+ ...l.unit.measurements.map((s) => ({
247
+ label: s.name,
248
+ sublabel: s.abbrev,
249
+ value: s.id
250
+ }))
251
+ ];
252
+ return F(K.FmSelect, {
253
+ modelValue: e.row.original.trackingMeasurement ?? null,
254
+ items: n,
255
+ disabled: a.disabled ?? !1,
256
+ "onUpdate:modelValue": (s) => {
257
+ a.skuRefs = a.skuRefs.map((t) => t._id === e.row.original._id ? { ...t, trackingMeasurement: s } : t);
258
+ }
259
+ });
260
+ },
261
+ enableSorting: !1
262
+ },
263
+ {
264
+ id: "move",
265
+ header: "",
266
+ cell(e) {
267
+ const l = e.row.original;
268
+ return F("div", { class: "w-full flex justify-end" }, [
269
+ F(K.FmButton, {
270
+ key: l._id,
271
+ type: "button",
272
+ icon: "keyboard_arrow_up",
273
+ variant: "tertiary",
274
+ size: "md",
275
+ disabled: a.disabled ?? !1,
276
+ onClick: () => {
277
+ const n = [...a.skuRefs], s = n.findIndex((t) => t._id === l._id);
278
+ if (s > 0) {
279
+ const t = n[s - 1];
280
+ n[s - 1] = l, n[s] = t;
281
+ }
282
+ a.skuRefs = [...n];
283
+ }
284
+ }),
285
+ F(K.FmButton, {
286
+ key: l._id,
287
+ type: "button",
288
+ icon: "keyboard_arrow_down",
289
+ variant: "tertiary",
290
+ size: "md",
291
+ disabled: a.disabled ?? !1,
292
+ onClick: () => {
293
+ const n = [...a.skuRefs], s = n.findIndex((t) => t._id === l._id);
294
+ if (s < n.length - 1) {
295
+ const t = n[s + 1];
296
+ n[s + 1] = l, n[s] = t;
297
+ }
298
+ a.skuRefs = [...n];
299
+ }
300
+ })
301
+ ]);
302
+ },
303
+ enableSorting: !1,
304
+ size: 40,
305
+ meta: {
306
+ cellClass: "",
307
+ headerClass: ""
308
+ }
309
+ }
310
+ ]);
311
+ return {
312
+ get columnDefs() {
313
+ return k.value;
314
+ },
315
+ promptAddIngredient: async () => {
316
+ if (!a.isDefaultList && !a.allowOverride)
317
+ return v.alert("Not allowed", "You cannot add ingredients to this list.");
318
+ const m = f.skus.map((n) => ({
319
+ label: n.name,
320
+ sublabel: n.code,
321
+ value: n._id
322
+ })), e = (a.skuRefs ?? []).map((n) => n._id), l = await v.multiSelect(m, e, (n) => {
323
+ var t, _, c, p;
324
+ const s = (t = a.skuRefs) == null ? void 0 : t.findIndex((r) => r._id === n);
325
+ return {
326
+ _id: n,
327
+ trackingMeasurement: typeof s != "number" || s == -1 ? (_ = f.skuById[n]) == null ? void 0 : _.trackingMeasurement : (p = (c = a.skuRefs) == null ? void 0 : c[s]) == null ? void 0 : p.trackingMeasurement
328
+ };
329
+ });
330
+ a.skuRefs = l ?? a.skuRefs;
331
+ },
332
+ columnVisibility: {
333
+ delete: a.isDefaultList || !!a.allowOverride,
334
+ unit: !a.isDefaultList && !a.allowOverride,
335
+ unitOption: a.isDefaultList || !!a.allowOverride
336
+ }
337
+ };
338
+ }
339
+ const Ne = { class: "flex flex-col gap-16" }, Oe = { class: "flex flex-col" }, qe = { class: "flex flex-col gap-4" }, Ke = { class: "flex flex-col gap-16" }, je = { class: "flex flex-col" }, He = { class: "flex flex-col gap-4" }, Je = /* @__PURE__ */ j({
340
+ __name: "IngredientGroupRuleField",
341
+ props: {
342
+ disabled: { type: Boolean },
343
+ modelValue: {}
344
+ },
345
+ setup(a) {
346
+ const v = a, { t: f } = U(), k = Me(), i = w(() => {
347
+ const s = /* @__PURE__ */ new Map();
348
+ return s.set("restaurantId", new Set(k.restaurants.value.map((t) => t._id))), s;
349
+ }), m = w(() => [
350
+ ...[...i.value.entries()].map(([t, _]) => ({
351
+ type: "string",
352
+ key: t,
353
+ entity: "restaurant",
354
+ values: [..._]
355
+ }))
356
+ ]), e = re("modelValue", {
357
+ get default() {
358
+ return {
359
+ _id: `skuGroupRule_${(/* @__PURE__ */ new Date()).toISOString()}_${ce(4)}`,
360
+ name: "",
361
+ rule: null,
362
+ skuRefs: []
363
+ };
364
+ },
365
+ watchProps: !0
366
+ }), l = w({
367
+ get() {
368
+ return e.rule ? Ie.build(e.rule) : null;
369
+ },
370
+ set(s) {
371
+ e.rule = Ge.build(s);
372
+ }
373
+ }), n = me({
374
+ get disabled() {
375
+ return v.disabled ?? !1;
376
+ },
377
+ get skuRefs() {
378
+ return e.skuRefs ?? [];
379
+ },
380
+ set skuRefs(s) {
381
+ e.skuRefs = s;
382
+ },
383
+ isDefaultList: !1,
384
+ allowOverride: !1
385
+ });
386
+ return (s, t) => {
387
+ const _ = h("FmTextField"), c = h("FmLabel"), p = h("FmFormGroup"), r = h("FmTable");
388
+ return S(), B("div", Ne, [
389
+ g(_, {
390
+ modelValue: o(e).name,
391
+ "onUpdate:modelValue": t[0] || (t[0] = (y) => o(e).name = y),
392
+ label: o(f)("inventory.ingredientGroup.form.rules.name"),
393
+ "label-mark": "required",
394
+ rules: [o(ue)()]
395
+ }, null, 8, ["modelValue", "label", "rules"]),
396
+ d("div", Oe, [
397
+ d("div", qe, [
398
+ g(c, {
399
+ label: o(f)("inventory.ingredientGroup.form.rules.title"),
400
+ required: ""
401
+ }, null, 8, ["label"]),
402
+ g(o(Se), {
403
+ modelValue: l.value,
404
+ "onUpdate:modelValue": t[1] || (t[1] = (y) => l.value = y),
405
+ attributes: m.value
406
+ }, null, 8, ["modelValue", "attributes"])
407
+ ]),
408
+ g(p, {
409
+ "model-value": l.value,
410
+ rules: [
411
+ (y) => {
412
+ var G;
413
+ return !!((G = y == null ? void 0 : y.rules) != null && G.length) || "At least one rule is required";
414
+ }
415
+ ]
416
+ }, null, 8, ["model-value", "rules"])
417
+ ]),
418
+ d("div", Ke, [
419
+ d("div", je, [
420
+ d("div", He, [
421
+ d("div", null, [
422
+ g(c, {
423
+ label: o(f)("inventory.ingredientGroup.form.rules.ingredients"),
424
+ required: ""
425
+ }, null, 8, ["label"])
426
+ ])
427
+ ]),
428
+ g(p, {
429
+ "model-value": o(e).skuRefs,
430
+ rules: [
431
+ (y) => !!(y != null && y.length) || "At least one ingredient is required"
432
+ ]
433
+ }, null, 8, ["model-value", "rules"])
434
+ ]),
435
+ g(r, {
436
+ "row-data": o(e).skuRefs,
437
+ "column-defs": o(n).columnDefs,
438
+ "page-size": o(e).skuRefs.length,
439
+ "shrink-at": 9999,
440
+ "column-visibility": o(n).columnVisibility,
441
+ "hide-footer": ""
442
+ }, null, 8, ["row-data", "column-defs", "page-size", "column-visibility"])
443
+ ])
444
+ ]);
445
+ };
446
+ }
447
+ }), Ye = { class: "flex flex-col gap-16" }, Qe = { class: "flex flex-col gap-16" }, We = { class: "flex flex-col" }, Xe = { class: "flex items-center" }, Ze = { class: "flex-1" }, et = { class: "flex flex-col gap-8" }, tt = { class: "flex-1 fm-typo-en-title-sm-600" }, nt = { class: "flex-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, st = { class: "flex flex-col gap-16" }, ot = { class: "flex flex-col gap-8" }, at = { class: "flex-1 fm-typo-en-title-sm-600" }, lt = { class: "flex-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, it = { class: "flex flex-col gap-12" }, rt = { class: "flex items-center" }, ut = { class: "flex-1 fm-typo-en-body-lg-600 line-clamp-1" }, dt = { key: 0 }, ct = {
448
+ key: 1,
449
+ class: "fm-typo-en-body-lg-400"
450
+ }, mt = /* @__PURE__ */ j({
451
+ __name: "IngredientGroupForm",
452
+ props: {
453
+ mode: {},
454
+ disabled: { type: Boolean },
455
+ modelValue: {},
456
+ menu: {}
457
+ },
458
+ emits: ["validation-success"],
459
+ setup(a, { expose: v, emit: f }) {
460
+ const k = a, i = re("modelValue", {
461
+ watchProps: !0
462
+ }), m = f, { t: e } = U(), l = Le({
463
+ get items() {
464
+ return i.rules ?? [];
465
+ },
466
+ set items(t) {
467
+ i.rules = t;
468
+ },
469
+ create: function() {
470
+ var t;
471
+ return {
472
+ _id: `skuGroupRule_${(/* @__PURE__ */ new Date()).toISOString()}_${ce(4)}`,
473
+ name: "",
474
+ rule: null,
475
+ skuRefs: ((t = k.modelValue) == null ? void 0 : t.defaultSkuRefs) ?? []
476
+ };
477
+ },
478
+ id: function(t) {
479
+ return t._id;
480
+ }
481
+ }), n = me({
482
+ get disabled() {
483
+ return k.disabled;
484
+ },
485
+ get skuRefs() {
486
+ return i.defaultSkuRefs ?? [];
487
+ },
488
+ set skuRefs(t) {
489
+ i.defaultSkuRefs = t;
490
+ const _ = t.map((r) => r._id), c = i.rules;
491
+ if (!c) return;
492
+ const p = t.groupBy(
493
+ (r) => r._id,
494
+ (r) => r.trackingMeasurement
495
+ );
496
+ for (const r of c) {
497
+ const y = r.skuRefs.filter((x) => _.includes(x._id)), G = t.filter(
498
+ (x) => !y.some((R) => R._id === x._id)
499
+ );
500
+ r.skuRefs = [...y, ...G].map((x) => {
501
+ var R;
502
+ return {
503
+ ...x,
504
+ trackingMeasurement: ((R = p.get(x._id)) == null ? void 0 : R[0]) ?? null
505
+ };
506
+ });
507
+ }
508
+ i.rules = [...c];
509
+ },
510
+ isDefaultList: !0
511
+ }), s = V();
512
+ return v({
513
+ validateInputs: () => {
514
+ var t;
515
+ return (t = s.value) == null ? void 0 : t.validateInputs();
516
+ },
517
+ resetInputsValidation: () => {
518
+ var t;
519
+ return (t = s.value) == null ? void 0 : t.resetInputsValidation();
520
+ },
521
+ resetInputs: () => {
522
+ var t;
523
+ return (t = s.value) == null ? void 0 : t.resetInputs();
524
+ }
525
+ }), (t, _) => {
526
+ const c = h("FmTextField"), p = h("FmButton"), r = h("FmFormGroup"), y = h("FmTable"), G = h("FmCard"), x = h("FmForm");
527
+ return S(), T(x, {
528
+ onValidationSuccess: _[2] || (_[2] = (R) => m("validation-success")),
529
+ ref_key: "formRef",
530
+ ref: s,
531
+ class: "flex flex-col gap-64"
532
+ }, {
533
+ default: C(() => {
534
+ var R;
535
+ return [
536
+ d("div", Ye, [
537
+ g(c, {
538
+ label: o(e)("inventory.ingredientGroup.form.name"),
539
+ "label-mark": "required",
540
+ rules: [o(ue)()],
541
+ modelValue: o(i).name,
542
+ "onUpdate:modelValue": _[0] || (_[0] = (u) => o(i).name = u)
543
+ }, null, 8, ["label", "rules", "modelValue"]),
544
+ g(c, {
545
+ label: o(e)("inventory.ingredientGroup.form.ref"),
546
+ "label-mark": "optional",
547
+ modelValue: o(i).ref,
548
+ "onUpdate:modelValue": _[1] || (_[1] = (u) => o(i).ref = u)
549
+ }, null, 8, ["label", "modelValue"])
550
+ ]),
551
+ d("div", Qe, [
552
+ d("div", We, [
553
+ d("div", Xe, [
554
+ d("div", Ze, [
555
+ d("div", et, [
556
+ d("div", tt, A(o(e)("inventory.ingredientGroup.form.defaultRule.title")), 1)
557
+ ])
558
+ ]),
559
+ d("div", null, [
560
+ g(p, {
561
+ disabled: t.disabled,
562
+ label: "Add ingredient",
563
+ "prepend-icon": "link",
564
+ variant: "plain",
565
+ class: "border-1 rounded-lg border-fm-color-primary",
566
+ onClick: o(n).promptAddIngredient,
567
+ size: "md"
568
+ }, null, 8, ["disabled", "onClick"])
569
+ ])
570
+ ]),
571
+ g(r, {
572
+ "model-value": o(i).defaultSkuRefs,
573
+ rules: [
574
+ (u) => !!(u != null && u.length) || "At least one ingredient is required"
575
+ ]
576
+ }, null, 8, ["model-value", "rules"])
577
+ ]),
578
+ d("div", null, [
579
+ g(y, {
580
+ "row-data": o(i).defaultSkuRefs ?? [],
581
+ "column-defs": o(n).columnDefs,
582
+ "column-visibility": o(n).columnVisibility,
583
+ "page-size": (R = o(i).defaultSkuRefs) == null ? void 0 : R.length,
584
+ "shrink-at": 9999,
585
+ "hide-footer": ""
586
+ }, null, 8, ["row-data", "column-defs", "column-visibility", "page-size"])
587
+ ]),
588
+ d("div", null, [
589
+ d("div", nt, A(o(e)("inventory.ingredientGroup.form.defaultRule.description")), 1)
590
+ ])
591
+ ]),
592
+ d("div", st, [
593
+ d("div", ot, [
594
+ d("div", at, A(o(e)("inventory.ingredientGroup.form.rules.title")), 1),
595
+ d("div", lt, A(o(e)("inventory.ingredientGroup.form.rules.description")), 1)
596
+ ]),
597
+ (S(!0), B(pe, null, fe(o(i).rules, (u, b) => (S(), T(G, {
598
+ key: u.id,
599
+ variant: "outlined",
600
+ class: "p-16"
601
+ }, {
602
+ default: C(() => [
603
+ d("div", it, [
604
+ d("div", rt, [
605
+ d("div", ut, [
606
+ ve(A(o(e)("inventory.ingredientGroup.form.rules.rule_N", [b + 1])), 1),
607
+ u.name ? (S(), B("span", dt, ": ")) : se("", !0),
608
+ u.name ? (S(), B("span", ct, A(u.name), 1)) : se("", !0)
609
+ ]),
610
+ g(p, {
611
+ variant: "tertiary",
612
+ icon: "delete",
613
+ onClick: (D) => o(l).removeItem(u)
614
+ }, null, 8, ["onClick"])
615
+ ]),
616
+ d("div", null, [
617
+ g(Je, {
618
+ "model-value": u,
619
+ "onUpdate:modelValue": o(l).updateItem,
620
+ disabled: t.disabled,
621
+ menu: t.menu
622
+ }, null, 8, ["model-value", "onUpdate:modelValue", "disabled", "menu"])
623
+ ])
624
+ ])
625
+ ]),
626
+ _: 2
627
+ }, 1024))), 128)),
628
+ d("div", null, [
629
+ g(p, {
630
+ variant: "plain",
631
+ icon: "add",
632
+ label: o(e)("inventory.ingredientGroup.form.rules.addRule"),
633
+ onClick: o(l).addItem
634
+ }, null, 8, ["label", "onClick"])
635
+ ])
636
+ ])
637
+ ];
638
+ }),
639
+ _: 1
640
+ }, 512);
641
+ };
642
+ }
643
+ }), pt = {
644
+ key: 0,
645
+ class: "text-fm-color-typo-primary fm-typo-en-body-lg-400"
646
+ }, ft = { class: "flex gap-4" }, vt = /* @__PURE__ */ j({
647
+ __name: "IngredientGroupDialog",
648
+ props: {
649
+ show: { type: Boolean },
650
+ mode: { default: I.READ },
651
+ modelValue: {}
652
+ },
653
+ emits: ["update:show"],
654
+ setup(a) {
655
+ const v = a, f = P(), k = ze(() => f.readCachedMenu()), i = w(
656
+ () => k.result.value.state === Pe.success ? k.result.value.data : void 0
657
+ ), m = J(), { t: e } = U(), l = Ee(v, "show");
658
+ function n() {
659
+ return {
660
+ _id: "",
661
+ name: "",
662
+ rules: []
663
+ };
664
+ }
665
+ const s = V(n()), t = V(`${Math.random()}`);
666
+ ge(
667
+ () => v.show,
668
+ (u) => {
669
+ u && (s.value = z(v.modelValue ?? n()), t.value = s.value._id || `${Math.random()}`);
670
+ }
671
+ );
672
+ const _ = w(() => {
673
+ switch (v.mode) {
674
+ case I.READ:
675
+ return "";
676
+ case I.UPDATE:
677
+ return e("inventory.ingredientGroup.update.title");
678
+ case I.CREATE:
679
+ return e("inventory.ingredientGroup.create.title");
680
+ }
681
+ return "";
682
+ }), c = w(() => {
683
+ switch (v.mode) {
684
+ case I.READ:
685
+ return "";
686
+ case I.UPDATE:
687
+ return e("common.save");
688
+ case I.CREATE:
689
+ return e("common.add");
690
+ }
691
+ return "";
692
+ }), p = V(), r = V(!1);
693
+ async function y() {
694
+ r.value = !0;
695
+ const u = z(s.value);
696
+ try {
697
+ await f.createSkuGroup(u), l.value = !1, m.open({
698
+ title: e("inventory.common.success"),
699
+ message: e("inventory.ingredientGroup.create.success", { name: u.name }),
700
+ type: "success"
701
+ });
702
+ } catch (b) {
703
+ b instanceof ae || m.open({
704
+ title: e("inventory.ingredientGroup.create.error.title"),
705
+ message: e("inventory.ingredientGroup.create.error.message"),
706
+ type: "error"
707
+ });
708
+ } finally {
709
+ r.value = !1;
710
+ }
711
+ }
712
+ async function G() {
713
+ r.value = !0;
714
+ const u = z(s.value);
715
+ try {
716
+ await f.updateSkuGroup(u), r.value = !1, l.value = !1, m.open({
717
+ title: e("inventory.common.success"),
718
+ message: e("inventory.ingredientGroup.update.success", { name: u.name }),
719
+ type: "success"
720
+ });
721
+ } catch (b) {
722
+ b instanceof ae || m.open({
723
+ title: e("inventory.ingredientGroup.update.error.title"),
724
+ message: e("inventory.ingredientGroup.update.error.message"),
725
+ type: "error"
726
+ });
727
+ } finally {
728
+ r.value = !1;
729
+ }
730
+ }
731
+ function x() {
732
+ var u, b;
733
+ (b = (u = p.value) == null ? void 0 : u.validateInputs) == null || b.call(u);
734
+ }
735
+ function R() {
736
+ switch (v.mode) {
737
+ case I.READ:
738
+ return;
739
+ case I.UPDATE:
740
+ return G();
741
+ case I.CREATE:
742
+ return y();
743
+ }
744
+ }
745
+ return (u, b) => {
746
+ const D = h("FmButton"), E = h("FmSideSheet");
747
+ return S(), T(E, {
748
+ "model-value": o(l),
749
+ "onUpdate:modelValue": b[3] || (b[3] = ($) => ye(l) ? l.value = $ : null),
750
+ header: _.value,
751
+ "close-button": "",
752
+ "dismiss-away": "",
753
+ "max-width": 500
754
+ }, {
755
+ "side-sheet-footer": C(() => [
756
+ d("div", ft, [
757
+ g(D, {
758
+ loading: r.value,
759
+ label: c.value,
760
+ onClick: x
761
+ }, null, 8, ["loading", "label"]),
762
+ g(D, {
763
+ disabled: r.value,
764
+ label: o(e)("common.close"),
765
+ variant: "tertiary",
766
+ onClick: b[2] || (b[2] = ($) => l.value = !1)
767
+ }, null, 8, ["disabled", "label"])
768
+ ])
769
+ ]),
770
+ default: C(() => [
771
+ i.value ? (S(), T(mt, {
772
+ menu: i.value,
773
+ class: "w-full",
774
+ ref_key: "hasValidationExpose",
775
+ ref: p,
776
+ key: t.value,
777
+ "model-value": s.value,
778
+ "onUpdate:modelValue": b[0] || (b[0] = ($) => s.value = $),
779
+ mode: u.mode,
780
+ disabled: r.value,
781
+ onValidationSuccess: b[1] || (b[1] = ($) => R())
782
+ }, null, 8, ["menu", "model-value", "mode", "disabled"])) : (S(), B("div", pt, "Loading.."))
783
+ ]),
784
+ _: 1
785
+ }, 8, ["model-value", "header"]);
786
+ };
787
+ }
788
+ }), gt = { class: "flex flex-col py-8" }, yt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _t = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ft = /* @__PURE__ */ j({
789
+ __name: "IngredientGroupView",
790
+ setup(a) {
791
+ const v = P(), f = w(() => v.skuGroups), k = Fe(), { t: i } = U(), {
792
+ createIngredientGroup: m,
793
+ updateIngredientGroup: e,
794
+ importIngredientGroups: l,
795
+ exportIngredientGroups: n
796
+ } = H(), { columnDefs: s, loading: t } = ie(Ue()), { ingredientGroupDialogProps: _ } = ie(H());
797
+ function c(D) {
798
+ switch (D) {
799
+ case "add":
800
+ return m();
801
+ case "import":
802
+ return l();
803
+ case "export":
804
+ return n();
805
+ }
806
+ }
807
+ const p = V(""), r = V(!1), y = w(() => r.value || t.value), { breakpoints: G } = Te(), x = w(() => G.value.xs || G.value.sm), R = w(() => x.value ? 10 : 20), u = Ve(), b = w(() => [
808
+ {
809
+ label: i("inventory.ingredient.create.title"),
810
+ value: "add",
811
+ isPrimary: !0,
812
+ prependIcon: "add"
813
+ },
814
+ { label: i("common.import"), value: "import" },
815
+ { label: i("common.export"), value: "export" }
816
+ ]);
817
+ return (D, E) => {
818
+ const $ = h("FmTable");
819
+ return S(), T(Ce, {
820
+ title: o(i)("inventory.ingredientGroup.title"),
821
+ actions: b.value,
822
+ "onClick:action": c
823
+ }, {
824
+ default: C(() => [
825
+ d("div", {
826
+ class: _e([
827
+ "flex flex-col gap-8 max-h-full",
828
+ {
829
+ "p-0": x.value,
830
+ "px-24 ": !x.value
831
+ }
832
+ ])
833
+ }, [
834
+ g(De, {
835
+ searchable: "",
836
+ search: p.value,
837
+ "onUpdate:search": E[0] || (E[0] = (M) => p.value = M)
838
+ }, null, 8, ["search"]),
839
+ g($, {
840
+ style: be(o(u).tableHeight),
841
+ "column-defs": o(s),
842
+ "row-data": f.value,
843
+ "search-value": p.value,
844
+ loading: !o(k)._currentLocation || y.value,
845
+ "loading-text": "Loading",
846
+ onRowClick: E[1] || (E[1] = (M) => o(e)(M.original)),
847
+ "page-size": R.value
848
+ }, {
849
+ "list-row": C((M) => [
850
+ g($e, {
851
+ row: M,
852
+ onRowClick: o(e)
853
+ }, ke({
854
+ default: C((L) => {
855
+ var Y, Q, W, N, X, Z, ee, te, O, ne;
856
+ return [
857
+ d("div", gt, [
858
+ d("div", yt, [
859
+ g(o(le), {
860
+ render: (W = (Q = (Y = L.code) == null ? void 0 : Y.column) == null ? void 0 : Q.columnDef) == null ? void 0 : W.cell,
861
+ props: (X = (N = L.code) == null ? void 0 : N.getContext) == null ? void 0 : X.call(N)
862
+ }, null, 8, ["render", "props"])
863
+ ]),
864
+ d("div", _t, [
865
+ g(o(le), {
866
+ render: (te = (ee = (Z = L.name) == null ? void 0 : Z.column) == null ? void 0 : ee.columnDef) == null ? void 0 : te.cell,
867
+ props: (ne = (O = L.name) == null ? void 0 : O.getContext) == null ? void 0 : ne.call(O)
868
+ }, null, 8, ["render", "props"])
869
+ ])
870
+ ])
871
+ ];
872
+ }),
873
+ _: 2
874
+ }, [
875
+ r.value ? {
876
+ name: "loading-text",
877
+ fn: C(() => [
878
+ d("div", null, A(o(i)("inventory.ingredient.table.importing")), 1)
879
+ ]),
880
+ key: "0"
881
+ } : void 0
882
+ ]), 1032, ["row", "onRowClick"])
883
+ ]),
884
+ _: 1
885
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
886
+ ], 2),
887
+ (S(), T(xe, { to: "body" }, [
888
+ g(vt, he(we(o(_))), null, 16)
889
+ ]))
890
+ ]),
891
+ _: 1
892
+ }, 8, ["title", "actions"]);
893
+ };
894
+ }
895
+ });
896
+ export {
897
+ Ft as default
898
+ };