@feedmepos/mf-order-setting 0.0.102 → 0.0.103

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 (139) hide show
  1. package/dist/{DisplaySystemView-jnt6letY.js → DisplaySystemView-BBiZqcWq.js} +1497 -1468
  2. package/dist/{FoodCourtInvitationsView-DoynqFWB.js → FoodCourtInvitationsView-DwOkVs9m.js} +4 -4
  3. package/dist/{FoodCourtOrderSettingsView-DYZLhTHy.js → FoodCourtOrderSettingsView-C9Ag5Bsg.js} +1 -1
  4. package/dist/FoodCourtOrdersView-y4EwK3sn.js +1173 -0
  5. package/dist/{FoodCourtStallsView-CRMTt5BB.js → FoodCourtStallsView-Bi8H-yR7.js} +2 -2
  6. package/dist/{FoodCourtStatusView-C-b-eI-8.js → FoodCourtStatusView-jugAzTKg.js} +1 -1
  7. package/dist/KioskDevicesView-CYiew4X5.js +4 -0
  8. package/dist/KioskDevicesView.vue_vue_type_script_setup_true_lang-BCvbeo7R.js +1497 -0
  9. package/dist/KioskSettingView-AKBiij9a.js +1124 -0
  10. package/dist/KioskView-zKB6mC8I.js +765 -0
  11. package/dist/{OrderSettingsView-BBCnekaj.js → OrderSettingsView-CoV_yX3m.js} +22064 -21635
  12. package/dist/{RestaurantSelector.vue_vue_type_script_setup_true_lang-DjoTyV6m.js → RestaurantSelector.vue_vue_type_script_setup_true_lang-KSMU_jGl.js} +1 -1
  13. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  14. package/dist/{app-Dvk30CIa.js → app-CmuI6uSl.js} +3589 -2902
  15. package/dist/app.js +1 -1
  16. package/dist/{dayjs.min-DUFHhM7O.js → dayjs.min-B3MssMma.js} +1 -1
  17. package/dist/{featureFlag-BvcirzHS.js → featureFlag-CWvkPOBY.js} +123 -130
  18. package/dist/frontend/mf-order/src/api/food-court/index.d.ts +51 -0
  19. package/dist/frontend/mf-order/src/api/kiosk/index.d.ts +4 -0
  20. package/dist/frontend/mf-order/src/api/payment/index.d.ts +8 -0
  21. package/dist/frontend/mf-order/src/api/queue/index.d.ts +13 -0
  22. package/dist/frontend/mf-order/src/api/restaurant-setting/index.d.ts +9 -1
  23. package/dist/frontend/mf-order/src/app.d.ts +687 -0
  24. package/dist/frontend/mf-order/src/main.d.ts +687 -0
  25. package/dist/frontend/mf-order/src/modules/display-system/interface.d.ts +5 -0
  26. package/dist/frontend/mf-order/src/modules/kiosk/interface.d.ts +4 -0
  27. package/dist/frontend/mf-order/src/modules/kiosk/license.d.ts +92 -0
  28. package/dist/frontend/mf-order/src/modules/kiosk/outletLoad.d.ts +15 -0
  29. package/dist/frontend/mf-order/src/modules/kiosk/settingsSections.d.ts +24 -0
  30. package/dist/frontend/mf-order/src/modules/kiosk/useKioskSettings.d.ts +29 -0
  31. package/dist/frontend/mf-order/src/modules/payment/paymentDevice.d.ts +58 -0
  32. package/dist/frontend/mf-order/src/stores/kiosk/index.d.ts +67 -1
  33. package/dist/frontend/mf-order/src/stores/order-setting/index.d.ts +19 -10
  34. package/dist/frontend/mf-order/src/stores/payment/index.d.ts +59 -1
  35. package/dist/frontend/mf-order/src/views/food-court/food-court-export.d.ts +38 -0
  36. package/dist/frontend/mf-order/src/views/kiosk/devices/KioskDeviceCard.vue.d.ts +3 -0
  37. package/dist/frontend/mf-order/src/views/kiosk/devices/KioskDevicesView.vue.d.ts +7 -0
  38. package/dist/frontend/mf-order/src/views/kiosk/devices/KioskLicenseSummary.vue.d.ts +7 -0
  39. package/dist/frontend/mf-order/src/views/kiosk/devices/KioskLicensesView.vue.d.ts +6 -0
  40. package/dist/frontend/mf-order/src/views/kiosk/devices/KioskOtpDialog.vue.d.ts +3 -0
  41. package/dist/frontend/mf-order/src/views/kiosk/devices/KioskPaymentDeviceCard.vue.d.ts +17 -0
  42. package/dist/frontend/mf-order/src/views/kiosk/settings/KioskSettingView.vue.d.ts +5 -2
  43. package/dist/frontend/mf-order/src/views/order-settings/pickup/PickUpSettingDialogContent.vue.d.ts +0 -9
  44. package/dist/frontend/mf-order/src/views/order-settings/pos-status/PosOrderingStatus.vue.d.ts +17 -0
  45. package/dist/frontend/mf-order/src/views/order-settings/pos-status/pos-status.d.ts +44 -0
  46. package/dist/frontend/mf-order/src/views/order-settings/queue/called-message.d.ts +1 -0
  47. package/dist/frontend/mf-order/src/views/order-settings/queue/phone-join-mode.d.ts +25 -0
  48. package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
  49. package/dist/{index-C4n5H7t3.js → index-BQa8AudZ.js} +3 -3
  50. package/dist/index-CMOvrim4.js +147 -0
  51. package/dist/{index-CW4VlFWz.js → index-D5qh2_4b.js} +1 -1
  52. package/dist/{index-C5n6lil6.js → index-Dup6kWLX.js} +6 -6
  53. package/dist/{index-CGxCWKHB.js → index-wuFIsXHT.js} +188 -179
  54. package/dist/{order.dto-Cb_gh3iB.js → order.dto-BD9raQG5.js} +2782 -2735
  55. package/dist/package/entity/display/blocks.d.ts +12 -2
  56. package/dist/package/entity/marketing/marketing.dto.d.ts +18 -18
  57. package/dist/package/entity/order-platform/external/reconciliation/external-reconciliation.do.d.ts +24 -24
  58. package/dist/package/entity/order-platform/menu.dto.d.ts +20 -20
  59. package/dist/package/entity/order-setting/order-setting.do.d.ts +10 -0
  60. package/dist/package/entity/order-setting/order-setting.dto.d.ts +26 -0
  61. package/dist/package/entity/order-setting/queue/queue.do.d.ts +23 -0
  62. package/dist/package/entity/order-setting/queue/queue.dto.d.ts +14 -0
  63. package/dist/package/entity/queue/queue.do.d.ts +153 -0
  64. package/dist/package/entity/queue/queue.dto.d.ts +221 -2
  65. package/dist/package/entity/queue/queue.enum.d.ts +5 -0
  66. package/dist/package/entity/restaurant/restaurant.dto.d.ts +20 -0
  67. package/dist/style.css +1 -1
  68. package/dist/{index-ILnighyU.js → useInternalUser-CHtaur9A.js} +93 -81
  69. package/package.json +2 -1
  70. package/src/api/food-court/index.ts +63 -0
  71. package/src/api/kiosk/index.ts +8 -0
  72. package/src/api/payment/index.ts +18 -1
  73. package/src/api/queue/index.ts +39 -0
  74. package/src/api/restaurant-setting/index.ts +14 -0
  75. package/src/locales/en-US.json +197 -26
  76. package/src/locales/ja-JP.json +193 -23
  77. package/src/locales/th-TH.json +193 -21
  78. package/src/locales/zh-CN.json +197 -23
  79. package/src/modules/display-system/interface.spec.ts +26 -1
  80. package/src/modules/display-system/interface.ts +20 -0
  81. package/src/modules/kiosk/interface.ts +4 -0
  82. package/src/modules/kiosk/license.spec.ts +167 -0
  83. package/src/modules/kiosk/license.ts +175 -0
  84. package/src/modules/kiosk/outletLoad.spec.ts +25 -0
  85. package/src/modules/kiosk/outletLoad.ts +19 -0
  86. package/src/modules/kiosk/settingsSections.spec.ts +85 -0
  87. package/src/modules/kiosk/settingsSections.ts +82 -0
  88. package/src/modules/kiosk/useKioskSettings.spec.ts +157 -0
  89. package/src/modules/kiosk/useKioskSettings.ts +61 -0
  90. package/src/modules/payment/paymentDevice.spec.ts +175 -0
  91. package/src/modules/payment/paymentDevice.ts +156 -0
  92. package/src/stores/kiosk/index.ts +16 -1
  93. package/src/stores/kiosk/mapper.ts +2 -0
  94. package/src/stores/order-setting/index.spec.ts +83 -0
  95. package/src/stores/order-setting/index.ts +49 -27
  96. package/src/stores/payment/index.spec.ts +86 -0
  97. package/src/stores/payment/index.ts +48 -2
  98. package/src/views/display-system/DisplayInspector.vue +17 -8
  99. package/src/views/display-system/DisplayTemplateEditor.vue +3 -1
  100. package/src/views/food-court/FoodCourtOrdersView.vue +46 -1
  101. package/src/views/food-court/food-court-export.spec.ts +151 -0
  102. package/src/views/food-court/food-court-export.ts +283 -0
  103. package/src/views/kiosk/KioskStatePanel.vue +2 -2
  104. package/src/views/kiosk/KioskView.vue +219 -82
  105. package/src/views/kiosk/devices/KioskDeviceCard.vue +148 -23
  106. package/src/views/kiosk/devices/KioskDevicesView.vue +48 -10
  107. package/src/views/kiosk/devices/KioskLicenseSummary.vue +79 -0
  108. package/src/views/kiosk/devices/KioskLicensesView.vue +152 -0
  109. package/src/views/kiosk/devices/KioskOtpDialog.vue +41 -1
  110. package/src/views/kiosk/devices/KioskPaymentDeviceCard.spec.ts +97 -0
  111. package/src/views/kiosk/devices/KioskPaymentDeviceCard.vue +221 -0
  112. package/src/views/kiosk/settings/KioskPaymentTypeSection.vue +1 -1
  113. package/src/views/kiosk/settings/KioskSettingView.vue +702 -419
  114. package/src/views/order-settings/delivery/DeliverySetting.vue +4 -0
  115. package/src/views/order-settings/dine-in/DineInSetting.vue +4 -0
  116. package/src/views/order-settings/pickup/PickUpSetting.vue +4 -4
  117. package/src/views/order-settings/pickup/PickUpSettingDialogContent.vue +0 -23
  118. package/src/views/order-settings/pos-status/PosOrderingStatus.spec.ts +207 -0
  119. package/src/views/order-settings/pos-status/PosOrderingStatus.vue +209 -0
  120. package/src/views/order-settings/pos-status/pos-status.spec.ts +103 -0
  121. package/src/views/order-settings/pos-status/pos-status.ts +86 -0
  122. package/src/views/order-settings/queue/QueueSetting.source.spec.ts +43 -0
  123. package/src/views/order-settings/queue/QueueSetting.vue +289 -15
  124. package/src/views/order-settings/queue/called-message.spec.ts +29 -1
  125. package/src/views/order-settings/queue/called-message.ts +18 -0
  126. package/src/views/order-settings/queue/phone-join-mode.spec.ts +90 -0
  127. package/src/views/order-settings/queue/phone-join-mode.ts +49 -0
  128. package/dist/FoodCourtOrdersView-CAPOycT3.js +0 -544
  129. package/dist/KioskDevicesView-B0U9JxRl.js +0 -4
  130. package/dist/KioskDevicesView.vue_vue_type_script_setup_true_lang-V3ai4FVI.js +0 -937
  131. package/dist/KioskSettingView-rdom_aS8.js +0 -880
  132. package/dist/KioskView-DOON9zR6.js +0 -516
  133. package/dist/frontend/mf-order/src/views/kiosk/settings/KioskDisplayStandSection.vue.d.ts +0 -10
  134. package/dist/frontend/mf-order/src/views/kiosk/settings/KioskInstructionSection.vue.d.ts +0 -15
  135. package/dist/frontend/mf-order/src/views/kiosk/settings/KioskPickAtCounterSection.vue.d.ts +0 -10
  136. package/dist/index-CaHG3M7C.js +0 -135
  137. package/src/views/kiosk/settings/KioskDisplayStandSection.vue +0 -189
  138. package/src/views/kiosk/settings/KioskInstructionSection.vue +0 -40
  139. package/src/views/kiosk/settings/KioskPickAtCounterSection.vue +0 -68
