@feedmepos/mf-inventory-portal 0.0.19-dev.15 → 0.0.19-dev.17

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 (48) hide show
  1. package/dist/{ApprovalView-CRHU3Bv0.js → ApprovalView-YVJ8rI2M.js} +5 -5
  2. package/dist/{BindingsDialog-ChIRg0d3.js → BindingsDialog-C7ZO5bXe.js} +9 -9
  3. package/dist/{BindingsPicker-BJAbeiDf.js → BindingsPicker-BDsVbM3L.js} +1 -1
  4. package/dist/{BindingsTable-5MxWD_qa.js → BindingsTable-BiVQ4mvK.js} +1 -1
  5. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-vuSl8LVG.js +308 -0
  6. package/dist/{IngredientsView-qXrDtzSK.js → IngredientsView-CKDZsR2e.js} +5 -5
  7. package/dist/{IntegrationView-D6yFqod1.js → IntegrationView-DQZeJKul.js} +2 -2
  8. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DGurlvYg.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DDcFEUcz.js} +1 -1
  9. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-2Ady4pB4.js → PremiumBadge.vue_vue_type_script_setup_true_lang-6plo8rnV.js} +1 -1
  10. package/dist/{PurchaseOrderPrintPreview-BWwjMRqb.js → PurchaseOrderPrintPreview-Df-gYZFA.js} +1 -1
  11. package/dist/{ReceiveRequestView-C94SWDaj.js → ReceiveRequestView-CxW1ONAk.js} +8 -8
  12. package/dist/{RecipeView-CG9H_ZOo.js → RecipeView-B8eIaR2f.js} +4 -4
  13. package/dist/{StockView-BdXGfDNl.js → StockView-CqgqPyvI.js} +8 -8
  14. package/dist/SupplierView-CPHQT1Hn.js +817 -0
  15. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-DktBkwCx.js → TransferDetails.vue_vue_type_script_setup_true_lang-CBmoU3pN.js} +4 -4
  16. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DV6IxKMM.js +1435 -0
  17. package/dist/TransferTemplateView-BR2-tTiQ.js +1290 -0
  18. package/dist/{UnitView-Dx2vWJXi.js → UnitView-vUCf46QM.js} +5 -5
  19. package/dist/{WarehouseView-UkmUZnqH.js → WarehouseView-B3D5kkAU.js} +3 -3
  20. package/dist/api/purchase-order-template.d.ts +4 -0
  21. package/dist/api/supplier.d.ts +6 -4
  22. package/dist/{app-BLzTa0Ut.js → app-Ds9lsiAo.js} +5542 -5522
  23. package/dist/app.js +1 -1
  24. package/dist/{array-AvWd53LI.js → array-ClJzD_Lt.js} +3 -3
  25. package/dist/components/ChangeLocationComponent.vue.d.ts +14 -11
  26. package/dist/components/FmInventoryTableToolbar.vue.d.ts +0 -2
  27. package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
  28. package/dist/{decimal-DLYVb_I_.js → decimal-BZJuYjv-.js} +1 -1
  29. package/dist/format-unit-display-Dw4iQUDG.js +707 -0
  30. package/dist/{id-to-date-CKplrnj_.js → id-to-date-CLG4t5Zp.js} +1 -1
  31. package/dist/layout/SingleColumnLayout.vue.d.ts +1 -0
  32. package/dist/{layout-B9sdKjL9.js → layout-b03Lvqhx.js} +1 -1
  33. package/dist/stores/feature.d.ts +1 -0
  34. package/dist/stores/location.d.ts +1 -0
  35. package/dist/stores/supplier.d.ts +9 -9
  36. package/dist/supplier-C9OQNEl0.js +69 -0
  37. package/dist/tsconfig.app.tsbuildinfo +1 -1
  38. package/dist/views/supplier/components/SupplierDialogProps.d.ts +0 -1
  39. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +583 -1
  40. package/dist/{xlsx-C3AV6UrJ.js → xlsx-B5RUBjKV.js} +1209 -1209
  41. package/dist/{xlsx.util-slrhXhsk.js → xlsx.util-H2UkpLte.js} +4 -4
  42. package/package.json +3 -3
  43. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D0j4VOis.js +0 -306
  44. package/dist/SupplierView-ClL2oc8K.js +0 -813
  45. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BE95F9r1.js +0 -1437
  46. package/dist/TransferTemplateView-BXrNS8pg.js +0 -1279
  47. package/dist/format-unit-display-D_Z4TNZd.js +0 -668
  48. package/dist/supplier-BZ6HZcYB.js +0 -60
