@feedmepos/mf-order-setting 0.0.14 → 0.0.15-alpha.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedmepos/mf-order-setting",
3
- "version": "0.0.14",
3
+ "version": "0.0.15-alpha.1",
4
4
  "type": "module",
5
5
  "module": "./dist/app.js",
6
6
  "license": "UNLICENSED",
package/src/app.ts CHANGED
@@ -1,7 +1,11 @@
1
- import type { App } from 'vue'
2
- export { default as FmApp } from './App.vue'
3
- export { routes as routers } from '../src/router/routes'
1
+ import enUS from "./locales/en-US.json"
2
+ import zhCN from "./locales/zh-CN.json"
3
+ export type AppMessagesSchema = typeof enUS
4
4
 
5
- export function initOrderSettingApp(app: App) {
5
+ export const i18nMessages = {
6
+ "en-US": enUS,
7
+ "zh-CN": zhCN
8
+ }
6
9
 
7
- }
10
+ export { default as FmApp } from './App.vue'
11
+ export { routes as routers } from '../src/router/routes'
package/src/main.ts CHANGED
@@ -11,13 +11,7 @@ import { getAuth, signInWithCustomToken } from 'firebase/auth'
11
11
  import { initializeApp } from 'firebase/app'
12
12
  import { useIframeStore } from './stores/iframe'
13
13
  import { createFeedMeI18n, type I18n, detectLocale } from "@feedmepos/mf-common"
14
- import enUS from "./locales/en-US.json"
15
- import zhCN from "./locales/zh-CN.json"
16
-
17
- export const i18nMessages = {
18
- "en-US": enUS,
19
- "zh-CN": zhCN
20
- }
14
+ import { i18nMessages } from './app'
21
15
 