@@ -0,0 +1,86 @@
1
+ import semver from 'semver'
2
+
3
+ /**
4
+ * Read-only POS facts that decide whether a customer's online order is refused,
5
+ * shown at the top of the Order Setting tabs so support staff see the cause at
6
+ * once (Hock Kee Bangsar South, 2026-11-05: `acceptDineIn` was off on the POS
7
+ * while every portal toggle was on, and the refusal was blamed on the network).
8
+ *
9
+ * The rules here MUST stay in lockstep with the server's submit gate:
10
+ * - heartbeat: `Restaurant.isHeartbeatExpired` (backend/libs/manager/restaurant.ts)
11
+ * and Go `manager.IsHeartbeatExpired` (go/packages/ordering_backend/pkg/manager/restaurant.go);
12
+ * - accept toggles: `validateDineInCanSubmit` / `validatePickupCanSubmit` /
13
+ * `validateDeliveryCanSubmit` (backend/libs/manager/order/fn.ts), which refuse
14
+ * on any falsy value, so a missing toggle counts as off.
15
+ */
16
+
17
+ export type PosOrderChannel = 'dineIn' | 'pickup' | 'delivery'
18
+
19
+ /** The restaurant-setting toggle (set on the POS) that gates each channel. */
20
+ export const CHANNEL_ACCEPT_KEY = {
21
+ dineIn: 'acceptDineIn',
22
+ pickup: 'acceptPickup',
23
+ delivery: 'acceptDelivery'
24
+ } as const satisfies Record<PosOrderChannel, string>
25
+
26
+ type AcceptKey = (typeof CHANNEL_ACCEPT_KEY)[PosOrderChannel]
27
+
28
+ /** Seconds a heartbeat stays fresh: 120 for POS major 8 (pre-releases too), else 30. */
29
+ export function posHeartbeatTimeoutSeconds(posVersion?: string | null): number {
30
+ return semver.parse(posVersion ?? '')?.major === 8 ? 120 : 30
31
+ }
32
+
33
+ /**
34
+ * Whether the server would treat the Main POS as online at `now`. A missing or
35
+ * unreadable heartbeat is offline; the exact timeout boundary is offline too
36
+ * (`!moment().isBefore(heartbeat + timeout)` on the server).
37
+ */
38
+ export function isPosOnline(
39
+ heartbeat: string | Date | null | undefined,
40
+ posVersion: string | null | undefined,
41
+ now: number = Date.now()
42
+ ): boolean {
43
+ if (!heartbeat) return false
44
+ const at = new Date(heartbeat).getTime()
45
+ if (Number.isNaN(at)) return false
46
+ return now < at + posHeartbeatTimeoutSeconds(posVersion) * 1000
47
+ }
48
+
49
+ export type AcceptState = 'on' | 'off' | 'unknown'
50
+
51
+ /**
52
+ * The channel's POS toggle as the server reads it. A missing setting means the
53
+ * read failed, which is "unknown": never guess "on".
54
+ */
55
+ export function channelAcceptState(
56
+ setting: Partial<Record<AcceptKey, boolean | null>> | null | undefined,
57
+ channel: PosOrderChannel
58
+ ): AcceptState {
59
+ if (!setting) return 'unknown'
60
+ return setting[CHANNEL_ACCEPT_KEY[channel]] ? 'on' : 'off'
61
+ }
62
+
63
+ /**
64
+ * A heartbeat dated more than a minute after `now` means the POS clock is ahead.
65
+ * The server still counts it as online until that time passes, so a POS that is
66
+ * really off can look online: support staff must be told the status is not proof.
67
+ */
68
+ export function isHeartbeatInFuture(
69
+ heartbeat: string | Date | null | undefined,
70
+ now: number = Date.now()
71
+ ): boolean {
72
+ if (!heartbeat) return false
73
+ const at = new Date(heartbeat).getTime()
74
+ return !Number.isNaN(at) && at - now > 60_000
75
+ }
76
+
77
+ /** Short age of the last heartbeat: "45 s", "12 min", "3 h", "2 d". */
78
+ export function formatAge(heartbeat: string | Date, now: number = Date.now()): string {
79
+ const seconds = Math.max(0, Math.floor((now - new Date(heartbeat).getTime()) / 1000))
80
+ if (seconds < 60) return `${seconds} s`
81
+ const minutes = Math.floor(seconds / 60)
82
+ if (minutes < 60) return `${minutes} min`
83
+ const hours = Math.floor(minutes / 60)
84
+ if (hours < 48) return `${hours} h`
85
+ return `${Math.floor(hours / 24)} d`
86
+ }
@@ -63,3 +63,46 @@ describe('QueueSetting running-number wiring', () => {
63
63
  )
64
64
  })
