@feedmepos/mf-inventory-portal 0.0.19-dev.1 → 0.0.19-dev.2

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