@feedmepos/mf-order-setting 0.0.106 → 0.0.107

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 (50) hide show
  1. package/dist/{DisplaySystemView-aLqc6lz9.js → DisplaySystemView-D4I6fQwr.js} +4 -4
  2. package/dist/{FoodCourtInvitationsView-B30qld2i.js → FoodCourtInvitationsView-DODbUcup.js} +4 -4
  3. package/dist/{FoodCourtOrderSettingsView-CWmaKgbe.js → FoodCourtOrderSettingsView-BPb_clxQ.js} +1 -1
  4. package/dist/{FoodCourtOrdersView-FfrganVo.js → FoodCourtOrdersView-B4jGHCvq.js} +4 -4
  5. package/dist/{FoodCourtStallsView-CpGZNP6p.js → FoodCourtStallsView-Yo5imZIL.js} +2 -2
  6. package/dist/{FoodCourtStatusView-ljQUwIwk.js → FoodCourtStatusView-Qmg07OHi.js} +1 -1
  7. package/dist/{KioskDevicesView-BwDAYIhX.js → KioskDevicesView-gnKpLlRc.js} +1 -1
  8. package/dist/{KioskDevicesView.vue_vue_type_script_setup_true_lang-VidDJfGG.js → KioskDevicesView.vue_vue_type_script_setup_true_lang-BvLOXC6b.js} +5 -5
  9. package/dist/{KioskSettingView-mfhi9vuf.js → KioskSettingView-CarJ2tfl.js} +3 -3
  10. package/dist/{KioskView-6p5h92fk.js → KioskView-BQxmKeWX.js} +8 -8
  11. package/dist/{OrderSettingsView-Cf_Ye9U_.js → OrderSettingsView-DvThEQW-.js} +38157 -32660
  12. package/dist/{RestaurantSelector.vue_vue_type_script_setup_true_lang-TJJ3PBlq.js → RestaurantSelector.vue_vue_type_script_setup_true_lang-CiZeQGB6.js} +1 -1
  13. package/dist/{app-BorqCaJT.js → app-BvIV73_P.js} +312 -300
  14. package/dist/app.js +1 -1
  15. package/dist/{dayjs.min-CTTY2vkL.js → dayjs.min-B5uDRIkW.js} +1 -1
  16. package/dist/{featureFlag-DFenoxmg.js → featureFlag-BYngu4rF.js} +1 -1
  17. package/dist/frontend/mf-order/src/app.d.ts +12 -0
  18. package/dist/frontend/mf-order/src/main.d.ts +12 -0
  19. package/dist/frontend/mf-order/src/stores/menu/menu.d.ts +134 -0
  20. package/dist/frontend/mf-order/src/views/order-settings/components/SmsCreditCard.vue.d.ts +15 -0
  21. package/dist/frontend/mf-order/src/views/order-settings/pos-status/pos-status.d.ts +19 -0
  22. package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
  23. package/dist/{index-BZkJr7iu.js → index-BBXEB6tY.js} +1 -1
  24. package/dist/{index-C4Isv-r7.js → index-BWR9_xAj.js} +1 -1
  25. package/dist/{index-tLkJL436.js → index-CGf3YUfs.js} +2 -2
  26. package/dist/{index-nUvyt9Wm.js → index-DWIzd_V1.js} +1 -1
  27. package/dist/{index-DuJOWWP8.js → index-Mnxpcwdy.js} +4 -4
  28. package/dist/{order.dto-nVwtcdX2.js → order.dto-DBYyEQ7c.js} +82 -78
  29. package/dist/package/entity/order/order.do.d.ts +21 -0
  30. package/dist/style.css +1 -1
  31. package/dist/{useInternalUser-HhxjbzGl.js → useInternalUser-DxmgUn4T.js} +1 -1
  32. package/package.json +2 -2
  33. package/src/locales/en-US.json +10 -7
  34. package/src/locales/ja-JP.json +5 -2
  35. package/src/locales/th-TH.json +10 -7
  36. package/src/locales/zh-CN.json +5 -2
  37. package/src/views/all-orders/UpdateDeliveryOrderDialog.vue +9 -9
  38. package/src/views/order-settings/components/NotifyChannelEditor.vue +1 -1
  39. package/src/views/order-settings/components/SmsCreditCard.vue +31 -0
  40. package/src/views/order-settings/components/push-availability.ts +1 -1
  41. package/src/views/order-settings/delivery/DeliverySetting.vue +2 -1
  42. package/src/views/order-settings/delivery/inhouse/InHouseDelivery.vue +2 -2
  43. package/src/views/order-settings/discount-rule/DiscountRuleSetting.vue +1 -1
  44. package/src/views/order-settings/pos-status/PosOrderingStatus.spec.ts +96 -1
  45. package/src/views/order-settings/pos-status/PosOrderingStatus.vue +24 -2
  46. package/src/views/order-settings/pos-status/pos-status.spec.ts +22 -0
  47. package/src/views/order-settings/pos-status/pos-status.ts +23 -0
  48. package/src/views/order-settings/reservation/ReservationSetting.vue +36 -1
  49. package/src/views/order-settings/reservation/reservation-sms-credit.source.spec.ts +66 -0
  50. package/src/views/order-settings/sms/SmsSetting.vue +11 -23