65
65
  })
66
+
67
+ /**
68
+ * ITS-002916: a warning about the merchant's own line sits under the text box, and one about
69
+ * the whole SMS under the preview. Under the preview, "the default line is sent instead of this
70
+ * message" read as the preview bubble, which already shows the default line.
71
+ */
72
+ describe('QueueSetting called SMS warning placement (ITS-002916)', () => {
73
+ const at = (needle: string) => {
74
+ const index = sfc.indexOf(needle)
75
+ expect(index, needle).toBeGreaterThan(-1)
76
+ return index
77
+ }
78
+
79
+ it('shows line warnings and the save error under the text box, before the preview', () => {
80
+ // The Insert / character-count row is the text box's footer: the warnings come after it.
81
+ const countRow = at("t('order.queueCalledMessageCount'")
82
+ const previewLabel = at("t('order.queueCalledMessagePreview')")
83
+ const lineWarnings = at('v-for="warning in calledLineWarnings"')
84
+ const error = at('v-if="calledMessageError"')
85
+ expect(countRow).toBeLessThan(lineWarnings)
86
+ expect(lineWarnings).toBeLessThan(previewLabel)
87
+ expect(countRow).toBeLessThan(error)
88
+ expect(error).toBeLessThan(previewLabel)
89
+ })
90
+
91
+ it('shows whole-SMS warnings after the preview bubble', () => {
92
+ expect(at('v-for="warning in calledSmsWarnings"')).toBeGreaterThan(at('{{ calledCheck.preview }}'))
93
+ expect(sfc).not.toContain('v-for="warning in calledCheck.warnings"')
94
+ })
95
+
96
+ it('names the placeholder that makes the line fall back', () => {
97
+ expect(sfc).toMatch(
98
+ /t\('order\.queueCalledMessagePlaceholderWhileTimerOff', \{ placeholder: AUTO_CANCEL_TOKEN \}\)/
99
+ )
100
+ for (const locale of ['en-US', 'ja-JP', 'th-TH', 'zh-CN']) {
101
+ const json = readFileSync(
102
+ fileURLToPath(new URL(`../../../locales/${locale}.json`, import.meta.url)),
103
+ 'utf8'
104
+ )
105
+ expect(json, locale).toMatch(/"queueCalledMessagePlaceholderWhileTimerOff": "[^"]*\{placeholder\}/)
106
+ }
107
+ })
108
+ })
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { ref, watch, onMounted, computed } from 'vue'
2
+ import { ref, watch, onMounted, onBeforeUnmount, computed } from 'vue'
3
3
  import { OrderSettingApi } from '@/api/order-setting'
