@feedmepos/mf-inventory-portal 0.0.22-dev.1 → 0.0.22-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 (45) hide show
  1. package/dist/{ApprovalView-CtH8I01g.js → ApprovalView-BnkFRJgX.js} +19 -19
  2. package/dist/{BindingsDialog-DFrk_fyd.js → BindingsDialog-BDzmf8Wr.js} +1 -1
  3. package/dist/{BindingsPicker-400gISaV.js → BindingsPicker-CRGFd-d8.js} +1 -1
  4. package/dist/{BindingsTable-CnFKI6iP.js → BindingsTable-BnHju77G.js} +1 -1
  5. package/dist/ClosingTemplateView-D2EIa9YG.js +1030 -0
  6. package/dist/Entry.vue.d.ts +2 -0
  7. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-B9RU_arW.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BRV9dZhu.js} +13 -15
  8. package/dist/{IngredientsView-CRTAgKJz.js → IngredientsView-CiUpjKmC.js} +3 -3
  9. package/dist/{IntegrationView-CNFTKqjk.js → IntegrationView-UySDEAnh.js} +2 -2
  10. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-VkiVLx1K.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Cxy6vo9D.js} +1 -1
  11. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DkZrgqyr.js → PremiumBadge.vue_vue_type_script_setup_true_lang-ChrCZc0C.js} +1 -1
  12. package/dist/{PurchaseOrderPrintPreview-CJli-_Vn.js → PurchaseOrderPrintPreview-CGxMILW0.js} +1 -1
  13. package/dist/{ReceiveRequestView-DV_GDzJG.js → ReceiveRequestView-BHOC-ZLV.js} +13 -13
  14. package/dist/{RecipeView-CTm_7oNG.js → RecipeView-lgrm1J9x.js} +3 -3
  15. package/dist/Standalone.vue.d.ts +2 -0
  16. package/dist/{StockView-DtHT2ulM.js → StockView-BcXcQZpl.js} +6 -6
  17. package/dist/{SupplierView-B9A5R2Vm.js → SupplierView-Bl13ZM-9.js} +3 -3
  18. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-mUNCQTNw.js → TransferDetails.vue_vue_type_script_setup_true_lang-SXFiNrtm.js} +4 -4
  19. package/dist/{TransferDialog.vue_vue_type_script_setup_true_lang-BwkUuXqj.js → TransferDialog.vue_vue_type_script_setup_true_lang-DSBEn-Mt.js} +328 -347
  20. package/dist/{TransferTemplateView-DnyenkGu.js → TransferTemplateView-C_eqQ9a8.js} +47 -166
  21. package/dist/{UnitView-BL-jtVuZ.js → UnitView-DG8PGv5Y.js} +4 -4
  22. package/dist/WarehouseView-CeS8jrgw.js +1017 -0
  23. package/dist/api/closing-template.d.ts +14 -0
  24. package/dist/{app-C-z1MfF6.js → app-DYhspC_r.js} +12005 -11839
  25. package/dist/app.js +3 -3
  26. package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
  27. package/dist/components/VirtualScroll.vue.d.ts +47 -0
  28. package/dist/{decimal-DZz-_lgE.js → decimal-DwEh3AcZ.js} +1 -1
  29. package/dist/{defineDeepModel-7VQajdPt.js → defineDeepModel-htf7zxRR.js} +1 -1
  30. package/dist/extensions/promises.d.ts +14 -0
  31. package/dist/{format-time-from-id-9XFszs1J.js → format-time-from-id-1BxShIsX.js} +1 -1
  32. package/dist/helper/date2.d.ts +1 -0
  33. package/dist/{id-to-date-Bkue77uI.js → id-to-date-CzSDsYm2.js} +1 -1
  34. package/dist/{purchase-order-transaction-type-DHzMBgFs.js → purchase-order-transaction-type-lwIoC03T.js} +10 -10
  35. package/dist/style.css +1 -1
  36. package/dist/{supplier-C6YWXF2Y.js → supplier-DegAxD_n.js} +1 -1
  37. package/dist/tsconfig.app.tsbuildinfo +1 -1
  38. package/dist/{use-template-enabled-locations-CFCfbaOd.js → use-template-enabled-locations-B2ZtZAoX.js} +1 -1
  39. package/dist/views/closing-template/components/closing-template-publish/ClosingTemplatePublish.vue.d.ts +6 -0
  40. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +65 -1
  41. package/dist/{xlsx-Dl6dAHFx.js → xlsx-CSS2klUs.js} +1 -1
  42. package/dist/{xlsx.util-C1tUhDb8.js → xlsx.util-CeY18XxV.js} +2 -2
  43. package/package.json +1 -1
  44. package/dist/ClosingTemplateView--8m8cua_.js +0 -919
  45. package/dist/WarehouseView-BkUv1792.js +0 -1056
