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