4
4
  import { restaurantApi, type RestaurantSettingDoc } from '@/api/restaurant-setting'
5
5
  import { useLoading } from '@/composables/loading'
@@ -9,6 +9,10 @@ import {
9
9
  OrderSettingsDto,
10
10
  OrderSettingUpdateDto
11
11
  } from '@entity'
12
+ import type { QueueEntranceActivityDto, QueueEntranceStateDto } from '@entity/queue/queue.dto'
13
+ import dayjs from 'dayjs'
14
+ import { QueueEntranceCodeApi } from '@/api/queue'
15
+ import { SvcCompanyApiError } from '@/api'
12
16
  import RestaurantSelector from '../components/RestaurantSelector.vue'
13
17
  import NotifyChannelEditor from '../components/NotifyChannelEditor.vue'
14
18
  import { pushBlocked, usePushAvailability } from '../components/push-availability'
@@ -29,10 +33,17 @@ import { CALLED_MESSAGE_MAX_LENGTH } from '@common/queue/called-sms'
29
33
  import {
30
34
  AUTO_CANCEL_TOKEN,
31
35
  checkCalledMessage,
36
+ isLineWarning,
32
37
  previewQueueCode,
33
38
  withAutoCancelToken,
34
39
  type CalledMessageWarning
35
40
  } from './called-message'
41
+ import {
42
+ effectiveEntranceCodeResetTime,
43
+ phoneJoinModeOf,
44
+ withPhoneJoinMode,
45
+ type PhoneJoinMode
46
+ } from './phone-join-mode'
36
47
 
37
48
  const { t } = useI18n()
38
49
  const { showSuccess, showError } = useSnackbarFunctions()
@@ -144,6 +155,7 @@ async function init() {
144
155
  presetRemarks.value = queueQrSetting?.presetRemarks ?? []
145
156
  allowOverrideQueueCode.value = queueQrSetting?.allowOverrideQueueCode ?? false
146
157
  })
158
+ void loadEntranceState(true)
147
159
  }
148
160
  }
149
161
 
@@ -154,6 +166,174 @@ function updateQueueSetting<K extends keyof FdoOrderQueueSettings>(
154
166
  queueSettings.value[key] = value
155
167
  }
156
168
 
