@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
package/src/router/routes.ts
CHANGED
|
@@ -15,6 +15,10 @@ const permissionMeta = (permissions: CaslPermission[]): RouteMeta =>
|
|
|
15
15
|
const manageDevices = kioskPermission(Permission.Action.manage, 'deviceManagement');
|
|
16
16
|
const bindDevices = kioskPermission(Permission.Action.manage, 'deviceBinding');
|
|
17
17
|
const manageOrderSetting = orderSettingPermission(Permission.Action.manage);
|
|
18
|
+
const manageRestaurant: CaslPermission = {
|
|
19
|
+
action: Permission.Action.manage,
|
|
20
|
+
subject: Permission.Subject.Business.restaurant,
|
|
21
|
+
};
|
|
18
22
|
|
|
19
23
|
const routes: RouteRecordRaw[] = [
|
|
20
24
|
{
|
|
@@ -69,6 +73,46 @@ const routes: RouteRecordRaw[] = [
|
|
|
69
73
|
() => import('@/views/food-court/FoodCourtOrderSettingsView.vue'),
|
|
70
74
|
),
|
|
71
75
|
},
|
|
76
|
+
{
|
|
77
|
+
// Food Court Operations › Stalls (KDI-4915 + KDI-4919): the court owner's
|
|
78
|
+
// members. Owner-only on the backend, as Order Setting above.
|
|
79
|
+
path: PortalRoute.FoodCourtStallsView,
|
|
80
|
+
name: 'Food Court Stalls View',
|
|
81
|
+
component: defineAsyncComponent(() => import('@/views/food-court/FoodCourtStallsView.vue')),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
// Food Court Operations › Food Court: the court's Active / Inactive status (KDI-4915).
|
|
85
|
+
path: PortalRoute.FoodCourtStatusView,
|
|
86
|
+
name: 'Food Court Status View',
|
|
87
|
+
component: defineAsyncComponent(() => import('@/views/food-court/FoodCourtStatusView.vue')),
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
// Food Court Operations › Orders (KDI-4941): the court's orders. Owner-only on
|
|
91
|
+
// the backend, as Order Setting above. The detail is a side sheet the list
|
|
92
|
+
// opens from its child route, so the list and its filters stay mounted under it
|
|
93
|
+
// and a link to one order opens the list with it.
|
|
94
|
+
path: PortalRoute.FoodCourtOrdersView,
|
|
95
|
+
name: 'Food Court Orders View',
|
|
96
|
+
component: defineAsyncComponent(() => import('@/views/food-court/FoodCourtOrdersView.vue')),
|
|
97
|
+
children: [
|
|
98
|
+
{
|
|
99
|
+
path: ':orderId',
|
|
100
|
+
name: 'Food Court Order Detail View',
|
|
101
|
+
component: { render: () => null },
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
// Restaurant Operation › Invitations (KDI-4915): the STALL side, in the
|
|
107
|
+
// business context. The backend lets a user who can manage the restaurant
|
|
108
|
+
// accept, decline or leave (ActionGuard, restaurant manage).
|
|
109
|
+
path: PortalRoute.FoodCourtInvitationsView,
|
|
110
|
+
name: 'Food Court Invitations View',
|
|
111
|
+
component: withPermission(
|
|
112
|
+
defineAsyncComponent(() => import('@/views/food-court/FoodCourtInvitationsView.vue')),
|
|
113
|
+
),
|
|
114
|
+
meta: permissionMeta([manageRestaurant]),
|
|
115
|
+
},
|
|
72
116
|
];
|
|
73
117
|
|
|
74
118
|
export { routes }
|
|
@@ -6,6 +6,10 @@ const DisplaySystemView = '/display-system';
|
|
|
6
6
|
const FeedMeExpressView = '/delivery-settings';
|
|
7
7
|
const AllOrdersView = '/orders';
|
|
8
8
|
const FoodCourtOrderSettingView = '/food-court/order-settings';
|
|
9
|
+
const FoodCourtStallsView = '/food-court/stalls';
|
|
10
|
+
const FoodCourtStatusView = '/food-court/status';
|
|
11
|
+
const FoodCourtInvitationsView = '/food-court/invitations';
|
|
12
|
+
const FoodCourtOrdersView = '/food-court/orders';
|
|
9
13
|
|
|
10
14
|
export const PortalRoute = {
|
|
11
15
|
KioskRoute,
|
|
@@ -16,4 +20,8 @@ export const PortalRoute = {
|
|
|
16
20
|
FeedMeExpressView,
|
|
17
21
|
AllOrdersView,
|
|
18
22
|
FoodCourtOrderSettingView,
|
|
23
|
+
FoodCourtStallsView,
|
|
24
|
+
FoodCourtStatusView,
|
|
25
|
+
FoodCourtInvitationsView,
|
|
26
|
+
FoodCourtOrdersView,
|
|
19
27
|
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="py-[1.5rem]">
|
|
3
|
+
<FmPageHead :title="t('order.foodCourt.invitations.title')" :line-height="1.7" />
|
|
4
|
+
</div>
|
|
5
|
+
<div v-if="!restaurantId" class="px-[1.5rem] fm-typo-en-body-md-400 text-fm-color-typo-secondary">
|
|
6
|
+
{{ t('order.foodCourt.invitations.noRestaurant') }}
|
|
7
|
+
</div>
|
|
8
|
+
<div v-else class="px-[1.5rem] flex flex-col gap-6">
|
|
9
|
+
<JoinFoodCourtCard :restaurant-id="restaurantId" :restaurant-name="restaurantName" />
|
|
10
|
+
|
|
11
|
+
<div class="flex flex-col gap-4">
|
|
12
|
+
<span class="fm-typo-en-title-sm-600">{{ t('order.foodCourt.invitations.listTitle') }}</span>
|
|
13
|
+
<div v-if="loadFailed" class="flex flex-col gap-3 items-start">
|
|
14
|
+
<span class="fm-typo-en-body-md-400">{{
|
|
15
|
+
t('order.foodCourt.invitations.loadFailed')
|
|
16
|
+
}}</span>
|
|
17
|
+
<FmButton variant="secondary" :label="t('order.foodCourt.retry')" @click="load" />
|
|
18
|
+
</div>
|
|
19
|
+
<template v-else>
|
|
20
|
+
<FmSearch
|
|
21
|
+
v-model="searchKey"
|
|
22
|
+
class="max-w-[400px]"
|
|
23
|
+
:placeholder="t('order.foodCourt.invitations.searchPlaceholder')"
|
|
24
|
+
/>
|
|
25
|
+
<FmTable
|
|
26
|
+
v-if="isLoading || filteredMemberships.length"
|
|
27
|
+
:row-data="filteredMemberships"
|
|
28
|
+
:column-defs="columns"
|
|
29
|
+
:loading="isLoading"
|
|
30
|
+
:hide-footer="true"
|
|
31
|
+
:page-size="1000"
|
|
32
|
+
class="w-full"
|
|
33
|
+
/>
|
|
34
|
+
<div v-else class="text-center py-8 text-fm-color-typo-tertiary fm-typo-en-body-md-400">
|
|
35
|
+
{{
|
|
36
|
+
memberships.length
|
|
37
|
+
? t('order.foodCourt.invitations.noMatch')
|
|
38
|
+
: t('order.foodCourt.invitations.empty')
|
|
39
|
+
}}
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
import { computed, h, ref, watch } from 'vue'
|
|
48
|
+
import dayjs from 'dayjs'
|
|
49
|
+
import { useCoreStore, useI18n } from '@feedmepos/mf-common'
|
|
50
|
+
import { components, useDialog, type ColumnDef } from '@feedmepos/ui-library'
|
|
51
|
+
import { useSnackbarFunctions } from '@/components/snackbar'
|
|
52
|
+
import useSearch from '@/composables/search'
|
|
53
|
+
import { FoodCourtInvitationApi } from '@/api/food-court/invitation'
|
|
54
|
+
import {
|
|
55
|
+
MEMBERSHIP_STATUS_CHIP,
|
|
56
|
+
errorMessage,
|
|
57
|
+
toMembershipViews,
|
|
58
|
+
type FoodCourtMembershipView
|
|
59
|
+
} from './food-court-member'
|
|
60
|
+
import MembershipRowActions from './invitations/MembershipRowActions.vue'
|
|
61
|
+
import JoinFoodCourtCard from './invitations/JoinFoodCourtCard.vue'
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Restaurant Operation › Food Courts (route `/food-court/invitations`,
|
|
65
|
+
* KDI-4915): the STALL side, for the restaurant selected in the portal. It
|
|
66
|
+
* joins a food court with a code the court owner shared (the owner then
|
|
67
|
+
* approves the request), and lists the courts it has a row in; a joined court
|
|
68
|
+
* can be left (D1: the stall's deactivate is leave, and rejoining needs a new
|
|
69
|
+
* code). Invitations from before join codes are listed but can no longer be
|
|
70
|
+
* accepted.
|
|
71
|
+
*/
|
|
72
|
+
const { t } = useI18n()
|
|
73
|
+
const { showSuccess, showError } = useSnackbarFunctions()
|
|
74
|
+
const Dialog = useDialog()
|
|
75
|
+
const { currentRestaurant } = useCoreStore()
|
|
76
|
+
const { searchKey, filter } = useSearch()
|
|
77
|
+
|
|
78
|
+
const restaurantId = computed(() => currentRestaurant.value?._id ?? null)
|
|
79
|
+
const restaurantName = computed(() => currentRestaurant.value?.profile?.name ?? null)
|
|
80
|
+
|
|
81
|
+
const memberships = ref<FoodCourtMembershipView[]>([])
|
|
82
|
+
const isLoading = ref(false)
|
|
83
|
+
const loadFailed = ref(false)
|
|
84
|
+
|
|
85
|
+
const courtName = (membership: FoodCourtMembershipView): string =>
|
|
86
|
+
membership.courtName || t('order.foodCourt.invitations.unnamedCourt')
|
|
87
|
+
|
|
88
|
+
const filteredMemberships = computed(() =>
|
|
89
|
+
memberships.value.filter((m) => filter([courtName(m), m.courtAddress ?? '']))
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
async function load(): Promise<void> {
|
|
93
|
+
const id = restaurantId.value
|
|
94
|
+
loadFailed.value = false
|
|
95
|
+
if (!id) {
|
|
96
|
+
memberships.value = []
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
isLoading.value = true
|
|
100
|
+
try {
|
|
101
|
+
const rows = toMembershipViews(await FoodCourtInvitationApi.listMemberships(id))
|
|
102
|
+
if (id === restaurantId.value) memberships.value = rows
|
|
103
|
+
} catch (e) {
|
|
104
|
+
if (id !== restaurantId.value) return
|
|
105
|
+
loadFailed.value = true
|
|
106
|
+
showError(errorMessage(e))
|
|
107
|
+
} finally {
|
|
108
|
+
if (id === restaurantId.value) isLoading.value = false
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
watch(
|
|
113
|
+
restaurantId,
|
|
114
|
+
() => {
|
|
115
|
+
memberships.value = []
|
|
116
|
+
load()
|
|
117
|
+
},
|
|
118
|
+
{ immediate: true }
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
function leave(membership: FoodCourtMembershipView): void {
|
|
122
|
+
const id = restaurantId.value
|
|
123
|
+
if (!id) return
|
|
124
|
+
Dialog.open({
|
|
125
|
+
title: t('order.foodCourt.invitations.leaveTitle'),
|
|
126
|
+
message: t('order.foodCourt.invitations.leaveMessage', { court: courtName(membership) }),
|
|
127
|
+
primaryActions: {
|
|
128
|
+
text: t('order.foodCourt.invitations.leaveConfirm'),
|
|
129
|
+
variant: 'destructive',
|
|
130
|
+
close: true
|
|
131
|
+
},
|
|
132
|
+
secondaryActions: { text: t('order.cancel'), variant: 'tertiary', close: true }
|
|
133
|
+
}).onPrimary(async () => {
|
|
134
|
+
// Another restaurant selected meanwhile: the row is not of this one.
|
|
135
|
+
if (id !== restaurantId.value) return
|
|
136
|
+
try {
|
|
137
|
+
await FoodCourtInvitationApi.leaveFoodCourt(membership.foodCourtId, membership.memberId)
|
|
138
|
+
showSuccess(t('order.foodCourt.invitations.left'))
|
|
139
|
+
} catch (e) {
|
|
140
|
+
showError(errorMessage(e))
|
|
141
|
+
}
|
|
142
|
+
await load()
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const columns = computed<ColumnDef<FoodCourtMembershipView>[]>(() => [
|
|
147
|
+
{
|
|
148
|
+
id: 'courtName',
|
|
149
|
+
header: () => t('order.foodCourt.invitations.columnFoodCourt'),
|
|
150
|
+
cell: ({ row }) => courtName(row.original),
|
|
151
|
+
enableSorting: false
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: 'courtAddress',
|
|
155
|
+
header: () => t('order.foodCourt.invitations.columnLocation'),
|
|
156
|
+
cell: ({ row }) => row.original.courtAddress || '-',
|
|
157
|
+
enableSorting: false
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: 'joinedAt',
|
|
161
|
+
header: () => t('order.foodCourt.invitations.columnJoined'),
|
|
162
|
+
cell: ({ row }) =>
|
|
163
|
+
row.original.joinedAt ? dayjs(row.original.joinedAt).format('DD MMM YYYY') : '-',
|
|
164
|
+
enableSorting: false
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: 'status',
|
|
168
|
+
header: () => t('order.foodCourt.invitations.columnStatus'),
|
|
169
|
+
cell: ({ row }) => {
|
|
170
|
+
const chip = MEMBERSHIP_STATUS_CHIP[row.original.status]
|
|
171
|
+
return chip ? h(components.FmChip, { variant: chip.variant, label: t(chip.labelKey) }) : '-'
|
|
172
|
+
},
|
|
173
|
+
enableSorting: false
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: 'actions',
|
|
177
|
+
header: () => '',
|
|
178
|
+
cell: ({ row }) =>
|
|
179
|
+
h(MembershipRowActions, {
|
|
180
|
+
status: row.original.status,
|
|
181
|
+
onLeave: () => leave(row.original)
|
|
182
|
+
}),
|
|
183
|
+
enableSorting: false,
|
|
184
|
+
meta: { width: '64px' }
|
|
185
|
+
}
|
|
186
|
+
])
|
|
187
|
+
</script>
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="py-[1.5rem] flex flex-col gap-1">
|
|
3
|
+
<FmPageHead :title="t('order.foodCourt.orders.title')" :line-height="1.7" />
|
|
4
|
+
<span class="px-[1.5rem] fm-typo-en-body-md-400 text-fm-color-typo-secondary">
|
|
5
|
+
{{ t('order.foodCourt.orders.subtitle') }}
|
|
6
|
+
</span>
|
|
7
|
+
</div>
|
|
8
|
+
<div v-if="!foodCourtId" class="px-[1.5rem] fm-typo-en-body-md-400 text-fm-color-typo-secondary">
|
|
9
|
+
{{ t('order.foodCourt.noFoodCourtSelected') }}
|
|
10
|
+
</div>
|
|
11
|
+
<div v-else class="px-[1.5rem] flex flex-col gap-4">
|
|
12
|
+
<div class="flex items-center gap-3 flex-wrap">
|
|
13
|
+
<FmDateRangePicker v-model="dateRange" show-predefined-range>
|
|
14
|
+
<template #trigger-button>
|
|
15
|
+
<FmChip :label="dateRangeLabel" icon="calendar_today" />
|
|
16
|
+
</template>
|
|
17
|
+
</FmDateRangePicker>
|
|
18
|
+
<FmSelect
|
|
19
|
+
v-model="statuses"
|
|
20
|
+
class="min-w-[240px]"
|
|
21
|
+
multiselect
|
|
22
|
+
:items="statusItems"
|
|
23
|
+
:placeholder="t('order.foodCourt.orders.allStatuses')"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
<div v-if="loadFailed" class="py-4 flex flex-col gap-3 items-start">
|
|
27
|
+
<span class="fm-typo-en-body-md-400">{{ t('order.foodCourt.orders.loadFailed') }}</span>
|
|
28
|
+
<FmButton variant="secondary" :label="t('order.foodCourt.retry')" @click="load" />
|
|
29
|
+
</div>
|
|
30
|
+
<template v-else>
|
|
31
|
+
<FmTable
|
|
32
|
+
v-if="isLoading || rows.length"
|
|
33
|
+
:row-data="rows"
|
|
34
|
+
:column-defs="columns"
|
|
35
|
+
:loading="isLoading"
|
|
36
|
+
:hide-footer="true"
|
|
37
|
+
:page-size="limit"
|
|
38
|
+
:shrink-at="false"
|
|
39
|
+
class="w-full"
|
|
40
|
+
@row-click="onRowClick"
|
|
41
|
+
/>
|
|
42
|
+
<div v-else class="text-center py-8 text-fm-color-typo-tertiary fm-typo-en-body-md-400">
|
|
43
|
+
{{ t('order.foodCourt.orders.empty') }}
|
|
44
|
+
</div>
|
|
45
|
+
<div class="flex items-center justify-between gap-3 flex-wrap pb-6">
|
|
46
|
+
<div class="flex items-center gap-2">
|
|
47
|
+
<span class="fm-typo-en-body-md-400 text-fm-color-typo-secondary">
|
|
48
|
+
{{ t('order.foodCourt.orders.perPage') }}
|
|
49
|
+
</span>
|
|
50
|
+
<FmSelect v-model="limit" class="w-[96px]" :items="limitItems" />
|
|
51
|
+
</div>
|
|
52
|
+
<div class="flex items-center gap-2">
|
|
53
|
+
<FmButton
|
|
54
|
+
variant="tertiary"
|
|
55
|
+
prepend-icon="chevron_left"
|
|
56
|
+
:label="t('order.foodCourt.orders.previous')"
|
|
57
|
+
:disabled="isLoading || page === 0"
|
|
58
|
+
@click="page -= 1"
|
|
59
|
+
/>
|
|
60
|
+
<span class="fm-typo-en-body-md-400">
|
|
61
|
+
{{ t('order.foodCourt.orders.page', { page: page + 1 }) }}
|
|
62
|
+
</span>
|
|
63
|
+
<FmButton
|
|
64
|
+
variant="tertiary"
|
|
65
|
+
append-icon="chevron_right"
|
|
66
|
+
:label="t('order.foodCourt.orders.next')"
|
|
67
|
+
:disabled="isLoading || !hasMore"
|
|
68
|
+
@click="page += 1"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<FoodCourtOrderSheet
|
|
76
|
+
v-if="foodCourtId"
|
|
77
|
+
:model-value="!!detailOrderId"
|
|
78
|
+
:food-court-id="foodCourtId"
|
|
79
|
+
:order-id="detailOrderId"
|
|
80
|
+
@update:model-value="(open: boolean) => !open && closeDetail()"
|
|
81
|
+
/>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<script setup lang="ts">
|
|
85
|
+
import { computed, h, ref, watch } from 'vue'
|
|
86
|
+
import dayjs from 'dayjs'
|
|
87
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
88
|
+
import { useI18n } from '@feedmepos/mf-common'
|
|
89
|
+
import { components, type ColumnDef } from '@feedmepos/ui-library'
|
|
90
|
+
import { useSnackbarFunctions } from '@/components/snackbar'
|
|
91
|
+
import { useFoodCourtId } from '@/composables/useFoodCourtContext'
|
|
92
|
+
import {
|
|
93
|
+
FoodCourtOrderApi,
|
|
94
|
+
type FoodCourtOrderStatus,
|
|
95
|
+
type FoodCourtOrderSummary
|
|
96
|
+
} from '@/api/food-court'
|
|
97
|
+
import { errorMessage } from './food-court-member'
|
|
98
|
+
import {
|
|
99
|
+
COURT_ORDER_STATUS_CHIP,
|
|
100
|
+
ORDER_LIST_STATUSES,
|
|
101
|
+
formatMoney,
|
|
102
|
+
formatOrderTime,
|
|
103
|
+
orderListWindow
|
|
104
|
+
} from './food-court-order'
|
|
105
|
+
import FoodCourtOrderSheet from './orders/FoodCourtOrderSheet.vue'
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Food Court Operations › Orders (KDI-4941, Figma "PORTAL – Food Court
|
|
109
|
+
* Operations" 1.10 / 1.11): the court's orders, newest first, one row per
|
|
110
|
+
* court order; a row opens its stall-by-stall detail in a side sheet. Only
|
|
111
|
+
* the court's owner or a FeedMe admin can read them (order-backend
|
|
112
|
+
* FoodCourtManagerGuard). Stall orders taken directly at a stall are not
|
|
113
|
+
* court orders, so they are not here.
|
|
114
|
+
*/
|
|
115
|
+
const DETAIL_ROUTE_NAME = 'Food Court Order Detail View'
|
|
116
|
+
const LIST_ROUTE_NAME = 'Food Court Orders View'
|
|
117
|
+
|
|
118
|
+
const { t } = useI18n()
|
|
119
|
+
const { showError } = useSnackbarFunctions()
|
|
120
|
+
const foodCourtId = useFoodCourtId()
|
|
121
|
+
const route = useRoute()
|
|
122
|
+
const router = useRouter()
|
|
123
|
+
|
|
124
|
+
const today = dayjs().format('YYYY-MM-DD')
|
|
125
|
+
const dateRange = ref<{ startDate: string | null; endDate: string | null }>({
|
|
126
|
+
startDate: today,
|
|
127
|
+
endDate: today
|
|
128
|
+
})
|
|
129
|
+
/** Empty = every status the list offers. */
|
|
130
|
+
const statuses = ref<FoodCourtOrderStatus[]>([])
|
|
131
|
+
const page = ref(0)
|
|
132
|
+
const limit = ref(25)
|
|
133
|
+
|
|
134
|
+
const rows = ref<FoodCourtOrderSummary[]>([])
|
|
135
|
+
const hasMore = ref(false)
|
|
136
|
+
const isLoading = ref(false)
|
|
137
|
+
const loadFailed = ref(false)
|
|
138
|
+
|
|
139
|
+
const statusItems = computed(() =>
|
|
140
|
+
ORDER_LIST_STATUSES.map((status) => ({
|
|
141
|
+
label: t(COURT_ORDER_STATUS_CHIP[status].labelKey),
|
|
142
|
+
value: status
|
|
143
|
+
}))
|
|
144
|
+
)
|
|
145
|
+
const limitItems = [10, 25, 50, 100].map((n) => ({ label: String(n), value: n }))
|
|
146
|
+
|
|
147
|
+
const dateRangeLabel = computed(() => {
|
|
148
|
+
const { startDate, endDate } = dateRange.value
|
|
149
|
+
const start = startDate ? dayjs(startDate).format('DD MMM YYYY') : ''
|
|
150
|
+
const end = endDate ? dayjs(endDate).format('DD MMM YYYY') : start
|
|
151
|
+
return start === end ? start : `${start} - ${end}`
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
/** Every call carries its own query; an answer for an older query is dropped. */
|
|
155
|
+
let latest = 0
|
|
156
|
+
|
|
157
|
+
async function load(): Promise<void> {
|
|
158
|
+
const id = foodCourtId.value
|
|
159
|
+
const call = ++latest
|
|
160
|
+
loadFailed.value = false
|
|
161
|
+
if (!id) {
|
|
162
|
+
rows.value = []
|
|
163
|
+
hasMore.value = false
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
isLoading.value = true
|
|
167
|
+
try {
|
|
168
|
+
const res = await FoodCourtOrderApi.listOrders(id, {
|
|
169
|
+
...orderListWindow(dateRange.value),
|
|
170
|
+
status: statuses.value.length ? statuses.value : ORDER_LIST_STATUSES,
|
|
171
|
+
page: page.value,
|
|
172
|
+
limit: limit.value
|
|
173
|
+
})
|
|
174
|
+
if (call !== latest) return
|
|
175
|
+
rows.value = res.items
|
|
176
|
+
hasMore.value = res.hasMore
|
|
177
|
+
} catch (e) {
|
|
178
|
+
if (call !== latest) return
|
|
179
|
+
rows.value = []
|
|
180
|
+
hasMore.value = false
|
|
181
|
+
loadFailed.value = true
|
|
182
|
+
showError(errorMessage(e))
|
|
183
|
+
} finally {
|
|
184
|
+
if (call === latest) isLoading.value = false
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// A new court or filter starts again from the first page.
|
|
189
|
+
watch(
|
|
190
|
+
[foodCourtId, dateRange, statuses, limit],
|
|
191
|
+
() => {
|
|
192
|
+
if (page.value === 0) load()
|
|
193
|
+
else page.value = 0
|
|
194
|
+
},
|
|
195
|
+
{ deep: true }
|
|
196
|
+
)
|
|
197
|
+
watch(page, load)
|
|
198
|
+
load()
|
|
199
|
+
|
|
200
|
+
const detailOrderId = computed(() =>
|
|
201
|
+
route.name === DETAIL_ROUTE_NAME && typeof route.params.orderId === 'string'
|
|
202
|
+
? route.params.orderId
|
|
203
|
+
: null
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
function openDetail(order: FoodCourtOrderSummary): void {
|
|
207
|
+
router.push({ name: DETAIL_ROUTE_NAME, params: { orderId: order._id }, query: route.query })
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Typed here, not inline in the template: the publish build's `vue-tsc --declaration` rejects an
|
|
211
|
+
// object type literal inside a template handler (TS1005), although the PR type-check (golar) accepts it.
|
|
212
|
+
function onRowClick(row: { original: FoodCourtOrderSummary }): void {
|
|
213
|
+
openDetail(row.original)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function closeDetail(): void {
|
|
217
|
+
if (detailOrderId.value) router.push({ name: LIST_ROUTE_NAME, query: route.query })
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const columns = computed<ColumnDef<FoodCourtOrderSummary>[]>(() => [
|
|
221
|
+
{
|
|
222
|
+
id: 'orderNumber',
|
|
223
|
+
header: () => t('order.foodCourt.orders.columnOrderNo'),
|
|
224
|
+
cell: ({ row }) => (row.original.orderNumber ? `#${row.original.orderNumber}` : '-'),
|
|
225
|
+
enableSorting: false,
|
|
226
|
+
meta: { width: '120px' }
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
id: 'createdAt',
|
|
230
|
+
header: () => t('order.foodCourt.orders.columnDate'),
|
|
231
|
+
cell: ({ row }) => formatOrderTime(row.original.paidAt ?? row.original.createdAt),
|
|
232
|
+
enableSorting: false
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
id: 'stalls',
|
|
236
|
+
header: () => t('order.foodCourt.orders.columnStalls'),
|
|
237
|
+
cell: ({ row }) => String(row.original.stallCount),
|
|
238
|
+
enableSorting: false,
|
|
239
|
+
meta: { width: '96px' }
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
id: 'paymentMethod',
|
|
243
|
+
header: () => t('order.foodCourt.orders.columnPayment'),
|
|
244
|
+
cell: ({ row }) => row.original.paymentMethod || '-',
|
|
245
|
+
enableSorting: false
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
id: 'total',
|
|
249
|
+
header: () => t('order.foodCourt.orders.columnTotal'),
|
|
250
|
+
cell: ({ row }) => formatMoney(row.original.total),
|
|
251
|
+
enableSorting: false
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
id: 'status',
|
|
255
|
+
header: () => t('order.foodCourt.orders.columnStatus'),
|
|
256
|
+
cell: ({ row }) => {
|
|
257
|
+
const chip = COURT_ORDER_STATUS_CHIP[row.original.status]
|
|
258
|
+
return chip ? h(components.FmChip, { variant: chip.variant, label: t(chip.labelKey) }) : '-'
|
|
259
|
+
},
|
|
260
|
+
enableSorting: false
|
|
261
|
+
}
|
|
262
|
+
])
|
|
263
|
+
</script>
|