@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.
Files changed (88) hide show
  1. package/dist/{DisplaySystemView-rCw3DE0u.js → DisplaySystemView-BH8SkCOF.js} +4 -4
  2. package/dist/FoodCourtInvitationsView-3cA0Z-5m.js +383 -0
  3. package/dist/FoodCourtOrderSettingsView-DysrLZJD.js +294 -0
  4. package/dist/FoodCourtOrdersView-CbZqHIXO.js +544 -0
  5. package/dist/FoodCourtStallsView-CTZzPUQ6.js +635 -0
  6. package/dist/FoodCourtStatusView-C71y7ghx.js +113 -0
  7. package/dist/{KioskDevicesView-B4dgvMq_.js → KioskDevicesView-BJpbuSzp.js} +1 -1
  8. 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
  9. package/dist/{KioskSettingView-DXx6wQQQ.js → KioskSettingView-CJxhMf7N.js} +3 -3
  10. package/dist/{KioskView-BmSHCl13.js → KioskView-BZsdRID1.js} +6 -6
  11. package/dist/{OrderSettingsView-9NOSAxLf.js → OrderSettingsView-gnyXaJjf.js} +10631 -10601
  12. package/dist/{app-y20uA-tu.js → app-CeEFBB-w.js} +4484 -3672
  13. package/dist/app.js +1 -1
  14. package/dist/dayjs.min-zBHHlxAP.js +285 -0
  15. package/dist/{featureFlag-GHmH1G2d.js → featureFlag-BTY_R78k.js} +1 -1
  16. package/dist/food-court-member-piX3gesl.js +212 -0
  17. package/dist/frontend/mf-order/src/api/food-court/index.d.ts +269 -0
  18. package/dist/frontend/mf-order/src/api/food-court/invitation.d.ts +55 -0
  19. package/dist/frontend/mf-order/src/app.d.ts +676 -0
  20. package/dist/frontend/mf-order/src/main.d.ts +676 -0
  21. package/dist/frontend/mf-order/src/stores/business/index.d.ts +3 -3
  22. package/dist/frontend/mf-order/src/stores/order-setting/index.d.ts +6 -0
  23. package/dist/frontend/mf-order/src/utils/constants/route.d.ts +4 -0
  24. package/dist/frontend/mf-order/src/views/food-court/FoodCourtInvitationsView.vue.d.ts +2 -0
  25. package/dist/frontend/mf-order/src/views/food-court/FoodCourtOrdersView.vue.d.ts +2 -0
  26. package/dist/frontend/mf-order/src/views/food-court/FoodCourtStallsView.vue.d.ts +2 -0
  27. package/dist/frontend/mf-order/src/views/food-court/FoodCourtStatusView.vue.d.ts +2 -0
  28. package/dist/frontend/mf-order/src/views/food-court/food-court-member.d.ts +150 -0
  29. package/dist/frontend/mf-order/src/views/food-court/food-court-order.d.ts +66 -0
  30. package/dist/frontend/mf-order/src/views/food-court/invitations/JoinFoodCourtCard.vue.d.ts +13 -0
  31. package/dist/frontend/mf-order/src/views/food-court/invitations/MembershipRowActions.vue.d.ts +11 -0
  32. package/dist/frontend/mf-order/src/views/food-court/orders/FoodCourtOrderSheet.vue.d.ts +16 -0
  33. package/dist/frontend/mf-order/src/views/food-court/stalls/EditStallSheet.vue.d.ts +15 -0
  34. package/dist/frontend/mf-order/src/views/food-court/stalls/GenerateJoinCodeSheet.vue.d.ts +21 -0
  35. package/dist/frontend/mf-order/src/views/food-court/stalls/StallAssignmentFields.vue.d.ts +16 -0
  36. package/dist/frontend/mf-order/src/views/food-court/stalls/StallRowActions.vue.d.ts +11 -0
  37. package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
  38. package/dist/{index-CmdP_QXF.js → index-601eG3_R.js} +1 -1
  39. package/dist/index-BeBZTUcq.js +122 -0
  40. package/dist/index-BtudnkMi.js +1065 -0
  41. package/dist/{index-BlG6mIU4.js → index-CGiWgTn1.js} +38 -37
  42. package/dist/{index-wMygvJpP.js → index-D5nv3ncu.js} +2 -2
  43. package/dist/index-DLDihONy.js +25142 -0
  44. package/dist/order.dto-JM_fmWnQ.js +14842 -0
  45. package/dist/package/entity/food-court/food-court.do.d.ts +1 -1
  46. package/dist/package/entity/food-court/food-court.dto.d.ts +7 -7
  47. package/dist/package/entity/food-court/order-v2.dto.d.ts +4 -4
  48. package/dist/package/entity/order-platform/order-platform.dto.d.ts +190 -92
  49. package/dist/package/entity/order-setting/order-setting.do.d.ts +10 -0
  50. package/dist/package/entity/order-setting/order-setting.dto.d.ts +20 -0
  51. package/dist/package/entity/order-setting/queue/queue.do.d.ts +22 -0
  52. package/dist/package/entity/order-setting/queue/queue.dto.d.ts +7 -0
  53. package/dist/package/entity/queue/queue.do.d.ts +1 -0
  54. package/dist/package/entity/queue/queue.dto.d.ts +8 -8
  55. package/dist/package/entity/restaurant/restaurant.dto.d.ts +20 -0
  56. package/dist/search-BAPEUu1R.js +15 -0
  57. package/dist/useFoodCourtContext-2p5sJMcB.js +16 -0
  58. package/package.json +3 -3
  59. package/src/api/food-court/index.ts +357 -0
  60. package/src/api/food-court/invitation.ts +81 -0
  61. package/src/locales/en-US.json +171 -2
  62. package/src/locales/ja-JP.json +171 -2
  63. package/src/locales/th-TH.json +171 -2
  64. package/src/locales/zh-CN.json +171 -2
  65. package/src/router/routes.ts +44 -0
  66. package/src/utils/constants/route.ts +8 -0
  67. package/src/views/food-court/FoodCourtInvitationsView.vue +187 -0
  68. package/src/views/food-court/FoodCourtOrdersView.vue +263 -0
  69. package/src/views/food-court/FoodCourtStallsView.vue +369 -0
  70. package/src/views/food-court/FoodCourtStatusView.vue +111 -0
  71. package/src/views/food-court/food-court-member.spec.ts +339 -0
  72. package/src/views/food-court/food-court-member.ts +397 -0
  73. package/src/views/food-court/food-court-order.spec.ts +137 -0
  74. package/src/views/food-court/food-court-order.ts +206 -0
  75. package/src/views/food-court/invitations/JoinFoodCourtCard.vue +201 -0
  76. package/src/views/food-court/invitations/MembershipRowActions.vue +19 -0
  77. package/src/views/food-court/orders/FoodCourtOrderSheet.vue +226 -0
  78. package/src/views/food-court/stalls/EditStallSheet.vue +91 -0
  79. package/src/views/food-court/stalls/GenerateJoinCodeSheet.vue +281 -0
  80. package/src/views/food-court/stalls/StallAssignmentFields.vue +36 -0
  81. package/src/views/food-court/stalls/StallRowActions.vue +31 -0
  82. package/src/views/order-settings/OrderSettingsView.vue +2 -4
  83. package/src/views/order-settings/dine-in/DineInSetting.vue +1 -4
  84. package/src/views/order-settings/queue/QueueSetting.vue +27 -0
  85. package/src/views/order-settings/reservation/ReservationSetting.vue +8 -0
  86. package/dist/FoodCourtOrderSettingsView-DUQXCKzB.js +0 -323
  87. package/dist/index-CUI1lL9F.js +0 -1347
  88. package/dist/order.dto-CyHtvyly.js +0 -38829