169
+ // ---- Phone join + entrance QR (ITS-002803) ---------------------------------
170
+ //
171
+ // One choice on the page for two stored flags; the mapping lives in phone-join-mode.ts.
172
+ // The entrance QR itself is not part of the settings document: it is queue-backend's live
173
+ // code, read through its own portal routes, so Get link and Revoke act at once rather than on
174
+ // Save. Printing it is POS-only.
175
+
176
+ const phoneJoinMode = computed(() => phoneJoinModeOf(queueSettings.value))
177
+
178
+ function setPhoneJoinMode(mode: PhoneJoinMode) {
179
+ queueSettings.value = withPhoneJoinMode(queueSettings.value, mode)
180
+ }
181
+
182
+ /** What the picker shows: the stored time, or queue-backend's default when unset. */
183
+ const entranceResetTime = computed(() =>
184
+ effectiveEntranceCodeResetTime(queueSettings.value.entranceCodeResetTime)
185
+ )
186
+
187
+ function updateEntranceResetTime(time: string | null) {
188
+ if (time) updateQueueSetting('entranceCodeResetTime', time)
189
+ }
190
+
191
+ const entranceState = ref<QueueEntranceStateDto | null>(null)
192
+ /** Today's live code, when there is one. */
193
+ const entranceCurrent = computed(() => entranceState.value?.current ?? null)
194
+ const entranceBusy = ref(false)
195
+ /** The entrance-code routes check restaurant-level manage, which some users who may save settings lack. */
196
+ const entranceForbidden = ref(false)
197
+
198
+ /** `fresh` on opening an outlet, so its status never shows another outlet's code meanwhile. */
199
+ async function loadEntranceState(fresh = false) {
200
+ const restaurantId = currentRestaurant.value?._id
201
+ if (fresh) {
202
+ entranceState.value = null
203
+ entranceForbidden.value = false
204
+ }
205
+ if (!restaurantId) return
206
+ try {
207
+ const state = await QueueEntranceCodeApi.getEntranceCodeState(restaurantId)
208
+ // A slow answer for the outlet the merchant just switched away from is dropped.
209
+ if (currentRestaurant.value?._id === restaurantId) {
210
+ entranceState.value = state
211
+ refreshEntranceStateAtExpiry(state.current?.expiresAt)
212
+ }
213
+ } catch (e) {
214
+ // The rest of the page works without it. A 403 is said out loud: reading it as "no code
215
+ // today" would offer a Get link that fails the same way.
216
+ if (currentRestaurant.value?._id === restaurantId)
217
+ // The portal client rejects with SvcCompanyApiError, which carries the HTTP status itself.
218
+ entranceForbidden.value = e instanceof SvcCompanyApiError && e.status === 403
219
+ }
220
+ }
221
+
222
+ /**
223
+ * A page left open across the daily reset would keep showing an expired link; read the state
224
+ * again just after the live code expires (capped, so a timer never outlives a long day).
225
+ */
226
+ let entranceExpiryTimer: ReturnType<typeof setTimeout> | undefined
227
+ function refreshEntranceStateAtExpiry(expiresAt: string | undefined) {
228
+ clearTimeout(entranceExpiryTimer)
229
+ entranceExpiryTimer = undefined
230
+ if (!expiresAt) return
231
+ const wait = dayjs(expiresAt).diff(dayjs()) + 1000
232
+ if (wait > 0 && wait <= 24 * 60 * 60 * 1000) {
233
+ entranceExpiryTimer = setTimeout(() => void loadEntranceState(), wait)
234
+ }
235
+ }
236
+ onBeforeUnmount(() => clearTimeout(entranceExpiryTimer))
237
+
238
+ const entranceStatusText = computed(() => {
239
+ if (entranceForbidden.value) return t('order.queueEntranceForbidden')
240
+ const current = entranceCurrent.value
241
+ if (!current) return t('order.queueEntranceNoCode')
242
+ const validUntil = t('order.queueEntranceValidUntil', {
243
+ time: dayjs(current.expiresAt).format('D MMM YYYY, HH:mm')
244
+ })
245
+ if (!current.printedAt) return `${t('order.queueEntranceNotPrinted')} · ${validUntil}`
246
+ const time = dayjs(current.printedAt).format('HH:mm')
247
+ const printed = current.printedBy?.name
248
+ ? t('order.queueEntrancePrintedBy', { time, name: current.printedBy.name })
249
+ : t('order.queueEntrancePrinted', { time })
250
+ return `${printed} · ${validUntil}`
251
+ })
252
+
253
+ /** The last 5 actions on the code, newest first (who printed, revoked, …). */
254
+ const entranceActivity = computed(() => entranceState.value?.activity ?? [])
255
+
256
+ const ENTRANCE_ACTIVITY_LABEL: Record<QueueEntranceActivityDto['action'], string> = {
257
+ PRINTED: 'order.queueEntranceActivityPrinted',
258
+ REPRINTED: 'order.queueEntranceActivityReprinted',
259
+ REPLACED: 'order.queueEntranceActivityReplaced',
260
+ REVOKED: 'order.queueEntranceActivityRevoked',
261
+ LINK_ISSUED: 'order.queueEntranceActivityLinkIssued'
262
+ }
263
+
264
+ function entranceActivityText(activity: QueueEntranceActivityDto): string {
265
+ const action = t(ENTRANCE_ACTIVITY_LABEL[activity.action])
266
+ const name = activity.by?.name
267
+ const what = name ? t('order.queueEntranceActivityBy', { action, name }) : action
268
+ return `${dayjs(activity.at).format('D MMM, HH:mm')} · ${what}`
269
+ }
270
+
271
+ function errorText(e: unknown): string {
272
+ return e instanceof Error ? e.message : `${e}`
273
+ }
274
+
275
+ /**
276
+ * Printing the entrance QR is POS-only (user decision 2026-11-04). The portal hands out today's
277
+ * link (shown once there is a live code, fetched on request when there is none) and can revoke
278
+ * the code. Neither counts as a print.
279
+ */
280
+ async function getEntranceLink() {
281
+ const restaurantId = currentRestaurant.value?._id
282
+ if (!restaurantId || entranceBusy.value) return
283
+ entranceBusy.value = true
284
+ try {
285
+ await QueueEntranceCodeApi.getEntranceLink(restaurantId)
286
+ } catch (e) {
287
+ showError(errorText(e))
288
+ } finally {
289
+ entranceBusy.value = false
290
+ await loadEntranceState()
291
+ }
292
+ }
293
+
294
+ function confirmRevokeEntrance() {
295
+ Dialog.open({
296
+ title: t('order.queueEntranceRevokeConfirmTitle'),
297
+ message: t('order.queueEntranceRevokeConfirmMessage'),
298
+ dismissAway: false,
299
+ primaryActions: { text: t('order.queueEntranceRevoke'), variant: 'destructive', close: true },
300
+ secondaryActions: { text: t('order.cancel'), variant: 'tertiary', close: true }
301
+ }).onPrimary(() => {
302
+ void revokeEntrance()
303
+ })
304
+ }
305
+
306
+ /** A new code now; the old QR keeps working for 5 minutes. Staff then print the new one on the POS. */
307
+ async function revokeEntrance() {
308
+ const restaurantId = currentRestaurant.value?._id
309
+ if (!restaurantId || entranceBusy.value) return
310
+ entranceBusy.value = true
311
+ try {
312
+ await QueueEntranceCodeApi.revokeEntranceCode(restaurantId)
313
+ showSuccess(t('order.queueEntranceRevoked'))
314
+ } catch (e) {
315
+ showError(errorText(e))
316
+ } finally {
317
+ entranceBusy.value = false
318
+ await loadEntranceState()
319
+ }
320
+ }
321
+
322
+ /** Synchronous with the click, so the clipboard still counts it as a user gesture. */
323
+ function copyEntranceLink() {
324
+ const url = entranceCurrent.value?.url
325
+ if (!url) return
326
+ // Absent outside a secure context or in some embedded webviews.
327
+ if (!navigator.clipboard) {
328
+ showError(t('order.queueEntranceLinkCopyFailed'))
329
+ return
330
+ }
331
+ navigator.clipboard.writeText(url).then(
332
+ () => showSuccess(t('order.queueEntranceLinkCopied')),
333
+ () => showError(t('order.queueEntranceLinkCopyFailed'))
334
+ )
335
+ }
336
+
157
337
  function enableAutoCancel(on: boolean) {
158
338
  autoCancelEnabled.value = on
159
339
  // Off is an explicit 0: a save that leaves the field out keeps the stored minutes (queue-field-inherit.ts).
@@ -171,13 +351,20 @@ const calledCheck = computed(() =>
171
351
  })
