@feedmepos/mf-order-setting 0.0.95 → 0.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DisplaySystemView-rCw3DE0u.js → DisplaySystemView-BH8SkCOF.js} +4 -4
- package/dist/FoodCourtInvitationsView-3cA0Z-5m.js +383 -0
- package/dist/FoodCourtOrderSettingsView-DysrLZJD.js +294 -0
- package/dist/FoodCourtOrdersView-CbZqHIXO.js +544 -0
- package/dist/FoodCourtStallsView-CTZzPUQ6.js +635 -0
- package/dist/FoodCourtStatusView-C71y7ghx.js +113 -0
- package/dist/{KioskDevicesView-B4dgvMq_.js → KioskDevicesView-BJpbuSzp.js} +1 -1
- package/dist/{KioskDevicesView.vue_vue_type_script_setup_true_lang-B-Oi8ZLq.js → KioskDevicesView.vue_vue_type_script_setup_true_lang-CQFpwn28.js} +7 -6
- package/dist/{KioskSettingView-DXx6wQQQ.js → KioskSettingView-CJxhMf7N.js} +3 -3
- package/dist/{KioskView-BmSHCl13.js → KioskView-BZsdRID1.js} +6 -6
- package/dist/{OrderSettingsView-9NOSAxLf.js → OrderSettingsView-gnyXaJjf.js} +10631 -10601
- package/dist/{app-y20uA-tu.js → app-CeEFBB-w.js} +4484 -3672
- package/dist/app.js +1 -1
- package/dist/dayjs.min-zBHHlxAP.js +285 -0
- package/dist/{featureFlag-GHmH1G2d.js → featureFlag-BTY_R78k.js} +1 -1
- package/dist/food-court-member-piX3gesl.js +212 -0
- package/dist/frontend/mf-order/src/api/food-court/index.d.ts +269 -0
- package/dist/frontend/mf-order/src/api/food-court/invitation.d.ts +55 -0
- package/dist/frontend/mf-order/src/app.d.ts +676 -0
- package/dist/frontend/mf-order/src/main.d.ts +676 -0
- package/dist/frontend/mf-order/src/stores/business/index.d.ts +3 -3
- package/dist/frontend/mf-order/src/stores/order-setting/index.d.ts +6 -0
- package/dist/frontend/mf-order/src/utils/constants/route.d.ts +4 -0
- package/dist/frontend/mf-order/src/views/food-court/FoodCourtInvitationsView.vue.d.ts +2 -0
- package/dist/frontend/mf-order/src/views/food-court/FoodCourtOrdersView.vue.d.ts +2 -0
- package/dist/frontend/mf-order/src/views/food-court/FoodCourtStallsView.vue.d.ts +2 -0
- package/dist/frontend/mf-order/src/views/food-court/FoodCourtStatusView.vue.d.ts +2 -0
- package/dist/frontend/mf-order/src/views/food-court/food-court-member.d.ts +150 -0
- package/dist/frontend/mf-order/src/views/food-court/food-court-order.d.ts +66 -0
- package/dist/frontend/mf-order/src/views/food-court/invitations/JoinFoodCourtCard.vue.d.ts +13 -0
- package/dist/frontend/mf-order/src/views/food-court/invitations/MembershipRowActions.vue.d.ts +11 -0
- package/dist/frontend/mf-order/src/views/food-court/orders/FoodCourtOrderSheet.vue.d.ts +16 -0
- package/dist/frontend/mf-order/src/views/food-court/stalls/EditStallSheet.vue.d.ts +15 -0
- package/dist/frontend/mf-order/src/views/food-court/stalls/GenerateJoinCodeSheet.vue.d.ts +21 -0
- package/dist/frontend/mf-order/src/views/food-court/stalls/StallAssignmentFields.vue.d.ts +16 -0
- package/dist/frontend/mf-order/src/views/food-court/stalls/StallRowActions.vue.d.ts +11 -0
- package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{index-CmdP_QXF.js → index-601eG3_R.js} +1 -1
- package/dist/index-BeBZTUcq.js +122 -0
- package/dist/index-BtudnkMi.js +1065 -0
- package/dist/{index-BlG6mIU4.js → index-CGiWgTn1.js} +38 -37
- package/dist/{index-wMygvJpP.js → index-D5nv3ncu.js} +2 -2
- package/dist/index-DLDihONy.js +25142 -0
- package/dist/order.dto-JM_fmWnQ.js +14842 -0
- package/dist/package/entity/food-court/food-court.do.d.ts +1 -1
- package/dist/package/entity/food-court/food-court.dto.d.ts +7 -7
- package/dist/package/entity/food-court/order-v2.dto.d.ts +4 -4
- package/dist/package/entity/order-platform/order-platform.dto.d.ts +190 -92
- package/dist/package/entity/order-setting/order-setting.do.d.ts +10 -0
- package/dist/package/entity/order-setting/order-setting.dto.d.ts +20 -0
- package/dist/package/entity/order-setting/queue/queue.do.d.ts +22 -0
- package/dist/package/entity/order-setting/queue/queue.dto.d.ts +7 -0
- package/dist/package/entity/queue/queue.do.d.ts +1 -0
- package/dist/package/entity/queue/queue.dto.d.ts +8 -8
- package/dist/package/entity/restaurant/restaurant.dto.d.ts +20 -0
- package/dist/search-BAPEUu1R.js +15 -0
- package/dist/useFoodCourtContext-2p5sJMcB.js +16 -0
- package/package.json +3 -3
- package/src/api/food-court/index.ts +357 -0
- package/src/api/food-court/invitation.ts +81 -0
- package/src/locales/en-US.json +171 -2
- package/src/locales/ja-JP.json +171 -2
- package/src/locales/th-TH.json +171 -2
- package/src/locales/zh-CN.json +171 -2
- package/src/router/routes.ts +44 -0
- package/src/utils/constants/route.ts +8 -0
- package/src/views/food-court/FoodCourtInvitationsView.vue +187 -0
- package/src/views/food-court/FoodCourtOrdersView.vue +263 -0
- package/src/views/food-court/FoodCourtStallsView.vue +369 -0
- package/src/views/food-court/FoodCourtStatusView.vue +111 -0
- package/src/views/food-court/food-court-member.spec.ts +339 -0
- package/src/views/food-court/food-court-member.ts +397 -0
- package/src/views/food-court/food-court-order.spec.ts +137 -0
- package/src/views/food-court/food-court-order.ts +206 -0
- package/src/views/food-court/invitations/JoinFoodCourtCard.vue +201 -0
- package/src/views/food-court/invitations/MembershipRowActions.vue +19 -0
- package/src/views/food-court/orders/FoodCourtOrderSheet.vue +226 -0
- package/src/views/food-court/stalls/EditStallSheet.vue +91 -0
- package/src/views/food-court/stalls/GenerateJoinCodeSheet.vue +281 -0
- package/src/views/food-court/stalls/StallAssignmentFields.vue +36 -0
- package/src/views/food-court/stalls/StallRowActions.vue +31 -0
- package/src/views/order-settings/OrderSettingsView.vue +2 -4
- package/src/views/order-settings/dine-in/DineInSetting.vue +1 -4
- package/src/views/order-settings/queue/QueueSetting.vue +27 -0
- package/src/views/order-settings/reservation/ReservationSetting.vue +8 -0
- package/dist/FoodCourtOrderSettingsView-DUQXCKzB.js +0 -323
- package/dist/index-CUI1lL9F.js +0 -1347
- package/dist/order.dto-CyHtvyly.js +0 -38829
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="py-[1.5rem]">
|
|
3
|
+
<FmPageHead :title="t('order.foodCourt.stalls.title')" :line-height="1.7" />
|
|
4
|
+
</div>
|
|
5
|
+
<div v-if="!foodCourtId" class="px-[1.5rem] fm-typo-en-body-md-400 text-fm-color-typo-secondary">
|
|
6
|
+
{{ t('order.foodCourt.noFoodCourtSelected') }}
|
|
7
|
+
</div>
|
|
8
|
+
<div v-else-if="loadFailed" class="p-[1.5rem] m-5 flex flex-col gap-3 items-start">
|
|
9
|
+
<span class="fm-typo-en-body-md-400">{{ t('order.foodCourt.stalls.loadFailed') }}</span>
|
|
10
|
+
<FmButton variant="secondary" :label="t('order.foodCourt.retry')" @click="load" />
|
|
11
|
+
</div>
|
|
12
|
+
<div v-else class="px-[1.5rem] flex flex-col gap-4">
|
|
13
|
+
<div class="flex items-center justify-between gap-3 flex-wrap">
|
|
14
|
+
<FmSearch
|
|
15
|
+
v-model="searchKey"
|
|
16
|
+
class="flex-1 min-w-[200px] max-w-[400px]"
|
|
17
|
+
:placeholder="t('order.foodCourt.stalls.searchPlaceholder')"
|
|
18
|
+
/>
|
|
19
|
+
<FmButton
|
|
20
|
+
variant="primary"
|
|
21
|
+
prepend-icon="add"
|
|
22
|
+
:label="t('order.foodCourt.stalls.generateJoinCode')"
|
|
23
|
+
@click="generateOpen = true"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
<FmTable
|
|
27
|
+
v-if="isLoading || filteredRows.length"
|
|
28
|
+
:row-data="filteredRows"
|
|
29
|
+
:column-defs="columns"
|
|
30
|
+
:loading="isLoading"
|
|
31
|
+
:hide-footer="true"
|
|
32
|
+
:page-size="1000"
|
|
33
|
+
class="w-full"
|
|
34
|
+
/>
|
|
35
|
+
<div v-else class="text-center py-8 text-fm-color-typo-tertiary fm-typo-en-body-md-400">
|
|
36
|
+
{{ rows.length ? t('order.foodCourt.stalls.noMatch') : t('order.foodCourt.stalls.empty') }}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<template v-if="foodCourtId">
|
|
41
|
+
<GenerateJoinCodeSheet v-model="generateOpen" :food-court-id="foodCourtId" @created="load" />
|
|
42
|
+
<EditStallSheet
|
|
43
|
+
v-model="editOpen"
|
|
44
|
+
:food-court-id="foodCourtId"
|
|
45
|
+
:member="editing"
|
|
46
|
+
@saved="load"
|
|
47
|
+
/>
|
|
48
|
+
</template>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import { computed, h, ref, watch } from 'vue'
|
|
53
|
+
import dayjs from 'dayjs'
|
|
54
|
+
import { useI18n } from '@feedmepos/mf-common'
|
|
55
|
+
import { components, useDialog, type ColumnDef } from '@feedmepos/ui-library'
|
|
56
|
+
import { useSnackbarFunctions } from '@/components/snackbar'
|
|
57
|
+
import { useFoodCourtId } from '@/composables/useFoodCourtContext'
|
|
58
|
+
import useSearch from '@/composables/search'
|
|
59
|
+
import { FoodCourtJoinCodeApi, FoodCourtMemberApi } from '@/api/food-court'
|
|
60
|
+
import {
|
|
61
|
+
STALL_STATUS_CHIP,
|
|
62
|
+
errorMessage,
|
|
63
|
+
requesterName,
|
|
64
|
+
stallName,
|
|
65
|
+
toStallRows,
|
|
66
|
+
type JoinCodeStallRow,
|
|
67
|
+
type MemberStallRow,
|
|
68
|
+
type StallAction,
|
|
69
|
+
type StallRow
|
|
70
|
+
} from './food-court-member'
|
|
71
|
+
import StallRowActions from './stalls/StallRowActions.vue'
|
|
72
|
+
import GenerateJoinCodeSheet from './stalls/GenerateJoinCodeSheet.vue'
|
|
73
|
+
import EditStallSheet from './stalls/EditStallSheet.vue'
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Food Court Operations › Stalls (KDI-4915 + KDI-4919, Figma 1.20-1.32): the
|
|
77
|
+
* court owner generates single-use join codes for stalls, approves or
|
|
78
|
+
* declines the stalls' requests to join, pauses (Deactivate = `visible:
|
|
79
|
+
* false`) or removes stalls, and sets each stall's number and display name
|
|
80
|
+
* for this court. Legacy invitations (from before join codes) can only be
|
|
81
|
+
* cancelled.
|
|
82
|
+
*/
|
|
83
|
+
const { t } = useI18n()
|
|
84
|
+
const { showSuccess, showError } = useSnackbarFunctions()
|
|
85
|
+
const Dialog = useDialog()
|
|
86
|
+
const foodCourtId = useFoodCourtId()
|
|
87
|
+
const { searchKey, filter } = useSearch()
|
|
88
|
+
|
|
89
|
+
const rows = ref<StallRow[]>([])
|
|
90
|
+
const isLoading = ref(false)
|
|
91
|
+
const loadFailed = ref(false)
|
|
92
|
+
const generateOpen = ref(false)
|
|
93
|
+
const editOpen = ref(false)
|
|
94
|
+
const editing = ref<MemberStallRow | null>(null)
|
|
95
|
+
/** A confirm dialog this page opened is showing. */
|
|
96
|
+
const confirmOpen = ref(false)
|
|
97
|
+
|
|
98
|
+
const filteredRows = computed(() =>
|
|
99
|
+
rows.value.filter((row) =>
|
|
100
|
+
filter([
|
|
101
|
+
row.unitNo ?? '',
|
|
102
|
+
stallName(row),
|
|
103
|
+
row.restaurantName ?? '',
|
|
104
|
+
row.restaurantId ?? '',
|
|
105
|
+
row.kind === 'joinCode' ? (row.businessName ?? '') : ''
|
|
106
|
+
])
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
async function load(): Promise<void> {
|
|
111
|
+
const id = foodCourtId.value
|
|
112
|
+
loadFailed.value = false
|
|
113
|
+
if (!id) {
|
|
114
|
+
rows.value = []
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
isLoading.value = true
|
|
118
|
+
try {
|
|
119
|
+
const [members, joinCodes] = await Promise.all([
|
|
120
|
+
FoodCourtMemberApi.listMembers(id),
|
|
121
|
+
FoodCourtJoinCodeApi.listJoinCodes(id)
|
|
122
|
+
])
|
|
123
|
+
if (id === foodCourtId.value) rows.value = toStallRows(members, joinCodes)
|
|
124
|
+
} catch (e) {
|
|
125
|
+
if (id !== foodCourtId.value) return
|
|
126
|
+
loadFailed.value = true
|
|
127
|
+
showError(errorMessage(e))
|
|
128
|
+
} finally {
|
|
129
|
+
if (id === foodCourtId.value) isLoading.value = false
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The portal switched court: close whatever was open on the previous one and
|
|
135
|
+
* drop its row, so nothing acts on this court with the other court's ids.
|
|
136
|
+
*/
|
|
137
|
+
function closeOverlays(): void {
|
|
138
|
+
generateOpen.value = false
|
|
139
|
+
editOpen.value = false
|
|
140
|
+
editing.value = null
|
|
141
|
+
if (confirmOpen.value) {
|
|
142
|
+
confirmOpen.value = false
|
|
143
|
+
Dialog.close()
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
watch(
|
|
148
|
+
foodCourtId,
|
|
149
|
+
() => {
|
|
150
|
+
closeOverlays()
|
|
151
|
+
rows.value = []
|
|
152
|
+
load()
|
|
153
|
+
},
|
|
154
|
+
{ immediate: true }
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
/** Runs one row action on the court it was started on, toasts its result, then reloads the list. */
|
|
158
|
+
async function run(
|
|
159
|
+
courtId: string,
|
|
160
|
+
action: (foodCourtId: string) => Promise<unknown>,
|
|
161
|
+
successKey: string
|
|
162
|
+
): Promise<void> {
|
|
163
|
+
// The portal switched court since the action was started: the row is not of this court.
|
|
164
|
+
if (courtId !== foodCourtId.value) return
|
|
165
|
+
try {
|
|
166
|
+
await action(courtId)
|
|
167
|
+
showSuccess(t(successKey))
|
|
168
|
+
} catch (e) {
|
|
169
|
+
showError(errorMessage(e))
|
|
170
|
+
}
|
|
171
|
+
if (courtId === foodCourtId.value) await load()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function confirmAction(
|
|
175
|
+
row: StallRow,
|
|
176
|
+
keys: { title: string; message: string; confirm: string },
|
|
177
|
+
onConfirm: (courtId: string) => Promise<void>
|
|
178
|
+
): void {
|
|
179
|
+
const courtId = foodCourtId.value
|
|
180
|
+
if (!courtId) return
|
|
181
|
+
confirmOpen.value = true
|
|
182
|
+
const closed = () => {
|
|
183
|
+
confirmOpen.value = false
|
|
184
|
+
}
|
|
185
|
+
Dialog.open({
|
|
186
|
+
title: t(keys.title),
|
|
187
|
+
message: t(keys.message, { stall: stallName(row) }),
|
|
188
|
+
primaryActions: { text: t(keys.confirm), variant: 'destructive', close: true },
|
|
189
|
+
secondaryActions: { text: t('order.cancel'), variant: 'tertiary', close: true }
|
|
190
|
+
})
|
|
191
|
+
.onPrimary(() => {
|
|
192
|
+
closed()
|
|
193
|
+
return onConfirm(courtId)
|
|
194
|
+
})
|
|
195
|
+
.onSecondary(closed)
|
|
196
|
+
.onClose(closed)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function onMemberAction(member: MemberStallRow, action: StallAction): void {
|
|
200
|
+
const courtId = foodCourtId.value
|
|
201
|
+
if (!courtId) return
|
|
202
|
+
const { memberId } = member
|
|
203
|
+
switch (action) {
|
|
204
|
+
case 'edit':
|
|
205
|
+
editing.value = member
|
|
206
|
+
editOpen.value = true
|
|
207
|
+
return
|
|
208
|
+
case 'deactivate':
|
|
209
|
+
confirmAction(
|
|
210
|
+
member,
|
|
211
|
+
{
|
|
212
|
+
title: 'order.foodCourt.stalls.deactivateTitle',
|
|
213
|
+
message: 'order.foodCourt.stalls.deactivateMessage',
|
|
214
|
+
confirm: 'order.foodCourt.stalls.actionDeactivate'
|
|
215
|
+
},
|
|
216
|
+
(id) =>
|
|
217
|
+
run(
|
|
218
|
+
id,
|
|
219
|
+
(fc) => FoodCourtMemberApi.updateMember(fc, { memberId, visible: false }),
|
|
220
|
+
'order.foodCourt.stalls.deactivated'
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
return
|
|
224
|
+
case 'activate':
|
|
225
|
+
run(
|
|
226
|
+
courtId,
|
|
227
|
+
(fc) => FoodCourtMemberApi.updateMember(fc, { memberId, visible: true }),
|
|
228
|
+
'order.foodCourt.stalls.activated'
|
|
229
|
+
)
|
|
230
|
+
return
|
|
231
|
+
case 'remove':
|
|
232
|
+
confirmAction(
|
|
233
|
+
member,
|
|
234
|
+
{
|
|
235
|
+
title: 'order.foodCourt.stalls.removeTitle',
|
|
236
|
+
message: 'order.foodCourt.stalls.removeMessage',
|
|
237
|
+
confirm: 'order.foodCourt.stalls.actionRemove'
|
|
238
|
+
},
|
|
239
|
+
(id) =>
|
|
240
|
+
run(
|
|
241
|
+
id,
|
|
242
|
+
(fc) => FoodCourtMemberApi.removeMember(fc, memberId),
|
|
243
|
+
'order.foodCourt.stalls.removed'
|
|
244
|
+
)
|
|
245
|
+
)
|
|
246
|
+
return
|
|
247
|
+
case 'cancelInvite':
|
|
248
|
+
confirmAction(
|
|
249
|
+
member,
|
|
250
|
+
{
|
|
251
|
+
title: 'order.foodCourt.stalls.cancelInviteTitle',
|
|
252
|
+
message: 'order.foodCourt.stalls.cancelInviteMessage',
|
|
253
|
+
confirm: 'order.foodCourt.stalls.actionCancelInvite'
|
|
254
|
+
},
|
|
255
|
+
(id) =>
|
|
256
|
+
run(
|
|
257
|
+
id,
|
|
258
|
+
(fc) => FoodCourtMemberApi.revokeInvite(fc, memberId),
|
|
259
|
+
'order.foodCourt.stalls.inviteCancelled'
|
|
260
|
+
)
|
|
261
|
+
)
|
|
262
|
+
return
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function onJoinCodeAction(row: JoinCodeStallRow, action: StallAction): void {
|
|
267
|
+
const courtId = foodCourtId.value
|
|
268
|
+
if (!courtId) return
|
|
269
|
+
const { joinCodeId } = row
|
|
270
|
+
switch (action) {
|
|
271
|
+
case 'approve':
|
|
272
|
+
run(
|
|
273
|
+
courtId,
|
|
274
|
+
(fc) => FoodCourtJoinCodeApi.approveJoinRequest(fc, joinCodeId),
|
|
275
|
+
'order.foodCourt.stalls.requestApproved'
|
|
276
|
+
)
|
|
277
|
+
return
|
|
278
|
+
case 'decline':
|
|
279
|
+
confirmAction(
|
|
280
|
+
row,
|
|
281
|
+
{
|
|
282
|
+
title: 'order.foodCourt.stalls.declineRequestTitle',
|
|
283
|
+
message: 'order.foodCourt.stalls.declineRequestMessage',
|
|
284
|
+
confirm: 'order.foodCourt.stalls.actionDecline'
|
|
285
|
+
},
|
|
286
|
+
(id) =>
|
|
287
|
+
run(
|
|
288
|
+
id,
|
|
289
|
+
(fc) => FoodCourtJoinCodeApi.declineJoinRequest(fc, joinCodeId),
|
|
290
|
+
'order.foodCourt.stalls.requestDeclined'
|
|
291
|
+
)
|
|
292
|
+
)
|
|
293
|
+
return
|
|
294
|
+
case 'cancelCode':
|
|
295
|
+
confirmAction(
|
|
296
|
+
row,
|
|
297
|
+
{
|
|
298
|
+
title: 'order.foodCourt.stalls.cancelCodeTitle',
|
|
299
|
+
message: 'order.foodCourt.stalls.cancelCodeMessage',
|
|
300
|
+
confirm: 'order.foodCourt.stalls.actionCancelCode'
|
|
301
|
+
},
|
|
302
|
+
(id) =>
|
|
303
|
+
run(
|
|
304
|
+
id,
|
|
305
|
+
(fc) => FoodCourtJoinCodeApi.cancelJoinCode(fc, joinCodeId),
|
|
306
|
+
'order.foodCourt.stalls.codeCancelled'
|
|
307
|
+
)
|
|
308
|
+
)
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function onAction(row: StallRow, action: StallAction): void {
|
|
314
|
+
if (row.kind === 'member') onMemberAction(row, action)
|
|
315
|
+
else onJoinCodeAction(row, action)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** The Stall cell: the stall's name, and under a join code who asked to join or until when it works. */
|
|
319
|
+
function stallCell(row: StallRow) {
|
|
320
|
+
const name = stallName(row) || t('order.foodCourt.stalls.codeNoStall')
|
|
321
|
+
if (row.kind === 'member') return name
|
|
322
|
+
const detail =
|
|
323
|
+
row.status === 'PENDING'
|
|
324
|
+
? t('order.foodCourt.stalls.requestedBy', { outlet: requesterName(row) })
|
|
325
|
+
: t('order.foodCourt.stalls.codeExpires', {
|
|
326
|
+
date: dayjs(row.expiresAt).format('DD MMM YYYY, h:mm A')
|
|
327
|
+
})
|
|
328
|
+
return h('div', { class: 'flex flex-col min-w-0' }, [
|
|
329
|
+
h('span', name),
|
|
330
|
+
h('span', { class: 'fm-typo-en-body-sm-400 text-fm-color-typo-tertiary' }, detail)
|
|
331
|
+
])
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const columns = computed<ColumnDef<StallRow>[]>(() => [
|
|
335
|
+
{
|
|
336
|
+
id: 'unitNo',
|
|
337
|
+
header: () => t('order.foodCourt.stalls.columnNo'),
|
|
338
|
+
cell: ({ row }) => row.original.unitNo || '-',
|
|
339
|
+
enableSorting: false,
|
|
340
|
+
meta: { width: '96px' }
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
id: 'stall',
|
|
344
|
+
header: () => t('order.foodCourt.stalls.columnStall'),
|
|
345
|
+
cell: ({ row }) => stallCell(row.original),
|
|
346
|
+
enableSorting: false
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
id: 'status',
|
|
350
|
+
header: () => t('order.foodCourt.stalls.columnStatus'),
|
|
351
|
+
cell: ({ row }) => {
|
|
352
|
+
const chip = STALL_STATUS_CHIP[row.original.listStatus]
|
|
353
|
+
return chip ? h(components.FmChip, { variant: chip.variant, label: t(chip.labelKey) }) : '-'
|
|
354
|
+
},
|
|
355
|
+
enableSorting: false
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
id: 'actions',
|
|
359
|
+
header: () => '',
|
|
360
|
+
cell: ({ row }) =>
|
|
361
|
+
h(StallRowActions, {
|
|
362
|
+
listStatus: row.original.listStatus,
|
|
363
|
+
onAction: (action: StallAction) => onAction(row.original, action)
|
|
364
|
+
}),
|
|
365
|
+
enableSorting: false,
|
|
366
|
+
meta: { width: '64px' }
|
|
367
|
+
}
|
|
368
|
+
])
|
|
369
|
+
</script>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="py-[1.5rem]">
|
|
3
|
+
<FmPageHead :title="t('order.foodCourt.status.title')" :line-height="1.7" />
|
|
4
|
+
</div>
|
|
5
|
+
<div v-if="!foodCourtId" class="px-[1.5rem] fm-typo-en-body-md-400 text-fm-color-typo-secondary">
|
|
6
|
+
{{ t('order.foodCourt.noFoodCourtSelected') }}
|
|
7
|
+
</div>
|
|
8
|
+
<FmCircularProgress v-else-if="isLoading" size="xxl" />
|
|
9
|
+
<div v-else-if="loadFailed" class="p-[1.5rem] m-5 flex flex-col gap-3 items-start">
|
|
10
|
+
<span class="fm-typo-en-body-md-400">{{ t('order.foodCourt.status.loadFailed') }}</span>
|
|
11
|
+
<FmButton variant="secondary" :label="t('order.foodCourt.retry')" @click="load" />
|
|
12
|
+
</div>
|
|
13
|
+
<div v-else-if="current" class="px-[1.5rem] flex flex-col gap-4 max-w-3xl">
|
|
14
|
+
<div class="fm-typo-en-title-sm-600">{{ t('order.foodCourt.status.section') }}</div>
|
|
15
|
+
<FmCard variant="outlined" class="p-4 flex flex-col gap-3">
|
|
16
|
+
<!-- Re-keyed after a refused change so the switch shows the stored status again. -->
|
|
17
|
+
<FmSwitch
|
|
18
|
+
:key="switchKey"
|
|
19
|
+
:model-value="current.status === 'ACTIVE'"
|
|
20
|
+
:label="t('order.foodCourt.status.operation')"
|
|
21
|
+
:sublabel="t('order.foodCourt.status.operationSublabel')"
|
|
22
|
+
label-placement="right"
|
|
23
|
+
:disabled="isSaving"
|
|
24
|
+
@update:model-value="toggle"
|
|
25
|
+
/>
|
|
26
|
+
<span
|
|
27
|
+
v-if="current.status === 'INACTIVE' && !current.payoutReady"
|
|
28
|
+
class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
|
|
29
|
+
>
|
|
30
|
+
{{ t('order.foodCourt.status.payoutHint') }}
|
|
31
|
+
</span>
|
|
32
|
+
</FmCard>
|
|
33
|
+
<div
|
|
34
|
+
class="flex items-center gap-2 p-3 rounded-lg bg-fm-color-system-warning-100 fm-typo-en-body-md-400 text-fm-color-typo-warning"
|
|
35
|
+
>
|
|
36
|
+
<FmIcon name="warning" size="sm" color="typo-warning" />
|
|
37
|
+
<span>{{ t('order.foodCourt.status.offWarning') }}</span>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import { ref, watch } from 'vue'
|
|
44
|
+
import { useI18n } from '@feedmepos/mf-common'
|
|
45
|
+
import { useSnackbarFunctions } from '@/components/snackbar'
|
|
46
|
+
import { useFoodCourtId } from '@/composables/useFoodCourtContext'
|
|
47
|
+
import { FoodCourtStatusApi, type FoodCourtStatusView } from '@/api/food-court'
|
|
48
|
+
import { errorMessage } from './food-court-member'
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Food Court Operations › Food Court (KDI-4915 AC2-4, Figma 1.10): the court's
|
|
52
|
+
* own Active / Inactive switch. Only an Active court takes orders. The backend
|
|
53
|
+
* refuses Active (400) until the court's payout account is approved.
|
|
54
|
+
*/
|
|
55
|
+
const { t } = useI18n()
|
|
56
|
+
const { showSuccess, showError } = useSnackbarFunctions()
|
|
57
|
+
const foodCourtId = useFoodCourtId()
|
|
58
|
+
|
|
59
|
+
const current = ref<FoodCourtStatusView>()
|
|
60
|
+
const isLoading = ref(false)
|
|
61
|
+
const loadFailed = ref(false)
|
|
62
|
+
const isSaving = ref(false)
|
|
63
|
+
const switchKey = ref(0)
|
|
64
|
+
|
|
65
|
+
/** A failed load shows its error (snackbar) and a retry, not an empty pane. */
|
|
66
|
+
async function load(): Promise<void> {
|
|
67
|
+
const id = foodCourtId.value
|
|
68
|
+
current.value = undefined
|
|
69
|
+
loadFailed.value = false
|
|
70
|
+
if (!id) return
|
|
71
|
+
isLoading.value = true
|
|
72
|
+
try {
|
|
73
|
+
const status = await FoodCourtStatusApi.getStatus(id)
|
|
74
|
+
if (id === foodCourtId.value) current.value = status
|
|
75
|
+
} catch (e) {
|
|
76
|
+
if (id !== foodCourtId.value) return
|
|
77
|
+
loadFailed.value = true
|
|
78
|
+
showError(errorMessage(e))
|
|
79
|
+
} finally {
|
|
80
|
+
if (id === foodCourtId.value) isLoading.value = false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
watch(foodCourtId, load, { immediate: true })
|
|
85
|
+
|
|
86
|
+
async function toggle(on: boolean): Promise<void> {
|
|
87
|
+
const id = foodCourtId.value
|
|
88
|
+
if (!id || !current.value || isSaving.value) return
|
|
89
|
+
isSaving.value = true
|
|
90
|
+
try {
|
|
91
|
+
const saved = await FoodCourtStatusApi.updateStatus(id, on ? 'ACTIVE' : 'INACTIVE')
|
|
92
|
+
// The portal may have switched to another court meanwhile.
|
|
93
|
+
if (id !== foodCourtId.value) return
|
|
94
|
+
current.value = saved
|
|
95
|
+
showSuccess(
|
|
96
|
+
t(
|
|
97
|
+
saved.status === 'ACTIVE'
|
|
98
|
+
? 'order.foodCourt.status.activated'
|
|
99
|
+
: 'order.foodCourt.status.deactivated'
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
} catch (e) {
|
|
103
|
+
// 400 = no approved payout account: show why, and keep the stored status.
|
|
104
|
+
if (id !== foodCourtId.value) return
|
|
105
|
+
showError(errorMessage(e))
|
|
106
|
+
switchKey.value++
|
|
107
|
+
} finally {
|
|
108
|
+
isSaving.value = false
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
</script>
|