@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
@@ -2,46 +2,87 @@
2
2
  <div class="py-[1.5rem]">
3
3
  <FmPageHead :title="t('order.kiosk')" />
4
4
  <div class="px-[1.5rem]">
5
- <FmTabs v-model:model-value="selectedMenuItem" :items="menuItems"></FmTabs>
5
+ <!-- The outlet picker sits on the tab row (it scopes Devices and Settings). Licences
6
+ are business-wide, so it is hidden there (v-show keeps its state). It wraps
7
+ under the tabs when the row is too narrow, and is full width on phones. -->
8
+ <div class="flex flex-wrap items-center justify-between gap-x-24 gap-y-8 xs:flex-col xs:items-stretch">
9
+ <FmTabs v-model:model-value="activeTab" :items="menuItems"></FmTabs>
10
+ <div
11
+ v-show="selectedMenuItem != 'licenses'"
12
+ class="kiosk-outlet-picker w-[360px] max-w-full xs:w-full"
13
+ ref="restaurantPicker"
14
+ :title="currentRestaurant?.profile.name"
15
+ >
16
+ <FmSelect
17
+ v-model="currentSelect"
18
+ :items="restaurantItems"
19
+ :placeholder="t('order.searchRestaurant')"
20
+ :aria-label="t('order.activateLocation')"
21
+ searchable
22
+ :search-debounce="150"
23
+ :on-search="searchRestaurant"
24
+ @update:model-value="selectRestaurant"
25
+ @dropdown-changed="onDropdownChanged"
26
+ >
27
+ <template #prepend>
28
+ <FmIcon name="storefront" size="md" color="#7d7d7d" />
29
+ </template>
30
+ <template #append-menu>
31
+ <FmMenuItem
32
+ v-if="!restaurantItems.length"
33
+ disabled
34
+ :label="t('order.noRestaurantFound')"
35
+ />
36
+ </template>
37
+ </FmSelect>
38
+ </div>
39
+ </div>
6
40
  <div class="pt-[1.5rem]">
7
41
  <div class="flex flex-col gap-10">
8
- <div class="flex flex-col gap-2" ref="restaurantPicker">
9
- <span class="fm-typo-en-title-sm-600"> {{ t('order.activateLocation') }} </span>
10
- <span class="fm-typo-en-title-sm-400"> {{ t('order.selectRestaurant') }}: </span>
11
- <FmSelect
12
- class="w-1/2"
13
- v-model="currentSelect"
14
- :items="restaurantItems"
15
- :placeholder="t('order.searchRestaurant')"
16
- searchable
17
- :search-debounce="150"
18
- :on-search="searchRestaurant"
19
- @update:model-value="selectRestaurant"
20
- @dropdown-changed="onDropdownChanged"
21
- >
22
- <template #append-menu>
23
- <FmMenuItem
24
- v-if="!restaurantItems.length"
25
- disabled
26
- :label="t('order.noRestaurantFound')"
27
- />
28
- </template>
29
- </FmSelect>
30
- </div>
31
42
  <KioskDevicesView
32
43
  v-if="selectedMenuItem == 'device'"
33
44
  :devices="devices"
45
+ :licenses="licenses"
34
46
  :load-error="devicesLoadError"
47
+ :loading="devicesLoading"
35
48
  @request-otp="requestOtp"
36
49
  @retry="loadDevices"
37
50
  />
38
- <KioskSettingView
39
- :key="`KioskSettingView-${currentRestaurantId}`"
40
- v-if="selectedMenuItem == 'setting' && canManageOrderSetting"
41
- :restaurant-id="currentRestaurantId"
42
- @update-kiosk-order-setting="updateKioskOrderSetting"
43
- :form="OrderSettingStore.state.kiosk ?? defaultKioskOrderSetting"
51
+ <KioskLicensesView
52
+ v-if="selectedMenuItem == 'licenses'"
53
+ :licenses="licenses"
44
54
  />