172
352
  )
173
353
 
354
+ /** Under the text box: about the merchant's line. Under the preview: about the whole SMS. */
355
+ const calledLineWarnings = computed(() => calledCheck.value.warnings.filter(isLineWarning))
356
+ const calledSmsWarnings = computed(() =>
357
+ calledCheck.value.warnings.filter((warning) => !isLineWarning(warning))
358
+ )
359
+
174
360
  const calledWarningText: Record<CalledMessageWarning, () => string> = {
175
361
  multiPart: () => t('order.queueCalledMessageMultiPart', { parts: calledCheck.value.parts }),
176
362
  notSevenBit: () => t('order.queueCalledMessageNotSevenBit'),
177
363
  linkOrPhone: () => t('order.queueCalledMessageLinkOrPhone'),
178
364
  timerNotMentioned: () =>
179
365
  t('order.queueCalledMessageTimerNotMentioned', { placeholder: AUTO_CANCEL_TOKEN }),
180
- placeholderWhileTimerOff: () => t('order.queueCalledMessagePlaceholderWhileTimerOff')
366
+ placeholderWhileTimerOff: () =>
367
+ t('order.queueCalledMessagePlaceholderWhileTimerOff', { placeholder: AUTO_CANCEL_TOKEN })
181
368
  }
182
369
 
