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