55
+ <!-- The form shows only this outlet's loaded settings, never defaults: saving
56
+ defaults would overwrite the merchant's real settings. -->
57
+ <template v-if="selectedMenuItem == 'setting' && canManageOrderSetting">
58
+ <KioskStatePanel
59
+ v-if="settingsStatus === 'error'"
60
+ icon="error"
61
+ :title="t('order.settingsLoadErrorTitle')"
62
+ :message="t('order.settingsLoadErrorMessage')"
63
+ >
64
+ <FmButton
65
+ variant="secondary"
66
+ :label="t('order.retry')"
67
+ prepend-icon="refresh"
68
+ @click="loadSettings"
69
+ />
70
+ </KioskStatePanel>
71
+ <KioskStatePanel
72
+ v-else-if="!settingsForm"
73
+ icon="hourglass_empty"
74
+ :title="t('order.settingsLoading')"
75
+ message=""
76
+ />
77
+ <KioskSettingView
78
+ v-else
79
+ :key="`KioskSettingView-${currentRestaurantId}`"
80
+ :restaurant-id="currentRestaurantId"
81
+ :form="settingsForm"
82
+ :save="saveKioskSetting"
83
+ @dirty-change="(dirty: boolean) => (settingsDirty = dirty)"
84
+ />
85
+ </template>
45
86
  </div>
46
87
  </div>
47
88
  </div>
@@ -50,30 +91,36 @@
50
91
 
51
92
  <script setup lang="ts">
52
93
  import KioskDevicesView from '@/views/kiosk/devices/KioskDevicesView.vue'
94
+ import KioskLicensesView from '@/views/kiosk/devices/KioskLicensesView.vue'
53
95
  import {
54
96
  useDialog,
55
97
  useSnackbar,
56
98
  type FmTabProps,
57
99
  type ISelectItem
58
100
  } from '@feedmepos/ui-library'
59
- import { ref, computed, defineAsyncComponent, watch, onMounted } from 'vue'
101
+ import { ref, computed, defineAsyncComponent, watch } from 'vue'
102
+ import { onBeforeRouteLeave } from 'vue-router'
60
103
  import { useKioskStore } from '@/stores/kiosk'
61
104
  import type { MfKioskDevice } from '@/modules/kiosk/interface'
105
+ import type { MfKioskLicenseList } from '@/modules/kiosk/license'
62
106
  import KioskOtpDialog from '@/views/kiosk/devices/KioskOtpDialog.vue'
63
- import { SvcCompanyApiError } from '@/api'
107
+ import { SvcCompanyApiError, SvcConfig } from '@/api'
64
108
  import { bindDeviceErrorKey } from '@/modules/kiosk/bindDeviceError'
65
109
  import { useCoreStore, useI18n } from '@feedmepos/mf-common'
66
110
  import { useOrderSettings } from '@/stores/order-setting'
67
111
  import { usePaymentStore } from '@/stores/payment'
68
- import type { MfKioskOrderSetting } from '@/modules/order-setting/kiosk/interface'
69
- import { defaultKioskOrderSetting } from '@/stores/order-setting/mapper'
112
+ import KioskStatePanel from '@/views/kiosk/KioskStatePanel.vue'
113
+ import { outletToLoad } from '@/modules/kiosk/outletLoad'
114
+ import { useKioskSettings } from '@/modules/kiosk/useKioskSettings'
70
115
  import { useOrderSettingPermission } from '@/composables/useOrderSettingPermission'
116
+ import { useInternalUser } from '@/composables/useInternalUser'
71
117
  import { capitalCase } from 'change-case'
72
118
 
73
119
  const { t } = useI18n()
74
120
  const { canManageOrderSetting } = useOrderSettingPermission()
121
+ const { isInternal } = useInternalUser()
75
122
 
76
- type KioskMenuItemValue = 'device' | 'setting'
123
+ type KioskMenuItemValue = 'device' | 'licenses' | 'setting'
77
124
 
