@feedmepos/mf-inventory-portal 0.0.10-dev.2 → 0.0.11

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