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