@@ -0,0 +1,206 @@
1
+ import dayjs from 'dayjs'
2
+ import { Dinero } from '@feedmepos/core'
3
+ import type { FdoDinero } from '@feedmepos/core/entity'
4
+ import type {
5
+ FoodCourtBill,
6
+ FoodCourtBillSubItem,
7
+ FoodCourtOrderReceipt,
8
+ FoodCourtOrderStatus,
9
+ FoodCourtStallOrder
10
+ } from '@/api/food-court'
11
+ import type { StatusChip } from './food-court-member'
12
+
13
+ /**
14
+ * The statuses the Orders list offers. DRAFT is left out: it is a cart the
15
+ * customer never checked out, not an order.
16
+ */
17
+ export const ORDER_LIST_STATUSES: FoodCourtOrderStatus[] = ['PAID', 'PENDING_PAYMENT', 'CANCELLED']
18
+
19
+ export const COURT_ORDER_STATUS_CHIP: Record<FoodCourtOrderStatus, StatusChip> = {
20
+ PAID: { variant: 'success', labelKey: 'order.foodCourt.orders.statusPaid' },
21
+ PENDING_PAYMENT: { variant: 'warning', labelKey: 'order.foodCourt.orders.statusPendingPayment' },
22
+ CANCELLED: { variant: 'neutral', labelKey: 'order.foodCourt.orders.statusCancelled' },
23
+ DRAFT: { variant: 'neutral', labelKey: 'order.foodCourt.orders.statusDraft' }
24
+ }
25
+
26
+ /**
27
+ * A stall order's chip. A refunded or voided bill wins over the order state;
28
+ * otherwise NEW = the stall POS has not accepted it yet.
29
+ */
30
+ export function stallOrderChip(
31
+ order: Pick<FoodCourtStallOrder, 'status' | 'bill'> | null
32
+ ): StatusChip {
33
+ switch (order?.bill?.status) {
34
+ case 'REFUNDED':
35
+ return { variant: 'critical', labelKey: 'order.foodCourt.orders.stallRefunded' }
36
+ case 'VOIDED':
37
+ return { variant: 'critical', labelKey: 'order.foodCourt.orders.stallVoided' }
38
+ }
39
+ switch (order?.status) {
40
+ case 'ACCEPTED':
41
+ return { variant: 'success', labelKey: 'order.foodCourt.orders.stallAccepted' }
42
+ case 'DECLINED':
43
+ return { variant: 'critical', labelKey: 'order.foodCourt.orders.stallDeclined' }
44
+ case 'NEW':
45
+ return { variant: 'warning', labelKey: 'order.foodCourt.orders.stallWaiting' }
46
+ default:
47
+ return { variant: 'neutral', labelKey: 'order.foodCourt.orders.stallUnknown' }
48
+ }
49
+ }
50
+
51
+ /**
52
+ * The list's time window for a picked date range (YYYY-MM-DD, either end
53
+ * optional): from the start day's 00:00 to the day after the end day, both in
54
+ * the browser's zone, which is the court's for a portal user on site.
55
+ */
56
+ export function orderListWindow(
57
+ range: { startDate: string | null; endDate: string | null },
58
+ now: dayjs.Dayjs = dayjs()
59
+ ): { from: string; to: string } {
60
+ const start = range.startDate ? dayjs(range.startDate) : now
61
+ const end = range.endDate ? dayjs(range.endDate) : start
62
+ return {
63
+ from: start.startOf('day').format(),
64
+ to: end.add(1, 'day').startOf('day').format()
65
+ }
66
+ }
67
+
68
+ export function formatMoney(value: FdoDinero | null | undefined): string {
69
+ return value ? Dinero.fromFdoDinero(value).toFormat(true) : '-'
70
+ }
71
+
72
+ export function formatOrderTime(iso: string | null | undefined, withSeconds = false): string {
73
+ return iso ? dayjs(iso).format(withSeconds ? 'DD MMM YYYY, HH:mm:ss' : 'DD MMM YYYY, HH:mm') : '-'
74
+ }
75
+
76
+ /** One line of a stall's bill: an item, or one of its add-ons under it. */
77
+ export interface BillItemLine {
78
+ key: string
79
+ name: string
80
+ quantity: number
81
+ /** Null for an add-on with no price of its own. */
82
+ amount: FdoDinero | null
83
+ remark: string | null
84
+ /** An add-on or option, shown indented under its item. */
85
+ sub: boolean
86
+ }
87
+
88
+ /** A total under the items: subtotal, discount, a tax, rounding. */
89
+ export interface BillTotalLine {
90
+ key: string
91
+ /** An i18n key, or the tax's own name when `labelIsName`. */
92
+ label: string
93
+ labelIsName: boolean
94
+ amount: FdoDinero
95
+ }
96
+
97
+ export interface StallOrderView {
98
+ key: string
99
+ unitNo: string | null
100
+ name: string
101
+ /** The stall's share of the court payment, frozen at checkout. */
102
+ amount: FdoDinero
103
+ /** The stall order; null when the receipt does not carry it. */
104
+ order: FoodCourtStallOrder | null
105
+ items: BillItemLine[]
106
+ /** The number of items (quantities added up), voided ones left out. */
107
+ itemCount: number
108
+ totals: BillTotalLine[]
109
+ }
110
+
111
+ function subItemLines(parentKey: string, subItems: FoodCourtBillSubItem[] = []): BillItemLine[] {
112
+ return subItems.flatMap((sub, index) => {
113
+ const key = `${parentKey}.${index}`
114
+ return [
115
+ {
116
+ key,
117
+ name: sub.name,
118
+ quantity: sub.quantity,
119
+ amount: sub.price && sub.price.amount !== 0 ? sub.price : null,
120
+ remark: null,
121
+ sub: true
122
+ },
123
+ ...subItemLines(key, sub.subItems)
124
+ ]
125
+ })
126
+ }
127
+
128
+ function itemsOf(bill: FoodCourtBill | null | undefined): BillItemLine[] {
129
+ if (!bill) return []
130
+ return Object.entries(bill.items ?? {})
131
+ .filter(([, item]) => item.status !== 'VOIDED')
132
+ .flatMap(([key, item]) => [
133
+ {
134
+ key,
135
+ name: item.product?.name ?? '',
136
+ quantity: item.quantity,
137
+ amount: item.nettTotal ?? null,
138
+ remark: item.remark || null,
139
+ sub: false
140
+ },
141
+ ...subItemLines(key, item.subItems)
142
+ ])
143
+ }
144
+
145
+ function isZero(value: FdoDinero | null | undefined): boolean {
146
+ return !value || value.amount === 0
147
+ }
148
+
149
+ /**
150
+ * Subtotal, then a discount when the bill has one, each tax charged on top
151
+ * (an inclusive tax is already in the prices), rounding when there is some.
152
+ */
153
+ function totalsOf(bill: FoodCourtBill | null | undefined): BillTotalLine[] {
154
+ if (!bill) return []
155
+ const lines: BillTotalLine[] = [
156
+ {
157
+ key: 'subtotal',
158
+ label: 'order.foodCourt.orders.subtotal',
159
+ labelIsName: false,
160
+ amount: bill.grossTotal
161
+ }
162
+ ]
163
+ if (bill.adjustedTotal && bill.adjustedTotal.amount !== bill.grossTotal.amount) {
164
+ lines.push({
165
+ key: 'discount',
166
+ label: 'order.foodCourt.orders.discount',
167
+ labelIsName: false,
168
+ amount: { ...bill.adjustedTotal, amount: bill.adjustedTotal.amount - bill.grossTotal.amount }
169
+ })
170
+ }
171
+ for (const [code, tax] of Object.entries(bill.nettTaxes ?? {})) {
172
+ if (tax.inclusive || isZero(tax.total)) continue
173
+ lines.push({ key: `tax.${code}`, label: tax.name, labelIsName: true, amount: tax.total })
174
+ }
175
+ if (!isZero(bill.rounding)) {
176
+ lines.push({
177
+ key: 'rounding',
178
+ label: 'order.foodCourt.orders.rounding',
179
+ labelIsName: false,
180
+ amount: bill.rounding!
181
+ })
182
+ }
183
+ return lines
184
+ }
185
+
186
+ /**
187
+ * The detail's stall cards, in checkout order: each stall row matched with its
188
+ * stall order by id, so a stall that left the court keeps its snapshot name.
189
+ */
190
+ export function stallOrderViews(receipt: FoodCourtOrderReceipt): StallOrderView[] {
191
+ const byId = new Map((receipt.pf_orders ?? []).map((o) => [String(o._id), o]))
192
+ return (receipt.stalls ?? []).map((stall) => {
193
+ const order = byId.get(String(stall.orderId)) ?? null
194
+ const items = itemsOf(order?.bill)
195
+ return {
196
+ key: stall.orderId,
197
+ unitNo: stall.unitNo || null,
198
+ name: stall.displayName || stall.restaurantId,
199
+ amount: stall.amount,
200
+ order,
201
+ items,
202
+ itemCount: items.filter((line) => !line.sub).reduce((sum, line) => sum + line.quantity, 0),
203
+ totals: totalsOf(order?.bill)
204
+ }
205
+ })
206
+ }
@@ -0,0 +1,201 @@
1
+ <template>
2
+ <FmCard variant="outlined" class="p-4 flex flex-col gap-4 max-w-[560px]">
3
+ <div class="flex flex-col gap-1">
4
+ <span class="fm-typo-en-title-sm-600">{{ t('order.foodCourt.invitations.joinTitle') }}</span>
5
+ <span v-if="step === 'enter'" class="fm-typo-en-body-md-400 text-fm-color-typo-secondary">
6
+ {{ t('order.foodCourt.invitations.joinIntro') }}
7
+ </span>
8
+ </div>
9
+
10
+ <!-- Enter the code the food court shared. -->
11
+ <template v-if="step === 'enter'">
12
+ <FmTextField
13
+ v-model="code"
14
+ :label="t('order.foodCourt.invitations.joinCode')"
15
+ placeholder="ABCDE-FGHJK"
16
+ :max-length="24"
17
+ :formatter="(v: string) => v.toUpperCase()"
18
+ :helper-text="errorText ?? ''"
19
+ :helper-state="errorText ? 'error' : 'none'"
20
+ :invalid="!!errorText"
21
+ :disabled="isBusy"
22
+ @update:model-value="errorText = null"
23
+ @keydown.enter="preview"
24
+ />
25
+ <div>
26
+ <FmButton
27
+ variant="primary"
28
+ :label="t('order.foodCourt.invitations.preview')"
29
+ :disabled="isBusy || !normalizeJoinCode(code)"
30
+ @click="preview"
31
+ />
32
+ </div>
33
+ </template>
34
+
35
+ <!-- What the code opens, then ask to join as the current restaurant. -->
36
+ <template v-else-if="step === 'preview' && previewed">
37
+ <div class="flex flex-col gap-1 p-3 rounded-lg bg-fm-color-neutral-gray-100 min-w-0">
38
+ <span class="fm-typo-en-body-lg-600 break-words">{{ previewed.name }}</span>
39
+ <span
40
+ v-if="previewAddress"
41
+ class="fm-typo-en-body-md-400 text-fm-color-typo-secondary break-words"
42
+ >
43
+ {{ previewAddress }}
44
+ </span>
45
+ <span v-if="previewStall" class="fm-typo-en-body-sm-400 text-fm-color-typo-secondary">
46
+ {{ previewStall }}
47
+ </span>
48
+ </div>
49
+ <span v-if="errorText" class="fm-typo-en-body-md-400 text-fm-color-typo-error">
50
+ {{ errorText }}
51
+ </span>
52
+ <div class="flex gap-4 flex-wrap">
53
+ <FmButton
54
+ variant="primary"
55
+ :label="t('order.foodCourt.invitations.requestToJoin', { restaurant: joinAsName })"
56
+ :disabled="isBusy"
57
+ @click="redeem"
58
+ />
59
+ <FmButton
60
+ variant="secondary"
61
+ :label="t('order.foodCourt.invitations.useAnotherCode')"
62
+ :disabled="isBusy"
63
+ @click="reset"
64
+ />
65
+ </div>
66
+ </template>
67
+
68
+ <!-- Sent: the court owner approves or declines it. -->
69
+ <template v-else-if="step === 'sent'">
70
+ <div class="flex items-start gap-3">
71
+ <FmIcon name="check_circle" size="lg" color="system-success-300" />
72
+ <div class="flex flex-col gap-1 min-w-0">
73
+ <span class="fm-typo-en-body-lg-600">{{
74
+ t('order.foodCourt.invitations.requestSent')
75
+ }}</span>
76
+ <span class="fm-typo-en-body-md-400 text-fm-color-typo-secondary break-words">
77
+ {{ t('order.foodCourt.invitations.requestSentDetail', { court: sentCourtName }) }}
78
+ </span>
79
+ </div>
80
+ </div>
81
+ <div>
82
+ <FmButton
83
+ variant="secondary"
84
+ :label="t('order.foodCourt.invitations.joinAnother')"
85
+ @click="reset"
86
+ />
87
+ </div>
88
+ </template>
89
+ </FmCard>
90
+ </template>
91
+
92
+ <script setup lang="ts">
93
+ import { computed, ref, watch } from 'vue'
94
+ import { useI18n } from '@feedmepos/mf-common'
95
+ import { FoodCourtInvitationApi, type FoodCourtJoinCodePreview } from '@/api/food-court/invitation'
96
+ import {
97
+ errorMessage,
98
+ formatCourtAddress,
99
+ isWellFormedJoinCode,
100
+ joinCodeErrorKey,
101
+ normalizeJoinCode
102
+ } from '../food-court-member'
103
+
104
+ /**
105
+ * Restaurant Operation › Food Courts › Join a food court (KDI-4915 join by
106
+ * code): the stall enters the code a court owner shared, sees which court it
107
+ * opens (name and address only), then asks to join as the restaurant selected
108
+ * in the portal. The owner approves or declines in the court's Stalls list.
109
+ */
110
+ const props = defineProps<{
111
+ restaurantId: string
112
+ /** The current restaurant's own name: what the stall asks to join as. */
113
+ restaurantName: string | null
114
+ }>()
115
+
116
+ const { t } = useI18n()
117
+
118
+ type Step = 'enter' | 'preview' | 'sent'
119
+ const step = ref<Step>('enter')
120
+ const code = ref('')
121
+ const isBusy = ref(false)
122
+ const errorText = ref<string | null>(null)
123
+ const previewed = ref<FoodCourtJoinCodePreview | null>(null)
124
+ const sentCourtName = ref('')
125
+
126
+ const joinAsName = computed(() => props.restaurantName || props.restaurantId)
127
+ const previewAddress = computed(() => formatCourtAddress(previewed.value?.address))
128
+ const previewStall = computed(() => {
129
+ const stall = previewed.value?.stall
130
+ const parts = [
131
+ stall?.unitNo ? t('order.foodCourt.invitations.stallBadge', { number: stall.unitNo }) : null,
132
+ stall?.displayName || null
133
+ ].filter(Boolean)
134
+ return parts.length
135
+ ? t('order.foodCourt.invitations.joinAsStall', { stall: parts.join(' · ') })
136
+ : null
137
+ })
138
+
139
+ function failure(e: unknown): string {
140
+ const key = joinCodeErrorKey(e)
141
+ return key ? t(key) : errorMessage(e)
142
+ }
143
+
144
+ function reset(): void {
145
+ step.value = 'enter'
146
+ code.value = ''
147
+ errorText.value = null
148
+ previewed.value = null
149
+ }
150
+
151
+ // Another restaurant selected: what the card showed was for the previous one.
152
+ watch(
153
+ () => props.restaurantId,
154
+ () => reset()
155
+ )
156
+
157
+ async function preview(): Promise<void> {
158
+ if (isBusy.value) return
159
+ // A malformed code is never sent: the backend would count it as a failed attempt.
160
+ if (!isWellFormedJoinCode(code.value)) {
161
+ errorText.value = t('order.foodCourt.joinErrors.malformed')
162
+ return
163
+ }
164
+ const restaurantId = props.restaurantId
165
+ isBusy.value = true
166
+ errorText.value = null
167
+ try {
168
+ const res = await FoodCourtInvitationApi.previewJoinCode(normalizeJoinCode(code.value))
169
+ if (restaurantId !== props.restaurantId) return
170
+ previewed.value = res
171
+ step.value = 'preview'
172
+ } catch (e) {
173
+ if (restaurantId !== props.restaurantId) return
174
+ errorText.value = failure(e)
175
+ } finally {
176
+ isBusy.value = false
177
+ }
178
+ }
179
+
180
+ async function redeem(): Promise<void> {
181
+ const court = previewed.value
182
+ if (!court || isBusy.value) return
183
+ const restaurantId = props.restaurantId
184
+ isBusy.value = true
185
+ errorText.value = null
186
+ try {
187
+ const res = await FoodCourtInvitationApi.redeemJoinCode(
188
+ normalizeJoinCode(code.value),
189
+ restaurantId
190
+ )
191
+ if (restaurantId !== props.restaurantId) return
192
+ sentCourtName.value = res.name || court.name
193
+ step.value = 'sent'
194
+ } catch (e) {
195
+ if (restaurantId !== props.restaurantId) return
196
+ errorText.value = failure(e)
197
+ } finally {
198
+ isBusy.value = false
199
+ }
200
+ }
201
+ </script>
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <FmMenu v-if="status === 'JOINED'" stop-click-propagation>
3
+ <template #menu-button>
4
+ <FmButton variant="tertiary" icon="more_vert" />
5
+ </template>
6
+ <FmMenuItem :label="t('order.foodCourt.invitations.leave')" @click="emit('leave')" />
7
+ </FmMenu>
8
+ </template>
9
+
10
+ <script setup lang="ts">
11
+ import { useI18n } from '@feedmepos/mf-common'
12
+ import type { FoodCourtMembershipStatus } from '../food-court-member'
13
+
14
+ /** A Food Courts row's action, stall side: leave a joined court. Other rows have none. */
15
+ defineProps<{ status: FoodCourtMembershipStatus }>()
16
+ const emit = defineEmits<{ (e: 'leave'): void }>()
17
+
18
+ const { t } = useI18n()
19
+ </script>
@@ -0,0 +1,226 @@
1
+ <template>
2
+ <FmSideSheet
3
+ :model-value="modelValue"
4
+ :header="t('order.foodCourt.orders.detailTitle')"
5
+ dismiss-away
6
+ :max-width="560"
7
+ @update:model-value="(v: boolean) => emit('update:modelValue', v)"
8
+ >
9
+ <FmCircularProgress v-if="isLoading" size="xl" />
10
+ <div v-else-if="loadFailed" class="flex flex-col gap-3 items-start">
11
+ <span class="fm-typo-en-body-md-400">{{ t('order.foodCourt.orders.detailLoadFailed') }}</span>
12
+ <FmButton variant="secondary" :label="t('order.foodCourt.retry')" @click="load" />
13
+ </div>
14
+ <div v-else-if="receipt" class="flex flex-col gap-4">
15
+ <FmCard variant="outlined" class="p-4 flex flex-col gap-3">
16
+ <div class="flex items-center justify-between gap-2">
17
+ <span class="fm-typo-en-title-sm-600">
18
+ {{
19
+ receipt.orderNumber
20
+ ? t('order.foodCourt.orders.orderTitle', { number: `#${receipt.orderNumber}` })
21
+ : t('order.foodCourt.orders.noNumber')
22
+ }}
23
+ </span>
24
+ <FmChip
25
+ :variant="COURT_ORDER_STATUS_CHIP[receipt.status].variant"
26
+ :label="t(COURT_ORDER_STATUS_CHIP[receipt.status].labelKey)"
27
+ />
28
+ </div>
29
+ <div class="flex flex-col gap-2">
30
+ <div v-for="field in orderFields" :key="field.label" class="flex flex-col">
31
+ <span class="fm-typo-en-body-md-400 text-fm-color-typo-secondary">{{
32
+ field.label
33
+ }}</span>
34
+ <span class="fm-typo-en-body-md-600 break-all">{{ field.value }}</span>
35
+ </div>
36
+ </div>
37
+ </FmCard>
38
+
39
+ <FmCard
40
+ v-for="stall in stalls"
41
+ :key="stall.key"
42
+ variant="outlined"
43
+ class="p-4 flex flex-col gap-3"
44
+ >
45
+ <div class="flex items-center justify-between gap-2">
46
+ <div class="flex items-center gap-2 min-w-0">
47
+ <span
48
+ v-if="stall.unitNo"
49
+ class="px-2 py-[2px] rounded bg-fm-color-neutral-gray-100 fm-typo-en-body-sm-400 shrink-0"
50
+ >
51
+ {{ stall.unitNo }}
52
+ </span>
53
+ <span class="fm-typo-en-body-lg-600 truncate">{{ stall.name }}</span>
54
+ </div>
55
+ <FmChip
56
+ :variant="stallOrderChip(stall.order).variant"
57
+ :label="t(stallOrderChip(stall.order).labelKey)"
58
+ />
59
+ </div>
60
+ <span class="fm-typo-en-body-md-400 text-fm-color-typo-secondary">
61
+ {{ t('order.foodCourt.orders.billNo') }} •
62
+ <span class="fm-typo-en-body-md-600 text-fm-color-typo-primary">
63
+ {{ stall.order?.bill?.seqNumber || t('order.foodCourt.orders.notBilled') }}
64
+ </span>
65
+ </span>
66
+ <button
67
+ type="button"
68
+ class="flex items-center justify-between border-t border-fm-color-neutral-gray-200 pt-3"
69
+ @click="toggle(stall.key)"
70
+ >
71
+ <span class="fm-typo-en-body-md-400 text-fm-color-typo-secondary">
72
+ {{ t('order.foodCourt.orders.itemCount', { count: stall.itemCount }) }}
73
+ </span>
74
+ <span class="flex items-center gap-1 fm-typo-en-body-md-600">
75
+ {{ formatMoney(stall.amount) }}
76
+ <FmIcon :name="expanded.has(stall.key) ? 'expand_less' : 'expand_more'" size="md" />
77
+ </span>
78
+ </button>
79
+ <template v-if="expanded.has(stall.key)">
80
+ <div
81
+ v-if="!stall.items.length"
82
+ class="fm-typo-en-body-sm-400 text-fm-color-typo-tertiary"
83
+ >
84
+ {{ t('order.foodCourt.orders.noItems') }}
85
+ </div>
86
+ <div v-else class="flex flex-col gap-1">
87
+ <div
88
+ v-for="line in stall.items"
89
+ :key="line.key"
90
+ class="flex justify-between gap-3"
91
+ :class="
92
+ line.sub
93
+ ? 'pl-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary'
94
+ : 'fm-typo-en-body-md-600 pt-1'
95
+ "
96
+ >
97
+ <div class="flex flex-col min-w-0">
98
+ <span>{{ line.sub ? `+ ${line.name}` : `${line.quantity}x ${line.name}` }}</span>
99
+ <span v-if="line.remark" class="fm-typo-en-body-sm-400 text-fm-color-typo-tertiary">
100
+ {{ line.remark }}
101
+ </span>
102
+ </div>
103
+ <span class="shrink-0">{{ line.amount ? formatMoney(line.amount) : '' }}</span>
104
+ </div>
105
+ </div>
106
+ <div
107
+ v-if="stall.totals.length"
108
+ class="flex flex-col gap-1 border-t border-fm-color-neutral-gray-200 pt-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
109
+ >
110
+ <div v-for="line in stall.totals" :key="line.key" class="flex justify-between gap-3">
111
+ <span>{{ line.labelIsName ? line.label : t(line.label) }}</span>
112
+ <span>{{ formatMoney(line.amount) }}</span>
113
+ </div>
114
+ <div
115
+ class="flex justify-between gap-3 fm-typo-en-body-md-600 text-fm-color-typo-primary"
116
+ >
117
+ <span>{{ t('order.foodCourt.orders.stallTotal') }}</span>
118
+ <span>{{ formatMoney(stall.order?.bill?.nettTotal ?? stall.amount) }}</span>
119
+ </div>
120
+ </div>
121
+ </template>
122
+ </FmCard>
123
+
124
+ <FmCard variant="outlined" class="p-4 flex items-center justify-between">
125
+ <span class="fm-typo-en-title-sm-600">{{ t('order.foodCourt.orders.netTotal') }}</span>
126
+ <span class="fm-typo-en-title-sm-600">{{ formatMoney(receipt.total) }}</span>
127
+ </FmCard>
128
+ </div>
129
+ <template #side-sheet-footer>
130
+ <FmButton
131
+ variant="secondary"
132
+ :label="t('order.foodCourt.orders.close')"
133
+ size="lg"
134
+ @click="emit('update:modelValue', false)"
135
+ />
136
+ </template>
137
+ </FmSideSheet>
138
+ </template>
139
+
140
+ <script setup lang="ts">
141
+ import { computed, ref, watch } from 'vue'
142
+ import { useI18n } from '@feedmepos/mf-common'
143
+ import { useSnackbarFunctions } from '@/components/snackbar'
144
+ import { FoodCourtOrderApi, type FoodCourtOrderReceipt } from '@/api/food-court'
145
+ import { errorMessage } from '../food-court-member'
146
+ import {
147
+ COURT_ORDER_STATUS_CHIP,
148
+ formatMoney,
149
+ formatOrderTime,
150
+ stallOrderChip,
151
+ stallOrderViews
152
+ } from '../food-court-order'
153
+
154
+ /**
155
+ * Orders › Order detail (KDI-4941, Figma 1.11): one court order as its
156
+ * whole-court receipt, one card per stall with that stall's items and bill.
157
+ * Refund and receipt download are not built yet.
158
+ */
159
+ const props = defineProps<{
160
+ modelValue: boolean
161
+ foodCourtId: string
162
+ orderId: string | null
163
+ }>()
164
+ const emit = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>()
165
+
166
+ const { t } = useI18n()
167
+ const { showError } = useSnackbarFunctions()
168
+
169
+ const receipt = ref<FoodCourtOrderReceipt | null>(null)
170
+ const isLoading = ref(false)
171
+ const loadFailed = ref(false)
172
+ /** The stall cards opened to show their items; the first stall starts open. */
173
+ const expanded = ref(new Set<string>())
174
+
175
+ const stalls = computed(() => (receipt.value ? stallOrderViews(receipt.value) : []))
176
+
177
+ const orderFields = computed(() => {
178
+ const r = receipt.value
179
+ if (!r) return []
180
+ return [
181
+ {
182
+ label: t('order.foodCourt.orders.date'),
183
+ value: formatOrderTime(r.payment?.paidAt ?? null, true)
184
+ },
185
+ { label: t('order.foodCourt.orders.paidBy'), value: r.paymentMethod || '-' },
186
+ { label: t('order.foodCourt.orders.orderId'), value: r._id }
187
+ ]
188
+ })
189
+
190
+ function toggle(key: string): void {
191
+ const next = new Set(expanded.value)
192
+ if (next.has(key)) next.delete(key)
193
+ else next.add(key)
194
+ expanded.value = next
195
+ }
196
+
197
+ async function load(): Promise<void> {
198
+ const courtId = props.foodCourtId
199
+ const orderId = props.orderId
200
+ loadFailed.value = false
201
+ if (!orderId) return
202
+ isLoading.value = true
203
+ try {
204
+ const res = await FoodCourtOrderApi.getOrder(courtId, orderId)
205
+ if (orderId !== props.orderId || courtId !== props.foodCourtId) return
206
+ receipt.value = res
207
+ const first = res.stalls?.[0]?.orderId
208
+ expanded.value = new Set(first ? [first] : [])
209
+ } catch (e) {
210
+ if (orderId !== props.orderId || courtId !== props.foodCourtId) return
211
+ loadFailed.value = true
212
+ showError(errorMessage(e))
213
+ } finally {
214
+ if (orderId === props.orderId && courtId === props.foodCourtId) isLoading.value = false
215
+ }
216
+ }
217
+
218
+ watch(
219
+ () => [props.foodCourtId, props.orderId] as const,
220
+ () => {
221
+ receipt.value = null
222
+ load()
223
+ },
224
+ { immediate: true }
225
+ )
226
+ </script>