78
125
  const KioskSettingView = defineAsyncComponent(
79
126
  () => import('@/views/kiosk/settings/KioskSettingView.vue')
@@ -131,45 +178,148 @@ function onDropdownChanged(open: boolean) {
131
178
  restaurantPicker.value?.querySelector('input')?.select()
132
179
  }
133
180
 
134
- const currentRestaurantId = ref<string>(currentRestaurant.value?._id ?? '')
181
+ const currentRestaurantId = ref<string>('')
182
+ /** The outlet whose data was (or is being) loaded; see `outletToLoad`. */
183
+ const loadedRestaurantId = ref<string | null>(null)
184
+
185
+ const devicesLoading = ref(false)
186
+ // Load / save rules for the Settings tab (clear on outlet change, show and save only
187
+ // this outlet's loaded settings, "saved" only after the backend accepted it).
188
+ const {
189
+ status: settingsStatus,
190
+ form: settingsForm,
191
+ load: loadSettings,
192
+ save: saveKioskSetting
193
+ } = useKioskSettings(OrderSettingStore, {
194
+ onSaved: () => SnackBar.open({ title: t('order.kioskSettingSuccess'), type: 'success' }),
195
+ onFailed: () => SnackBar.open({ title: t('order.kioskSettingFailed'), type: 'error' })
196
+ })
197
+ /** Unsaved edits in the Settings form, reported by KioskSettingView. */
198
+ const settingsDirty = ref(false)
135
199
 
136
200
  async function selectRestaurant(v: string) {
201
+ if (v === currentRestaurantId.value) return
202
+ if (settingsDirty.value && !(await confirmDiscard())) {
203
+ // Keep the outlet whose edits are still open.
204
+ currentSelect.value = currentRestaurantId.value || undefined
205
+ return
206
+ }
207
+ settingsDirty.value = false
137
208
  const restaurant = restaurants.value.find((r) => r._id == v)
138
- await changeRestaurant(restaurant)
139
- await loadRestaurantData()
140
209
  currentSelect.value = v
141
- currentRestaurantId.value = v
210
+ // The load watcher below picks up the new outlet.
211
+ await changeRestaurant(restaurant)
142
212
  }
143
213
 
214
+ // Load an outlet only once the portal has a signed-in token AND an outlet. On a
215
+ // first visit the page can mount before the token is ready; the API client then
216
+ // throws before sending anything, which used to show "Couldn't load devices" and
217
+ // default settings. A token refresh for the same outlet does not reload.
218
+ watch(
219
+ () => ({
220
+ hasToken: !!SvcConfig.getIdToken(),
221
+ restaurantId: currentRestaurant.value?._id
222
+ }),
223
+ (input) => {
224
+ const id = outletToLoad(input, loadedRestaurantId.value)
225
+ if (!id) return
226
+ loadedRestaurantId.value = id
227
+ currentRestaurantId.value = id
228
+ currentSelect.value = id
229
+ void loadRestaurantData()
230
+ },
231
+ { immediate: true }
232
+ )
233
+
144
234
  async function loadRestaurantData() {
145
- // Order settings are only needed for the (permission-gated) Settings tab. Skip the
146
- // fetch when the user can't manage them, and never let its failure block the Device
147
- // tab — the order-settings endpoint is now HRM-guarded and 403s without the subject.
148
- if (canManageOrderSetting.value) {
149
- try {
150
- await OrderSettingStore.getSetting()
151
- } catch {
152
- // Settings tab surfaces its own state; don't block device loading.
153
- }
235
+ // Never show the previous outlet's devices under this outlet's name.
236
+ KioskStore.state.devices = []
237
+ KioskStore.state.licenses = null
238
+ // Order settings are only needed for the (permission-gated) Settings tab, and
239
+ // their failure must never block the Devices tab: the order-settings endpoint is
240
+ // HRM-guarded and 403s without the subject.
241
+ await Promise.all([
242
+ canManageOrderSetting.value ? loadSettings() : Promise.resolve(),
243
+ PaymentStore.loadCheckouts(),
244
+ loadPaymentDevices(),
245
+ loadDevices()
246
+ ])
247
+ }
248
+
249
+ // Payment devices with their gateway setup: FeedMe staff only (the endpoint also
250
+ // carries terminal secrets, which the API layer drops; merchants never call it).
251
+ function loadPaymentDevices(): Promise<void> {
252
+ if (!isInternal.value) {
253
+ PaymentStore.clearPaymentDevices()
254
+ return Promise.resolve()
154
255
  }
155
- await PaymentStore.loadCheckouts()
156
- await loadDevices()
256
+ return PaymentStore.loadPaymentDevices()
157
257
  }
158
258
 
259
+ // The session user can arrive after the first outlet load.
260
+ watch(isInternal, (internal) => {
261
+ if (loadedRestaurantId.value) void loadPaymentDevices()
262
+ else if (!internal) PaymentStore.clearPaymentDevices()
263
+ })
264
+
159
265
  // Loads the device list, mapping a 403 to the in-tab "access denied" panel and any
160
266
  // other failure to a retryable error panel (instead of silently showing "no devices").
161
267
  async function loadDevices() {
162
268
  devicesLoadError.value = null
163
- try {
164
- await KioskStore.getDevices()
165
- } catch (e) {
166
- devicesLoadError.value =
167
- e instanceof SvcCompanyApiError && e.status === 403 ? 'forbidden' : 'error'
269
+ devicesLoading.value = true
270
+ await Promise.all([
271
+ KioskStore.getDevices().catch((e) => {
272
+ devicesLoadError.value =
273
+ e instanceof SvcCompanyApiError && e.status === 403 ? 'forbidden' : 'error'
274
+ }),
275
+ // Licences are extra information on top of the devices: a failure only shows
276
+ // a note in the summary (the store leaves `licenses` null).
277
+ KioskStore.getLicenses().catch(() => undefined)
278
+ ])
279
+ devicesLoading.value = false
280
+ }
281
+
282
+ const activeTab = computed<KioskMenuItemValue>({
283
+ get: () => selectedMenuItem.value,
284
+ set: (next) => {
285
+ if (next === selectedMenuItem.value) return
286
+ if (selectedMenuItem.value === 'setting' && settingsDirty.value) {
287
+ void confirmDiscard().then((discard) => {
288
+ if (!discard) return
289
+ settingsDirty.value = false
290
+ selectedMenuItem.value = next
291
+ })
292
+ return
293
+ }
294
+ selectedMenuItem.value = next
168
295
  }
296
+ })
297
+
298
+ /** Ask before throwing away unsaved Settings edits. Resolves true to discard. */
299
+ function confirmDiscard(): Promise<boolean> {
300
+ return new Promise((resolve) => {
301
+ Dialog.open({
302
+ title: t('order.unsavedLeaveTitle'),
303
+ message: t('order.unsavedLeaveMessage'),
304
+ primaryActions: { text: t('order.unsavedLeaveConfirm'), variant: 'destructive', close: true },
305
+ secondaryActions: { text: t('order.keepEditing'), variant: 'tertiary', close: true }
306
+ })
307
+ .onPrimary(() => resolve(true))
308
+ // A later resolve is ignored, so a close that follows the primary button keeps `true`.
309
+ .onClose(() => setTimeout(() => resolve(false), 0))
310
+ })
169
311
  }
170
312
 
313
+ onBeforeRouteLeave(async () => {
314
+ if (!settingsDirty.value) return true
315
+ return await confirmDiscard()
316
+ })
317
+
171
318
  const menuItems = computed<FmTabProps[]>(() => {
172
- const items: FmTabProps[] = [{ label: t('order.deviceBinding'), value: 'device' }]
319
+ const items: FmTabProps[] = [
320
+ { label: t('order.deviceBinding'), value: 'device' },
321
+ { label: t('order.licensesTab'), value: 'licenses' }
322
+ ]
173
323
  // The Settings tab is order settings — only show it to users who can manage them.
174
324
  if (canManageOrderSetting.value) {
175
325
  items.push({ label: t('order.settings'), value: 'setting' })
@@ -181,6 +331,8 @@ const devices = computed<MfKioskDevice[]>(() => {
181
331
  return KioskStore.state.devices
182
332
  })
183
333
 
334
+ const licenses = computed<MfKioskLicenseList | null>(() => KioskStore.state.licenses)
335
+
184
336
  async function requestOtp() {
185
337
  try {
186
338
  await KioskStore.requestOtp()
@@ -195,7 +347,8 @@ async function requestOtp() {
195
347
  title: capitalCase(t('order.bindDevice')),
196
348
  contentComponent: KioskOtpDialog,
197
349
  contentComponentProps: {
198
- otp: KioskStore.state.otp
350
+ otp: KioskStore.state.otp,
351
+ licenses: KioskStore.state.licenses
199
352
  }
200
353
  }).onClose(async () => {
201
354
  // Refresh devices after dialog closes (in case a device was bound)
@@ -203,38 +356,22 @@ async function requestOtp() {
203
356
  })
204
357
  }
205
358
 
206
- async function updateKioskOrderSetting(form: MfKioskOrderSetting) {
207
- try {
208
- OrderSettingStore.setKioskOrderSetting(form)
209
- await OrderSettingStore.updateKioskSetting()
210
- SnackBar.open({
211
- title: t('order.kioskSettingSuccess'),
212
- type: 'success'
213
- })
214
- } catch (e) {
215
- SnackBar.open({
216
- title: t('order.kioskSettingFailed'),
217
- type: 'error'
218
- })
219
- }
220
- }
221
-
222
- // Load data on mount if restaurant is already selected
223
- onMounted(async () => {
224
- if (currentRestaurant.value?._id) {
225
- currentRestaurantId.value = currentRestaurant.value._id
226
- await loadRestaurantData()
227
- }
228
- })
229
-
230
359
  watch(
231
360
  () => restaurants.value.length,
232
361
  async (_) => {
233
362
  // Only auto-select if no restaurant is currently selected
234
- if (currentSelect.value === undefined && restaurants.value.length > 0) {
363
+ if (!currentRestaurant.value && currentSelect.value === undefined && restaurants.value.length > 0) {
235
364
  await selectRestaurant(restaurants.value[0]._id)
236
365
  }
237
366
  },
238
367
  { immediate: true }
239
368
  )
240
369
  </script>
370
+
371
+ <style scoped>
372
+ /* A long outlet name ends with "…" instead of being cut mid-word; the full name is
373
+ in the menu and in the tooltip. */
374
+ .kiosk-outlet-picker :deep(input) {
375
+ text-overflow: ellipsis;
376
+ }
377
+ </style>
@@ -6,7 +6,7 @@
6
6
  <span
7
7
  class="px-2 py-1 fm-corner-radius-md fm-typo-en-body-sm-600 uppercase bg-fm-color-neutral-gray-200 text-fm-color-typo-secondary"
8
8
  >
9
- {{ isTabletApp ? 'Tablet' : 'Kiosk' }}
9
+ {{ isTabletApp ? t('order.licenseTypeTablet') : t('order.licenseTypeKiosk') }}
10
10
  </span>
11
11
  <span
12
12
  v-if="isTabletApp && device.slotInfo"
@@ -17,13 +17,13 @@
17
17
  </div>
18
18
  <div class="flex items-center gap-1">
19
19
  <FmSideSheet
20
- :header="device.name"
20
+ :header="normalizedRemarkValue || device.name"
21
21
  dismiss-away
22
22
  :maxWidth="700"
23
23
  @on:clickedAway="closeUpdateDevicePin"
24
24
  >
25
25
  <template #side-sheet-button>
26
- <FmButton variant="tertiary" icon="more_vert" />
26
+ <FmButton variant="tertiary" size="md" :label="t('order.deviceDetails')" />
27
27
  </template>
28
28
  <div v-if="!showPinSetting" class="py-[0.5rem] flex flex-col gap-[1.5rem] pr-2">
29
29
  <div>
@@ -110,19 +110,31 @@
110
110
  </div>
111
111
  </div>
112
112
 
113
- <div
114
- v-else-if="activeDetailTab === 'payment-gateway' && isPaymentCheckoutKiosk"
115
- class="w-full border p-[1.5rem] fm-corner-radius-lg flex flex-col gap-4"
116
- >
117
- <span class="fm-typo-en-title-sm-600">{{ t('order.paymentGateway') }}</span>
118
- <span class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary">
119
- {{ t('order.availablePaymentMethodsHint') }}
120
- </span>
121
- <KioskPaymentCheckoutList
122
- :checkouts="terminal?.checkouts ?? []"
123
- :load-error="PaymentStore.state.loadError"
113
+ <template v-else-if="activeDetailTab === 'payment-gateway' && hasPaymentTab">
114
+ <KioskPaymentDeviceCard
115
+ v-if="showPaymentDevice"
116
+ :payment-device="paymentDevice"
117
+ :loading="PaymentStore.state.paymentDevicesLoading"
118
+ :load-error="PaymentStore.state.paymentDevicesLoadError !== null"
119
+ :expected-device-id="expectedPaymentDeviceId"
120
+ :portal-url="paymentPortalUrl"
121
+ :reported="device.config.terminalInfo ?? null"
122
+ @retry="PaymentStore.loadPaymentDevices()"
124
123
  />
125
- </div>
124
+ <div
125
+ v-if="isPaymentCheckoutKiosk"
126
+ class="w-full border p-[1.5rem] fm-corner-radius-lg flex flex-col gap-4"
127
+ >
128
+ <span class="fm-typo-en-title-sm-600">{{ t('order.paymentGateway') }}</span>
129
+ <span class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary">
130
+ {{ t('order.availablePaymentMethodsHint') }}
131
+ </span>
132
+ <KioskPaymentCheckoutList
133
+ :checkouts="terminal?.checkouts ?? []"
134
+ :load-error="PaymentStore.state.loadError"
135
+ />
136
+ </div>
137
+ </template>
126
138
 
127
139
  </div>
128
140
  <div v-else>
@@ -158,24 +170,28 @@
158
170
  variant="plain"
159
171
  icon="link_off"
160
172
  class="text-fm-color-system-error-300"
173
+ :aria-label="t('order.unbindKioskDevice')"
174
+ :title="t('order.unbindKioskDevice')"
161
175
  @click="openUnbindDialog"
162
176
  />
163
177
  </div>
164
178
  </div>
165
179
 
166
- <!-- Device Name (truncated for long names) -->
180
+ <!-- Name: the merchant's remark when set (the only name a person gave the device);
181
+ otherwise the app-reported name, which is often a browser user-agent. -->
167
182
  <div
168
183
  class="fm-typo-en-body-md-600 text-fm-color-typo-primary mb-1 overflow-hidden text-ellipsis whitespace-nowrap"
169
- :title="device.name"
184
+ :title="normalizedRemarkValue || device.name"
170
185
  >
171
- {{ device.name }}
186
+ {{ normalizedRemarkValue || device.name }}
172
187
  </div>
173
188
 
174
189
  <div
175
190
  class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary mb-1 overflow-hidden text-ellipsis whitespace-nowrap"
176
- :title="normalizedRemarkValue || t('order.notSet')"
191
+ :title="normalizedRemarkValue ? device.name : t('order.notSet')"
177
192
  >
178
- {{ t('order.deviceRemark') }}: {{ normalizedRemarkValue || t('order.notSet') }}
193
+ <template v-if="normalizedRemarkValue">{{ device.name }}</template>
194
+ <template v-else>{{ t('order.deviceRemark') }}: {{ t('order.notSet') }}</template>
179
195
  </div>
180
196
 
181
197
  <!-- Machine ID Row (clickable to copy) -->
@@ -218,6 +234,35 @@
218
234
  {{ formatRelativeTime(device.lastStartup) }}
219
235
  </span>
220
236
  </div>
237
+
238
+ <!-- Licence line: status, plus a warning when the licence is of the other type -->
239
+ <div class="flex items-center gap-2 flex-wrap mt-2" data-testid="device-license-line">
240
+ <span class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary">{{ t('order.licenseLabel') }}</span>
241
+ <FmChip
242
+ compact
243
+ :variant="licenseChip.variant"
244
+ :label="t(licenseChip.labelKey, licenseChip.params)"
245
+ />
246
+ <FmChip
247
+ v-if="licenseMismatch"
248
+ compact
249
+ variant="warning"
250
+ icon="warning"
251
+ :label="t(licenseMismatch)"
252
+ />
253
+ </div>
254
+
255
+ <!-- Staff only: whether payment-service has a payment device for this kiosk -->
256
+ <div
257
+ v-if="showPaymentDevice && PaymentStore.state.paymentDevices"
258
+ class="flex items-center gap-1 mt-2 fm-typo-en-body-sm-400"
259
+ :class="paymentDevice ? 'text-fm-color-typo-secondary' : 'text-fm-color-system-warning-300'"
260
+ data-testid="device-payment-line"
261
+ >
262
+ <FmIcon :name="paymentDevice ? 'point_of_sale' : 'link_off'" size="sm" />
263
+ <span>{{ paymentDevice ? t('order.paymentDeviceLinked') : t('order.paymentDeviceMissingShort') }}</span>
264
+ <span v-if="paymentDevice?.status && paymentDevice.status !== 'Active'">· {{ paymentDevice.status }}</span>
265
+ </div>
221
266
  </div>
222
267
  </template>
223
268
  <script setup lang="ts">
@@ -232,7 +277,17 @@ import { computed, ref, watch } from 'vue'
232
277
  import KioskUnbindConfirm from './KioskUnbindConfirm.vue'
233
278
  import { useKioskPermission } from '@/composables/useKioskPermission'
234
279
  import KioskPaymentCheckoutList from '../settings/KioskPaymentCheckoutList.vue'
235
- import { usePaymentStore } from '@/stores/payment'
280
+ import KioskPaymentDeviceCard from './KioskPaymentDeviceCard.vue'
281
+ import { terminalDeviceId, usePaymentStore } from '@/stores/payment'
282
+ import { useInternalUser } from '@/composables/useInternalUser'
283
+ import { paymentPortalKioskUrl } from '@/modules/payment/paymentDevice'
284
+ import {
285
+ deviceLicenseChip,
286
+ deviceLicenseState,
287
+ licenseMismatchKey,
288
+ shortLicenseId,
289
+ type MfKioskLicenseType
290
+ } from '@/modules/kiosk/license'
236
291
  dayjs.extend(relativeTime)
237
292
 
238
293
  const { t } = useI18n()
@@ -247,8 +302,30 @@ const showPinSetting = ref(false)
247
302
 
248
303
  interface Props {
249
304
  device: MfKioskDevice
305
+ /** Type of the licence this device holds, when the licence list loaded. */
306
+ licenseType?: MfKioskLicenseType
250
307
  }
251
308
  const props = defineProps<Props>()
309
+
310
+ const licenseChip = computed(() =>
311
+ deviceLicenseChip(
312
+ deviceLicenseState({
313
+ licenseId: props.device.licenseId,
314
+ expiredAt: props.device.licenseExpiredAt
315
+ }),
316
+ (d) => dayjs(d).format('DD MMM YYYY')
317
+ )
318
+ )
319
+
320
+ const licenseMismatch = computed(() =>
321
+ licenseMismatchKey(props.device.deviceAppType, props.licenseType)
322
+ )
323
+
324
+ function licenseTypeLabel(type: MfKioskLicenseType | undefined): string {
325
+ if (type === 'TABLET') return t('order.licenseTypeTablet')
326
+ if (type === 'KIOSK') return t('order.licenseTypeKiosk')
327
+ return '-'
328
+ }
252
329
  const unBindTextFieldValue = ref<string>('')
253
330
 
254
331
  const isPaymentCheckoutKiosk = computed(
@@ -263,8 +340,35 @@ const terminal = computed(() =>
263
340
  )
264
341
  )
265
342
 
343
+ // Support (FeedMe staff) sees which payment-service device this kiosk uses, so they
344
+ // do not have to work it out on the payment portal. Merchants keep the checklist only.
345
+ const { isInternal } = useInternalUser()
346
+ const showPaymentDevice = computed(
347
+ () => isInternal.value && props.device.deviceAppType === 'KIOSK_APP'
348
+ )
349
+ const hasPaymentTab = computed(() => isPaymentCheckoutKiosk.value || showPaymentDevice.value)
350
+ const expectedPaymentDeviceId = computed(() =>
351
+ terminalDeviceId(CoreStore.currentRestaurant.value?._id ?? '', props.device.machineId)
352
+ )
353
+ const paymentDevice = computed(() =>
354
+ PaymentStore.paymentDeviceFor(
355
+ CoreStore.currentRestaurant.value?._id ?? '',
356
+ props.device.machineId
357
+ )
358
+ )
359
+ const paymentPortalUrl = computed(() => {
360
+ if (!paymentDevice.value) return null
361
+ return paymentPortalKioskUrl(window.location.origin, paymentDevice.value.id, {
362
+ country: CoreStore.currentCountry.value,
363
+ businessId: CoreStore.currentBusiness.value?._id,
364
+ restaurantId: CoreStore.currentRestaurant.value?._id
365
+ })
366
+ })
367
+
266
368
  const appType = computed(() => {
267
- return props.device?.deviceAppType === 'TABLET_APP' ? t('order.tabletOnly') : t('order.kioskOnly')
369
+ return props.device?.deviceAppType === 'TABLET_APP'
370
+ ? t('order.licenseTypeTablet')
371
+ : t('order.licenseTypeKiosk')
268
372
  })
269
373
 
270
374
  interface OtherSectionEntry {
@@ -512,7 +616,7 @@ const detailTabItems = computed<FmTabProps[]>(() => {
512
616
  }
513
617
  ]
514
618
 
515
- if (isPaymentCheckoutKiosk.value) {
619
+ if (hasPaymentTab.value) {
516
620
  items.push({
517
621
  label: t('order.paymentGateway'),
518
622
  value: 'payment-gateway'
@@ -594,6 +698,27 @@ const detailRows = computed<DeviceDetailRow[]>(() => {
594
698
  })
595
699
  }
596
700
 
701
+ if (props.device.licenseId) {
702
+ rows.push(
703
+ {
704
+ label: t('order.licenseType'),
705
+ value: licenseTypeLabel(props.licenseType)
706
+ },
707
+ { label: t('order.licenseId'), value: shortLicenseId(props.device.licenseId), isMono: true },
708
+ {
709
+ label: t('order.licenseExpiry'),
710
+ // The chip text already carries the date when the licence is simply active.
711
+ value: !props.device.licenseExpiredAt
712
+ ? t('order.notSet')
713
+ : licenseChip.value.variant === 'success'
714
+ ? dayjs(props.device.licenseExpiredAt).format('DD MMM YYYY')
715
+ : `${dayjs(props.device.licenseExpiredAt).format('DD MMM YYYY')} · ${t(licenseChip.value.labelKey, licenseChip.value.params)}`
716
+ }
717
+ )
718
+ } else {
719
+ rows.push({ label: t('order.licenseType'), value: t('order.licenseNoneDetail') })
720
+ }
721
+
597
722
  return rows
598
723
  })
599
724