@@ -0,0 +1,817 @@
1
+ import { defineComponent as Q, mergeModels as he, computed as g, useModel as Se, resolveComponent as R, openBlock as U, createElementBlock as L, createElementVNode as u, createVNode as c, withCtx as P, toDisplayString as E, unref as l, Fragment as xe, renderList as we, ref as q, createBlock as z, createCommentVNode as X, isRef as ce, watch as ke, normalizeStyle as Ce, Teleport as Ie } from "vue";
2
+ import { u as ye } from "./supplier-C9OQNEl0.js";
3
+ import { D as me, R as O, F as A } from "./row-action.enum-PMKMRrZR.js";
4
+ import { c as Me, _ as $e, F as J, u as Ae } from "./layout-b03Lvqhx.js";
5
+ import { c as Z, u as be, a2 as Ue, d as ve, g as De, y as Fe, C as W, h as Re, R as D, b as Pe, j as ge } from "./app-Ds9lsiAo.js";
6
+ import { useI18n as Y, useCoreStore as Ne } from "@feedmepos/mf-common";
7
+ import { useDialog as Ve, useSnackbar as _e, useProxiedModel as fe, useBreakpoints as Ee } from "@feedmepos/ui-library";
8
+ import { _ as Te, a as Be } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-vuSl8LVG.js";
9
+ import { _ as Le } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
10
+ function qe(F, k) {
11
+ const { t: V } = Y();
12
+ function s(y, n) {
13
+ if (y === O.Edit) {
14
+ F(Z(n));
15
+ return;
16
+ }
17
+ if (y === O.Delete) {
18
+ k(Z(n));
19
+ return;
20
+ }
21
+ }
22
+ return { columnDefs: [
23
+ {
24
+ accessorKey: "name",
25
+ header: () => V("inventory.supplier.table.supplier"),
26
+ enableSorting: !0,
27
+ size: 200
28
+ },
29
+ {
30
+ accessorKey: "contactName",
31
+ header: () => V("inventory.supplier.table.pic"),
32
+ enableSorting: !1,
33
+ size: 250
34
+ },
35
+ {
36
+ accessorKey: "phoneNumber",
37
+ header: () => V("inventory.supplier.table.contact"),
38
+ enableSorting: !1,
39
+ size: 200
40
+ },
41
+ {
42
+ accessorKey: "email",
43
+ header: () => V("inventory.supplier.table.email"),
44
+ enableSorting: !1,
45
+ size: "auto"
46
+ },
47
+ {
48
+ id: "action",
49
+ header: "",
50
+ cell(y) {
51
+ return Me(
52
+ [me[O.Edit], me[O.Delete]],
53
+ (n) => {
54
+ s(n, y.row.original);
55
+ }
56
+ );
57
+ },
58
+ size: 40,
59
+ meta: {
60
+ cellClass: "",
61
+ headerClass: ""
62
+ }
63
+ }
64
+ ] };
65
+ }
66
+ const ze = { class: "flex flex-col gap-12" }, Ye = { class: "flex flex-col" }, He = { class: "flex items-center gap-8 py-8" }, Ke = { class: "flex-1" }, je = { class: "fm-typo-en-title-sm-800" }, Ge = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Oe = { class: "flex flex-col gap-4" }, Je = { class: "flex-1" }, Qe = { class: "flex flex-col" }, We = { class: "fm-typo-en-body-lg-400" }, Xe = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ze = { class: "flex-1" }, et = { class: "flex" }, tt = { class: "text-fm-color-typo-secondary" }, lt = /* @__PURE__ */ Q({
67
+ __name: "SupplierSupplyItemField",
68
+ props: /* @__PURE__ */ he({
69
+ modelValue: {}
70
+ }, {
71
+ modelValue: {},
72
+ modelModifiers: {}
73
+ }),
74
+ emits: ["update:modelValue"],
75
+ setup(F) {
76
+ const k = Ne(), V = be(), s = g(() => V.skus), m = Ve(), { t: y } = Y(), n = Se(F, "modelValue");
77
+ function _() {
78
+ var b;
79
+ const i = V.skus.map((r) => ({
80
+ label: r.name,
81
+ sublabel: r.code,
82
+ value: r._id
83
+ })), h = ((b = n.value) == null ? void 0 : b.map((r) => r.skuId)) ?? [], w = g(
84
+ () => {
85
+ var r;
86
+ return ((r = De(k.currentCountry.value)) == null ? void 0 : r.currency) ?? "MYR";
87
+ }
88
+ );
89
+ m.open({
90
+ title: y("inventory.supplier.supplyItems.selectItem"),
91
+ closeButton: !0,
92
+ contentComponent: Fe,
93
+ contentComponentProps: {
94
+ modelValue: h,
95
+ items: i
96
+ },
97
+ primaryActions: {
98
+ text: "Confirm",
99
+ close: !0
100
+ },
101
+ secondaryActions: {
102
+ text: "Close",
103
+ close: !0,
104
+ variant: "tertiary"
105
+ }
106
+ }).onPrimary((r) => {
107
+ const o = r.map((S) => V.skuById[S]).filter((S) => S);
108
+ o.sort((S, a) => S.code.localeCompare(a.code));
109
+ const p = o.map((S) => {
110
+ var $;
111
+ const a = ($ = n.value) == null ? void 0 : $.find((t) => t.skuId === S._id);
112
+ return a || {
113
+ skuId: S._id,
114
+ defaultCost: S.defaultCost ?? {
115
+ costPerUnit: {
116
+ currency: w.value,
117
+ amount: 0,
118
+ precision: 2
119
+ }
120
+ }
121
+ };
122
+ });
123
+ n.value = p;
124
+ });
125
+ }
126
+ function v(i) {
127
+ switch (i) {
128
+ case W.MY:
129
+ return "MYR";
130
+ case W.SG:
131
+ return "SGD";
132
+ case W.ID:
133
+ return "IDR";
134
+ default:
135
+ return "MYR";
136
+ }
137
+ }
138
+ function N(i) {
139
+ const h = [...(n == null ? void 0 : n.value) ?? []];
140
+ h.splice(i, 1), n.value = h;
141
+ }
142
+ function x(i) {
143
+ var b;
144
+ const h = i.skuId, w = (b = s.value.find((r) => r._id === h)) == null ? void 0 : b.unit;
145
+ if (!w)
146
+ throw new Error(`Cannot find ingredient: ${h}`);
147
+ return w;
148
+ }
149
+ function I(i) {
150
+ return {
151
+ amount: i.defaultCost.costPerUnit,
152
+ measurement: i.defaultCost.measurement
153
+ };
154
+ }
155
+ function M(i, h) {
156
+ const b = (n.value ?? []).map((r) => r.skuId !== i.skuId ? r : {
157
+ ...r,
158
+ defaultCost: {
159
+ ...r.defaultCost,
160
+ measurement: h.measurement,
161
+ costPerUnit: {
162
+ ...r.defaultCost.costPerUnit,
163
+ ...h.amount
164
+ }
165
+ }
166
+ });
167
+ n.value = b;
168
+ }
169
+ return (i, h) => {
170
+ const w = R("FmButton");
171
+ return U(), L("div", ze, [
172
+ u("div", Ye, [
173
+ u("div", He, [
174
+ u("div", Ke, [
175
+ c(Le, { "z-index": 50 }, {
176
+ default: P(() => [
177
+ u("div", je, E(l(y)("inventory.supplier.supplyItems.title")), 1)
178
+ ]),
179
+ _: 1
180
+ })
181
+ ]),
182
+ u("div", null, [
183
+ c(w, {
184
+ "prepend-icon": "link",
185
+ label: l(y)("inventory.supplier.supplyItems.addItems"),
186
+ variant: "plain",
187
+ onClick: _
188
+ }, null, 8, ["label"])
189
+ ])
190
+ ]),
191
+ u("div", Ge, E(l(y)("inventory.supplier.supplyItems.overridePriceHint")), 1)
192
+ ]),
193
+ u("div", Oe, [
194
+ (U(!0), L(xe, null, we(n.value, (b, r) => {
195
+ var o, p, S;
196
+ return U(), L("div", {
197
+ key: b.skuId,
198
+ class: "flex"
199
+ }, [
200
+ u("div", Je, [
201
+ u("div", Qe, [
202
+ u("div", We, E((o = l(V).skuById[b.skuId]) == null ? void 0 : o.name), 1),
203
+ u("div", Xe, E((p = l(V).skuById[b.skuId]) == null ? void 0 : p.code), 1)
204
+ ])
205
+ ]),
206
+ u("div", Ze, [
207
+ u("div", et, [
208
+ c(Ue, {
209
+ "model-value": I(b),
210
+ unit: x(b),
211
+ "onUpdate:modelValue": (a) => M(b, a),
212
+ placement: n.value && r === ((S = n.value) == null ? void 0 : S.length) - 1 ? "top" : "bottom",
213
+ separator: "/",
214
+ "apply-default-rules": "",
215
+ precision: 4,
216
+ "format-minimum-precision": 2
217
+ }, {
218
+ prepend: P(() => {
219
+ var a, f;
220
+ return [
221
+ u("div", tt, E(v(((a = l(k).currentCountry) == null ? void 0 : a.value) ?? l(ve)) === "MYR" ? "RM" : v(((f = l(k).currentCountry) == null ? void 0 : f.value) ?? l(ve))), 1)
222
+ ];
223
+ }),
224
+ _: 2
225
+ }, 1032, ["model-value", "unit", "onUpdate:modelValue", "placement"]),
226
+ u("div", null, [
227
+ c(w, {
228
+ "prepend-icon": "close",
229
+ variant: "tertiary",
230
+ onClick: (a) => N(r)
231
+ }, null, 8, ["onClick"])
232
+ ])
233
+ ])
234
+ ])
235
+ ]);
236
+ }), 128))
237
+ ])
238
+ ]);
239
+ };
240
+ }
241
+ }), ot = { class: "flex flex-col gap-40" }, st = { class: "flex flex-col gap-16" }, nt = { key: 0 }, at = { class: "flex flex-col gap-8" }, rt = { class: "fm-typo-en-title-sm-800" }, ut = { class: "grid grid-cols-2 gap-24" }, it = { class: "flex flex-col gap-8" }, dt = { class: "fm-typo-en-title-sm-800" }, pt = { class: "flex flex-col gap-16" }, ct = {
242
+ key: 0,
243
+ class: "flex flex-col gap-8"
244
+ }, mt = /* @__PURE__ */ Q({
245
+ __name: "SupplierForm",
246
+ props: {
247
+ modelValue: {},
248
+ disabled: { type: Boolean }
249
+ },
250
+ emits: ["update:modelValue", "validation-success"],
251
+ setup(F, { expose: k, emit: V }) {
252
+ const s = F, m = V, y = Pe(), n = be(), _ = g(() => Re(n.skus, "_id")), { t: v } = Y(), N = ge(), x = g(() => N.businessLevel), I = g({
253
+ get() {
254
+ var t;
255
+ return ((t = s.modelValue) == null ? void 0 : t.name) ?? "";
256
+ },
257
+ set(t) {
258
+ const e = s.modelValue ?? {};
259
+ e.name = t, m("update:modelValue", e);
260
+ }
261
+ }), M = g({
262
+ get() {
263
+ var t;
264
+ return ((t = s.modelValue) == null ? void 0 : t.registrationNumber) ?? "";
265
+ },
266
+ set(t) {
267
+ const e = s.modelValue ?? {};
268
+ e.registrationNumber = t, m("update:modelValue", e);
269
+ }
270
+ }), i = g({
271
+ get() {
272
+ var t, e;
273
+ return ((e = (t = s.modelValue) == null ? void 0 : t.address) == null ? void 0 : e.line1) ?? "";
274
+ },
275
+ set(t) {
276
+ const e = s.modelValue ?? {};
277
+ e.address ?? (e.address = {}), e.address.line1 = t, m("update:modelValue", e);
278
+ }
279
+ }), h = g({
280
+ get() {
281
+ var t, e;
282
+ return ((e = (t = s.modelValue) == null ? void 0 : t.address) == null ? void 0 : e.line2) ?? "";
283
+ },
284
+ set(t) {
285
+ const e = s.modelValue ?? {};
286
+ e.address ?? (e.address = {}), e.address.line2 = t, m("update:modelValue", e);
287
+ }
288
+ }), w = g({
289
+ get() {
290
+ var t, e;
291
+ return ((e = (t = s.modelValue) == null ? void 0 : t.address) == null ? void 0 : e.city) ?? "";
292
+ },
293
+ set(t) {
294
+ const e = s.modelValue ?? {};
295
+ e.address ?? (e.address = {}), e.address.city = t, m("update:modelValue", e);
296
+ }
297
+ }), b = g({
298
+ get() {
299
+ var t, e;
300
+ return ((e = (t = s.modelValue) == null ? void 0 : t.address) == null ? void 0 : e.postcode) ?? "";
301
+ },
302
+ set(t) {
303
+ const e = s.modelValue ?? {};
304
+ e.address ?? (e.address = {}), e.address.postcode = t, m("update:modelValue", e);
305
+ }
306
+ }), r = g({
307
+ get() {
308
+ var t, e;
309
+ return ((e = (t = s.modelValue) == null ? void 0 : t.address) == null ? void 0 : e.state) ?? "";
310
+ },
311
+ set(t) {
312
+ const e = s.modelValue ?? {};
313
+ e.address ?? (e.address = {}), e.address.state = t, m("update:modelValue", e);
314
+ }
315
+ }), o = g({
316
+ get() {
317
+ var t, e;
318
+ return ((e = (t = s.modelValue) == null ? void 0 : t.address) == null ? void 0 : e.country) ?? "";
319
+ },
320
+ set(t) {
321
+ const e = s.modelValue ?? {};
322
+ e.address ?? (e.address = {}), e.address.country = t, m("update:modelValue", e);
323
+ }
324
+ }), p = g({
325
+ get() {
326
+ var t;
327
+ return ((t = s.modelValue) == null ? void 0 : t.contactName) ?? "";
328
+ },
329
+ set(t) {
330
+ const e = s.modelValue ?? {};
331
+ e.contactName = t, m("update:modelValue", e);
332
+ }
333
+ }), S = g({
334
+ get() {
335
+ var t;
336
+ return ((t = s.modelValue) == null ? void 0 : t.phoneNumber) ?? "";
337
+ },
338
+ set(t) {
339
+ const e = s.modelValue ?? {};
340
+ e.phoneNumber = t, m("update:modelValue", e);
341
+ }
342
+ }), a = g({
343
+ get() {
344
+ var t;
345
+ return ((t = s.modelValue) == null ? void 0 : t.email) ?? "";
346
+ },
347
+ set(t) {
348
+ const e = s.modelValue ?? {};
349
+ e.email = t, m("update:modelValue", e);
350
+ }
351
+ }), f = g({
352
+ get() {
353
+ var e;
354
+ return (((e = s.modelValue) == null ? void 0 : e.supplyItems) ?? []).filter((T) => _.value[T.skuId]);
355
+ },
356
+ set(t) {
357
+ const e = s.modelValue ?? {};
358
+ e.supplyItems = t, m("update:modelValue", e);
359
+ }
360
+ }), $ = q();
361
+ return k({
362
+ validateInputs: () => {
363
+ var t, e;
364
+ (e = (t = $.value) == null ? void 0 : t.validateInputs) == null || e.call(t);
365
+ },
366
+ resetInputsValidation: () => {
367
+ var t, e;
368
+ (e = (t = $.value) == null ? void 0 : t.resetInputsValidation) == null || e.call(t);
369
+ },
370
+ resetInputs: () => {
371
+ var t, e;
372
+ (e = (t = $.value) == null ? void 0 : t.resetInputs) == null || e.call(t);
373
+ }
374
+ }), (t, e) => {
375
+ const T = R("FmChip"), C = R("FmTextField"), H = R("FmPhoneNumber"), B = R("FmForm");
376
+ return U(), z(B, {
377
+ ref_key: "formRef",
378
+ ref: $,
379
+ onValidationSuccess: e[12] || (e[12] = (d) => m("validation-success"))
380
+ }, {
381
+ default: P(() => [
382
+ u("div", ot, [
383
+ u("div", st, [
384
+ x.value ? (U(), L("div", nt, [
385
+ c(T, {
386
+ label: "Business supplier",
387
+ compact: ""
388
+ })
389
+ ])) : X("", !0),
390
+ c(C, {
391
+ disabled: t.disabled,
392
+ rules: [l(D)()],
393
+ "label-mark": "required",
394
+ label: l(v)("inventory.supplier.companyName"),
395
+ modelValue: I.value,
396
+ "onUpdate:modelValue": e[0] || (e[0] = (d) => I.value = d)
397
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
398
+ c(C, {
399
+ disabled: t.disabled,
400
+ rules: [l(D)()],
401
+ "label-mark": "required",
402
+ label: l(v)("inventory.supplier.registrationNo"),
403
+ modelValue: M.value,
404
+ "onUpdate:modelValue": e[1] || (e[1] = (d) => M.value = d)
405
+ }, null, 8, ["disabled", "rules", "label", "modelValue"])
406
+ ]),
407
+ u("div", at, [
408
+ u("div", rt, E(l(v)("inventory.supplier.address.title")), 1),
409
+ u("div", ut, [
410
+ c(C, {
411
+ disabled: t.disabled,
412
+ rules: [l(D)()],
413
+ "label-mark": "required",
414
+ label: l(v)("inventory.supplier.address.line1"),
415
+ modelValue: i.value,
416
+ "onUpdate:modelValue": e[2] || (e[2] = (d) => i.value = d)
417
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
418
+ c(C, {
419
+ disabled: t.disabled,
420
+ "label-mark": "optional",
421
+ label: l(v)("inventory.supplier.address.line2"),
422
+ modelValue: h.value,
423
+ "onUpdate:modelValue": e[3] || (e[3] = (d) => h.value = d)
424
+ }, null, 8, ["disabled", "label", "modelValue"]),
425
+ c(C, {
426
+ disabled: t.disabled,
427
+ rules: [l(D)()],
428
+ "label-mark": "required",
429
+ label: l(v)("inventory.supplier.address.city"),
430
+ modelValue: w.value,
431
+ "onUpdate:modelValue": e[4] || (e[4] = (d) => w.value = d)
432
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
433
+ c(C, {
434
+ disabled: t.disabled,
435
+ rules: [l(D)()],
436
+ "label-mark": "required",
437
+ label: l(v)("inventory.supplier.address.postcode"),
438
+ modelValue: b.value,
439
+ "onUpdate:modelValue": e[5] || (e[5] = (d) => b.value = d)
440
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
441
+ c(C, {
442
+ disabled: t.disabled,
443
+ rules: [l(D)()],
444
+ "label-mark": "required",
445
+ label: l(v)("inventory.supplier.address.state"),
446
+ modelValue: r.value,
447
+ "onUpdate:modelValue": e[6] || (e[6] = (d) => r.value = d)
448
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
449
+ c(C, {
450
+ disabled: t.disabled,
451
+ rules: [l(D)()],
452
+ "label-mark": "required",
453
+ label: l(v)("inventory.supplier.address.country"),
454
+ modelValue: o.value,
455
+ "onUpdate:modelValue": e[7] || (e[7] = (d) => o.value = d)
456
+ }, null, 8, ["disabled", "rules", "label", "modelValue"])
457
+ ])
458
+ ]),
459
+ u("div", it, [
460
+ u("div", dt, E(l(v)("inventory.supplier.contact.title")), 1),
461
+ u("div", pt, [
462
+ c(C, {
463
+ disabled: t.disabled,
464
+ rules: [l(D)()],
465
+ "label-mark": "required",
466
+ label: l(v)("inventory.supplier.contact.pic"),
467
+ modelValue: p.value,
468
+ "onUpdate:modelValue": e[8] || (e[8] = (d) => p.value = d)
469
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
470
+ c(H, {
471
+ disabled: t.disabled,
472
+ rules: [l(D)()],
473
+ "label-mark": "required",
474
+ label: l(v)("inventory.supplier.contact.phoneNumber"),
475
+ modelValue: S.value,
476
+ "onUpdate:modelValue": e[9] || (e[9] = (d) => S.value = d)
477
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
478
+ c(C, {
479
+ disabled: t.disabled,
480
+ "label-mark": "optional",
481
+ label: l(v)("inventory.supplier.contact.email"),
482
+ modelValue: a.value,
483
+ "onUpdate:modelValue": e[10] || (e[10] = (d) => a.value = d)
484
+ }, null, 8, ["disabled", "label", "modelValue"])
485
+ ])
486
+ ]),
487
+ l(y).enableTotalCost ? (U(), L("div", ct, [
488
+ c(lt, {
489
+ modelValue: f.value,
490
+ "onUpdate:modelValue": e[11] || (e[11] = (d) => f.value = d)
491
+ }, null, 8, ["modelValue"])
492
+ ])) : X("", !0)
493
+ ])
494
+ ]),
495
+ _: 1
496
+ }, 512);
497
+ };
498
+ }
499
+ }), vt = { class: "flex gap-4" }, ft = /* @__PURE__ */ Q({
500
+ __name: "SupplierDialog",
501
+ props: {
502
+ mode: {},
503
+ supplier: {},
504
+ show: { type: Boolean }
505
+ },
506
+ emits: ["update:show", "submitted"],
507
+ setup(F, { expose: k, emit: V }) {
508
+ const s = F, m = V, y = q(!1), n = _e(), { t: _ } = Y(), v = ye(), N = g(() => {
509
+ switch (s.mode) {
510
+ case A.READ:
511
+ return "";
512
+ case A.UPDATE:
513
+ return _("inventory.supplier.update.title");
514
+ case A.CREATE:
515
+ return _("inventory.supplier.create.title");
516
+ }
517
+ return "";
518
+ }), x = g(() => {
519
+ switch (s.mode) {
520
+ case A.READ:
521
+ return "";
522
+ case A.UPDATE:
523
+ return _("common.save");
524
+ case A.CREATE:
525
+ return _("common.add");
526
+ }
527
+ return "";
528
+ }), I = q();
529
+ k({
530
+ validateInputs: () => {
531
+ var o, p;
532
+ (p = (o = I.value) == null ? void 0 : o.validateInputs) == null || p.call(o);
533
+ },
534
+ resetInputsValidation: () => {
535
+ var o, p;
536
+ (p = (o = I.value) == null ? void 0 : o.resetInputsValidation) == null || p.call(o);
537
+ },
538
+ resetInputs: () => {
539
+ var o, p;
540
+ (p = (o = I.value) == null ? void 0 : o.resetInputs) == null || p.call(o);
541
+ }
542
+ });
543
+ const M = fe(s, "show"), i = fe(s, "supplier");
544
+ function h() {
545
+ var o, p;
546
+ (p = (o = I.value) == null ? void 0 : o.validateInputs) == null || p.call(o);
547
+ }
548
+ function w() {
549
+ switch (s.mode) {
550
+ case A.READ:
551
+ return;
552
+ case A.UPDATE:
553
+ return r();
554
+ case A.CREATE:
555
+ return b();
556
+ }
557
+ }
558
+ async function b() {
559
+ y.value = !0;
560
+ try {
561
+ await Promise.all([
562
+ v.createSupplier(i.value),
563
+ new Promise((o) => setTimeout(o, 1e3))
564
+ ]), n.open({
565
+ title: _("common.success"),
566
+ message: _("inventory.supplier.create.success", { name: i.value.name }),
567
+ type: "success"
568
+ }), m("update:show", !1), m("submitted");
569
+ } catch (o) {
570
+ n.open({
571
+ title: "Something went wrong",
572
+ message: `Cannot create ${i.value.name} supplier. Please try again`,
573
+ type: "error"
574
+ }), console.error("cannot create supplier", o);
575
+ } finally {
576
+ y.value = !1;
577
+ }
578
+ }
579
+ async function r() {
580
+ if (i.value === null) {
581
+ n.open({
582
+ title: _("inventory.supplier.update.error.title"),
583
+ message: _("inventory.supplier.update.error.emptySupplier"),
584
+ type: "error"
585
+ });
586
+ return;
587
+ }
588
+ y.value = !0;
589
+ try {
590
+ await Promise.all([
591
+ v.updateSupplier(i.value),
592
+ new Promise((o) => setTimeout(o, 1e3))
593
+ ]), n.open({
594
+ title: _("common.success"),
595
+ message: _("inventory.supplier.update.success", { name: i.value.name }),
596
+ type: "success"
597
+ }), m("update:show", !1), m("submitted");
598
+ } catch (o) {
599
+ n.open({
600
+ title: _("inventory.supplier.update.error.title"),
601
+ message: _("inventory.supplier.update.error.message"),
602
+ type: "error"
603
+ }), console.error("cannot update supplier", o);
604
+ } finally {
605
+ y.value = !1;
606
+ }
607
+ }
608
+ return (o, p) => {
609
+ const S = R("FmButton"), a = R("FmSideSheet");
610
+ return U(), z(a, {
611
+ header: N.value,
612
+ modelValue: l(M),
613
+ "onUpdate:modelValue": p[1] || (p[1] = (f) => ce(M) ? M.value = f : null),
614
+ "dismiss-away": !y.value,
615
+ "close-button": "",
616
+ "max-width": 500
617
+ }, {
618
+ default: P(() => {
619
+ var f;
620
+ return [
621
+ (U(), z(mt, {
622
+ class: "w-full",
623
+ ref_key: "formRef",
624
+ ref: I,
625
+ modelValue: l(i),
626
+ "onUpdate:modelValue": p[0] || (p[0] = ($) => ce(i) ? i.value = $ : null),
627
+ onValidationSuccess: w,
628
+ key: ((f = o.supplier) == null ? void 0 : f._id) ?? "",
629
+ disabled: y.value
630
+ }, null, 8, ["modelValue", "disabled"]))
631
+ ];
632
+ }),
633
+ "side-sheet-footer": P(() => [
634
+ u("div", vt, [
635
+ c(S, {
636
+ loading: y.value,
637
+ label: x.value,
638
+ onClick: h
639
+ }, null, 8, ["loading", "label"])
640
+ ])
641
+ ]),
642
+ _: 1
643
+ }, 8, ["header", "modelValue", "dismiss-away"]);
644
+ };
645
+ }
646
+ }), yt = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, bt = { class: "flex flex-col py-8" }, gt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Vt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _t = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ht = {
647
+ key: 0,
648
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
649
+ }, St = "You are managing business-level supplier list. These suppliers will be made visible to all locations.", Dt = /* @__PURE__ */ Q({
650
+ __name: "SupplierView",
651
+ setup(F) {
652
+ const k = ye(), V = ge(), s = q(!1), m = Ve(), y = _e(), { t: n } = Y();
653
+ V.watchLocation(v);
654
+ const _ = g(() => V.businessLevel);
655
+ ke(_, v);
656
+ async function v() {
657
+ if (V._currentLocation) {
658
+ s.value = !0;
659
+ try {
660
+ await Promise.all([
661
+ k.readSuppliers(),
662
+ new Promise((f) => setTimeout(f, 1e3))
663
+ ]);
664
+ } catch {
665
+ y.open({
666
+ title: "Cannot fetch supplier list",
667
+ type: "error"
668
+ });
669
+ } finally {
670
+ s.value = !1;
671
+ }
672
+ }
673
+ }
674
+ const N = g(
675
+ () => _.value ? k.businessSuppliers : k.locationSuppliers
676
+ ), x = q({});
677
+ function I() {
678
+ x.value.mode = A.CREATE, x.value.supplier = {}, x.value.show = !0;
679
+ }
680
+ function M(a) {
681
+ x.value.mode = A.UPDATE, x.value.supplier = Z(a), x.value.show = !0;
682
+ }
683
+ async function i(a) {
684
+ m.open({
685
+ title: n("inventory.supplier.delete.confirm"),
686
+ message: n("inventory.supplier.delete.confirmMessage", { name: a.name }),
687
+ primaryActions: {
688
+ text: n("common.delete"),
689
+ close: !0,
690
+ variant: "destructive"
691
+ },
692
+ secondaryActions: {
693
+ text: n("common.cancel"),
694
+ close: !0
695
+ }
696
+ }).onPrimary(() => h(a));
697
+ }
698
+ async function h(a) {
699
+ m.open({
700
+ title: n("inventory.supplier.deletingSupplier"),
701
+ closeButton: !1
702
+ });
703
+ try {
704
+ await k.deleteSupplier(a), y.open({
705
+ title: n("inventory.supplier.delete.success"),
706
+ message: n("inventory.supplier.delete.successMessage", { name: a == null ? void 0 : a.name }),
707
+ type: "success"
708
+ }), v();
709
+ } catch (f) {
710
+ y.open({
711
+ title: n("inventory.supplier.delete.error"),
712
+ message: n("inventory.supplier.delete.errorMessage", { name: a == null ? void 0 : a.name }),
713
+ type: "error"
714
+ }), console.error("failed to delete supplier", f);
715
+ } finally {
716
+ m.close();
717
+ }
718
+ }
719
+ const { columnDefs: w } = qe(M, i);
720
+ function b(a) {
721
+ a === "create" && I();
722
+ }
723
+ const r = q(""), { breakpoints: o } = Ee(), p = g(() => o.value.xs || o.value.sm ? 10 : 20), S = Ae();
724
+ return (a, f) => {
725
+ const $ = R("FmTable");
726
+ return U(), z(Te, {
727
+ title: l(n)("inventory.supplier.title"),
728
+ actions: [
729
+ {
730
+ label: l(n)("inventory.supplier.create.title"),
731
+ value: "create",
732
+ isPrimary: !0,
733
+ prependIcon: "add"
734
+ }
735
+ ],
736
+ "onClick:action": b,
737
+ "using-business-helper-text": St
738
+ }, {
739
+ default: P(() => [
740
+ u("div", yt, [
741
+ c(Be, {
742
+ searchable: "",
743
+ "change-location": "",
744
+ search: r.value,
745
+ "onUpdate:search": f[0] || (f[0] = (t) => r.value = t),
746
+ "show-business": "",
747
+ actions: [{ icon: "refresh", onClick: () => v() }]
748
+ }, null, 8, ["search", "actions"]),
749
+ c($, {
750
+ style: Ce(l(S).tableHeight),
751
+ "column-defs": l(w),
752
+ "row-data": N.value,
753
+ "search-value": r.value,
754
+ loading: !l(V)._currentLocation || s.value,
755
+ onRowClick: f[1] || (f[1] = (t) => M(t.original)),
756
+ "page-size": p.value
757
+ }, {
758
+ "list-row": P((t) => [
759
+ c($e, {
760
+ row: t,
761
+ onRowClick: M
762
+ }, {
763
+ default: P((e) => {
764
+ var T, C, H, B, d, ee, te, le, K, oe, se, ne, ae, j, re, ue, ie, de, G, pe;
765
+ return [
766
+ u("div", bt, [
767
+ u("div", gt, [
768
+ c(l(J), {
769
+ render: (H = (C = (T = e.name) == null ? void 0 : T.column) == null ? void 0 : C.columnDef) == null ? void 0 : H.cell,
770
+ props: (d = (B = e.name) == null ? void 0 : B.getContext) == null ? void 0 : d.call(B)
771
+ }, null, 8, ["render", "props"])
772
+ ]),
773
+ u("div", Vt, [
774
+ c(l(J), {
775
+ render: (le = (te = (ee = e.contactName) == null ? void 0 : ee.column) == null ? void 0 : te.columnDef) == null ? void 0 : le.cell,
776
+ props: (oe = (K = e.contactName) == null ? void 0 : K.getContext) == null ? void 0 : oe.call(K)
777
+ }, null, 8, ["render", "props"])
778
+ ]),
779
+ u("div", _t, [
780
+ c(l(J), {
781
+ render: (ae = (ne = (se = e.phoneNumber) == null ? void 0 : se.column) == null ? void 0 : ne.columnDef) == null ? void 0 : ae.cell,
782
+ props: (re = (j = e.phoneNumber) == null ? void 0 : j.getContext) == null ? void 0 : re.call(j)
783
+ }, null, 8, ["render", "props"])
784
+ ]),
785
+ t.original.email ? (U(), L("div", ht, [
786
+ c(l(J), {
787
+ render: (de = (ie = (ue = e.email) == null ? void 0 : ue.column) == null ? void 0 : ie.columnDef) == null ? void 0 : de.cell,
788
+ props: (pe = (G = e.email) == null ? void 0 : G.getContext) == null ? void 0 : pe.call(G)
789
+ }, null, 8, ["render", "props"])
790
+ ])) : X("", !0)
791
+ ])
792
+ ];
793
+ }),
794
+ _: 2
795
+ }, 1032, ["row"])
796
+ ]),
797
+ _: 1
798
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
799
+ ]),
800
+ (U(), z(Ie, { to: "body" }, [
801
+ c(ft, {
802
+ show: x.value.show,
803
+ "onUpdate:show": f[2] || (f[2] = (t) => x.value.show = t),
804
+ supplier: x.value.supplier,
805
+ mode: x.value.mode,
806
+ onSubmitted: f[3] || (f[3] = (t) => v())
807
+ }, null, 8, ["show", "supplier", "mode"])
808
+ ]))
809
+ ]),
810
+ _: 1
811
+ }, 8, ["title", "actions"]);
812
+ };
813
+ }
814
+ });
815
+ export {
816
+ Dt as default
817
+ };