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

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 (196) hide show
  1. package/dist/App.vue.d.ts +1 -1
  2. package/dist/{ApprovalView-Bcxk6B7K.js → ApprovalView-CF-RhtHH.js} +5 -5
  3. package/dist/{BindingsDialog-XDkcjW_c.js → BindingsDialog-0_fCmf7t.js} +26 -26
  4. package/dist/{BindingsPicker-CgbiqX72.js → BindingsPicker-CT-56t-W.js} +17 -17
  5. package/dist/BindingsTable-DEftAnTN.js +120 -0
  6. package/dist/Entry.vue.d.ts +1 -1
  7. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-6yg6_JPe.js +308 -0
  8. package/dist/IngredientsView-Au6oRwF2.js +1663 -0
  9. package/dist/{IntegrationView-CErHEVAO.js → IntegrationView-D7hqf0P5.js} +278 -278
  10. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-XXoPyhlc.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-HcOKpAlW.js} +1 -1
  11. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BpyUheXn.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BTOE1vFl.js} +1 -1
  12. package/dist/PurchaseOrderPrintPreview-C92PdleC.js +152 -0
  13. package/dist/{ReceiveRequestView-BKbeFDxm.js → ReceiveRequestView-BaxEQWOD.js} +8 -8
  14. package/dist/{RecipeView-Drp4l4gL.js → RecipeView-CDgZpLPk.js} +181 -181
  15. package/dist/Standalone.vue.d.ts +1 -1
  16. package/dist/{StockView-Cj6fErwD.js → StockView-B77CrARl.js} +498 -502
  17. package/dist/SupplierView-DQ3hB7q2.js +819 -0
  18. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-lsyakQIl.js +738 -0
  19. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DN7NCT72.js +1435 -0
  20. package/dist/TransferTemplateView-Dt04xMCK.js +1290 -0
  21. package/dist/{UnitView-C_tAxIpq.js → UnitView-DlmlVNOx.js} +242 -242
  22. package/dist/{WarehouseView-BAqVtbD6.js → WarehouseView-DXWls5vv.js} +360 -362
  23. package/dist/api/bill.d.ts +238 -84
  24. package/dist/api/inventory.d.ts +3 -3
  25. package/dist/api/purchase-order-template.d.ts +4 -0
  26. package/dist/api/stock.d.ts +0 -8
  27. package/dist/api/supplier.d.ts +2 -0
  28. package/dist/app-P7rGzGsF.js +68600 -0
  29. package/dist/app.d.ts +200 -7
  30. package/dist/app.js +3 -3
  31. package/dist/{array-AvWd53LI.js → array-ClJzD_Lt.js} +3 -3
  32. package/dist/components/ChangeLocationComponent.vue.d.ts +14 -1
  33. package/dist/components/DeferableLoading.vue.d.ts +1 -1
  34. package/dist/components/DeleteDialog.vue.d.ts +1 -1
  35. package/dist/components/FmCoordinateInput.vue.d.ts +3 -3
  36. package/dist/components/FmDroppableField.vue.d.ts +6 -6
  37. package/dist/components/FmFilterableSelect.vue.d.ts +3 -3
  38. package/dist/components/FmInventoryTableToolbar.vue.d.ts +19 -10
  39. package/dist/components/FmMinMaxInput.vue.d.ts +20 -0
  40. package/dist/components/FmMinMaxInputProps.d.ts +16 -0
  41. package/dist/components/FmMinMaxInputRules.d.ts +4 -0
  42. package/dist/components/FmMultiselectDialog.vue.d.ts +5 -5
  43. package/dist/components/FmMultiselectDialogProps.d.ts +14 -1
  44. package/dist/components/FmUnitInputRules.d.ts +1 -0
  45. package/dist/components/MultiSelectDialog.vue.d.ts +1 -1
  46. package/dist/components/NavigationTab.vue.d.ts +1 -1
  47. package/dist/components/NumberPrecisionInput.vue.d.ts +3 -3
  48. package/dist/components/PremiumBadge.vue.d.ts +3 -3
  49. package/dist/components/PreviewBadge.vue.d.ts +3 -3
  50. package/dist/components/StockForecast.vue.d.ts +1 -1
  51. package/dist/components/TableActionableRow.vue.d.ts +4 -4
  52. package/dist/components/UnitDisplayControl.vue.d.ts +1 -1
  53. package/dist/components/icons/IconCommunity.vue.d.ts +1 -1
  54. package/dist/components/icons/IconDocumentation.vue.d.ts +1 -1
  55. package/dist/components/icons/IconEcosystem.vue.d.ts +1 -1
  56. package/dist/components/icons/IconSupport.vue.d.ts +1 -1
  57. package/dist/components/icons/IconTooling.vue.d.ts +1 -1
  58. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +6 -6
  59. package/dist/components/map/CoordinateDialog.vue.d.ts +4 -4
  60. package/dist/components/map/GoogleMap.vue.d.ts +6 -6
  61. package/dist/components/nested-multiselect/FmNestedMultiselectDialog.vue.d.ts +3 -3
  62. package/dist/components/row-action.enum.d.ts +3 -1
  63. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +3 -3
  64. package/dist/components/shell/inventory/binding-ui.vue.d.ts +6 -6
  65. package/dist/components/ui-library/FmDateRangePickerChip.vue.d.ts +5 -5
  66. package/dist/composable/useIframe.d.ts +1 -1
  67. package/dist/composable/useSearch.d.ts +1 -1
  68. package/dist/{decimal-D3KXLC4T.js → decimal-4ONRlhOO.js} +1 -1
  69. package/dist/format-unit-display-DJpElzu_.js +707 -0
  70. package/dist/helper/number.d.ts +2 -0
  71. package/dist/{id-to-date-Cj02m808.js → id-to-date-D8Ey2CVj.js} +1 -1
  72. package/dist/is-linked-ingredient-error-fJ2TJb3z.js +37 -0
  73. package/dist/layout/InventoryLayout.vue.d.ts +1 -1
  74. package/dist/layout/SingleColumnLayout.vue.d.ts +6 -5
  75. package/dist/layout/components/NavigationButton.vue.d.ts +4 -4
  76. package/dist/layout-D-zXtsSp.js +151 -0
  77. package/dist/row-action.enum-PMKMRrZR.js +50 -0
  78. package/dist/stores/feature.d.ts +5 -1
  79. package/dist/stores/inventory.d.ts +4 -4
  80. package/dist/stores/location.d.ts +185 -152
  81. package/dist/stores/supplier.d.ts +666 -12
  82. package/dist/stores/warehouse.d.ts +17 -5
  83. package/dist/supplier-DsUIjl-L.js +69 -0
  84. package/dist/tsconfig.app.tsbuildinfo +1 -1
  85. package/dist/views/InventoryView.vue.d.ts +1 -1
  86. package/dist/views/SelectBussinessDialog.vue.d.ts +1 -1
  87. package/dist/views/approval/ApprovalView.vue.d.ts +1 -1
  88. package/dist/views/dev/ComponentPreview.vue.d.ts +1 -1
  89. package/dist/views/dev/components/CoordinateTest.vue.d.ts +1 -1
  90. package/dist/views/dev/components/DateRange.vue.d.ts +1 -1
  91. package/dist/views/dev/components/FmDecimalInputTest.vue.d.ts +1 -1
  92. package/dist/views/dev/components/FmMultiselectDialogGrouped.vue.d.ts +2 -0
  93. package/dist/views/dev/components/FmSelectTest.vue.d.ts +1 -1
  94. package/dist/views/dev/components/InventoryIframe.vue.d.ts +1 -1
  95. package/dist/views/dev/components/LayoutDev.vue.d.ts +1 -1
  96. package/dist/views/dev/components/MfCommontTest.vue.d.ts +1 -1
  97. package/dist/views/dev/components/NestedSelection.vue.d.ts +1 -1
  98. package/dist/views/dev/components/NumberStepper.vue.d.ts +1 -1
  99. package/dist/views/dev/components/TabStorageTest.vue.d.ts +1 -1
  100. package/dist/views/dev/components/UnitInput.vue.d.ts +1 -1
  101. package/dist/views/dev/helpers/pinia-test.d.ts +1 -1
  102. package/dist/views/home/HomeView.vue.d.ts +1 -1
  103. package/dist/views/iframe/inventory-bindings/bindings-dialog/BindingsDialog.vue.d.ts +1 -1
  104. package/dist/views/iframe/inventory-bindings/bindings-picker/BindingsPicker.vue.d.ts +1 -1
  105. package/dist/views/iframe/inventory-bindings/bindings-table/BindingsTable.vue.d.ts +1 -1
  106. package/dist/views/ingredients/IngredientsView.vue.d.ts +1 -1
  107. package/dist/views/ingredients/components/cannot-delete/CannotDelete.vue.d.ts +4 -4
  108. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +3 -3
  109. package/dist/views/ingredients/components/import-ingredients/ImportIngredientItem.vue.d.ts +1 -1
  110. package/dist/views/ingredients/components/import-ingredients/ImportIngredients.vue.d.ts +1 -1
  111. package/dist/views/ingredients/components/ingredient-binded-item/IngredientBindedItem.vue.d.ts +1 -1
  112. package/dist/views/ingredients/components/ingredient-dialog/IngredientDialog.vue.d.ts +5 -5
  113. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +6 -6
  114. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +5 -5
  115. package/dist/views/ingredients/components/inventory-binding/InventoryBindingSummary.vue.d.ts +3 -3
  116. package/dist/views/ingredients/composables/use-ingredient-form.d.ts +8 -8
  117. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -1
  118. package/dist/views/integration/IntegrationView.vue.d.ts +1 -1
  119. package/dist/views/integration/components/ApplyAddon.vue.d.ts +5 -5
  120. package/dist/views/integration/components/ApplyProduct.vue.d.ts +5 -5
  121. package/dist/views/integration/components/ApplyProductDialog.vue.d.ts +5 -5
  122. package/dist/views/integration/components/ApplyProductDialogV4.vue.d.ts +5 -5
  123. package/dist/views/receive-request/ReceiveRequestView.vue.d.ts +1 -1
  124. package/dist/views/receive-request/components/select-template-dialog/SelectTemplateDialog.vue.d.ts +8 -0
  125. package/dist/views/receive-request/components/supplier-price-history/SupplierPriceHistory.vue.d.ts +1 -1
  126. package/dist/views/receive-request/components/transfer-details/TransferDetails.vue.d.ts +3 -3
  127. package/dist/views/receive-request/components/transfer-dialog/TransferDialog.vue.d.ts +4 -4
  128. package/dist/views/receive-request/components/transfer-dialog/TransferDialogProps.d.ts +1 -1
  129. package/dist/views/receive-request/components/transfer-form/SparkIcon.vue.d.ts +4 -4
  130. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +34 -32
  131. package/dist/views/receive-request/components/transfer-form/TransferForm2.vue.d.ts +8 -2
  132. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
  133. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +6 -6
  134. package/dist/views/receive-request/components/transfer-form/components/TransferItem.vue.d.ts +3 -3
  135. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +3 -3
  136. package/dist/views/receive-request/components/transfer-form/composables/use-backdate-po.d.ts +4 -4
  137. package/dist/views/receive-request/components/transfer-form/composables/use-compare-price.d.ts +3 -3
  138. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +2 -9
  139. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +1016 -70
  140. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +36 -36
  141. package/dist/views/receive-request/print-preview/PurchaseOrderPrintPreview.vue.d.ts +1 -1
  142. package/dist/views/recipe/RecipeView.vue.d.ts +1 -1
  143. package/dist/views/recipe/components/recipe-dialog/RecipeDialog.vue.d.ts +5 -5
  144. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +4 -4
  145. package/dist/views/recipe/composables/use-recipe-form.d.ts +8 -8
  146. package/dist/views/stock/StockView.vue.d.ts +1 -1
  147. package/dist/views/stock/components/StockHeaderPreview.vue.d.ts +1 -1
  148. package/dist/views/stock/components/StockHistory.vue.d.ts +3 -3
  149. package/dist/views/stock/components/StockRecordCard.vue.d.ts +123 -46
  150. package/dist/views/stock/components/dialog/AdjustSkuDialog.vue.d.ts +4 -4
  151. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +5 -5
  152. package/dist/views/stock/components/dialog/ConvertSkuDialog.vue.d.ts +4 -4
  153. package/dist/views/stock/composables/use-stock-action.d.ts +11 -11
  154. package/dist/views/stock/helper/stock-row-action.d.ts +4 -2
  155. package/dist/views/supplier/SupplierView.vue.d.ts +1 -1
  156. package/dist/views/supplier/components/SupplierDialog.vue.d.ts +4 -4
  157. package/dist/views/supplier/components/SupplierForm.vue.d.ts +10 -10
  158. package/dist/views/supplier/components/SupplierSupplyItemField.vue.d.ts +3 -3
  159. package/dist/views/supplier/composables/use-supplier-table.d.ts +3 -3
  160. package/dist/views/transfer-template/TransferTemplateView.vue.d.ts +1 -1
  161. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetails.vue.d.ts +20 -0
  162. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetailsProps.d.ts +9 -0
  163. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +4 -4
  164. package/dist/views/transfer-template/components/transfer-template-form/TransferTemplateForm.vue.d.ts +2 -2
  165. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItem.vue.d.ts +3 -3
  166. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +7 -7
  167. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +15 -9
  168. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1428 -43
  169. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +893 -13
  170. package/dist/views/unit/UnitView.vue.d.ts +1 -1
  171. package/dist/views/unit/components/unit-dialog/UnitDialog.vue.d.ts +5 -5
  172. package/dist/views/unit/components/unit-form/UnitForm.vue.d.ts +4 -4
  173. package/dist/views/unit/components/unit-summary/UnitSummary.vue.d.ts +3 -3
  174. package/dist/views/unit/components/unit-used-by/UnitUsedBy.vue.d.ts +1 -1
  175. package/dist/views/unit/composables/use-unit-form.d.ts +8 -8
  176. package/dist/views/warehouse/WarehouseView.vue.d.ts +1 -1
  177. package/dist/views/warehouse/components/WarehouseDialog.vue.d.ts +4 -4
  178. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +38 -14
  179. package/dist/{xlsx-B-2KyDJq.js → xlsx-zfERRe6K.js} +3383 -3383
  180. package/dist/{xlsx.util-D6EzRE71.js → xlsx.util-DnbiJzsk.js} +4 -4
  181. package/package.json +6 -5
  182. package/dist/BindingsTable-xNXNsBAd.js +0 -145
  183. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DFPkUHl-.js +0 -272
  184. package/dist/IngredientsView-DD7ns3mP.js +0 -1751
  185. package/dist/PurchaseOrderPrintPreview-L_iaaURb.js +0 -152
  186. package/dist/SupplierView-EFsHWet-.js +0 -801
  187. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-kM5fyqq6.js +0 -745
  188. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-CyFMCmXw.js +0 -1605
  189. package/dist/TransferTemplateView-Cymhrayh.js +0 -933
  190. package/dist/app-CeUU5Gd8.js +0 -66938
  191. package/dist/is-linked-ingredient-error-C6AghEwR.js +0 -37
  192. package/dist/layout-2zzAZIVO.js +0 -147
  193. package/dist/purchase-order-transaction-type-Dz0YF5qh.js +0 -294
  194. package/dist/row-action.enum-7jVyol1k.js +0 -36
  195. package/dist/supplier-mDVKd7Ge.js +0 -54
  196. package/dist/views/stock/components/StockRecalculateDialog.vue.d.ts +0 -9