22
16
  function initI18n(): I18n {
23
17
  const i18n = createFeedMeI18n({
@@ -30,16 +24,15 @@ function initI18n(): I18n {
30
24
 
31
25
  const app = createApp(Entry)
32
26
 
33
- app.use(initI18n())
34
- app.use(createPinia())
35
- app.use(router)
36
-
37
-
38
-
39
27
  app.use(FeedMeUI, {
40
28
  locale: detectLocale(),
41
29
  })
42
30
 
31
+ app.use(createPinia())
32
+ app.use(router)
33
+ app.use(initI18n())
34
+
35
+
43
36
  const CoreStore = useCoreStore();
44
37
  const iframeMode = computed(() => {
45
38
  return new URLSearchParams(window.location.search).get('iframe') === 'true';
@@ -54,7 +54,7 @@ onMounted(async () => {
54
54
  await startAsyncCallWithErr(async () => {
55
55
  await Promise.all(
56
56
  restaurants.value.map(async (r) => {
57
- changeRestaurant(r)
57
+ await changeRestaurant(r)
58
58
  await restaurantStore.readRestaurantSetting(r._id)
59
59
  })
60
60
  )
@@ -5,22 +5,40 @@
5
5
  <div v-if="!isLoading">
6
6
  <div class="p-[1.5rem] flex flex-col gap-5">
7
7
  <FmCard variant="outlined" class="p-5 sm:w-2/3 md:w-2/3 lg:w-1/3 xl:w-1/3">
8
- <div class="flex-grow fm-typo-en-title-sm-600 mb-3">{{ t('order.enableServiceCharge') }}</div>
9
- <FmSwitch v-model="data.active" value="first"
8
+ <div class="flex-grow fm-typo-en-title-sm-600 mb-3">
9
+ {{ t('order.enableServiceCharge') }}
10
+ </div>
11
+ <FmSwitch
12
+ v-model="data.active"
13
+ value="first"
10
14
  :sublabel="t('order.serviceChargeSublabel')"
11
- :label="t('order.serviceCharge')" label-placement="right" :disabled="!canUseServiceCharge" />
12
- <div v-if="!canUseServiceCharge" class="fm-typo-en-body-md-400 text-fm-color-typo-error ml-14">
15
+ :label="t('order.serviceCharge')"
16
+ label-placement="right"
17
+ :disabled="!canUseServiceCharge"
18
+ />
19
+ <div
20
+ v-if="!canUseServiceCharge"
21
+ class="fm-typo-en-body-md-400 text-fm-color-typo-error ml-14"
22
+ >
13
23
  {{ t('order.serviceChargeRule') }}
14
24
  </div>
15
25
 
16
26
  <div class="flex flex-col gap-5 m-5" v-if="data.active">
17
- <FmRadioGroup :model-value="chargeTime" :label="t('order.chargeWhen')" @update:model-value="updateChargeWhen">
27
+ <FmRadioGroup
28
+ :model-value="chargeTime"
29
+ :label="t('order.chargeWhen')"
30
+ @update:model-value="updateChargeWhen"
31
+ >
18
32
  <FmRadio value="beforeDiscount" :label="t('order.beforeBillDiscount')" />
19
33
  <FmRadio value="afterDiscount" :label="t('order.afterBillDiscount')" />
20
34
  </FmRadioGroup>
21
35
  <RateInput :model-value="data.rate" @update:model-value="handleUpdateRate" />
22
36
 
23
- <FmRadioGroup :model-value="chargeValue" :label="t('order.selectServiceChargeType')" @update:model-value="updateInclusive">
37
+ <FmRadioGroup
38
+ :model-value="chargeValue"
39
+ :label="t('order.selectServiceChargeType')"
40
+ @update:model-value="updateInclusive"
41
+ >
24
42
  <FmRadio value="exclusive" :label="t('order.exclusive')" />
25
43
  <FmRadio value="inclusive" :label="t('order.inclusive')" />
26
44
  </FmRadioGroup>
@@ -29,24 +47,40 @@
29
47
  </div>
30
48
  <div v-if="data.active">
31
49
  <div class="flex flex-col gap-5 m-5">
32
- <div class="flex-grow fm-typo-en-title-sm-600 mb-3 mt-3">{{ t('order.customServiceCharge') }}</div>
50
+ <div class="flex-grow fm-typo-en-title-sm-600 mb-3 mt-3">
51
+ {{ t('order.customServiceCharge') }}
52
+ </div>
33
53
  <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-5">
34
54
  <div v-for="(rule, index) in data.rules" :key="index" class="h-full">
35
55
  <FmCard variant="outlined">
36
56
  <FmCardSection>
37
- <ServiceChargeRule :model-value="rule" :inclusive="data.inclusive"
38
- :charge-before-discount="isBeforeDiscountBoolean" :items="menuStore.categorizedItems"
39
- :tables="tableSettingStore.tables" :is-loading-menu="isLoadingMenu"
40
- :is-loading-table="isLoadingTables" @delete="deleteRule(index)"
41
- @update:model-value="(v: FdoServiceChargeRule) => updateRule(index, v)" />
57
+ <ServiceChargeRule
58
+ :model-value="rule"
59
+ :inclusive="data.inclusive"
60
+ :charge-before-discount="isBeforeDiscountBoolean"
61
+ :items="menuStore.categorizedItems"
62
+ :tables="tableSettingStore.tables"
63
+ :is-loading-menu="isLoadingMenu"
64
+ :is-loading-table="isLoadingTables"
65
+ @delete="deleteRule(index)"
66
+ @update:model-value="(v: FdoServiceChargeRule) => updateRule(index, v)"
67
+ />
42
68
  </FmCardSection>
43
69
  </FmCard>
44
70
  </div>
45
71
  <div>
46
- <FmCard variant="outlined" class="flex items-center justify-center w-full h-full border-dashed">
72
+ <FmCard
73
+ variant="outlined"
74
+ class="flex items-center justify-center w-full h-full border-dashed"
75
+ >
47
76
  <FmCardSection class="flex items-center justify-center w-full">
48
- <FmButton variant="plain" :label="t('order.addServiceCharge')" icon="add" @click="createRule"
49
- class="border fm-corner-radius-lg border-fm-color-primary" />
77
+ <FmButton
78
+ variant="plain"
79
+ :label="t('order.addServiceCharge')"
80
+ icon="add"
81
+ @click="createRule"
82
+ class="border fm-corner-radius-lg border-fm-color-primary"
83
+ />
50
84
  </FmCardSection>
51
85
  </FmCard>
52
86
  </div>
@@ -54,7 +88,12 @@
54
88
  </div>
55
89
  </div>
56
90
  <div class="fm-corner-radius-lg flex flex-col gap-5 m-5">
57
- <FmButton variant="primary" :label="t('order.saveSetting')" class="mr-auto" @click="updateServiceChargeSetting" />
91
+ <FmButton
92
+ variant="primary"
93
+ :label="t('order.saveSetting')"
94
+ class="mr-auto"
95
+ @click="updateServiceChargeSetting"
96
+ />
58
97
  </div>
59
98
  </div>
60
99
  <FmCircularProgress size="xxl" v-else />
@@ -145,11 +184,14 @@ function updateInclusive(inclusiveValue: string) {
145
184
  }
146
185
 
147
186
  function createRule() {
148
- data.value.rules.push({
149
- rate: data.value.rate,
150
- inclusive: data.value.inclusive,
151
- condition: {}
152
- })
187
+ data.value.rules = [
188
+ ...data.value.rules,
189
+ {
190
+ rate: data.value.rate,
191
+ inclusive: data.value.inclusive,
192
+ condition: {}
193
+ }
194
+ ]
153
195
  }
154
196
 
155
197
  function updateRule(index: number, rule: FdoServiceChargeRule) {
@@ -157,7 +199,7 @@ function updateRule(index: number, rule: FdoServiceChargeRule) {
157
199
  }
158
200
 
159
201
  function deleteRule(index: number) {
160
- data.value.rules.splice(index, 1)
202
+ data.value.rules = data.value.rules.filter((_, id) => id !== index)
161
203
  }
162
204
 
163
205
  import { useSnackbarFunctions } from '@/components/snackbar'
@@ -170,7 +212,9 @@ async function updateServiceChargeSetting() {
170
212
  await restaurantStore.updateServiceCharge(data.value)
171
213
  showSuccess('Service charge setting updated. ')
172
214
  })
173
- const restaurantSetting = await restaurantStore.readRestaurantSetting(currentRestaurant.value?._id || '')
215
+ const restaurantSetting = await restaurantStore.readRestaurantSetting(
216
+ currentRestaurant.value?._id || ''
217
+ )
174
218
  initialize(restaurantSetting)
175
219
  }
176
220
 
@@ -1,4 +0,0 @@
1
- import { _ as f } from "./app-vuQcAuTZ.js";
2
- export {
3
- f as default
4
- };