@feedmepos/mf-inventory-portal 0.0.17-dev.5 → 0.0.17-dev.6

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