@@ -1,1751 +0,0 @@
1
- import { ref as z, defineComponent as le, computed as C, resolveComponent as R, openBlock as y, createBlock as B, withCtx as $, createVNode as f, unref as d, createElementBlock as U, Fragment as Q, createElementVNode as c, createCommentVNode as O, onMounted as nt, watch as je, normalizeClass as X, createTextVNode as He, toDisplayString as L, renderList as oe, isRef as Ee, renderSlot as ge, createSlots as Oe, normalizeStyle as ot, Teleport as De, normalizeProps as lt, guardReactiveProps as at } from "vue";
2
- import { u as ae, c as Ye, S as rt, _ as st, A as _e, a as Ge, g as xe, t as qe, F as ve, R as be, U as it, M as ut, d as Ae, b as We, C as Ce, e as Te, f as dt, h as ct, I as mt, i as pt, j as vt } from "./app-CeUU5Gd8.js";
3
- import { useDialog as Ke, useSnackbar as Ve, useProxiedModel as Pe, useDialogChild as ft, useBreakpoints as yt } from "@feedmepos/ui-library";
4
- import { i as gt, _ as bt } from "./is-linked-ingredient-error-C6AghEwR.js";
5
- import { F as K, D as Be, R as he } from "./row-action.enum-7jVyol1k.js";
6
- import { useI18n as re, useCoreStore as fe } from "@feedmepos/mf-common";
7
- import { defineStore as ht, storeToRefs as _t } from "pinia";
8
- import { c as xt, _ as Vt, F as ze, u as kt } from "./layout-2zzAZIVO.js";
9
- import { _ as Ct, a as Ft } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DFPkUHl-.js";
10
- import { g as St, _ as Fe, S as Se } from "./StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js";
11
- import { _ as we, t as Je, d as Qe, s as wt, r as Mt } from "./xlsx.util-D6EzRE71.js";
12
- import { _ as Me } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
13
- import "./array-AvWd53LI.js";
14
- const $e = ht("ingredientForm", function() {
15
- const i = Ke(), m = Ve(), r = ae(), t = z(!1), { t: l } = re(), o = z();
16
- function p() {
17
- const h = {
18
- unit: {},
19
- mode: K.CREATE,
20
- show: !0,
21
- "onUpdate:show"(u) {
22
- o.value.show = u;
23
- }
24
- };
25
- o.value = h;
26
- }
27
- async function b(h) {
28
- const u = {
29
- unit: Ye(h),
30
- mode: K.UPDATE,
31
- show: !0,
32
- "onUpdate:show"(x) {
33
- o.value.show = x;
34
- }
35
- };
36
- o.value = u;
37
- }
38
- async function _(h) {
39
- t.value = !0;
40
- try {
41
- await r.deleteSku(h), m.open({
42
- title: "Success",
43
- message: `Deleted ${h.name}`,
44
- type: "success"
45
- });
46
- } catch (u) {
47
- u instanceof rt && gt(u) ? i.open({
48
- title: "Cannot delete ingredient",
49
- contentComponent: bt,
50
- contentComponentProps: {
51
- subject: (h == null ? void 0 : h.name) ?? "",
52
- items: u.errorResponse.message
53
- },
54
- secondaryActions: {
55
- text: "Close",
56
- close: !0
57
- }
58
- }) : console.log("unable to delete ingredient", u), m.open({
59
- title: `Cannot delete ${h.name}`,
60
- message: "Please try again.",
61
- type: "error"
62
- }), console.error("failed to delete ingredient", u);
63
- } finally {
64
- t.value = !1;
65
- }
66
- }
67
- function g(h) {
68
- i.open({
69
- title: l("inventory.ingredient.delete.title", [(h == null ? void 0 : h.name) ?? ""]),
70
- closeButton: !1,
71
- message: l("inventory.ingredient.delete.message"),
72
- primaryActions: {
73
- text: l("common.delete"),
74
- close: !0,
75
- variant: "destructive"
76
- },
77
- secondaryActions: {
78
- text: l("common.cancel"),
79
- close: !0
80
- }
81
- }).onPrimary(() => _(h));
82
- }
83
- return {
84
- createIngredient: p,
85
- updateIngredient: b,
86
- deleteIngredient: g,
87
- ingredientDialogProps: o,
88
- ingredientViewLoading: t
89
- };
90
- });
91
- function $t() {
92
- const { updateIngredient: s, deleteIngredient: i } = $e(), { t: m } = re();
93
- async function r(l, o) {
94
- const p = Ye(o);
95
- if (l === he.Edit) {
96
- await s(p);
97
- return;
98
- }
99
- if (l === he.Delete) {
100
- await i(p);
101
- return;
102
- }
103
- }
104
- return { columnDefs: [
105
- {
106
- accessorKey: "code",
107
- header: () => m("inventory.ingredient.code"),
108
- enableSorting: !0,
109
- size: 300
110
- },
111
- {
112
- accessorKey: "name",
113
- header: () => m("inventory.ingredient.name"),
114
- enableSorting: !0,
115
- size: 300
116
- },
117
- {
118
- id: "unit",
119
- header: () => m("inventory.ingredient.unit"),
120
- cell(l) {
121
- var p;
122
- const o = l.row.original;
123
- if (o.trackingMeasurement) {
124
- const b = (p = o.unit.measurements) == null ? void 0 : p.find(
125
- (_) => _.id === o.trackingMeasurement
126
- );
127
- if (b)
128
- return `${b.name} (${b.abbrev})`;
129
- }
130
- return `${o.unit.name} (${o.unit.abbrev})`;
131
- },
132
- enableSorting: !1,
133
- size: "auto"
134
- },
135
- {
136
- id: "action",
137
- header: "",
138
- cell(l) {
139
- return xt(
140
- [Be[he.Edit], Be[he.Delete]],
141
- (o) => {
142
- r(o, l.row.original);
143
- }
144
- );
145
- },
146
- enableSorting: !1,
147
- size: 40,
148
- meta: {
149
- cellClass: "",
150
- headerClass: ""
151
- }
152
- }
153
- ] };
154
- }
155
- const It = /* @__PURE__ */ le({
156
- __name: "ConvertForm",
157
- props: {
158
- modelValue: {},
159
- rootValue: {},
160
- disabled: { type: Boolean }
161
- },
162
- emits: ["update:modelValue"],
163
- setup(s, { emit: i }) {
164
- const m = s, r = C(() => {
165
- var u;
166
- return (u = m.rootValue) == null ? void 0 : u.unit;
167
- }), t = C(() => {
168
- var u;
169
- return (u = m.rootValue) == null ? void 0 : u._id;
170
- }), l = i, { t: o } = re(), p = C({
171
- get() {
172
- return !!m.modelValue;
173
- },
174
- set(u) {
175
- u ? l("update:modelValue", {
176
- measurement: null,
177
- inventoryBindings: []
178
- }) : l("update:modelValue", null);
179
- }
180
- }), b = C(() => St(r.value));
181
- function _(u) {
182
- const x = m.modelValue ?? {};
183
- x.measurement = u ? `${u}` : null, l("update:modelValue", x);
184
- }
185
- function g(u) {
186
- const x = m.modelValue ?? {};
187
- x.inventoryBindings = u, l("update:modelValue", x);
188
- }
189
- const h = C(() => {
190
- if (!m.modelValue) return null;
191
- const u = m.modelValue;
192
- return u.measurement ? b.value.find((x) => x.value === u.measurement) ?? null : b.value.find((x) => x.value === null) ?? null;
193
- });
194
- return (u, x) => {
195
- const D = R("FmSwitch"), S = R("FmSelect"), w = R("FmCard");
196
- return y(), B(w, {
197
- variant: "outlined",
198
- class: "p-16 flex flex-col gap-16"
199
- }, {
200
- default: $(() => {
201
- var M, V;
202
- return [
203
- f(D, {
204
- value: "",
205
- "model-value": p.value,
206
- "onUpdate:modelValue": x[0] || (x[0] = (H) => p.value = H),
207
- label: d(o)("inventory.ingredient.convertible.title"),
208
- sublabel: d(o)("inventory.ingredient.convertible.subtitle"),
209
- labelPlacement: "right"
210
- }, null, 8, ["model-value", "label", "sublabel"]),
211
- p.value ? (y(), U(Q, { key: 0 }, [
212
- c("div", null, [
213
- f(S, {
214
- label: d(o)("inventory.ingredient.convertible.convertTo"),
215
- modelValue: (M = h.value) == null ? void 0 : M.value,
216
- "onUpdate:modelValue": _,
217
- items: b.value
218
- }, null, 8, ["label", "modelValue", "items"])
219
- ]),
220
- f(st, {
221
- id: t.value,
222
- "model-value": ((V = u.modelValue) == null ? void 0 : V.inventoryBindings) ?? [],
223
- "onUpdate:modelValue": g,
224
- "exclude-binding-id": t.value,
225
- rules: [d(_e)(1)]
226
- }, null, 8, ["id", "model-value", "exclude-binding-id", "rules"])
227
- ], 64)) : O("", !0)
228
- ];
229
- }),
230
- _: 1
231
- });
232
- };
233
- }
234
- });
235
- function ue() {
236
- return {
237
- low: 6,
238
- mid: 14
239
- };
240
- }
241
- const Rt = { class: "text-fm-color-typo-secondary" }, Ut = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, Et = { class: "col-span-2 mt-16" }, Dt = { class: "col-span-2 mt-16 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16" }, At = { class: "w-full" }, Tt = {
242
- key: 0,
243
- class: "flex flex-col gap-8"
244
- }, Pt = {
245
- type: "button",
246
- class: "inline-flex h-32 items-center"
247
- }, Bt = {
248
- key: 2,
249
- class: "col-span-2 mt-16 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
250
- }, zt = { class: "col-span-2 flex flex-col gap-12" }, Lt = { class: "flex flex-col gap-4" }, Nt = { class: "fm-typo-en-title-sm-800" }, jt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ht = { class: "col-span-2 flex flex-col gap-4" }, Ot = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, Yt = { class: "flex-1 p-12 flex flex-col gap-8" }, Gt = { class: "mx-auto" }, qt = { class: "flex flex-col" }, Wt = { class: "fm-typo-en-body-sm-600 translate-y-4" }, Kt = /* @__PURE__ */ c("div", {
251
- class: "text-fm-color-typo-secondary",
252
- style: { "padding-right": "32px" }
253
- }, "days", -1), Jt = /* @__PURE__ */ c("div", {
254
- class: "h-full bg-fm-color-neutral-gray-200 relative",
255
- style: { width: "1px" }
256
- }, [
257
- /* @__PURE__ */ c("div", {
258
- class: "absolute bg-white",
259
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
260
- }, " < ")
261
- ], -1), Qt = { class: "flex-1 p-12 flex flex-col gap-8" }, Xt = { class: "mx-auto" }, Zt = { class: "flex flex-col" }, en = { class: "fm-typo-en-body-sm-600 translate-y-4" }, tn = /* @__PURE__ */ c("div", {
262
- class: "text-fm-color-typo-secondary",
263
- style: { "padding-right": "32px" }
264
- }, "days", -1), nn = /* @__PURE__ */ c("div", {
265
- class: "h-full bg-fm-color-neutral-gray-200 relative",
266
- style: { width: "1px" }
267
- }, [
268
- /* @__PURE__ */ c("div", {
269
- class: "absolute bg-white",
270
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
271
- }, " < ")
272
- ], -1), on = { class: "flex-1 p-12 flex flex-col gap-8" }, ln = { class: "mx-auto" }, an = { class: "flex flex-col" }, rn = { class: "fm-typo-en-body-sm-600 translate-y-4" };
273
- var Ie = /* @__PURE__ */ ((s) => (s.Daily = "Daily", s.Consumables = "Consumables", s.ShortTerm = "Short term", s.Kitchen = "Kitchen", s))(Ie || {});
274
- const sn = /* @__PURE__ */ le({
275
- __name: "IngredientForm",
276
- props: {
277
- mode: {},
278
- modelValue: {},
279
- disabled: { type: Boolean }
280
- },
281
- emits: ["update:modelValue", "click:submit"],
282
- setup(s, { expose: i, emit: m }) {
283
- var pe;
284
- const { t: r } = re(), t = s, l = m, o = ae(), p = fe(), b = We();
285
- function _(e) {
286
- if (e.length === 0) return;
287
- const n = e[0], v = t.modelValue ?? {
288
- unit: o.units.find((k) => k)
289
- };
290
- v.unit || (v.unit = n, l("update:modelValue", v));
291
- }
292
- nt(() => {
293
- _(o.units);
294
- }), je([() => o.units], ([e]) => {
295
- _(e);
296
- });
297
- function g() {
298
- l("click:submit");
299
- }
300
- const h = C({
301
- get() {
302
- var e;
303
- return ((e = t.modelValue) == null ? void 0 : e.code) ?? "";
304
- },
305
- set(e) {
306
- const n = t.modelValue ? {
307
- ...t.modelValue
308
- } : {};
309
- n.code = e, l("update:modelValue", n);
310
- }
311
- }), u = C({
312
- get() {
313
- var e;
314
- return ((e = t.modelValue) == null ? void 0 : e.name) ?? "";
315
- },
316
- set(e) {
317
- const n = t.modelValue ? {
318
- ...t.modelValue
319
- } : {};
320
- n.name = e, l("update:modelValue", n);
321
- }
322
- }), x = C({
323
- get() {
324
- var n, v;
325
- const e = (v = (n = t.modelValue) == null ? void 0 : n.defaultCost) == null ? void 0 : v.costPerUnit;
326
- return e ? +Ge(e) : 0;
327
- },
328
- set(e) {
329
- var v, k, T, I;
330
- const n = t.modelValue ? {
331
- ...t.modelValue
332
- } : {};
333
- n.defaultCost ?? (n.defaultCost = {
334
- costPerUnit: {
335
- amount: 0,
336
- precision: 2,
337
- currency: ((v = xe(p.currentCountry.value)) == null ? void 0 : v.currency) ?? "MYR"
338
- },
339
- measurement: (I = (T = (k = t.modelValue) == null ? void 0 : k.unit) == null ? void 0 : T.measurements) == null ? void 0 : I.find(
340
- (Y) => {
341
- var G;
342
- return Y.id === ((G = t.modelValue) == null ? void 0 : G.trackingMeasurement);
343
- }
344
- )
345
- }), n.defaultCost.costPerUnit = {
346
- ...n.defaultCost.costPerUnit,
347
- ...qe(+e, 4)
348
- }, l("update:modelValue", n);
349
- }
350
- }), D = C(() => {
351
- var n, v, k;
352
- const e = ((n = t.modelValue) == null ? void 0 : n.unit) ?? o.units.find((T) => T);
353
- return e ? {
354
- _id: e._id,
355
- measurement: (v = t.modelValue) == null ? void 0 : v.trackingMeasurement,
356
- name: ((k = e.measurements.find((T) => {
357
- var I;
358
- return T.id === ((I = t.modelValue) == null ? void 0 : I.trackingMeasurement);
359
- })) == null ? void 0 : k.name) ?? e.name
360
- } : null;
361
- }), S = C(
362
- () => o.units.flatMap(({ name: e, _id: n, abbrev: v, measurements: k }) => [
363
- {
364
- label: `${e}`,
365
- value: null,
366
- displayAsSection: !0
367
- },
368
- {
369
- label: `${e} (${v})`,
370
- value: { _id: n },
371
- displayAsSection: !1
372
- },
373
- ...k.map(({ id: T, name: I, abbrev: Y }) => ({
374
- label: `${I} (${Y})`,
375
- value: { _id: n, measurement: T },
376
- displayAsSection: !1
377
- }))
378
- ])
379
- );
380
- function w(e) {
381
- var n, v, k, T, I;
382
- return ((v = (n = t.modelValue) == null ? void 0 : n.unit) == null ? void 0 : v._id) === ((k = e.value) == null ? void 0 : k._id) && ((T = t.modelValue) == null ? void 0 : T.trackingMeasurement) === ((I = e.value) == null ? void 0 : I.measurement);
383
- }
384
- function M(e) {
385
- var Y, G;
386
- if (!e) return;
387
- const { _id: n, measurement: v } = e, k = v || void 0, T = o.units.find((ie) => ie._id === n);
388
- if (!T)
389
- return;
390
- const I = t.modelValue ?? {};
391
- I.unit = T, I.trackingMeasurement = k, I.convert && (I.convert.measurement = k || null), b.enableTotalCost && (I.defaultCost = {
392
- measurement: T.measurements.find((ie) => ie.id === k),
393
- costPerUnit: {
394
- ...((Y = I.defaultCost) == null ? void 0 : Y.costPerUnit) ?? {
395
- amount: 0,
396
- precision: 2,
397
- currency: ((G = xe(p.currentCountry.value)) == null ? void 0 : G.currency) ?? "MYR"
398
- }
399
- }
400
- }), l("update:modelValue", I);
401
- }
402
- const V = C({
403
- get() {
404
- var e;
405
- return ((e = t.modelValue) == null ? void 0 : e.operationalGroup) ?? null;
406
- },
407
- set(e) {
408
- const n = t.modelValue ? {
409
- ...t.modelValue
410
- } : {};
411
- n.operationalGroup = e, l("update:modelValue", n);
412
- }
413
- }), H = C(
414
- () => [
415
- ...new Set(
416
- o.skus.map((e) => e.operationalGroup ?? "").filter((e) => e && !Object.values(Ie).includes(e))
417
- )
418
- ].sort()
419
- ), J = C({
420
- get() {
421
- return V.value !== null;
422
- },
423
- set(e) {
424
- e ? V.value = "" : V.value = null;
425
- }
426
- }), ee = C({
427
- get() {
428
- var e;
429
- return ((e = t.modelValue) == null ? void 0 : e.convert) ?? null;
430
- },
431
- set(e) {
432
- const n = t.modelValue ? {
433
- ...t.modelValue
434
- } : {};
435
- e ? n.convert = e : n.convert = null, l("update:modelValue", n);
436
- }
437
- }), de = C(() => ve.options.filter(
438
- (e) => e === ve.enum.FIFO || e === ve.enum.WAVG
439
- ).map((e) => ({
440
- label: r(`inventory.ingredient.valuationMethod.${e}`),
441
- value: e
442
- }))), Z = C({
443
- get() {
444
- var e;
445
- return ((e = t.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
446
- },
447
- set(e) {
448
- const n = t.modelValue ? {
449
- ...t.modelValue
450
- } : {};
451
- n.valuation = e, l("update:modelValue", n);
452
- }
453
- }), a = z();
454
- i({
455
- validateInputs: () => {
456
- var e, n;
457
- (n = (e = a.value) == null ? void 0 : e.validateInputs) == null || n.call(e);
458
- },
459
- resetInputsValidation: () => {
460
- var e, n;
461
- (n = (e = a.value) == null ? void 0 : e.resetInputsValidation) == null || n.call(e);
462
- },
463
- resetInputs: () => {
464
- var e, n;
465
- (n = (e = a.value) == null ? void 0 : e.resetInputs) == null || n.call(e);
466
- }
467
- });
468
- const N = z(!1), W = C(
469
- () => {
470
- var e, n, v;
471
- return (e = t.modelValue) != null && e._id ? ((v = o.menu.bindedBySkuId[(n = t.modelValue) == null ? void 0 : n._id]) == null ? void 0 : v.filter(
472
- (k) => k.from === "INGREDIENT"
473
- )) ?? [] : [];
474
- }
475
- ), se = C(
476
- () => {
477
- var e, n, v;
478
- return (e = t.modelValue) != null && e._id ? ((v = o.menu.bindedBySkuId[(n = t.modelValue) == null ? void 0 : n._id]) == null ? void 0 : v.filter(
479
- (k) => k.from === "RECIPE"
480
- )) ?? [] : [];
481
- }
482
- ), te = C(
483
- () => {
484
- var e, n, v;
485
- return (e = t.modelValue) != null && e._id ? ((v = o.menu.bindedBySkuId[(n = t.modelValue) == null ? void 0 : n._id]) == null ? void 0 : v.filter((k) => k.from === "MENU")) ?? [] : [];
486
- }
487
- ), A = C(
488
- () => o.skus.map((e) => ({ label: e.name, value: e.code }))
489
- ), E = z((pe = t.modelValue) == null ? void 0 : pe.code);
490
- function ce(e) {
491
- var v;
492
- const n = e.el;
493
- n && ((v = n.querySelector("[x-should-scroll-into=true]")) == null || v.scrollIntoView());
494
- }
495
- function ne(e) {
496
- switch (e) {
497
- case Ce.MY:
498
- return "MYR";
499
- case Ce.SG:
500
- return "SGD";
501
- case Ce.ID:
502
- return "IDR";
503
- default:
504
- return "MYR";
505
- }
506
- }
507
- const me = C(
508
- () => {
509
- var e, n, v, k, T, I;
510
- return ((k = (v = (n = (e = t.modelValue) == null ? void 0 : e.unit) == null ? void 0 : n.measurements) == null ? void 0 : v.find(
511
- (Y) => {
512
- var G;
513
- return Y.id === ((G = t.modelValue) == null ? void 0 : G.trackingMeasurement);
514
- }
515
- )) == null ? void 0 : k.abbrev) ?? ((I = (T = t.modelValue) == null ? void 0 : T.unit) == null ? void 0 : I.abbrev);
516
- }
517
- ), P = C({
518
- get() {
519
- var e, n;
520
- return ((n = (e = t.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : n.low) ?? ue().low;
521
- },
522
- set(e) {
523
- var k;
524
- const n = ((k = t.modelValue) == null ? void 0 : k.thresholds) ?? ue();
525
- n.low = e;
526
- const v = t.modelValue ? {
527
- ...t.modelValue
528
- } : {};
529
- v.thresholds = n, l("update:modelValue", v);
530
- }
531
- }), j = C({
532
- get() {
533
- var e, n;
534
- return ((n = (e = t.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : n.mid) ?? ue().mid;
535
- },
536
- set(e) {
537
- var k;
538
- const n = ((k = t.modelValue) == null ? void 0 : k.thresholds) ?? ue();
539
- n.mid = e;
540
- const v = t.modelValue ? {
541
- ...t.modelValue
542
- } : {};
543
- v.thresholds = n, l("update:modelValue", v);
544
- }
545
- });
546
- function ye() {
547
- return function(n) {
548
- return typeof (n == null ? void 0 : n.low) != "number" || typeof (n == null ? void 0 : n.mid) != "number" ? "Required" : n.low >= n.mid ? "Days for red indicator should be less than yellow indicator." : !0;
549
- };
550
- }
551
- return (e, n) => {
552
- const v = R("FmTextField"), k = R("FmLabel"), T = R("FmField"), I = R("FmMenuHeader"), Y = R("FmMenuDivider"), G = R("FmMenuItem"), ie = R("FmMenu"), ke = R("FmFormGroup"), Ze = R("FmSelect"), Re = R("FmSwitch"), et = R("FmIcon"), Ue = R("FmStepperField"), tt = R("FmForm");
553
- return y(), B(tt, {
554
- disabled: e.disabled,
555
- ref_key: "formRef",
556
- ref: a,
557
- class: "grid grid-cols-2 gap-24",
558
- onValidationSuccess: g
559
- }, {
560
- default: $(() => [
561
- f(v, {
562
- label: d(r)("inventory.ingredient.code"),
563
- "model-value": h.value,
564
- "onUpdate:modelValue": n[0] || (n[0] = (F) => h.value = F),
565
- rules: [d(be)(), d(it)(A.value, E.value)],
566
- "label-mark": "required"
567
- }, null, 8, ["label", "model-value", "rules"]),
568
- f(v, {
569
- label: d(r)("inventory.ingredient.name"),
570
- "model-value": u.value,
571
- "onUpdate:modelValue": n[1] || (n[1] = (F) => u.value = F),
572
- rules: [d(be)()],
573
- "label-mark": "required"
574
- }, null, 8, ["label", "model-value", "rules"]),
575
- f(ke, {
576
- class: "col-span-2",
577
- "model-value": D.value,
578
- rules: [d(be)()],
579
- "label-mark": "required"
580
- }, {
581
- label: $(() => [
582
- f(k, {
583
- label: d(r)("inventory.ingredient.unit")
584
- }, null, 8, ["label"])
585
- ]),
586
- default: $(({ invalid: F }) => [
587
- f(ie, null, {
588
- "menu-button": $(() => [
589
- f(T, {
590
- class: X([
591
- "fm-typo-en-body-lg-400",
592
- {
593
- "text-fm-color-typo-primary": !e.disabled,
594
- "text-fm-color-typo-disabled": e.disabled
595
- }
596
- ]),
597
- invalid: F,
598
- "append-icon": "expand_more"
599
- }, {
600
- default: $(() => {
601
- var q;
602
- return [
603
- He(L((q = D.value) == null ? void 0 : q.name), 1)
604
- ];
605
- }),
606
- _: 2
607
- }, 1032, ["class", "invalid"])
608
- ]),
609
- default: $(() => [
610
- c("div", {
611
- class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
612
- onVnodeMounted: ce
613
- }, [
614
- (y(!0), U(Q, null, oe(S.value, (q) => (y(), U(Q, {
615
- key: q.label
616
- }, [
617
- q.displayAsSection ? (y(), U(Q, { key: 0 }, [
618
- f(I, {
619
- label: q.label
620
- }, null, 8, ["label"]),
621
- f(Y)
622
- ], 64)) : (y(), B(G, {
623
- key: 1,
624
- label: q.label,
625
- "model-value": w(q),
626
- onClick: (Gn) => M(q.value),
627
- "x-should-scroll-into": `${w(q)}`
628
- }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
629
- ], 64))), 128))
630
- ], 512)
631
- ]),
632
- _: 2
633
- }, 1024)
634
- ]),
635
- _: 1
636
- }, 8, ["model-value", "rules"]),
637
- d(b).enableTotalCost ? (y(), B(Ze, {
638
- key: 0,
639
- class: "col-span-1",
640
- "model-value": Z.value,
641
- "onUpdate:modelValue": n[2] || (n[2] = (F) => Z.value = F),
642
- items: de.value
643
- }, {
644
- label: $(() => [
645
- f(Me, { "z-index": 50 }, {
646
- default: $(() => [
647
- f(k, {
648
- label: d(r)("inventory.ingredient.valuationMethod.title")
649
- }, null, 8, ["label"])
650
- ]),
651
- _: 1
652
- })
653
- ]),
654
- _: 1
655
- }, 8, ["model-value", "items"])) : O("", !0),
656
- d(b).enableTotalCost ? (y(), B(v, {
657
- key: 1,
658
- "model-value": x.value,
659
- "onUpdate:modelValue": n[3] || (n[3] = (F) => x.value = F),
660
- rules: [d(_e)(0), d(ut)(4)]
661
- }, {
662
- label: $(() => [
663
- f(Me, { "z-index": 50 }, {
664
- default: $(() => [
665
- f(k, {
666
- label: d(r)("inventory.ingredient.pricePerUnit")
667
- }, null, 8, ["label"])
668
- ]),
669
- _: 1
670
- })
671
- ]),
672
- prepend: $(() => {
673
- var F, q;
674
- return [
675
- c("div", Rt, L(ne(((F = d(p).currentCountry) == null ? void 0 : F.value) ?? d(Ae)) === "MYR" ? "RM" : ne(((q = d(p).currentCountry) == null ? void 0 : q.value) ?? d(Ae))), 1)
676
- ];
677
- }),
678
- append: $(() => [
679
- c("div", Ut, " / " + L(me.value), 1)
680
- ]),
681
- _: 1
682
- }, 8, ["model-value", "rules"])) : O("", !0),
683
- c("div", Et, [
684
- f(It, {
685
- "model-value": ee.value,
686
- "onUpdate:modelValue": n[4] || (n[4] = (F) => ee.value = F),
687
- "root-value": e.modelValue
688
- }, null, 8, ["model-value", "root-value"])
689
- ]),
690
- c("div", Dt, [
691
- c("div", At, [
692
- f(Re, {
693
- label: d(r)("inventory.ingredient.operational.applyOperationalGroup"),
694
- sublabel: d(r)("inventory.ingredient.operational.subtitle"),
695
- modelValue: J.value,
696
- "onUpdate:modelValue": n[5] || (n[5] = (F) => J.value = F),
697
- "label-placement": "right"
698
- }, null, 8, ["label", "sublabel", "modelValue"])
699
- ]),
700
- J.value ? (y(), U("div", Tt, [
701
- f(ie, null, {
702
- "menu-button": $(() => [
703
- f(v, {
704
- label: d(r)("inventory.ingredient.operational.operationalLabel"),
705
- modelValue: V.value,
706
- "onUpdate:modelValue": n[6] || (n[6] = (F) => V.value = F),
707
- placeholder: d(r)("inventory.ingredient.operational.operationalLabelHint")
708
- }, {
709
- append: $(() => [
710
- c("button", Pt, [
711
- f(et, { name: "expand_more" })
712
- ])
713
- ]),
714
- _: 1
715
- }, 8, ["label", "modelValue", "placeholder"])
716
- ]),
717
- default: $(() => [
718
- f(I, {
719
- label: d(r)("inventory.ingredient.operational.preset")
720
- }, null, 8, ["label"]),
721
- (y(!0), U(Q, null, oe(Object.values(Ie), (F) => (y(), B(G, {
722
- key: F,
723
- label: F,
724
- "model-value": V.value === F,
725
- onClick: (q) => V.value = F
726
- }, null, 8, ["label", "model-value", "onClick"]))), 128)),
727
- H.value.length ? (y(), B(I, {
728
- key: 0,
729
- label: d(r)("inventory.ingredient.operational.custom")
730
- }, null, 8, ["label"])) : O("", !0),
731
- (y(!0), U(Q, null, oe(H.value, (F) => (y(), B(G, {
732
- key: F,
733
- label: F,
734
- "model-value": V.value === F,
735
- onClick: (q) => V.value = F
736
- }, null, 8, ["label", "model-value", "onClick"]))), 128))
737
- ]),
738
- _: 1
739
- }),
740
- f(ke, {
741
- "model-value": V.value,
742
- rules: [d(be)()]
743
- }, null, 8, ["model-value", "rules"])
744
- ])) : O("", !0)
745
- ]),
746
- e.mode !== d(K).CREATE ? (y(), U("div", Bt, [
747
- c("div", null, [
748
- f(Re, {
749
- label: d(r)("inventory.ingredient.bindedItems.title"),
750
- modelValue: N.value,
751
- "onUpdate:modelValue": n[7] || (n[7] = (F) => N.value = F),
752
- "label-placement": "right"
753
- }, null, 8, ["label", "modelValue"])
754
- ]),
755
- N.value && W.value.length ? (y(), B(we, {
756
- key: 0,
757
- name: d(r)("inventory.ingredient.bindedItems.ingredient"),
758
- bindings: W.value
759
- }, null, 8, ["name", "bindings"])) : O("", !0),
760
- N.value && se.value.length ? (y(), B(we, {
761
- key: 1,
762
- name: d(r)("inventory.ingredient.bindedItems.recipe"),
763
- bindings: se.value
764
- }, null, 8, ["name", "bindings"])) : O("", !0),
765
- N.value && te.value.length ? (y(), B(we, {
766
- key: 2,
767
- name: d(r)("inventory.ingredient.bindedItems.menu"),
768
- bindings: te.value
769
- }, null, 8, ["name", "bindings"])) : O("", !0)
770
- ])) : O("", !0),
771
- c("div", zt, [
772
- c("div", Lt, [
773
- f(Me, null, {
774
- default: $(() => [
775
- c("div", Nt, L(d(r)("inventory.ingredient.threshold.title")), 1)
776
- ]),
777
- _: 1
778
- }),
779
- c("div", jt, L(d(r)("inventory.ingredient.threshold.subtitle")), 1)
780
- ]),
781
- c("div", Ht, [
782
- f(ke, {
783
- "model-value": { low: P.value, mid: j.value },
784
- rules: [ye()]
785
- }, null, 8, ["model-value", "rules"]),
786
- c("div", Ot, [
787
- c("div", Yt, [
788
- c("div", Gt, [
789
- f(Fe, {
790
- days: P.value,
791
- level: d(Se).low
792
- }, null, 8, ["days", "level"])
793
- ]),
794
- c("div", qt, [
795
- c("div", Wt, L(d(r)("inventory.ingredient.threshold.whenRemaining")), 1),
796
- f(Ue, {
797
- modelValue: P.value,
798
- "onUpdate:modelValue": n[8] || (n[8] = (F) => P.value = F),
799
- rules: [d(_e)(0)]
800
- }, {
801
- append: $(() => [
802
- Kt
803
- ]),
804
- _: 1
805
- }, 8, ["modelValue", "rules"])
806
- ])
807
- ]),
808
- Jt,
809
- c("div", Qt, [
810
- c("div", Xt, [
811
- f(Fe, {
812
- days: j.value,
813
- level: d(Se).mid
814
- }, null, 8, ["days", "level"])
815
- ]),
816
- c("div", Zt, [
817
- c("div", en, L(d(r)("inventory.ingredient.threshold.whenRemaining")), 1),
818
- f(Ue, {
819
- modelValue: j.value,
820
- "onUpdate:modelValue": n[9] || (n[9] = (F) => j.value = F),
821
- rules: [d(_e)(0)]
822
- }, {
823
- append: $(() => [
824
- tn
825
- ]),
826
- _: 1
827
- }, 8, ["modelValue", "rules"])
828
- ])
829
- ]),
830
- nn,
831
- c("div", on, [
832
- c("div", ln, [
833
- f(Fe, {
834
- days: j.value + 1,
835
- level: d(Se).high
836
- }, null, 8, ["days", "level"])
837
- ]),
838
- c("div", an, [
839
- c("div", rn, L(d(r)("inventory.ingredient.threshold.stockIsStaple")), 1)
840
- ])
841
- ])
842
- ])
843
- ])
844
- ])
845
- ]),
846
- _: 1
847
- }, 8, ["disabled"]);
848
- };
849
- }
850
- }), un = { class: "flex gap-4" }, dn = /* @__PURE__ */ le({
851
- __name: "IngredientDialog",
852
- props: {
853
- show: { type: Boolean },
854
- unit: {},
855
- mode: { default: K.READ }
856
- },
857
- emits: ["update:show"],
858
- setup(s) {
859
- const i = s, m = ae(), r = Ve(), { t } = re(), l = Pe(i, "show"), o = Pe(i, "unit"), p = C(() => {
860
- switch (i.mode) {
861
- case K.READ:
862
- return "";
863
- case K.UPDATE:
864
- return t("inventory.ingredient.update.title");
865
- case K.CREATE:
866
- return t("inventory.ingredient.create.title");
867
- }
868
- return "";
869
- }), b = C(() => {
870
- switch (i.mode) {
871
- case K.READ:
872
- return "";
873
- case K.UPDATE:
874
- return t("common.save");
875
- case K.CREATE:
876
- return t("common.add");
877
- }
878
- return "";
879
- }), _ = z(), g = z(!1);
880
- async function h() {
881
- g.value = !0;
882
- try {
883
- await m.createSku(o.value), l.value = !1, r.open({
884
- title: t("common.success"),
885
- message: t("inventory.ingredient.create.success", { name: o.value.name }),
886
- type: "success"
887
- });
888
- } catch (S) {
889
- S instanceof Te || r.open({
890
- title: t("inventory.ingredient.create.error.title"),
891
- message: t("inventory.ingredient.create.error.message"),
892
- type: "error"
893
- });
894
- } finally {
895
- g.value = !1;
896
- }
897
- }
898
- async function u() {
899
- g.value = !0;
900
- try {
901
- await m.updateSku(o.value), g.value = !1, l.value = !1, r.open({
902
- title: t("common.success"),
903
- message: t("inventory.ingredient.update.success", { name: o.value.name }),
904
- type: "success"
905
- });
906
- } catch (S) {
907
- S instanceof Te || r.open({
908
- title: t("inventory.ingredient.update.error.title"),
909
- message: t("inventory.ingredient.update.error.message"),
910
- type: "error"
911
- });
912
- } finally {
913
- g.value = !1;
914
- }
915
- }
916
- function x() {
917
- var S, w;
918
- (w = (S = _.value) == null ? void 0 : S.validateInputs) == null || w.call(S);
919
- }
920
- function D() {
921
- switch (i.mode) {
922
- case K.READ:
923
- return;
924
- case K.UPDATE:
925
- return u();
926
- case K.CREATE:
927
- return h();
928
- }
929
- }
930
- return (S, w) => {
931
- const M = R("FmButton"), V = R("FmSideSheet");
932
- return y(), B(V, {
933
- "model-value": d(l),
934
- "onUpdate:modelValue": w[3] || (w[3] = (H) => Ee(l) ? l.value = H : null),
935
- header: p.value,
936
- "close-button": "",
937
- "dismiss-away": "",
938
- "max-width": 500
939
- }, {
940
- "side-sheet-footer": $(() => [
941
- c("div", un, [
942
- f(M, {
943
- loading: g.value,
944
- label: b.value,
945
- onClick: x
946
- }, null, 8, ["loading", "label"]),
947
- f(M, {
948
- disabled: g.value,
949
- label: d(t)("common.close"),
950
- variant: "tertiary",
951
- onClick: w[2] || (w[2] = (H) => l.value = !1)
952
- }, null, 8, ["disabled", "label"])
953
- ])
954
- ]),
955
- default: $(() => [
956
- f(sn, {
957
- class: "w-full",
958
- ref_key: "hasValidationExpose",
959
- ref: _,
960
- modelValue: d(o),
961
- "onUpdate:modelValue": w[0] || (w[0] = (H) => Ee(o) ? o.value = H : null),
962
- mode: S.mode,
963
- disabled: g.value,
964
- "onClick:submit": w[1] || (w[1] = (H) => D())
965
- }, null, 8, ["modelValue", "mode", "disabled"])
966
- ]),
967
- _: 1
968
- }, 8, ["model-value", "header"]);
969
- };
970
- }
971
- });
972
- function* cn(s) {
973
- for (; ; )
974
- yield s[Math.floor(Math.random() * s.length)];
975
- }
976
- function mn(s = 4, i = cn("qwertyuiopasdfghjklzxcvbnm".split(""))) {
977
- return Array.from({ length: s }).map(() => i.next().value).join("");
978
- }
979
- function pn() {
980
- return `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${mn()}`;
981
- }
982
- const vn = {
983
- _id: "",
984
- name: "",
985
- abbrev: "",
986
- precision: 0,
987
- measurements: []
988
- };
989
- function fn(s) {
990
- var m, r, t, l, o;
991
- return {
992
- code: s.code,
993
- name: s.name,
994
- unit: ((m = s.unit.measurements.find((p) => p.id === s.trackingMeasurement)) == null ? void 0 : m.abbrev) ?? s.unit.abbrev,
995
- baseUnit: s.unit.abbrev,
996
- valuationMethod: s.valuation ?? "WAVG",
997
- pricePerUnit: (r = s.defaultCost) != null && r.costPerUnit ? +Ge((t = s.defaultCost) == null ? void 0 : t.costPerUnit) : 0,
998
- thresholdLow: ((l = s.thresholds) == null ? void 0 : l.low) ?? ue().low,
999
- thresholdMid: ((o = s.thresholds) == null ? void 0 : o.mid) ?? ue().mid
1000
- };
1001
- }
1002
- function Xe() {
1003
- var t;
1004
- const s = [
1005
- {
1006
- id: "code",
1007
- name: "Code"
1008
- },
1009
- {
1010
- id: "name",
1011
- name: "Name"
1012
- },
1013
- {
1014
- id: "unit",
1015
- name: "Unit"
1016
- },
1017
- {
1018
- id: "baseUnit",
1019
- name: "Base unit"
1020
- }
1021
- ], i = We(), m = fe(), r = xe(m.currentCountry.value);
1022
- return i.enableTotalCost && s.push(
1023
- {
1024
- id: "valuationMethod",
1025
- name: "Valuation method"
1026
- },
1027
- {
1028
- id: "pricePerUnit",
1029
- name: `Price per unit (${r == null ? void 0 : r.currency})`
1030
- }
1031
- ), ((t = m.currentBusiness.value) == null ? void 0 : t.menuVersion) === "v4" && s.push(
1032
- {
1033
- id: "thresholdLow",
1034
- name: "Show RED when remaining"
1035
- },
1036
- {
1037
- id: "thresholdMid",
1038
- name: "Show YELLOW when remaining"
1039
- }
1040
- ), s;
1041
- }
1042
- function yn() {
1043
- const i = ae().skus.map(fn), r = fe().currentBusiness.value, t = Xe(), l = [
1044
- ["Business name:", r == null ? void 0 : r.name],
1045
- ["Business ID:", r == null ? void 0 : r._id],
1046
- ["Menu version", r == null ? void 0 : r.menuVersion],
1047
- [],
1048
- t.map((_) => _.name),
1049
- ...i.map((_) => t.map((g) => _[g.id]))
1050
- ], o = t.map((_) => `system:${_.id}`), p = Je(l, o), b = `${r == null ? void 0 : r.name} ingredients (${dt(/* @__PURE__ */ new Date())}).xlsx`;
1051
- return Qe(p, b), b;
1052
- }
1053
- function gn() {
1054
- const i = fe().currentBusiness.value, m = Xe(), r = [
1055
- ["Business name:", i == null ? void 0 : i.name],
1056
- ["Business ID:", i == null ? void 0 : i._id],
1057
- ["Menu version", i == null ? void 0 : i.menuVersion],
1058
- [],
1059
- m.map((p) => p.name)
1060
- ], t = m.map((p) => `system:${p.id}`), l = Je(r, t), o = "FeedMe ingredients template.xlsx";
1061
- return Qe(l, o), o;
1062
- }
1063
- function bn(s) {
1064
- const [
1065
- i,
1066
- m,
1067
- r,
1068
- t,
1069
- l,
1070
- o,
1071
- ...p
1072
- ] = wt(s);
1073
- if (!i || !i.length || i.some((u) => u.length && !u.startsWith("system:")))
1074
- throw new Error("Missing meta header. Excel file does not come from the template.");
1075
- const b = i.map((u) => u.split(":")[1]), g = ["code", "name", "unit", "baseUnit"].filter((u) => !b.includes(u));
1076
- if (g.length)
1077
- throw new Error(
1078
- `Missing meta headers (${g.join()}). Excel file does not come from the template.`
1079
- );
1080
- return p.map((u, x) => {
1081
- const D = {};
1082
- for (const S in b) {
1083
- const w = b[S];
1084
- Object.assign(D, { [w]: u[S] });
1085
- }
1086
- return {
1087
- index: x,
1088
- data: D
1089
- };
1090
- });
1091
- }
1092
- function Le(s, i, m) {
1093
- var M;
1094
- const t = ae().units, l = new Array(), o = m.filter((V) => V.data.code === s.code);
1095
- o.length > 1 && l.push(
1096
- `Code ${s.code} is already used in row ${o.map((V) => V.index + 6).join()}.`
1097
- );
1098
- const p = t.find((V) => V.abbrev === s.baseUnit), b = p == null ? void 0 : p.measurements.find((V) => V.abbrev === s.unit);
1099
- if (!p)
1100
- l.push(`Cannot find base unit of symbol ${s.baseUnit}.`);
1101
- else if (s.baseUnit !== s.unit && !b) {
1102
- const V = `Cannot find unit conversion for ${s.baseUnit} with symbol ${s.unit || "[empty]"}.`;
1103
- l.push(V);
1104
- }
1105
- const _ = ve.options.find(
1106
- (V) => V === s.valuationMethod
1107
- );
1108
- s.valuationMethod && !_ && l.push(
1109
- `Expected valuation method to be one of ${ve.options.join()} but got ${s.valuationMethod} instead.`
1110
- );
1111
- const h = fe().currentCountry.value, u = (V) => `${V}`.length && mt()(V) === !0, x = u(`${s.pricePerUnit}`) === !0 ? {
1112
- costPerUnit: {
1113
- ...qe(Number(s.pricePerUnit) || 0),
1114
- currency: ((M = xe(h)) == null ? void 0 : M.currency) ?? "MYR"
1115
- },
1116
- measurement: b
1117
- } : void 0, D = u(`${s.thresholdLow}`) && u(`${s.thresholdMid}`) ? {
1118
- low: Number(s.thresholdLow) || 0,
1119
- mid: Number(s.thresholdMid) || 0
1120
- } : void 0;
1121
- return {
1122
- type: "create",
1123
- sku: {
1124
- _id: pn(),
1125
- code: s.code,
1126
- name: s.name,
1127
- unit: p ?? t.find((V) => V) ?? vn,
1128
- trackingMeasurement: b == null ? void 0 : b.id,
1129
- valuation: _,
1130
- defaultCost: x,
1131
- thresholds: D
1132
- },
1133
- errors: l,
1134
- excelRowNumber: i + 6
1135
- };
1136
- }
1137
- function hn(s) {
1138
- try {
1139
- const i = bn(s).filter((_) => _.data.code), r = ae().skus, t = ct(r, "code"), l = i.filter((_) => !t[_.data.code]), o = i.filter((_) => t[_.data.code]), p = l.map(
1140
- (_) => Le(_.data, _.index, i)
1141
- ), b = o.map((_) => {
1142
- const g = Le(_.data, _.index, i), h = t[_.data.code];
1143
- return {
1144
- ...g,
1145
- type: "update",
1146
- original: h,
1147
- sku: {
1148
- // to maintain original props not in the import excel, e.g. inventory binding, etc...
1149
- ...h,
1150
- code: g.sku.code || h.code,
1151
- name: g.sku.name || h.name,
1152
- unit: g.sku.unit || h.unit,
1153
- trackingMeasurement: g.sku.trackingMeasurement || h.trackingMeasurement,
1154
- valuation: g.sku.valuation || h.valuation,
1155
- defaultCost: g.sku.defaultCost || h.defaultCost,
1156
- thresholds: g.sku.thresholds || h.thresholds
1157
- }
1158
- };
1159
- });
1160
- return {
1161
- invalidExcel: !1,
1162
- importCreateResult: p,
1163
- importUpdateResult: b
1164
- };
1165
- } catch (i) {
1166
- return {
1167
- invalidExcel: !0,
1168
- invalidExcelMessage: (i == null ? void 0 : i.message) ?? "Invalid excel",
1169
- importCreateResult: [],
1170
- importUpdateResult: []
1171
- };
1172
- }
1173
- }
1174
- const _n = {
1175
- key: 0,
1176
- class: "relative"
1177
- }, xn = ["accept", "disabled"], Vn = { class: "flex flex-col gap-8" }, kn = ["accept", "disabled"], Cn = /* @__PURE__ */ le({
1178
- __name: "FmDroppableField",
1179
- props: {
1180
- buttonLabel: {},
1181
- label: { default: "" },
1182
- disabled: { type: Boolean, default: !1 },
1183
- accept: { default: "" },
1184
- maxFileSize: { default: 8e6 },
1185
- contentClass: {}
1186
- },
1187
- emits: ["file-upload", "file-rejected"],
1188
- setup(s, { emit: i }) {
1189
- const m = s, r = i, t = z(!1), l = z(null), o = z(null), p = z(), b = (a) => {
1190
- m.disabled || (a.stopPropagation(), a.preventDefault());
1191
- }, _ = (a) => {
1192
- m.disabled || (a.stopPropagation(), a.preventDefault(), t.value = !0);
1193
- }, g = (a) => {
1194
- m.disabled || (a.stopPropagation(), a.preventDefault(), t.value = !1);
1195
- }, h = (a) => {
1196
- var N;
1197
- m.disabled || (a.stopPropagation(), a.preventDefault(), t.value = !1, u((N = a.dataTransfer) == null ? void 0 : N.files));
1198
- };
1199
- function u(a) {
1200
- if (a)
1201
- if (p.value = a, l.value = D(a[0]), o.value = S(a[0]), l.value && o.value)
1202
- r("file-upload", a[0]);
1203
- else {
1204
- const N = x();
1205
- r("file-rejected", [
1206
- {
1207
- file: a[0],
1208
- reason: N
1209
- }
1210
- ]);
1211
- }
1212
- }
1213
- const x = () => {
1214
- const a = new Array();
1215
- return l.value || a.push("invalid-type"), o.value || a.push("invalid-size"), a;
1216
- }, D = (a) => {
1217
- if (!m.accept) return !0;
1218
- const N = m.accept.split(",").map((W) => W.trim());
1219
- for (const W of N)
1220
- if (w(W)) {
1221
- if (V(W) === V(a.type)) return !0;
1222
- } else if (M(a) === W || a.type === W) return !0;
1223
- return !1;
1224
- }, S = (a) => a.size <= m.maxFileSize, w = (a) => a.indexOf("*") !== -1, M = (a) => "." + a.name.split(".").pop(), V = (a) => a.substring(0, a.indexOf("/")), H = C(() => {
1225
- if (t.value) return "Drop file to upload";
1226
- if (l.value) {
1227
- if (!o.value) return `File size exceeds ${m.maxFileSize * 1e-6}mb`;
1228
- } else return "File type is not valid";
1229
- return "";
1230
- }), J = C(() => p.value ? !l.value || !o.value : !1), ee = (a) => {
1231
- const N = a.target;
1232
- u(N.files);
1233
- }, de = C(() => {
1234
- var a;
1235
- return (a = p.value) == null ? void 0 : a.item(0);
1236
- }), Z = z();
1237
- return (a, N) => {
1238
- const W = R("FmLabel"), se = R("FmButton");
1239
- return y(), U("label", {
1240
- class: "fm-droppable-field",
1241
- ref_key: "fmButtonRef",
1242
- ref: Z
1243
- }, [
1244
- a.$slots.default ? (y(), U("div", _n, [
1245
- c("input", {
1246
- accept: a.accept,
1247
- disabled: a.disabled,
1248
- class: "fm-droppable-field__input",
1249
- type: "file",
1250
- onChange: ee
1251
- }, null, 40, xn)
1252
- ])) : O("", !0),
1253
- ge(a.$slots, "default", {
1254
- isDragging: t.value,
1255
- isValidFileType: l.value,
1256
- isValidFileSize: o.value,
1257
- singleValidFile: de.value,
1258
- openFileDialog: () => {
1259
- var te;
1260
- return console.log("click", Z.value), (te = Z.value) == null ? void 0 : te.click();
1261
- }
1262
- }, () => [
1263
- c("div", Vn, [
1264
- a.$slots.label ? ge(a.$slots, "label", { key: 0 }, void 0, !0) : (y(), B(W, {
1265
- key: 1,
1266
- label: a.label
1267
- }, null, 8, ["label"]))
1268
- ]),
1269
- c("div", {
1270
- class: X([[
1271
- a.contentClass ? a.contentClass : "w-full h-full",
1272
- {
1273
- "fm-droppable-field__container--dragging": t.value,
1274
- "fm-droppable-field__container--invalid": J.value && !a.disabled,
1275
- "fm-droppable-field__container--disabled": a.disabled
1276
- }
1277
- ], "fm-droppable-field__container"]),
1278
- onDragenter: b,
1279
- onDragleave: g,
1280
- onDragover: _,
1281
- onDrop: h
1282
- }, [
1283
- (t.value || J.value) && !a.disabled ? (y(), U("div", {
1284
- key: 0,
1285
- class: X({
1286
- "fm-typo-en-body-lg-600": !0,
1287
- "text-fm-color-primary": t.value,
1288
- "text-fm-color-typo-error": J.value
1289
- })
1290
- }, L(H.value), 3)) : (y(), B(se, {
1291
- key: 1,
1292
- disabled: a.disabled,
1293
- label: a.buttonLabel ?? "Add files",
1294
- size: "md",
1295
- variant: "secondary"
1296
- }, null, 8, ["disabled", "label"])),
1297
- ge(a.$slots, "accept-text", {}, () => [
1298
- m.accept ? (y(), U("div", {
1299
- key: 0,
1300
- class: X([[a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-md-400"])
1301
- }, L(`Accepts ${m.accept}`), 3)) : O("", !0)
1302
- ], !0),
1303
- c("input", {
1304
- accept: a.accept,
1305
- disabled: a.disabled,
1306
- class: "fm-droppable-field__input",
1307
- type: "file",
1308
- onChange: ee
1309
- }, null, 40, kn)
1310
- ], 34),
1311
- ge(a.$slots, "helper-text", {}, () => [
1312
- c("div", {
1313
- class: X([[a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-sm-400"])
1314
- }, L(`Max size ${m.maxFileSize * 1e-6}mb`), 3)
1315
- ], !0)
1316
- ], !0)
1317
- ], 512);
1318
- };
1319
- }
1320
- }), Fn = /* @__PURE__ */ pt(Cn, [["__scopeId", "data-v-311b22a0"]]), Sn = { class: "flex items-center gap-12 pl-8" }, wn = /* @__PURE__ */ c("div", null, "•", -1), Mn = { class: "flex flex-col" }, $n = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, In = {
1321
- key: 0,
1322
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1323
- }, Rn = { key: 0 }, Ne = /* @__PURE__ */ le({
1324
- __name: "ImportIngredientItem",
1325
- props: {
1326
- type: {},
1327
- code: {},
1328
- name: {},
1329
- errors: {}
1330
- },
1331
- setup(s) {
1332
- return (i, m) => {
1333
- const r = R("FmIcon"), t = R("FmTooltip");
1334
- return y(), U("div", Sn, [
1335
- wn,
1336
- c("div", Mn, [
1337
- c("div", $n, [
1338
- c("div", {
1339
- class: X({
1340
- "text-fm-color-system-error-300": i.errors.length
1341
- })
1342
- }, [
1343
- He(L(i.name) + " ", 1),
1344
- i.type === "create" ? (y(), U("span", In, "(new)")) : O("", !0)
1345
- ], 2),
1346
- i.errors.length ? (y(), U("div", Rn, [
1347
- f(t, { "z-index": 50 }, {
1348
- content: $(() => [
1349
- c("ol", null, [
1350
- (y(!0), U(Q, null, oe(i.errors, (l, o) => (y(), U("li", { key: o }, L(l), 1))), 128))
1351
- ])
1352
- ]),
1353
- default: $(() => [
1354
- f(r, {
1355
- name: "error",
1356
- size: "sm",
1357
- color: "system-error-300"
1358
- })
1359
- ]),
1360
- _: 1
1361
- })
1362
- ])) : O("", !0)
1363
- ]),
1364
- c("div", {
1365
- class: X([
1366
- "fm-typo-en-body-sm-400",
1367
- {
1368
- "text-fm-color-system-error-200": i.errors.length,
1369
- "text-fm-color-typo-secondary": !i.errors.length
1370
- }
1371
- ])
1372
- }, L(i.code), 3)
1373
- ])
1374
- ]);
1375
- };
1376
- }
1377
- }), Un = { class: "flex flex-col gap-24" }, En = { class: "fm-typo-en-body-md-400" }, Dn = { class: "flex flex-col gap-8" }, An = { class: "line-clamp-2 text-ellipsis break-all" }, Tn = {
1378
- key: 2,
1379
- class: "shrink-0"
1380
- }, Pn = {
1381
- key: 0,
1382
- class: "flex flex-col"
1383
- }, Bn = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, zn = {
1384
- key: 0,
1385
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1386
- }, Ln = { class: "fm-typo-en-body-lg-600" }, Nn = /* @__PURE__ */ le({
1387
- __name: "ImportIngredients",
1388
- setup(s) {
1389
- const i = z(null), m = ft(), r = Ve(), t = z(!1), l = z(new Array()), o = z([]), p = z([]), b = C(
1390
- () => !!l.value.length || o.value.some((u) => u.errors.length) || p.value.some((u) => u.errors.length)
1391
- ), _ = C(
1392
- () => !!o.value.length || !!p.value.length
1393
- ), { t: g } = re();
1394
- async function h(u) {
1395
- l.value = [], o.value = [], p.value = [];
1396
- try {
1397
- t.value = !0;
1398
- const [x] = await Promise.all([
1399
- Mt(u),
1400
- // fake buffer
1401
- new Promise((w) => setTimeout(w, 1e3))
1402
- ]), D = x.SheetNames.find((w) => w);
1403
- if (!D) {
1404
- l.value.push(g("inventory.ingredient.import.fileError.noSheet"));
1405
- return;
1406
- }
1407
- const S = hn(x.Sheets[D]);
1408
- if (S.invalidExcel) {
1409
- l.value.push(S.invalidExcelMessage ?? g("inventory.ingredient.import.fileError.invalidExcel"));
1410
- return;
1411
- }
1412
- if (o.value = S.importCreateResult, p.value = S.importUpdateResult, !o.value.length && !p.value.length) {
1413
- l.value.push(g("inventory.ingredient.import.fileError.noData"));
1414
- return;
1415
- }
1416
- m.emitData(S);
1417
- } catch (x) {
1418
- r.open({
1419
- title: g("inventory.ingredient.import.fileError.unableToRead"),
1420
- message: x == null ? void 0 : x.message,
1421
- type: "error"
1422
- }), console.error("Error in reading file", x);
1423
- } finally {
1424
- l.value.length && r.open({
1425
- title: g("inventory.ingredient.import.fileError.invalidExcel"),
1426
- type: "error"
1427
- }), t.value = !1;
1428
- }
1429
- }
1430
- return je(i, (u) => {
1431
- u && h(u);
1432
- }), (u, x) => {
1433
- const D = R("FmCircularProgress"), S = R("FmIcon"), w = R("FmButton");
1434
- return y(), U("div", Un, [
1435
- c("div", En, L(d(g)("inventory.ingredient.import.uploadDescription")), 1),
1436
- f(Fn, {
1437
- class: X({
1438
- "w-full": !0,
1439
- "h-[200px]": !i.value
1440
- }),
1441
- accept: ".xlsx",
1442
- onFileUpload: x[0] || (x[0] = (M) => i.value = M),
1443
- label: d(g)("inventory.ingredient.import.uploadTemplate"),
1444
- "button-label": d(g)("inventory.ingredient.import.selectFile")
1445
- }, Oe({ _: 2 }, [
1446
- i.value ? {
1447
- name: "default",
1448
- fn: $(({ openFileDialog: M }) => [
1449
- c("div", Dn, [
1450
- c("div", {
1451
- class: X([
1452
- "fm-corner-radius-md p-16 flex items-center gap-16",
1453
- {
1454
- "border border-fm-color-neutral-gray-100": t.value,
1455
- "border border-fm-color-neutral-gray-200": !t.value && !b.value,
1456
- "border border-fm-color-system-error-200": b.value
1457
- }
1458
- ])
1459
- }, [
1460
- t.value ? (y(), B(D, {
1461
- key: 0,
1462
- size: "md",
1463
- color: "neutral-gray-200"
1464
- })) : (y(), B(S, {
1465
- key: 1,
1466
- name: b.value ? "error" : "attach_file",
1467
- outline: "",
1468
- color: b.value ? "system-error-300" : void 0
1469
- }, null, 8, ["name", "color"])),
1470
- c("div", {
1471
- class: X([
1472
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1473
- {
1474
- "text-fm-color-typo-disabled": t.value,
1475
- "text-fm-color-typo-primary": !t.value
1476
- }
1477
- ])
1478
- }, [
1479
- c("div", An, L(i.value.name), 1)
1480
- ], 2),
1481
- t.value ? O("", !0) : (y(), U("div", Tn, [
1482
- f(w, {
1483
- label: d(g)("inventory.ingredient.import.replaceFile"),
1484
- variant: b.value ? "destructive" : "secondary",
1485
- "prepend-icon": b.value ? void 0 : "autorenew",
1486
- onClick: M
1487
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
1488
- ]))
1489
- ], 2),
1490
- l.value.length ? (y(), U("div", Pn, [
1491
- (y(!0), U(Q, null, oe(l.value, (V, H) => (y(), U("div", {
1492
- key: H,
1493
- class: "flex gap-8 items-center"
1494
- }, [
1495
- f(S, {
1496
- name: "error",
1497
- size: "sm",
1498
- color: "system-error-300"
1499
- }),
1500
- c("div", Bn, L(V), 1)
1501
- ]))), 128))
1502
- ])) : O("", !0)
1503
- ])
1504
- ]),
1505
- key: "0"
1506
- } : void 0
1507
- ]), 1032, ["class", "label", "button-label"]),
1508
- _.value ? (y(), U("div", zn, [
1509
- c("div", Ln, L(d(g)("inventory.ingredient.import.summary")), 1),
1510
- (y(!0), U(Q, null, oe(o.value, (M) => (y(), B(Ne, {
1511
- key: M.sku._id,
1512
- code: M.sku.code,
1513
- name: M.sku.name,
1514
- errors: M.errors,
1515
- type: "create"
1516
- }, null, 8, ["code", "name", "errors"]))), 128)),
1517
- (y(!0), U(Q, null, oe(p.value, (M) => (y(), B(Ne, {
1518
- key: M.sku._id,
1519
- code: M.sku.code,
1520
- name: M.sku.name,
1521
- errors: M.errors,
1522
- type: "update"
1523
- }, null, 8, ["code", "name", "errors"]))), 128))
1524
- ])) : O("", !0)
1525
- ]);
1526
- };
1527
- }
1528
- }), jn = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, Hn = { class: "flex flex-col py-8" }, On = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Yn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, ro = /* @__PURE__ */ le({
1529
- __name: "IngredientsView",
1530
- setup(s) {
1531
- const i = ae(), m = C(() => i.skus), r = vt(), t = Ke(), l = Ve(), { t: o } = re(), { createIngredient: p, updateIngredient: b } = $e(), { ingredientDialogProps: _, ingredientViewLoading: g } = _t($e()), { columnDefs: h } = $t();
1532
- function u(A) {
1533
- switch (A) {
1534
- case "add":
1535
- return p();
1536
- case "import":
1537
- return W();
1538
- }
1539
- }
1540
- const x = z(""), D = z(!1), S = C(() => D.value || g.value), { breakpoints: w } = yt(), M = C(() => w.value.xs || w.value.sm), V = C(() => M.value ? 10 : 20), H = kt(), J = z(!1), ee = [
1541
- {
1542
- value: "import",
1543
- label: o("common.import")
1544
- },
1545
- {
1546
- value: "export",
1547
- label: o("common.export")
1548
- }
1549
- ];
1550
- function de(A) {
1551
- switch (J.value = !1, A) {
1552
- case "import":
1553
- return W();
1554
- case "export":
1555
- return N();
1556
- }
1557
- }
1558
- const Z = C(() => M.value ? [{ icon: "more_vert", onClick: te }] : [{ icon: "ios_share", onClick: N }]), a = C(() => {
1559
- const A = [
1560
- {
1561
- label: o("inventory.ingredient.create.title"),
1562
- value: "add",
1563
- isPrimary: !0,
1564
- prependIcon: "add"
1565
- }
1566
- ];
1567
- return M.value ? A : [...A, { label: o("inventory.ingredient.import.title"), value: "import" }];
1568
- });
1569
- function N() {
1570
- const A = yn();
1571
- l.open({
1572
- title: o("inventory.ingredient.export.success"),
1573
- message: o("inventory.ingredient.export.filename", [A]),
1574
- type: "success"
1575
- });
1576
- }
1577
- function W() {
1578
- t.open({
1579
- title: o("inventory.ingredient.import.title"),
1580
- contentComponent: Nn,
1581
- overlay: !0,
1582
- closeButton: !0,
1583
- primaryActions: {
1584
- text: o("common.import"),
1585
- close: !1
1586
- },
1587
- secondaryActions: {
1588
- text: o("common.close"),
1589
- close: !0
1590
- },
1591
- tertiaryActions: {
1592
- text: o("inventory.ingredient.import.actions.downloadTemplate"),
1593
- close: !1,
1594
- variant: "plain"
1595
- }
1596
- }).onPrimary((A) => {
1597
- if (!A) {
1598
- l.open({
1599
- title: o("inventory.ingredient.import.error.noData"),
1600
- type: "error"
1601
- });
1602
- return;
1603
- }
1604
- if (!A.importCreateResult.length && !A.importUpdateResult.length) {
1605
- l.open({
1606
- title: o("inventory.ingredient.import.error.invalidContent"),
1607
- message: o("inventory.ingredient.import.error.noImportData"),
1608
- type: "error"
1609
- });
1610
- return;
1611
- }
1612
- if (A.importCreateResult.some((E) => E.errors.length) || A.importUpdateResult.some((E) => E.errors.length)) {
1613
- l.open({
1614
- title: o("inventory.ingredient.import.error.invalidContent"),
1615
- message: o("inventory.ingredient.import.error.hasErrors"),
1616
- type: "error"
1617
- });
1618
- return;
1619
- }
1620
- t.close(), se(A);
1621
- }).onTertiary(gn);
1622
- }
1623
- async function se(A) {
1624
- D.value = !0;
1625
- try {
1626
- const E = [
1627
- ...A.importCreateResult.map(({ sku: P }) => ({ type: "create", sku: P })),
1628
- ...A.importUpdateResult.map(({ sku: P }) => ({ type: "update", sku: P }))
1629
- ], ce = 100;
1630
- let ne = 0;
1631
- const me = () => {
1632
- ne += ce, l.open({
1633
- title: o("inventory.ingredient.import.progress", [
1634
- Math.min(ne, E.length),
1635
- E.length
1636
- ])
1637
- });
1638
- };
1639
- for (const P of E.chunk(100))
1640
- me(), await i.importSkus({
1641
- create: P.filter((j) => j.type === "create").map((j) => j.sku),
1642
- update: P.filter((j) => j.type === "update").map((j) => j.sku)
1643
- });
1644
- l.open({
1645
- title: o("inventory.ingredient.import.success"),
1646
- type: "success"
1647
- });
1648
- } catch (E) {
1649
- l.open({
1650
- title: o("inventory.ingredient.import.error.failed"),
1651
- message: o("inventory.ingredient.import.error.systemMessage", [E == null ? void 0 : E.message]),
1652
- type: "error"
1653
- }), console.error("Error in importing skus", A, E);
1654
- } finally {
1655
- D.value = !1;
1656
- }
1657
- }
1658
- function te() {
1659
- J.value = !0;
1660
- }
1661
- return (A, E) => {
1662
- const ce = R("FmTable"), ne = R("FmCollapsibleTabs"), me = R("FmBottomSheet");
1663
- return y(), B(Ct, {
1664
- title: d(o)("inventory.ingredient.title"),
1665
- actions: a.value,
1666
- "onClick:action": u
1667
- }, {
1668
- default: $(() => [
1669
- c("div", jn, [
1670
- f(Ft, {
1671
- searchable: "",
1672
- search: x.value,
1673
- "onUpdate:search": E[0] || (E[0] = (P) => x.value = P),
1674
- actions: Z.value
1675
- }, null, 8, ["search", "actions"]),
1676
- f(ce, {
1677
- style: ot(d(H).tableHeight),
1678
- "column-defs": d(h),
1679
- "row-data": m.value,
1680
- "search-value": x.value,
1681
- loading: !d(r)._currentLocation || S.value,
1682
- "loading-text": "Loading",
1683
- onRowClick: E[1] || (E[1] = (P) => d(b)(P.original)),
1684
- "page-size": V.value
1685
- }, {
1686
- "list-row": $((P) => [
1687
- f(Vt, {
1688
- row: P,
1689
- onRowClick: d(b)
1690
- }, Oe({
1691
- default: $((j) => {
1692
- var ye, pe, e, n, v, k, T, I, Y, G;
1693
- return [
1694
- c("div", Hn, [
1695
- c("div", On, [
1696
- f(d(ze), {
1697
- render: (e = (pe = (ye = j.code) == null ? void 0 : ye.column) == null ? void 0 : pe.columnDef) == null ? void 0 : e.cell,
1698
- props: (v = (n = j.code) == null ? void 0 : n.getContext) == null ? void 0 : v.call(n)
1699
- }, null, 8, ["render", "props"])
1700
- ]),
1701
- c("div", Yn, [
1702
- f(d(ze), {
1703
- render: (I = (T = (k = j.name) == null ? void 0 : k.column) == null ? void 0 : T.columnDef) == null ? void 0 : I.cell,
1704
- props: (G = (Y = j.name) == null ? void 0 : Y.getContext) == null ? void 0 : G.call(Y)
1705
- }, null, 8, ["render", "props"])
1706
- ])
1707
- ])
1708
- ];
1709
- }),
1710
- _: 2
1711
- }, [
1712
- D.value ? {
1713
- name: "loading-text",
1714
- fn: $(() => [
1715
- c("div", null, L(d(o)("inventory.ingredient.table.importing")), 1)
1716
- ]),
1717
- key: "0"
1718
- } : void 0
1719
- ]), 1032, ["row", "onRowClick"])
1720
- ]),
1721
- _: 1
1722
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1723
- ]),
1724
- (y(), B(De, { to: "body" }, [
1725
- f(dn, lt(at(d(_))), null, 16)
1726
- ])),
1727
- (y(), B(De, { to: "body" }, [
1728
- f(me, {
1729
- "dismiss-away": "",
1730
- modelValue: J.value,
1731
- "onUpdate:modelValue": E[3] || (E[3] = (P) => J.value = P)
1732
- }, {
1733
- default: $(() => [
1734
- f(ne, {
1735
- class: "pb-8",
1736
- items: ee,
1737
- "onUpdate:modelValue": E[2] || (E[2] = (P) => de(P))
1738
- })
1739
- ]),
1740
- _: 1
1741
- }, 8, ["modelValue"])
1742
- ]))
1743
- ]),
1744
- _: 1
1745
- }, 8, ["title", "actions"]);
1746
- };
1747
- }
1748
- });
1749
- export {
1750
- ro as default
1751
- };