@@ -0,0 +1,1017 @@
1
+ import { ref as W, defineComponent as j, watch as ee, onMounted as te, onUnmounted as Fe, openBlock as S, createElementBlock as z, toRaw as be, reactive as xe, createElementVNode as g, toDisplayString as U, unref as c, createVNode as V, resolveComponent as L, createSlots as $e, withCtx as N, createTextVNode as We, renderSlot as De, createBlock as I, createCommentVNode as Ae, computed as F, isRef as we, normalizeClass as Se, normalizeStyle as Re } from "vue";
2
+ import { n as Pe, T as Te, V as Ue, c as G, W as ae, X as le, Y as Ee, i as Le, R as E, j as Ne } from "./app-DYhspC_r.js";
3
+ import { useCoreStore as Be, useI18n as q } from "@feedmepos/mf-common";
4
+ import { D as Ve, R as Z, F as T } from "./row-action.enum-PMKMRrZR.js";
5
+ import { c as qe, _ as ze, F as J } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
6
+ import { u as Ie, _ as je, a as Oe } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BRV9dZhu.js";
7
+ import { useDialogChild as Ge, useDialog as Me, useSnackbar as se, useProxiedModel as oe, useBreakpoints as Ke } from "@feedmepos/ui-library";
8
+ const Q = Pe((m, h) => {
9
+ const y = Be();
10
+ return {
11
+ async readWarehouses() {
12
+ var l;
13
+ const a = ((l = y.currentBusiness.value) == null ? void 0 : l._id) ?? "", n = `${m.inventoryBackendUrl}/businesses/${a}/warehouses`;
14
+ return await h.get(n);
15
+ },
16
+ async createWarehouse(a) {
17
+ var p;
18
+ const n = ((p = y.currentBusiness.value) == null ? void 0 : p._id) ?? "", l = `${m.inventoryBackendUrl}/businesses/${n}/warehouse`;
19
+ return await h.post(l, a);
20
+ },
21
+ async updateWarehouse(a, n) {
22
+ var r;
23
+ const l = ((r = y.currentBusiness.value) == null ? void 0 : r._id) ?? "", p = `${m.inventoryBackendUrl}/businesses/${l}/warehouse/${a}`;
24
+ return await h.put(p, n);
25
+ },
26
+ async deleteWarehouse(a) {
27
+ var p;
28
+ const n = ((p = y.currentBusiness.value) == null ? void 0 : p._id) ?? "", l = `${m.inventoryBackendUrl}/businesses/${n}/warehouse/${a}`;
29
+ return await h.delete(l);
30
+ }
31
+ };
32
+ });
33
+ function He() {
34
+ return {
35
+ warehouses: []
36
+ };
37
+ }
38
+ const _e = W(He());
39
+ function Ce() {
40
+ return {
41
+ // state
42
+ get warehouses() {
43
+ return _e.value.warehouses;
44
+ },
45
+ set warehouses(m) {
46
+ _e.value.warehouses = m;
47
+ },
48
+ // actions
49
+ async readWarehouses() {
50
+ const m = Q();
51
+ this.warehouses = await m.readWarehouses();
52
+ },
53
+ async createWarehouse(m) {
54
+ await Q().createWarehouse(m);
55
+ },
56
+ async updateWarehouse(m) {
57
+ await Q().updateWarehouse(m._id, m.profile);
58
+ },
59
+ async deleteWarehouse(m) {
60
+ await Q().deleteWarehouse(m._id);
61
+ },
62
+ async init() {
63
+ const m = Te();
64
+ try {
65
+ await this.readWarehouses();
66
+ } catch (h) {
67
+ throw h instanceof Ue || m.error("Error at reading warehouses"), h;
68
+ }
69
+ }
70
+ };
71
+ }
72
+ function Xe(m, h) {
73
+ function y(p, r) {
74
+ if (p === Z.Edit) {
75
+ m(G(r));
76
+ return;
77
+ }
78
+ if (p === Z.Delete) {
79
+ h(G(r));
80
+ return;
81
+ }
82
+ }
83
+ const { t: a } = q(), n = [
84
+ {
85
+ accessorKey: "warehouse",
86
+ header: () => a("inventory.warehouse.table.warehouse"),
87
+ size: 200
88
+ },
89
+ {
90
+ accessorKey: "contact",
91
+ header: () => a("inventory.warehouse.table.contact"),
92
+ size: 200
93
+ },
94
+ {
95
+ accessorKey: "email",
96
+ header: () => a("inventory.warehouse.table.email"),
97
+ size: 200
98
+ },
99
+ {
100
+ accessorKey: "address",
101
+ header: () => a("inventory.warehouse.table.address"),
102
+ size: "auto"
103
+ },
104
+ {
105
+ id: "action",
106
+ header: "",
107
+ cell(p) {
108
+ return qe(
109
+ [Ve[Z.Edit], Ve[Z.Delete]],
110
+ (r) => {
111
+ y(r, p.row.original.original);
112
+ }
113
+ );
114
+ },
115
+ enableSorting: !1,
116
+ size: 40,
117
+ meta: {
118
+ cellClass: "",
119
+ headerClass: ""
120
+ }
121
+ }
122
+ ];
123
+ function l(p) {
124
+ return p.map((r) => ({
125
+ original: r,
126
+ warehouse: r.profile.name,
127
+ contact: r.profile.phoneNo,
128
+ email: r.profile.email,
129
+ get address() {
130
+ const u = r.profile.address;
131
+ return [
132
+ u == null ? void 0 : u.line1,
133
+ u == null ? void 0 : u.line2,
134
+ u == null ? void 0 : u.city,
135
+ u == null ? void 0 : u.postcode,
136
+ u == null ? void 0 : u.state,
137
+ u == null ? void 0 : u.country
138
+ ].map((v) => v == null ? void 0 : v.trim()).filter((v) => v).join(", ");
139
+ }
140
+ }));
141
+ }
142
+ return { columnDefs: n, formatRowData: l };
143
+ }
144
+ const Ye = /* @__PURE__ */ j({
145
+ __name: "GoogleMap",
146
+ props: {
147
+ markers: {
148
+ type: Array,
149
+ default: () => []
150
+ },
151
+ polygons: {
152
+ type: Array,
153
+ default: () => []
154
+ },
155
+ zoom: {
156
+ type: Number,
157
+ default: 14
158
+ },
159
+ editable: {
160
+ type: Boolean,
161
+ default: !1
162
+ },
163
+ center: {
164
+ type: Object,
165
+ default: ae.jb
166
+ }
167
+ },
168
+ emits: ["map-click", "marker-change", "polygon-change", "polygon-right-click"],
169
+ setup(m, { expose: h, emit: y }) {
170
+ const a = m, n = y;
171
+ h({
172
+ setCenter: (s) => {
173
+ var f, b;
174
+ (f = r.value) == null || f.setCenter(s), (b = r.value) == null || b.setZoom(18);
175
+ }
176
+ });
177
+ const { googleMap: l } = le(), p = W(), r = W(null), u = [];
178
+ function _(s) {
179
+ return {
180
+ lat: s.latLng.lat(),
181
+ lng: s.latLng.lng()
182
+ };
183
+ }
184
+ function v(s, f, b) {
185
+ const x = l.maps.event.addListener(s, f, b);
186
+ u.push(x);
187
+ }
188
+ const M = W([]);
189
+ function $(s, f, b) {
190
+ v(s, f, b);
191
+ }
192
+ function C(s) {
193
+ R(null), M.value = s.map((f, b) => {
194
+ const x = new l.maps.Marker({
195
+ position: f,
196
+ draggable: !0
197
+ });
198
+ return $(x, "dragend", (D) => {
199
+ n("marker-change", { index: b, position: _(D) });
200
+ }), x;
201
+ }), R(r.value);
202
+ }
203
+ function R(s) {
204
+ M.value.map((f) => be(f).setMap(s));
205
+ }
206
+ const d = W([]);
207
+ function k(s, f, b) {
208
+ v(s, f, b);
209
+ }
210
+ function A(s, f, b) {
211
+ v(s, f, b);
212
+ }
213
+ function o(s) {
214
+ return d.value[s].getPath().getArray().map(({ lat: b, lng: x }) => ({
215
+ lat: b(),
216
+ lng: x()
217
+ }));
218
+ }
219
+ function e(s) {
220
+ const f = o(s);
221
+ n("polygon-change", { index: s, path: f });
222
+ }
223
+ function t(s, f) {
224
+ const x = o(s).filter((D, K) => K !== f);
225
+ n("polygon-change", { index: s, path: x });
226
+ }
227
+ function B(s, f) {
228
+ f.vertex !== void 0 ? t(s, f.vertex) : n("polygon-right-click", s);
229
+ }
230
+ function w(s) {
231
+ i(null), d.value = s.map((f, b) => {
232
+ const x = new l.maps.Polygon({
233
+ paths: f.paths,
234
+ strokeColor: f.strokeColor,
235
+ fillColor: f.fillColor,
236
+ fillOpacity: 0.5,
237
+ editable: a.editable
238
+ });
239
+ return k(x, "contextmenu", (D) => B(b, D)), x.getPaths().forEach((D) => {
240
+ A(D, "insert_at", () => e(b)), A(D, "set_at", () => e(b));
241
+ }), x;
242
+ }), i(r.value);
243
+ }
244
+ function i(s) {
245
+ d.value.map((f) => be(f).setMap(s));
246
+ }
247
+ function O(s, f, b) {
248
+ v(s, f, b);
249
+ }
250
+ function P() {
251
+ r.value = new l.maps.Map(p.value, {
252
+ center: a.center,
253
+ zoom: a.zoom,
254
+ mapTypeControl: !1,
255
+ streetViewControl: !1,
256
+ draggable: !0,
257
+ scrollwheel: !0
258
+ }), O(r.value, "click", (s) => n("map-click", _(s)));
259
+ }
260
+ return ee(() => a.markers, C, { deep: !0 }), ee(() => a.polygons, w, { deep: !0 }), te(() => {
261
+ !p.value || !l || (P(), C(a.markers), w(a.polygons));
262
+ }), Fe(() => {
263
+ u.forEach((s) => s.remove());
264
+ }), (s, f) => (S(), z("div", {
265
+ ref_key: "mapRef",
266
+ ref: p,
267
+ class: "map app-map"
268
+ }, null, 512));
269
+ }
270
+ }), Ze = { class: "flex flex-col gap-24" }, Je = { class: "flex flex-col gap-8" }, Qe = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, eo = { class: "fm-typo-en-body-lg-600" }, oo = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, to = { class: "fm-typo-en-body-lg-600" }, ao = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, lo = { class: "fm-typo-en-body-lg-600" }, so = /* @__PURE__ */ j({
271
+ __name: "CoordinateDialog",
272
+ props: {
273
+ address: {
274
+ type: String,
275
+ required: !0
276
+ },
277
+ coordinate: {
278
+ type: Object,
279
+ default: void 0
280
+ }
281
+ },
282
+ setup(m) {
283
+ const h = m, y = Ge(), a = le(), { t: n } = q(), l = xe(
284
+ G(h.coordinate ? h.coordinate : ae.jb)
285
+ ), p = W(""), r = Ee(async function() {
286
+ p.value = await a.getFirstMatchingAddress(
287
+ l.lat,
288
+ l.lng
289
+ );
290
+ }, 1e3);
291
+ te(() => {
292
+ y.emitData(G(l)), r();
293
+ });
294
+ function u({ position: v }) {
295
+ l.lat = v.lat, l.lng = v.lng, y.emitData(G(l)), r();
296
+ }
297
+ const _ = W();
298
+ return (v, M) => (S(), z("div", Ze, [
299
+ g("div", Je, [
300
+ g("div", null, [
301
+ g("span", Qe, U(c(n)("inventory.formField.coordinate.address")) + ": ", 1),
302
+ g("span", eo, U(p.value), 1)
303
+ ]),
304
+ g("div", null, [
305
+ g("span", oo, U(c(n)("inventory.formField.coordinate.longitude")) + ": ", 1),
306
+ g("span", to, U(l.lng), 1)
307
+ ]),
308
+ g("div", null, [
309
+ g("span", ao, U(c(n)("inventory.formField.coordinate.latitude")) + ": ", 1),
310
+ g("span", lo, U(l.lat), 1)
311
+ ])
312
+ ]),
313
+ V(Ye, {
314
+ ref_key: "gmapRef",
315
+ ref: _,
316
+ class: "h-[272px] sm:h-[240px] xs:h-[240px]",
317
+ editable: "",
318
+ center: l,
319
+ markers: [l],
320
+ onMarkerChange: u,
321
+ onMapClick: M[0] || (M[0] = ($) => u({ position: $ }))
322
+ }, null, 8, ["center", "markers"])
323
+ ]));
324
+ }
325
+ }), ro = /* @__PURE__ */ Le(so, [["__scopeId", "data-v-272f5e8b"]]);
326
+ function ke([m, h]) {
327
+ return {
328
+ lat: h,
329
+ lng: m
330
+ };
331
+ }
332
+ function no({ lng: m, lat: h }) {
333
+ return [m, h];
334
+ }
335
+ const uo = { class: "flex gap-8 items-center" }, io = { key: 0 }, co = { key: 1 }, po = /* @__PURE__ */ j({
336
+ __name: "FmCoordinateInput",
337
+ props: {
338
+ address: {},
339
+ modelValue: {},
340
+ dialogTitle: {},
341
+ label: {},
342
+ helperText: {},
343
+ helperState: {},
344
+ labelMark: {},
345
+ labelInfo: {},
346
+ placeholder: {},
347
+ disabled: { type: Boolean },
348
+ rules: {}
349
+ },
350
+ emits: ["update:modelValue"],
351
+ setup(m, { emit: h }) {
352
+ const y = m, a = h, n = le(), l = Me(), p = se(), r = oe(y, "modelValue"), u = W(!1), { t: _ } = q();
353
+ function v(d) {
354
+ if (d != null && d[0] && (d != null && d[1]))
355
+ return _("inventory.formField.coordinate.longLat", [d[0].toFixed(3), d[1].toFixed(3)]);
356
+ }
357
+ async function M(d) {
358
+ var e, t;
359
+ const k = y.modelValue, A = !k && ((e = y.address) != null && e.formatted) ? await n.getFirstMatchingCoordinate(y.address.formatted) : null, o = k ? ke(k) : A ? ke(A) : ae.jb;
360
+ l.open({
361
+ title: y.dialogTitle ?? y.label ?? _("inventory.formField.coordinate.pinLocation"),
362
+ closeButton: !0,
363
+ contentComponent: ro,
364
+ contentComponentProps: {
365
+ address: (t = y.address) == null ? void 0 : t.formatted,
366
+ coordinate: o
367
+ },
368
+ primaryActions: {
369
+ text: _("common.select"),
370
+ close: !0
371
+ },
372
+ secondaryActions: {
373
+ text: _("common.close"),
374
+ close: !0
375
+ }
376
+ }).onPrimary(d);
377
+ }
378
+ const $ = (d) => a("update:modelValue", d ? no(d) : null);
379
+ async function C() {
380
+ if (!y.disabled) {
381
+ if (!n.isGoogleMapReady) {
382
+ p.open({
383
+ title: _("common.error"),
384
+ message: _("inventory.formField.coordinate.error.loadMap"),
385
+ type: "error"
386
+ });
387
+ return;
388
+ }
389
+ M($);
390
+ }
391
+ }
392
+ function R() {
393
+ a("update:modelValue", null);
394
+ }
395
+ return (d, k) => {
396
+ const A = L("FmField"), o = L("FmButton"), e = L("FmFormGroup");
397
+ return S(), z("div", uo, [
398
+ V(e, {
399
+ class: "flex-1",
400
+ "model-value": c(r),
401
+ label: d.label,
402
+ disabled: d.disabled,
403
+ required: d.labelMark === "required",
404
+ optional: d.labelMark === "optional",
405
+ info: d.labelInfo,
406
+ rules: d.rules,
407
+ focused: u.value,
408
+ "helper-text": d.helperText,
409
+ "helper-state": d.helperState,
410
+ onClick: k[0] || (k[0] = (t) => C())
411
+ }, $e({
412
+ default: N(({ invalid: t }) => [
413
+ d.modelValue && d.modelValue[0] && d.modelValue[1] ? (S(), z("div", io, [
414
+ V(A, {
415
+ invalid: t,
416
+ class: "fm-typo-en-body-lg-400"
417
+ }, {
418
+ default: N(() => [
419
+ We(U(v(d.modelValue)), 1)
420
+ ]),
421
+ _: 2
422
+ }, 1032, ["invalid"])
423
+ ])) : (S(), z("div", co, [
424
+ V(o, {
425
+ label: c(_)("inventory.formField.coordinate.addCoordinate"),
426
+ "prepend-icon": "add",
427
+ variant: "plain"
428
+ }, null, 8, ["label"])
429
+ ]))
430
+ ]),
431
+ _: 2
432
+ }, [
433
+ d.$slots.label ? {
434
+ name: "label",
435
+ fn: N(() => [
436
+ De(d.$slots, "label")
437
+ ]),
438
+ key: "0"
439
+ } : void 0
440
+ ]), 1032, ["model-value", "label", "disabled", "required", "optional", "info", "rules", "focused", "helper-text", "helper-state"]),
441
+ d.modelValue && d.modelValue[0] && d.modelValue[1] ? (S(), I(o, {
442
+ key: 0,
443
+ "prepend-icon": "delete",
444
+ variant: "tertiary",
445
+ onClick: k[1] || (k[1] = (t) => R())
446
+ })) : Ae("", !0)
447
+ ]);
448
+ };
449
+ }
450
+ }), mo = { class: "flex flex-col gap-40" }, fo = { class: "flex flex-col gap-16" }, ho = { class: "flex flex-col gap-8" }, yo = { class: "fm-typo-en-title-sm-800" }, vo = { class: "grid grid-cols-2 gap-24" }, go = { class: "flex flex-col gap-8" }, bo = { class: "fm-typo-en-title-sm-800" }, wo = { class: "flex flex-col gap-8" }, Vo = { class: "fm-typo-en-title-sm-800" }, _o = { class: "flex flex-col gap-16" }, ko = /* @__PURE__ */ j({
451
+ __name: "WarehouseForm",
452
+ props: {
453
+ modelValue: {},
454
+ disabled: { type: Boolean }
455
+ },
456
+ emits: ["update:modelValue", "validation-success"],
457
+ setup(m, { expose: h, emit: y }) {
458
+ const a = m, n = y, { t: l } = q(), p = F({
459
+ get() {
460
+ var o, e;
461
+ return ((e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.name) ?? "";
462
+ },
463
+ set(o) {
464
+ const e = a.modelValue ?? {};
465
+ e.profile ?? (e.profile = {}), e.profile.name = o, n("update:modelValue", e);
466
+ }
467
+ }), r = F({
468
+ get() {
469
+ var o, e;
470
+ return ((e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.regNo) ?? "";
471
+ },
472
+ set(o) {
473
+ const e = a.modelValue ?? {};
474
+ e.profile ?? (e.profile = {}), e.profile.regNo = o, n("update:modelValue", e);
475
+ }
476
+ }), u = F({
477
+ get() {
478
+ var o, e, t;
479
+ return ((t = (e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.address) == null ? void 0 : t.line1) ?? "";
480
+ },
481
+ set(o) {
482
+ var t;
483
+ const e = a.modelValue ?? {};
484
+ e.profile ?? (e.profile = {}), (t = e.profile).address ?? (t.address = {}), e.profile.address.line1 = o, n("update:modelValue", e);
485
+ }
486
+ }), _ = F({
487
+ get() {
488
+ var o, e, t;
489
+ return ((t = (e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.address) == null ? void 0 : t.line2) ?? "";
490
+ },
491
+ set(o) {
492
+ var t;
493
+ const e = a.modelValue ?? {};
494
+ e.profile ?? (e.profile = {}), (t = e.profile).address ?? (t.address = {}), e.profile.address.line2 = o, n("update:modelValue", e);
495
+ }
496
+ }), v = F({
497
+ get() {
498
+ var o, e, t;
499
+ return ((t = (e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.address) == null ? void 0 : t.city) ?? "";
500
+ },
501
+ set(o) {
502
+ var t;
503
+ const e = a.modelValue ?? {};
504
+ e.profile ?? (e.profile = {}), (t = e.profile).address ?? (t.address = {}), e.profile.address.city = o, n("update:modelValue", e);
505
+ }
506
+ }), M = F({
507
+ get() {
508
+ var o, e, t;
509
+ return ((t = (e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.address) == null ? void 0 : t.postcode) ?? "";
510
+ },
511
+ set(o) {
512
+ var t;
513
+ const e = a.modelValue ?? {};
514
+ e.profile ?? (e.profile = {}), (t = e.profile).address ?? (t.address = {}), e.profile.address.postcode = o, n("update:modelValue", e);
515
+ }
516
+ }), $ = F({
517
+ get() {
518
+ var o, e, t;
519
+ return ((t = (e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.address) == null ? void 0 : t.state) ?? "";
520
+ },
521
+ set(o) {
522
+ var t;
523
+ const e = a.modelValue ?? {};
524
+ e.profile ?? (e.profile = {}), (t = e.profile).address ?? (t.address = {}), e.profile.address.state = o, n("update:modelValue", e);
525
+ }
526
+ }), C = F({
527
+ get() {
528
+ var o, e, t;
529
+ return ((t = (e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.address) == null ? void 0 : t.country) ?? "";
530
+ },
531
+ set(o) {
532
+ var t;
533
+ const e = a.modelValue ?? {};
534
+ e.profile ?? (e.profile = {}), (t = e.profile).address ?? (t.address = {}), e.profile.address.country = o, n("update:modelValue", e);
535
+ }
536
+ }), R = F({
537
+ get() {
538
+ var o, e, t;
539
+ return ((t = (e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.address) == null ? void 0 : t.coordinates) ?? null;
540
+ },
541
+ set(o) {
542
+ var t;
543
+ const e = a.modelValue ?? {};
544
+ e.profile ?? (e.profile = {}), (t = e.profile).address ?? (t.address = {}), e.profile.address.coordinates = o, n("update:modelValue", e);
545
+ }
546
+ }), d = F({
547
+ get() {
548
+ var o, e;
549
+ return ((e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.phoneNo) ?? "";
550
+ },
551
+ set(o) {
552
+ const e = a.modelValue ?? {};
553
+ e.profile ?? (e.profile = {}), e.profile.phoneNo = o, n("update:modelValue", e);
554
+ }
555
+ }), k = F({
556
+ get() {
557
+ var o, e;
558
+ return ((e = (o = a.modelValue) == null ? void 0 : o.profile) == null ? void 0 : e.email) ?? "";
559
+ },
560
+ set(o) {
561
+ const e = a.modelValue ?? {};
562
+ e.profile ?? (e.profile = {}), e.profile.email = o, n("update:modelValue", e);
563
+ }
564
+ }), A = W();
565
+ return h({
566
+ validateInputs: () => {
567
+ var o, e;
568
+ (e = (o = A.value) == null ? void 0 : o.validateInputs) == null || e.call(o);
569
+ },
570
+ resetInputsValidation: () => {
571
+ var o, e;
572
+ (e = (o = A.value) == null ? void 0 : o.resetInputsValidation) == null || e.call(o);
573
+ },
574
+ resetInputs: () => {
575
+ var o, e;
576
+ (e = (o = A.value) == null ? void 0 : o.resetInputs) == null || e.call(o);
577
+ }
578
+ }), (o, e) => {
579
+ const t = L("FmTextField"), B = L("FmPhoneNumber"), w = L("FmForm");
580
+ return S(), I(w, {
581
+ ref_key: "formRef",
582
+ ref: A,
583
+ onValidationSuccess: e[11] || (e[11] = (i) => n("validation-success"))
584
+ }, {
585
+ default: N(() => [
586
+ g("div", mo, [
587
+ g("div", fo, [
588
+ V(t, {
589
+ disabled: o.disabled,
590
+ rules: [c(E)()],
591
+ "label-mark": "required",
592
+ label: c(l)("inventory.warehouse.companyName"),
593
+ modelValue: p.value,
594
+ "onUpdate:modelValue": e[0] || (e[0] = (i) => p.value = i)
595
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
596
+ V(t, {
597
+ disabled: o.disabled,
598
+ rules: [c(E)()],
599
+ "label-mark": "required",
600
+ label: c(l)("inventory.warehouse.registrationNo"),
601
+ modelValue: r.value,
602
+ "onUpdate:modelValue": e[1] || (e[1] = (i) => r.value = i)
603
+ }, null, 8, ["disabled", "rules", "label", "modelValue"])
604
+ ]),
605
+ g("div", ho, [
606
+ g("div", yo, U(c(l)("inventory.warehouse.address.title")), 1),
607
+ g("div", vo, [
608
+ V(t, {
609
+ disabled: o.disabled,
610
+ rules: [c(E)()],
611
+ "label-mark": "required",
612
+ label: c(l)("inventory.warehouse.address.line1"),
613
+ modelValue: u.value,
614
+ "onUpdate:modelValue": e[2] || (e[2] = (i) => u.value = i)
615
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
616
+ V(t, {
617
+ disabled: o.disabled,
618
+ "label-mark": "optional",
619
+ label: c(l)("inventory.warehouse.address.line2"),
620
+ modelValue: _.value,
621
+ "onUpdate:modelValue": e[3] || (e[3] = (i) => _.value = i)
622
+ }, null, 8, ["disabled", "label", "modelValue"]),
623
+ V(t, {
624
+ disabled: o.disabled,
625
+ rules: [c(E)()],
626
+ "label-mark": "required",
627
+ label: c(l)("inventory.warehouse.address.city"),
628
+ modelValue: v.value,
629
+ "onUpdate:modelValue": e[4] || (e[4] = (i) => v.value = i)
630
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
631
+ V(t, {
632
+ disabled: o.disabled,
633
+ rules: [c(E)()],
634
+ "label-mark": "required",
635
+ label: c(l)("inventory.warehouse.address.postcode"),
636
+ modelValue: M.value,
637
+ "onUpdate:modelValue": e[5] || (e[5] = (i) => M.value = i)
638
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
639
+ V(t, {
640
+ disabled: o.disabled,
641
+ rules: [c(E)()],
642
+ "label-mark": "required",
643
+ label: c(l)("inventory.warehouse.address.state"),
644
+ modelValue: $.value,
645
+ "onUpdate:modelValue": e[6] || (e[6] = (i) => $.value = i)
646
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
647
+ V(t, {
648
+ disabled: o.disabled,
649
+ rules: [c(E)()],
650
+ "label-mark": "required",
651
+ label: c(l)("inventory.warehouse.address.country"),
652
+ modelValue: C.value,
653
+ "onUpdate:modelValue": e[7] || (e[7] = (i) => C.value = i)
654
+ }, null, 8, ["disabled", "rules", "label", "modelValue"])
655
+ ])
656
+ ]),
657
+ g("div", go, [
658
+ g("div", bo, U(c(l)("inventory.warehouse.coordinate.title")), 1),
659
+ V(po, {
660
+ disabled: o.disabled,
661
+ rules: [c(E)()],
662
+ "label-mark": "required",
663
+ modelValue: R.value,
664
+ "onUpdate:modelValue": e[8] || (e[8] = (i) => R.value = i)
665
+ }, null, 8, ["disabled", "rules", "modelValue"])
666
+ ]),
667
+ g("div", wo, [
668
+ g("div", Vo, U(c(l)("inventory.warehouse.contact.title")), 1),
669
+ g("div", _o, [
670
+ V(B, {
671
+ disabled: o.disabled,
672
+ rules: [c(E)()],
673
+ "label-mark": "required",
674
+ label: c(l)("inventory.warehouse.contact.phoneNumber"),
675
+ modelValue: d.value,
676
+ "onUpdate:modelValue": e[9] || (e[9] = (i) => d.value = i)
677
+ }, null, 8, ["disabled", "rules", "label", "modelValue"]),
678
+ V(t, {
679
+ disabled: o.disabled,
680
+ "label-mark": "optional",
681
+ label: c(l)("inventory.warehouse.contact.email"),
682
+ modelValue: k.value,
683
+ "onUpdate:modelValue": e[10] || (e[10] = (i) => k.value = i)
684
+ }, null, 8, ["disabled", "label", "modelValue"])
685
+ ])
686
+ ])
687
+ ])
688
+ ]),
689
+ _: 1
690
+ }, 512);
691
+ };
692
+ }
693
+ }), Ao = { class: "flex gap-4" }, Mo = /* @__PURE__ */ j({
694
+ __name: "WarehouseDialog",
695
+ props: {
696
+ mode: {},
697
+ warehouse: {},
698
+ show: { type: Boolean }
699
+ },
700
+ emits: ["update:show", "submitted"],
701
+ setup(m, { expose: h, emit: y }) {
702
+ const a = m, n = y, l = W(!1), p = se(), { t: r } = q(), u = Ce(), _ = F(() => {
703
+ switch (a.mode) {
704
+ case T.READ:
705
+ return "";
706
+ case T.UPDATE:
707
+ return r("inventory.warehouse.update.title");
708
+ case T.CREATE:
709
+ return r("inventory.warehouse.create.title");
710
+ }
711
+ return "";
712
+ }), v = F(() => {
713
+ switch (a.mode) {
714
+ case T.READ:
715
+ return "";
716
+ case T.UPDATE:
717
+ return r("common.save");
718
+ case T.CREATE:
719
+ return r("common.add");
720
+ }
721
+ return "";
722
+ }), M = W();
723
+ h({
724
+ validateInputs: () => {
725
+ var o, e;
726
+ (e = (o = M.value) == null ? void 0 : o.validateInputs) == null || e.call(o);
727
+ },
728
+ resetInputsValidation: () => {
729
+ var o, e;
730
+ (e = (o = M.value) == null ? void 0 : o.resetInputsValidation) == null || e.call(o);
731
+ },
732
+ resetInputs: () => {
733
+ var o, e;
734
+ (e = (o = M.value) == null ? void 0 : o.resetInputs) == null || e.call(o);
735
+ }
736
+ });
737
+ const $ = oe(a, "show"), C = oe(a, "warehouse");
738
+ function R() {
739
+ var o, e;
740
+ (e = (o = M.value) == null ? void 0 : o.validateInputs) == null || e.call(o);
741
+ }
742
+ function d() {
743
+ switch (a.mode) {
744
+ case T.READ:
745
+ return;
746
+ case T.UPDATE:
747
+ return A();
748
+ case T.CREATE:
749
+ return k();
750
+ }
751
+ }
752
+ async function k() {
753
+ var o, e;
754
+ l.value = !0;
755
+ try {
756
+ await Promise.all([
757
+ u.createWarehouse(C.value),
758
+ new Promise((t) => setTimeout(t, 1e3))
759
+ ]), p.open({
760
+ title: r("common.success"),
761
+ message: r("inventory.warehouse.create.success", { name: (e = (o = C.value) == null ? void 0 : o.profile) == null ? void 0 : e.name }),
762
+ type: "success"
763
+ }), n("update:show", !1), n("submitted");
764
+ } catch (t) {
765
+ p.open({
766
+ title: r("inventory.warehouse.create.error.title"),
767
+ message: r("inventory.warehouse.create.error.message"),
768
+ type: "error"
769
+ }), console.error("cannot create warehouse", t);
770
+ } finally {
771
+ l.value = !1;
772
+ }
773
+ }
774
+ async function A() {
775
+ var o, e;
776
+ if (C.value === null) {
777
+ p.open({
778
+ title: r("inventory.warehouse.update.error.title"),
779
+ message: r("inventory.warehouse.update.error.emptyWarehouse"),
780
+ type: "error"
781
+ });
782
+ return;
783
+ }
784
+ l.value = !0;
785
+ try {
786
+ await Promise.all([
787
+ u.updateWarehouse(C.value),
788
+ new Promise((t) => setTimeout(t, 1e3))
789
+ ]), p.open({
790
+ title: r("common.success"),
791
+ message: r("inventory.warehouse.update.success", { name: (e = (o = C.value) == null ? void 0 : o.profile) == null ? void 0 : e.name }),
792
+ type: "success"
793
+ }), n("update:show", !1), n("submitted");
794
+ } catch (t) {
795
+ p.open({
796
+ title: r("inventory.warehouse.update.error.title"),
797
+ message: r("inventory.warehouse.update.error.message"),
798
+ type: "error"
799
+ }), console.error("cannot update warehouse", t);
800
+ } finally {
801
+ l.value = !1;
802
+ }
803
+ }
804
+ return (o, e) => {
805
+ const t = L("FmButton"), B = L("FmSideSheet");
806
+ return S(), I(B, {
807
+ header: _.value,
808
+ modelValue: c($),
809
+ "onUpdate:modelValue": e[1] || (e[1] = (w) => we($) ? $.value = w : null),
810
+ "dismiss-away": !l.value,
811
+ "close-button": "",
812
+ "max-width": 500
813
+ }, {
814
+ default: N(() => {
815
+ var w;
816
+ return [
817
+ (S(), I(ko, {
818
+ class: "w-full",
819
+ ref_key: "formRef",
820
+ ref: M,
821
+ modelValue: c(C),
822
+ "onUpdate:modelValue": e[0] || (e[0] = (i) => we(C) ? C.value = i : null),
823
+ onValidationSuccess: d,
824
+ key: ((w = o.warehouse) == null ? void 0 : w._id) ?? "",
825
+ disabled: l.value
826
+ }, null, 8, ["modelValue", "disabled"]))
827
+ ];
828
+ }),
829
+ "side-sheet-footer": N(() => [
830
+ g("div", Ao, [
831
+ V(t, {
832
+ loading: l.value,
833
+ label: v.value,
834
+ onClick: R
835
+ }, null, 8, ["loading", "label"])
836
+ ])
837
+ ]),
838
+ _: 1
839
+ }, 8, ["header", "modelValue", "dismiss-away"]);
840
+ };
841
+ }
842
+ }), Co = { class: "flex flex-col py-8" }, Fo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, xo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $o = {
843
+ key: 0,
844
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
845
+ }, Wo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-3" }, Lo = /* @__PURE__ */ j({
846
+ __name: "WarehouseView",
847
+ setup(m) {
848
+ const h = Ce(), y = Ne(), a = F(() => h.warehouses), n = Me(), l = se(), p = W(!1), { t: r } = q();
849
+ te(() => {
850
+ y._currentLocation && A();
851
+ }), ee([() => y._currentLocation], () => {
852
+ y._currentLocation && A();
853
+ });
854
+ const u = W({});
855
+ function _() {
856
+ u.value.mode = T.CREATE, u.value.warehouse = {}, u.value.show = !0;
857
+ }
858
+ function v(w) {
859
+ u.value.mode = T.UPDATE, u.value.warehouse = w, u.value.show = !0;
860
+ }
861
+ async function M(w) {
862
+ n.open({
863
+ title: r("inventory.warehouse.delete.confirm"),
864
+ message: r("inventory.warehouse.delete.confirmMessage", { name: w.profile.name }),
865
+ primaryActions: {
866
+ text: "Delete",
867
+ close: !0,
868
+ variant: "destructive"
869
+ },
870
+ secondaryActions: {
871
+ text: "Cancel",
872
+ close: !0
873
+ }
874
+ }).onPrimary(() => $(w));
875
+ }
876
+ async function $(w) {
877
+ const { t: i } = q();
878
+ n.open({
879
+ title: i("inventory.warehouse.delete.deletingWarehouse"),
880
+ closeButton: !1
881
+ });
882
+ try {
883
+ await h.deleteWarehouse(w), l.open({
884
+ title: i("inventory.warehouse.delete.success"),
885
+ message: i("inventory.warehouse.delete.deletedWarehouse", { name: w.profile.name }),
886
+ type: "success"
887
+ }), await A(!0);
888
+ } catch (O) {
889
+ l.open({
890
+ title: i("inventory.warehouse.delete.error"),
891
+ message: i("inventory.warehouse.delete.errorMessage", { name: w.profile.name }),
892
+ type: "error"
893
+ }), console.error("failed to delete warehouse", O);
894
+ } finally {
895
+ n.close();
896
+ }
897
+ }
898
+ const { columnDefs: C, formatRowData: R } = Xe(
899
+ v,
900
+ M
901
+ );
902
+ function d(w) {
903
+ w === "create" && _();
904
+ }
905
+ const k = W("");
906
+ async function A(w = !1) {
907
+ p.value = !0;
908
+ try {
909
+ await h.readWarehouses(), w && await y.readLocations();
910
+ } catch {
911
+ l.open({
912
+ title: "Cannot fetch warehouse list",
913
+ type: "error"
914
+ });
915
+ } finally {
916
+ p.value = !1;
917
+ }
918
+ }
919
+ const { breakpoints: o } = Ke(), e = F(() => o.value.xs || o.value.sm), t = F(() => e.value ? 10 : 20), B = Ie();
920
+ return (w, i) => {
921
+ const O = L("FmTable");
922
+ return S(), I(je, {
923
+ title: c(r)("inventory.warehouse.title"),
924
+ actions: [
925
+ {
926
+ label: c(r)("inventory.warehouse.create.title"),
927
+ value: "create",
928
+ isPrimary: !0,
929
+ prependIcon: "add"
930
+ }
931
+ ],
932
+ "onClick:action": d
933
+ }, {
934
+ default: N(() => [
935
+ g("div", {
936
+ class: Se([
937
+ "flex flex-col gap-8 max-h-full",
938
+ {
939
+ "p-0": e.value,
940
+ "px-24 ": !e.value
941
+ }
942
+ ])
943
+ }, [
944
+ V(Oe, {
945
+ searchable: "",
946
+ "change-location": "",
947
+ search: k.value,
948
+ "onUpdate:search": i[0] || (i[0] = (P) => k.value = P)
949
+ }, null, 8, ["search"]),
950
+ (S(), I(O, {
951
+ style: Re(c(B).tableHeight),
952
+ "column-defs": c(C),
953
+ "row-data": c(R)(a.value),
954
+ "search-value": k.value,
955
+ loading: !c(y)._currentLocation || p.value,
956
+ onRowClick: i[1] || (i[1] = (P) => v(P.original.original)),
957
+ key: a.value.length,
958
+ "page-size": t.value
959
+ }, {
960
+ "list-row": N((P) => [
961
+ V(ze, {
962
+ row: P,
963
+ onRowClick: (s) => v(s.original)
964
+ }, {
965
+ default: N((s) => {
966
+ var f, b, x, D, K, re, ne, ue, H, ie, de, ce, pe, me, X, fe, he, ye, ve, Y, ge;
967
+ return [
968
+ g("div", Co, [
969
+ g("div", Fo, [
970
+ V(c(J), {
971
+ render: (x = (b = (f = s.warehouse) == null ? void 0 : f.column) == null ? void 0 : b.columnDef) == null ? void 0 : x.cell,
972
+ props: (K = (D = s.warehouse) == null ? void 0 : D.getContext) == null ? void 0 : K.call(D)
973
+ }, null, 8, ["render", "props"])
974
+ ]),
975
+ g("div", xo, [
976
+ V(c(J), {
977
+ render: (ue = (ne = (re = s.contact) == null ? void 0 : re.column) == null ? void 0 : ne.columnDef) == null ? void 0 : ue.cell,
978
+ props: (ie = (H = s.contact) == null ? void 0 : H.getContext) == null ? void 0 : ie.call(H)
979
+ }, null, 8, ["render", "props"])
980
+ ]),
981
+ (de = P.original) != null && de.email ? (S(), z("div", $o, [
982
+ V(c(J), {
983
+ render: (me = (pe = (ce = s.email) == null ? void 0 : ce.column) == null ? void 0 : pe.columnDef) == null ? void 0 : me.cell,
984
+ props: (fe = (X = s.email) == null ? void 0 : X.getContext) == null ? void 0 : fe.call(X)
985
+ }, null, 8, ["render", "props"])
986
+ ])) : Ae("", !0),
987
+ g("div", Wo, [
988
+ V(c(J), {
989
+ render: (ve = (ye = (he = s.address) == null ? void 0 : he.column) == null ? void 0 : ye.columnDef) == null ? void 0 : ve.cell,
990
+ props: (ge = (Y = s.address) == null ? void 0 : Y.getContext) == null ? void 0 : ge.call(Y)
991
+ }, null, 8, ["render", "props"])
992
+ ])
993
+ ])
994
+ ];
995
+ }),
996
+ _: 2
997
+ }, 1032, ["row", "onRowClick"])
998
+ ]),
999
+ _: 1
1000
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1001
+ ], 2),
1002
+ V(Mo, {
1003
+ show: u.value.show,
1004
+ "onUpdate:show": i[2] || (i[2] = (P) => u.value.show = P),
1005
+ warehouse: u.value.warehouse,
1006
+ mode: u.value.mode,
1007
+ onSubmitted: i[3] || (i[3] = (P) => A(!0))
1008
+ }, null, 8, ["show", "warehouse", "mode"])
1009
+ ]),
1010
+ _: 1
1011
+ }, 8, ["title", "actions"]);
1012
+ };
1013
+ }
1014
+ });
1015
+ export {
1016
+ Lo as default
1017
+ };