@@ -15,10 +15,21 @@
15
15
  </div>
16
16
  <div class="flex items-center gap-x-3 gap-y-1 flex-wrap" data-testid="pos-status-accept">
17
17
  <FmChip compact :variant="acceptChip.variant" :label="acceptChip.label" />
18
- <span class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary">
18
+ <span
19
+ v-if="!deliveryNotSetUp"
20
+ class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
21
+ data-testid="pos-status-set-on-pos"
22
+ >
19
23
  {{ t('order.posStatus.setOnPos') }}
20
24
  </span>
21
25
  </div>
26
+ <span
27
+ v-if="channel === 'delivery'"
28
+ class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
29
+ data-testid="pos-status-delivery-scope"
30
+ >
31
+ {{ t('order.posStatus.deliveryScope') }}
32
+ </span>
22
33
 
23
34
  <div
24
35
  v-if="problems.length"
@@ -81,6 +92,7 @@ import {
81
92
  formatAge,
82
93
  isHeartbeatInFuture,
83
94
  isPosOnline,
95
+ ownDeliverySetUp,
84
96
  type AcceptState,
85
97
  type PosOrderChannel
86
98
  } from './pos-status'
@@ -120,7 +132,17 @@ const onlineChip = computed<Chip>(() => {
120
132
  : { variant: 'critical', label: t('order.posStatus.posOffline') }
121
133
  })
122
134
 