183
370
  function insertAutoCancelToken() {
@@ -577,12 +764,92 @@ async function saveAllowOverrideQueueCode(value: boolean) {
577
764
  />
578
765
  </div>
579
766
 
580
- <FmSwitch
581
- :model-value="queueSettings.disableRemoteQueue ?? false"
582
- @update:model-value="(v: boolean) => updateQueueSetting('disableRemoteQueue', v)"
583
- :label="t('order.disableRemoteQueue')"
584
- label-placement="right"
585
- />
767
+ <!--
768
+ Phone join (ITS-002803): replaces the "Disable Remote Queue" switch. Saved with the
769
+ page; POS / staff queues are never affected.
770
+ -->
771
+ <div class="flex flex-col gap-2">
772
+ <span class="fm-typo-en-body-md-600">{{ t('order.queuePhoneJoin') }}</span>
773
+ <span class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary">
774
+ {{ t('order.queuePhoneJoinDescription') }}
775
+ </span>
776
+ <FmRadioGroup
777
+ :model-value="phoneJoinMode"
778
+ @update:model-value="(v: PhoneJoinMode) => setPhoneJoinMode(v)"
779
+ >
780
+ <FmRadio value="anywhere" :label="t('order.queuePhoneJoinAnywhere')" />
781
+ <FmRadio value="entrance" :label="t('order.queuePhoneJoinEntrance')" />
782
+ <FmRadio value="off" :label="t('order.queuePhoneJoinOff')" />
783
+ </FmRadioGroup>
784
+ </div>
785
+
786
+ <!--
787
+ The entrance QR is printed on the POS. Here the merchant sets the mode and reset time
788
+ (saved with the page), can see or copy today's link, and can revoke the code; those act
789
+ at once through queue-backend rather than on Save.
790
+ -->
791
+ <div v-if="phoneJoinMode === 'entrance'" class="flex flex-col gap-4 ml-5">
792
+ <span class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary">
793
+ {{ t('order.queueEntranceDescription') }}
794
+ </span>
795
+ <div class="flex flex-col gap-2">
796
+ <span class="fm-typo-en-body-md-600">{{ t('order.queueEntranceResetTime') }}</span>
797
+ <span class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary">
798
+ {{ t('order.queueEntranceResetTimeHint') }}
799
+ </span>
800
+ <FmTimePicker
801
+ class="max-w-[200px]"
802
+ :model-value="entranceResetTime"
803
+ @update:model-value="(time: string | null) => updateEntranceResetTime(time)"
804
+ />
805
+ </div>
806
+ <div class="flex flex-col gap-2">
807
+ <span class="fm-typo-en-body-md-600">{{ t('order.queueEntranceQr') }}</span>
808
+ <span class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary">
809
+ {{ entranceStatusText }}
810
+ </span>
811
+ <div v-if="entranceCurrent" class="flex flex-wrap items-center gap-3">
812
+ <span
813
+ class="fm-typo-en-body-sm-400 max-w-[420px] truncate rounded px-2 py-1 bg-fm-color-neutral-gray-100"
814
+ :title="entranceCurrent.url"
815
+ >
816
+ {{ entranceCurrent.url }}
817
+ </span>
818
+ <FmButton
819
+ variant="secondary"
820
+ icon="content_copy"
821
+ :label="t('order.queueEntranceCopyLink')"
822
+ @click="copyEntranceLink"
823
+ />
824
+ <FmButton
825
+ variant="secondary"
826
+ color="error"
827
+ :label="t('order.queueEntranceRevoke')"
828
+ :disabled="entranceBusy"
829
+ @click="confirmRevokeEntrance"
830
+ />
831
+ </div>
832
+ <div v-else-if="!entranceForbidden">
833
+ <FmButton
834
+ variant="secondary"
835
+ icon="link"
836
+ :label="t('order.queueEntranceGetLink')"
837
+ :disabled="entranceBusy"
838
+ @click="getEntranceLink"
839
+ />
840
+ </div>
841
+ <div v-if="entranceActivity.length" class="flex flex-col gap-1">
842
+ <span class="fm-typo-en-body-sm-600">{{ t('order.queueEntranceActivityTitle') }}</span>
843
+ <span
844
+ v-for="activity in entranceActivity"
845
+ :key="`${activity.at}-${activity.action}`"
846
+ class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
847
+ >
848
+ {{ entranceActivityText(activity) }}
849
+ </span>
850
+ </div>
851
+ </div>
852
+ </div>
586
853
 
587
854
  <FmSwitch
588
855
  :model-value="allowOverrideQueueCode"
@@ -640,14 +907,8 @@ async function saveAllowOverrideQueueCode(value: boolean) {
640
907
  }}
641
908
  </span>
642
909
  </div>
643
- <span class="fm-typo-en-body-sm-600">{{ t('order.queueCalledMessagePreview') }}</span>
644
- <div
645
- class="rounded-lg p-3 bg-fm-color-neutral-gray-100 whitespace-pre-wrap fm-typo-en-body-md-400"
646
- >
647
- {{ calledCheck.preview }}
648
- </div>
649
910
  <span
650
- v-for="warning in calledCheck.warnings"
911
+ v-for="warning in calledLineWarnings"
651
912
  :key="warning"
652
913
  class="fm-typo-en-body-sm-400 text-fm-color-system-warning-400"
653
914
  >
@@ -659,6 +920,19 @@ async function saveAllowOverrideQueueCode(value: boolean) {
659
920
  >
660
921
  {{ calledMessageError }}
661
922
  </span>
923
+ <span class="fm-typo-en-body-sm-600">{{ t('order.queueCalledMessagePreview') }}</span>
924
+ <div
925
+ class="rounded-lg p-3 bg-fm-color-neutral-gray-100 whitespace-pre-wrap fm-typo-en-body-md-400"
926
+ >
927
+ {{ calledCheck.preview }}
928
+ </div>
929
+ <span
930
+ v-for="warning in calledSmsWarnings"
931
+ :key="warning"
932
+ class="fm-typo-en-body-sm-400 text-fm-color-system-warning-400"
933
+ >
934
+ {{ calledWarningText[warning]() }}
935
+ </span>
662
936
  </div>
663
937
 
664
938
  <FmSwitch
@@ -1,5 +1,10 @@
1
1
  import { describe, expect, it } from 'vitest'
2
- import { checkCalledMessage, previewQueueCode, withAutoCancelToken } from './called-message'
2
+ import {
3
+ checkCalledMessage,
4
+ isLineWarning,
5
+ previewQueueCode,
6
+ withAutoCancelToken
7
+ } from './called-message'
3
8
 
4
9
  /**
5
10
  * The preview must be exactly what queue-backend sends (both use
@@ -114,6 +119,29 @@ describe('checkCalledMessage', () => {
114
119
  })
115
120
  })
116
121
 
122
+ /**
123
+ * ITS-002916: the page shows a warning next to the part of the form it is about. Under
124
+ * the preview, "this message" read as the preview bubble, which already shows what is sent.
125
+ */
126
+ describe('isLineWarning', () => {
127
+ it('puts what the merchant fixes in their own line under the text box', () => {
128
+ expect(isLineWarning('placeholderWhileTimerOff')).toBe(true)
129
+ expect(isLineWarning('timerNotMentioned')).toBe(true)
130
+ expect(isLineWarning('linkOrPhone')).toBe(true)
131
+ })
132
+
133
+ it('keeps what is about the whole SMS under the preview', () => {
134
+ expect(isLineWarning('multiPart')).toBe(false)
135
+ expect(isLineWarning('notSevenBit')).toBe(false)
136
+ })
137
+
138
+ it('is right to treat the encoding as the whole SMS: the outlet name alone can switch it', () => {
139
+ expect(checkCalledMessage({ ...base, restaurantName: '吉布拉' }).warnings).toContain(
140
+ 'notSevenBit'
141
+ )
142
+ })
143
+ })
144
+
117
145
  describe('withAutoCancelToken', () => {
118
146
  it('appends the placeholder with one space', () => {
119
147
  expect(withAutoCancelToken('')).toBe('{{autoCancelMinutes}}')
@@ -34,6 +34,24 @@ export function previewQueueCode(
34
34
  export type CalledMessageWarning =
35
35
  'multiPart' | 'notSevenBit' | 'linkOrPhone' | 'timerNotMentioned' | 'placeholderWhileTimerOff'
36
36
 
37
+ /**
38
+ * What each warning is about, which decides where the page shows it: the merchant's own
39
+ * line under the text box, the whole SMS (its count and encoding, which the fixed outlet
40
+ * line also drives) under the preview. Shown under the preview, a line warning's "this
41
+ * message" read as the preview bubble, which already shows what is sent (ITS-002916).
42
+ */
43
+ const WARNING_SUBJECT: Record<CalledMessageWarning, 'line' | 'sms'> = {
44
+ multiPart: 'sms',
45
+ notSevenBit: 'sms',
46
+ linkOrPhone: 'line',
47
+ timerNotMentioned: 'line',
48
+ placeholderWhileTimerOff: 'line'
49
+ }
50
+
51
+ export function isLineWarning(warning: CalledMessageWarning): boolean {
52
+ return WARNING_SUBJECT[warning] === 'line'
53
+ }
54
+
37
55
  export type CalledMessageCheck = {
38
56
  /** The whole SMS as queue-backend would send it, with the outlet's longest code. */
39
57
  preview: string
@@ -0,0 +1,90 @@
1
+ /**
2
+ * ITS-002803: the Queue page's "Phone join" choice and the two stored flags behind it.
3
+ */
4
+ import { describe, expect, it } from 'vitest'
5
+ import {
6
+ DEFAULT_ENTRANCE_CODE_RESET_TIME,
7
+ effectiveEntranceCodeResetTime,
8
+ isEntranceCodeResetTimeValid,
9
+ phoneJoinModeOf,
10
+ withPhoneJoinMode
11
+ } from './phone-join-mode'
12
+
13
+ describe('phoneJoinModeOf', () => {
14
+ it.each([
15
+ [{}, 'anywhere'],
16
+ [{ disableRemoteQueue: null, requireEntranceCode: null }, 'anywhere'],
17
+ [{ disableRemoteQueue: false, requireEntranceCode: false }, 'anywhere'],
18
+ [{ disableRemoteQueue: false, requireEntranceCode: true }, 'entrance'],
19
+ [{ requireEntranceCode: true }, 'entrance'],
20
+ [{ disableRemoteQueue: true }, 'off'],
21
+ // Off wins on the server whatever requireEntranceCode says, so the page must say Off too.
22
+ [{ disableRemoteQueue: true, requireEntranceCode: true }, 'off'],
23
+ [{ disableRemoteQueue: true, requireEntranceCode: false }, 'off']
24
+ ] as const)('reads %o as %s', (settings, mode) => {
25
+ expect(phoneJoinModeOf(settings)).toBe(mode)
26
+ })
27
+ })
28
+
29
+ describe('withPhoneJoinMode', () => {
30
+ const stored = { enableOrder: true, disableRemoteQueue: true, requireEntranceCode: true }
31
+
32
+ it('Anywhere turns both flags off', () => {
33
+ expect(withPhoneJoinMode(stored, 'anywhere')).toEqual({
34
+ enableOrder: true,
35
+ disableRemoteQueue: false,
36
+ requireEntranceCode: false
37
+ })
38
+ })
39
+
40
+ it('Only with entrance QR needs the code and allows phone joins', () => {
41
+ expect(withPhoneJoinMode({ enableOrder: true }, 'entrance')).toEqual({
42
+ enableOrder: true,
43
+ disableRemoteQueue: false,
44
+ requireEntranceCode: true
45
+ })
46
+ })
47
+
48
+ it('Off leaves requireEntranceCode as stored', () => {
49
+ expect(
50
+ withPhoneJoinMode({ disableRemoteQueue: false, requireEntranceCode: true }, 'off')
51
+ ).toEqual({ disableRemoteQueue: true, requireEntranceCode: true })
52
+ expect(withPhoneJoinMode({ disableRemoteQueue: false }, 'off')).toEqual({
53
+ disableRemoteQueue: true
54
+ })
55
+ })
56
+
57
+ it('round-trips every mode', () => {
58
+ for (const mode of ['anywhere', 'entrance', 'off'] as const) {
59
+ expect(phoneJoinModeOf(withPhoneJoinMode(stored, mode))).toBe(mode)
60
+ }
61
+ })
62
+
63
+ it('returns a new object and leaves the input alone', () => {
64
+ const input = { disableRemoteQueue: false, requireEntranceCode: false }
65
+ const output = withPhoneJoinMode(input, 'entrance')
66
+ expect(output).not.toBe(input)
67
+ expect(input).toEqual({ disableRemoteQueue: false, requireEntranceCode: false })
68
+ })
69
+ })
70
+
71
+ describe('entrance code reset time', () => {
72
+ it('defaults to 04:00, as queue-backend does', () => {
73
+ expect(DEFAULT_ENTRANCE_CODE_RESET_TIME).toBe('04:00')
74
+ expect(effectiveEntranceCodeResetTime(undefined)).toBe('04:00')
75
+ expect(effectiveEntranceCodeResetTime(null)).toBe('04:00')
76
+ })
77
+
78
+ it.each(['00:00', '04:00', '09:30', '23:59'])('keeps a stored %s', (time) => {
79
+ expect(isEntranceCodeResetTimeValid(time)).toBe(true)
80
+ expect(effectiveEntranceCodeResetTime(time)).toBe(time)
81
+ })
82
+
83
+ it.each(['', '4:00', '24:00', '12:60', '04:00:00', '4am', ' 04:00'])(
84
+ 'shows the default for an unreadable %o',
85
+ (time) => {
86
+ expect(isEntranceCodeResetTimeValid(time)).toBe(false)
87
+ expect(effectiveEntranceCodeResetTime(time)).toBe('04:00')
88
+ }
89
+ )
90
+ })