135
+ // The delivery toggle covers in-house delivery and FeedMe Express only. With
136
+ // neither set up, "off" is not a fault and the POS has no switch for it, so the
137
+ // card stays neutral instead of raising a notice (see `ownDeliverySetUp`).
138
+ const deliveryNotSetUp = computed(
139
+ () => props.channel === 'delivery' && !ownDeliverySetUp(currentRestaurant.value)
140
+ )
141
+
123
142
  const acceptChip = computed<Chip>(() => {
143
+ if (deliveryNotSetUp.value && accept.value !== 'on') {
144
+ return { variant: 'neutral', label: t('order.posStatus.accept.delivery.notSetUp') }
145
+ }
124
146
  const label = t(`order.posStatus.accept.${props.channel}.${accept.value}`)
125
147
  if (accept.value === 'on') return { variant: 'success', label }
126
148
  if (accept.value === 'off') return { variant: 'critical', label }
@@ -129,7 +151,7 @@ const acceptChip = computed<Chip>(() => {
129
151
 
130
152
  const problems = computed(() => {
131
153
  const list: { key: string; testId: string; text: string }[] = []
132
- if (accept.value === 'off') {
154
+ if (accept.value === 'off' && !deliveryNotSetUp.value) {
133
155
  list.push({
134
156
  key: 'accept',
135
157
  testId: 'pos-status-accept-off-hint',
@@ -4,6 +4,7 @@ import {
4
4
  formatAge,
5
5
  isHeartbeatInFuture,
6
6
  isPosOnline,
7
+ ownDeliverySetUp,
7
8
  posHeartbeatTimeoutSeconds
8
9
  } from './pos-status'
9
10
 
@@ -101,3 +102,24 @@ describe('isHeartbeatInFuture', () => {
101
102
  expect(isPosOnline('2027-04-24T04:38:30.000Z', '7.12.40', NOW)).toBe(true)
102
103
  })
103
104
  })
105
+
106
+ describe('ownDeliverySetUp (what acceptDelivery covers)', () => {
107
+ it('is true when in-house delivery or FeedMe Express is enabled', () => {
108
+ expect(ownDeliverySetUp({ inHouseDelivery: { enable: true } })).toBe(true)
109
+ expect(ownDeliverySetUp({ feedmeDelivery: { enable: true } })).toBe(true)
110
+ expect(
111
+ ownDeliverySetUp({ inHouseDelivery: { enable: false }, feedmeDelivery: { enable: true } })
112
+ ).toBe(true)
113
+ })
114
+
115
+ it('is false when neither exists, or both are disabled, null or empty', () => {
116
+ expect(ownDeliverySetUp({})).toBe(false)
117
+ expect(ownDeliverySetUp({ inHouseDelivery: null, feedmeDelivery: null })).toBe(false)
118
+ expect(
119
+ ownDeliverySetUp({ inHouseDelivery: { enable: false }, feedmeDelivery: { enable: null } })
120
+ ).toBe(false)
121
+ expect(ownDeliverySetUp({ inHouseDelivery: {} })).toBe(false)
122
+ expect(ownDeliverySetUp(null)).toBe(false)
123
+ expect(ownDeliverySetUp(undefined)).toBe(false)
124
+ })
125
+ })
@@ -46,6 +46,29 @@ export function isPosOnline(
46
46
  return now < at + posHeartbeatTimeoutSeconds(posVersion) * 1000
47
47
  }
48
48
 
49
+ /**
50
+ * Whether the outlet has its own delivery set up: in-house delivery or FeedMe
51
+ * Express enabled in the portal.
52
+ *
53
+ * `acceptDelivery` gates only these two, never GrabFood / foodpanda /
54
+ * ShopeeFood, and the POS shows its delivery switch only when one of them is
55
+ * enabled (pos-v8 `restaurant_operation_form.go`, v7 `notification_header.dart`).
56
+ * Without either there is nothing to turn on, so the card must not show a red
57
+ * "Delivery orders off" pointing at the POS: on such an outlet support read it
58
+ * as the delivery platforms being off (ITS-003145).
59
+ */
60
+ export function ownDeliverySetUp(
61
+ restaurant:
62
+ | {
63
+ inHouseDelivery?: { enable?: boolean | null } | null
64
+ feedmeDelivery?: { enable?: boolean | null } | null
65
+ }
66
+ | null
67
+ | undefined
68
+ ): boolean {
69
+ return restaurant?.inHouseDelivery?.enable === true || restaurant?.feedmeDelivery?.enable === true
70
+ }
71
+
49
72
  export type AcceptState = 'on' | 'off' | 'unknown'
50
73
 
51
74
  /**
@@ -19,6 +19,9 @@ import { useSnackbarFunctions } from '@/components/snackbar'
19
19
  import { useDialog } from '@feedmepos/ui-library'
20
20
  import moment from 'moment'
21
21
  import CopySettingsSheet from './CopySettingsSheet.vue'
22
+ import SmsCreditCard from '../components/SmsCreditCard.vue'
23
+ import { smsApi } from '@/api/order-setting'
24
+ import { Dinero } from '@feedmepos/core'
22
25
  import { RESERVATION_MIN_POS_VERSION } from '../dine-in/reservation-pos'
23
26
  import notfound from '@/assets/images/not-found.png'
24
27
 
@@ -421,6 +424,33 @@ watch(
421
424
  { immediate: true }
422
425
  )
423
426
 
427
+ /**
428
+ * The business's SMS credit, shown above the notification switches with the price on the SMS
429
+ * switch (ITS-003281): an SMS the balance can't pay for is not sent, so with both switches on
430
+ * only the email arrives and nothing on this page said why. Read on its own, so a failed credit
431
+ * read never blocks the reservation settings; only the latest read is kept.
432
+ */
433
+ const smsCredit = ref<{ balance?: any; pricePerMessage?: any } | null>(null)
434
+ let smsCreditRead = 0
435
+ watch(
436
+ () => currentRestaurant.value?._id,
437
+ async () => {
438
+ const read = ++smsCreditRead
439
+ try {
440
+ const credit = await smsApi.read()
441
+ if (read === smsCreditRead) smsCredit.value = credit
442
+ } catch {
443
+ if (read === smsCreditRead) smsCredit.value = null
444
+ }
445
+ },
446
+ { immediate: true }
447
+ )
448
+ const smsPrice = computed(() =>
449
+ smsCredit.value?.pricePerMessage
450
+ ? Dinero.fromFdoDinero(smsCredit.value.pricePerMessage).toFormat(true)
451
+ : null
452
+ )
453
+
424
454
  async function readReservationSetting(): Promise<FdoOrderReservationSettingsV2> {
425
455
  return await startAsyncCallWithErr(async () => {
426
456
  if (!currentRestaurant.value?._id) {
@@ -815,6 +845,7 @@ function handleCopySettings(copiedSettings: Partial<FdoOrderReservationSettingsV
815
845
  <div class="flex-grow fm-typo-en-title-sm-600 my-8">
816
846
  {{ t('order.notificationSettings') }}
817
847
  </div>
848
+ <SmsCreditCard v-if="smsCredit" :credit="smsCredit" class="mb-5" />
818
849
  <FmCard variant="outlined" class="p-5">
819
850
  <div class="mb-5">
820
851
  <FmSwitch
@@ -822,7 +853,11 @@ function handleCopySettings(copiedSettings: Partial<FdoOrderReservationSettingsV
822
853
  @update:model-value="(v: boolean) => updateSetting('smsEnabled', v)"
823
854
  :label="t('order.smsEnabled')"
824
855
  label-placement="right"
825
- :sublabel="t('order.smsEnabledDescription')"
856
+ :sublabel="
857
+ smsPrice
858
+ ? t('order.smsEnabledCostDescription', { price: smsPrice })
859
+ : t('order.smsEnabledDescription')
860
+ "
826
861
  />
827
862
  </div>
828
863
  <div class="mb-5">
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ITS-003281: a merchant turned on both reservation SMS and email and only the email arrived,
3
+ * because the SMS credit (RM0.11) was below the price per message (RM0.20); they also asked
4
+ * whether it is charged, and read "Guest Message" as text that is sent. This reads the sources
5
+ * so the answers stay on the Reservation tab: the same Credit card as the Notifications tab,
6
+ * the price on the SMS switch, and copy that says the guest texts are not sent.
7
+ */
8
+ import { readFileSync } from 'node:fs'
9
+ import { fileURLToPath } from 'node:url'
10
+ import { describe, expect, it } from 'vitest'
11
+
12
+ const read = (path: string) => readFileSync(fileURLToPath(new URL(path, import.meta.url)), 'utf8')
13
+ const reservation = read('./ReservationSetting.vue')
14
+ const sms = read('../sms/SmsSetting.vue')
15
+ const locale = (name: string) => JSON.parse(read(`../../../locales/${name}.json`))
16
+
17
+ describe('SMS credit on the Reservation tab (ITS-003281)', () => {
18
+ it('shows the shared Credit card above the notification switches', () => {
19
+ const card = reservation.indexOf('<SmsCreditCard v-if="smsCredit" :credit="smsCredit"')
20
+ expect(card).toBeGreaterThan(-1)
21
+ expect(card).toBeLessThan(reservation.indexOf(":model-value=\"reservationSettings.smsEnabled\""))
22
+ expect(reservation).toContain('const credit = await smsApi.read()')
23
+ })
24
+
25
+ it('never lets a failed or late credit read break the settings', () => {
26
+ const watcher = reservation.slice(reservation.indexOf('let smsCreditRead = 0'), reservation.indexOf('const smsPrice'))
27
+ // A failure hides the card (v-if) and falls back to the price-less sublabel.
28
+ expect(watcher).toMatch(/catch \{\n\s+if \(read === smsCreditRead\) smsCredit\.value = null/)
29
+ // Only the latest read lands, so an older response can't overwrite a newer one.
30
+ expect(watcher).toContain('if (read === smsCreditRead) smsCredit.value = credit')
31
+ // Not wrapped in the page loader, so the settings load and save don't wait on it.
32
+ expect(watcher).not.toContain('startAsyncCallWithErr')
33
+ })
34
+
35
+ it('keeps the Notifications tab on the same card', () => {
36
+ expect(sms).toContain('<SmsCreditCard :credit="smsCredit"')
37
+ })
38
+
39
+ it('puts the price per SMS on the SMS switch once the credit is read', () => {
40
+ expect(reservation).toContain("t('order.smsEnabledCostDescription', { price: smsPrice })")
41
+ expect(reservation).toContain(": t('order.smsEnabledDescription')")
42
+ })
43
+
44
+ it('has the cost line in every locale, with the price placeholder', () => {
45
+ for (const name of ['en-US', 'ja-JP', 'th-TH', 'zh-CN']) {
46
+ const order = locale(name).order
47
+ expect(order.smsEnabledCostDescription, name).toContain('{price}')
48
+ expect(order.smsEnabledDescription, name).toBeTruthy()
49
+ }
50
+ })
51
+
52
+ it('says a long or non-Latin SMS counts as more than one message (sms-backend bills per part)', () => {
53
+ const order = locale('en-US').order
54
+ expect(order.smsEnabledCostDescription).toContain('{price} per message')
55
+ expect(order.smsEnabledCostDescription).toContain('counts as 2 or more messages')
56
+ })
57
+
58
+ it('names the guest texts as policies that are shown, not sent', () => {
59
+ const copy = locale('en-US').order.reservationSetting
60
+ expect(copy.guestMessage).toBe('Guest Policy')
61
+ expect(copy.enableGuestMessage).toBe('Enable guest policy')
62
+ expect(copy.message).toBe('Details')
63
+ expect(copy.guestMessageDescription).toContain('not sent by SMS or email')
64
+ expect(copy.cancellationPolicyDescription).toContain('not sent by SMS or email')
65
+ })
66
+ })
@@ -13,10 +13,10 @@ import {
13
13
  } from '@entity'
14
14
  import RestaurantSelector from '../components/RestaurantSelector.vue'
15
15
  import NotifyChannelEditor from '../components/NotifyChannelEditor.vue'
16
+ import SmsCreditCard from '../components/SmsCreditCard.vue'
16
17
  import { pushBlocked, usePushAvailability } from '../components/push-availability'
17
18
 
18
19
  import { useCoreStore } from '@feedmepos/mf-common'
19
- import { Dinero } from '@feedmepos/core'
20
20
  import { useSnackbarFunctions } from '@/components/snackbar'
21
21
  import { useI18n } from '@feedmepos/mf-common'
22
22
 
@@ -92,7 +92,7 @@ async function updateOrderSetting() {
92
92
  // Only pickup has a code-owned body for a blank template (`SMS.processSms`).
93
93
  // Anything else would send an empty message.
94
94
  function needsMessage(sms: OrderSmsSettingDto) {
95
- return sms.type !== F_ORDER_TYPE.Enum.PICKUP && !sms.message.raw?.trim()
95
+ return sms.type !== F_ORDER_TYPE.enum.PICKUP && !sms.message.raw?.trim()
96
96
  }
97
97
 
98
98
  async function toggleEnable(enable: boolean, sms: OrderSmsSettingDto) {
@@ -178,20 +178,20 @@ function initOrderSmsSettings() {
178
178
  return [
179
179
  {
180
180
  enable: false,
181
- type: F_ORDER_TYPE.Enum.PICKUP,
182
- action: F_SMS_ACTION.Enum.ACCEPT,
181
+ type: F_ORDER_TYPE.enum.PICKUP,
182
+ action: F_SMS_ACTION.enum.ACCEPT,
183
183
  message: { raw: '', keys: {} }
184
184
  },
185
185
  {
186
186
  enable: false,
187
- type: F_ORDER_TYPE.Enum.PICKUP,
188
- action: F_SMS_ACTION.Enum.SERVE,
187
+ type: F_ORDER_TYPE.enum.PICKUP,
188
+ action: F_SMS_ACTION.enum.SERVE,
189
189
  message: { raw: '', keys: {} }
190
190
  },
191
191
  {
192
192
  enable: false,
193
- type: F_ORDER_TYPE.Enum.DELIVERY,
194
- action: F_SMS_ACTION.Enum.ACCEPT,
193
+ type: F_ORDER_TYPE.enum.DELIVERY,
194
+ action: F_SMS_ACTION.enum.ACCEPT,
195
195
  message: { raw: '', keys: {} }
196
196
  }
197
197
  ]
@@ -210,9 +210,9 @@ function convertTypeI18n(type: F_ORDER_TYPE | F_ORDER_DINE_IN_TYPE) {
210
210
 
211
211
  function convertActionI18n(action: F_SMS_ACTION) {
212
212
  switch (action) {
213
- case F_SMS_ACTION.Enum.ACCEPT:
213
+ case F_SMS_ACTION.enum.ACCEPT:
214
214
  return t('order.accept')
215
- case F_SMS_ACTION.Enum.SERVE:
215
+ case F_SMS_ACTION.enum.SERVE:
216
216
  return t('order.serve')
217
217
  default:
218
218
  throw new Error('convertActionI18n - Invalid action')
@@ -226,19 +226,7 @@ function convertActionI18n(action: F_SMS_ACTION) {
226
226
  <FmCircularProgress size="xxl" />
227
227
  </div>
228
228
  <div v-else>
229
- <FmCard variant="outlined" class="p-5 m-5 w-2/3">
230
- <div class="flex flex-col gap-">
231
- <div class="flex-grow fm-typo-en-title-sm-600 mb-5">{{ t('order.credit') }}</div>
232
-
233
- <span class="text-fm-color-neutral-gray-400">{{ t('order.balance') }}</span>
234
- <span class="font-bold">{{ Dinero.fromFdoDinero(smsCredit?.balance).toFormat(true) }}</span>
235
-
236
- <span class="text-fm-color-neutral-gray-400">{{ t('order.pricePerMessage') }}</span>
237
- <span class="font-bold">{{
238
- Dinero.fromFdoDinero(smsCredit?.pricePerMessage).toFormat(true)
239
- }}</span>
240
- </div>
241
- </FmCard>
229
+ <SmsCreditCard :credit="smsCredit" class="m-5 w-2/3" />
242
230
 
243
231
  <FmCard variant="outlined" class="p-5 m-5 w-2/3">
244
232
  <div class="flex flex-col gap-5">