@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.
- package/dist/{DisplaySystemView-jnt6letY.js → DisplaySystemView-BBiZqcWq.js} +1497 -1468
- package/dist/{FoodCourtInvitationsView-DoynqFWB.js → FoodCourtInvitationsView-DwOkVs9m.js} +4 -4
- package/dist/{FoodCourtOrderSettingsView-DYZLhTHy.js → FoodCourtOrderSettingsView-C9Ag5Bsg.js} +1 -1
- package/dist/FoodCourtOrdersView-y4EwK3sn.js +1173 -0
- package/dist/{FoodCourtStallsView-CRMTt5BB.js → FoodCourtStallsView-Bi8H-yR7.js} +2 -2
- package/dist/{FoodCourtStatusView-C-b-eI-8.js → FoodCourtStatusView-jugAzTKg.js} +1 -1
- package/dist/KioskDevicesView-CYiew4X5.js +4 -0
- package/dist/KioskDevicesView.vue_vue_type_script_setup_true_lang-BCvbeo7R.js +1497 -0
- package/dist/KioskSettingView-AKBiij9a.js +1124 -0
- package/dist/KioskView-zKB6mC8I.js +765 -0
- package/dist/{OrderSettingsView-BBCnekaj.js → OrderSettingsView-CoV_yX3m.js} +22064 -21635
- 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
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/dist/{app-Dvk30CIa.js → app-CmuI6uSl.js} +3589 -2902
- package/dist/app.js +1 -1
- package/dist/{dayjs.min-DUFHhM7O.js → dayjs.min-B3MssMma.js} +1 -1
- package/dist/{featureFlag-BvcirzHS.js → featureFlag-CWvkPOBY.js} +123 -130
- package/dist/frontend/mf-order/src/api/food-court/index.d.ts +51 -0
- package/dist/frontend/mf-order/src/api/kiosk/index.d.ts +4 -0
- package/dist/frontend/mf-order/src/api/payment/index.d.ts +8 -0
- package/dist/frontend/mf-order/src/api/queue/index.d.ts +13 -0
- package/dist/frontend/mf-order/src/api/restaurant-setting/index.d.ts +9 -1
- package/dist/frontend/mf-order/src/app.d.ts +687 -0
- package/dist/frontend/mf-order/src/main.d.ts +687 -0
- package/dist/frontend/mf-order/src/modules/display-system/interface.d.ts +5 -0
- package/dist/frontend/mf-order/src/modules/kiosk/interface.d.ts +4 -0
- package/dist/frontend/mf-order/src/modules/kiosk/license.d.ts +92 -0
- package/dist/frontend/mf-order/src/modules/kiosk/outletLoad.d.ts +15 -0
- package/dist/frontend/mf-order/src/modules/kiosk/settingsSections.d.ts +24 -0
- package/dist/frontend/mf-order/src/modules/kiosk/useKioskSettings.d.ts +29 -0
- package/dist/frontend/mf-order/src/modules/payment/paymentDevice.d.ts +58 -0
- package/dist/frontend/mf-order/src/stores/kiosk/index.d.ts +67 -1
- package/dist/frontend/mf-order/src/stores/order-setting/index.d.ts +19 -10
- package/dist/frontend/mf-order/src/stores/payment/index.d.ts +59 -1
- package/dist/frontend/mf-order/src/views/food-court/food-court-export.d.ts +38 -0
- package/dist/frontend/mf-order/src/views/kiosk/devices/KioskDeviceCard.vue.d.ts +3 -0
- package/dist/frontend/mf-order/src/views/kiosk/devices/KioskDevicesView.vue.d.ts +7 -0
- package/dist/frontend/mf-order/src/views/kiosk/devices/KioskLicenseSummary.vue.d.ts +7 -0
- package/dist/frontend/mf-order/src/views/kiosk/devices/KioskLicensesView.vue.d.ts +6 -0
- package/dist/frontend/mf-order/src/views/kiosk/devices/KioskOtpDialog.vue.d.ts +3 -0
- package/dist/frontend/mf-order/src/views/kiosk/devices/KioskPaymentDeviceCard.vue.d.ts +17 -0
- package/dist/frontend/mf-order/src/views/kiosk/settings/KioskSettingView.vue.d.ts +5 -2
- package/dist/frontend/mf-order/src/views/order-settings/pickup/PickUpSettingDialogContent.vue.d.ts +0 -9
- package/dist/frontend/mf-order/src/views/order-settings/pos-status/PosOrderingStatus.vue.d.ts +17 -0
- package/dist/frontend/mf-order/src/views/order-settings/pos-status/pos-status.d.ts +44 -0
- package/dist/frontend/mf-order/src/views/order-settings/queue/called-message.d.ts +1 -0
- package/dist/frontend/mf-order/src/views/order-settings/queue/phone-join-mode.d.ts +25 -0
- package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{index-C4n5H7t3.js → index-BQa8AudZ.js} +3 -3
- package/dist/index-CMOvrim4.js +147 -0
- package/dist/{index-CW4VlFWz.js → index-D5qh2_4b.js} +1 -1
- package/dist/{index-C5n6lil6.js → index-Dup6kWLX.js} +6 -6
- package/dist/{index-CGxCWKHB.js → index-wuFIsXHT.js} +188 -179
- package/dist/{order.dto-Cb_gh3iB.js → order.dto-BD9raQG5.js} +2782 -2735
- package/dist/package/entity/display/blocks.d.ts +12 -2
- package/dist/package/entity/marketing/marketing.dto.d.ts +18 -18
- package/dist/package/entity/order-platform/external/reconciliation/external-reconciliation.do.d.ts +24 -24
- package/dist/package/entity/order-platform/menu.dto.d.ts +20 -20
- package/dist/package/entity/order-setting/order-setting.do.d.ts +10 -0
- package/dist/package/entity/order-setting/order-setting.dto.d.ts +26 -0
- package/dist/package/entity/order-setting/queue/queue.do.d.ts +23 -0
- package/dist/package/entity/order-setting/queue/queue.dto.d.ts +14 -0
- package/dist/package/entity/queue/queue.do.d.ts +153 -0
- package/dist/package/entity/queue/queue.dto.d.ts +221 -2
- package/dist/package/entity/queue/queue.enum.d.ts +5 -0
- package/dist/package/entity/restaurant/restaurant.dto.d.ts +20 -0
- package/dist/style.css +1 -1
- package/dist/{index-ILnighyU.js → useInternalUser-CHtaur9A.js} +93 -81
- package/package.json +2 -1
- package/src/api/food-court/index.ts +63 -0
- package/src/api/kiosk/index.ts +8 -0
- package/src/api/payment/index.ts +18 -1
- package/src/api/queue/index.ts +39 -0
- package/src/api/restaurant-setting/index.ts +14 -0
- package/src/locales/en-US.json +197 -26
- package/src/locales/ja-JP.json +193 -23
- package/src/locales/th-TH.json +193 -21
- package/src/locales/zh-CN.json +197 -23
- package/src/modules/display-system/interface.spec.ts +26 -1
- package/src/modules/display-system/interface.ts +20 -0
- package/src/modules/kiosk/interface.ts +4 -0
- package/src/modules/kiosk/license.spec.ts +167 -0
- package/src/modules/kiosk/license.ts +175 -0
- package/src/modules/kiosk/outletLoad.spec.ts +25 -0
- package/src/modules/kiosk/outletLoad.ts +19 -0
- package/src/modules/kiosk/settingsSections.spec.ts +85 -0
- package/src/modules/kiosk/settingsSections.ts +82 -0
- package/src/modules/kiosk/useKioskSettings.spec.ts +157 -0
- package/src/modules/kiosk/useKioskSettings.ts +61 -0
- package/src/modules/payment/paymentDevice.spec.ts +175 -0
- package/src/modules/payment/paymentDevice.ts +156 -0
- package/src/stores/kiosk/index.ts +16 -1
- package/src/stores/kiosk/mapper.ts +2 -0
- package/src/stores/order-setting/index.spec.ts +83 -0
- package/src/stores/order-setting/index.ts +49 -27
- package/src/stores/payment/index.spec.ts +86 -0
- package/src/stores/payment/index.ts +48 -2
- package/src/views/display-system/DisplayInspector.vue +17 -8
- package/src/views/display-system/DisplayTemplateEditor.vue +3 -1
- package/src/views/food-court/FoodCourtOrdersView.vue +46 -1
- package/src/views/food-court/food-court-export.spec.ts +151 -0
- package/src/views/food-court/food-court-export.ts +283 -0
- package/src/views/kiosk/KioskStatePanel.vue +2 -2
- package/src/views/kiosk/KioskView.vue +219 -82
- package/src/views/kiosk/devices/KioskDeviceCard.vue +148 -23
- package/src/views/kiosk/devices/KioskDevicesView.vue +48 -10
- package/src/views/kiosk/devices/KioskLicenseSummary.vue +79 -0
- package/src/views/kiosk/devices/KioskLicensesView.vue +152 -0
- package/src/views/kiosk/devices/KioskOtpDialog.vue +41 -1
- package/src/views/kiosk/devices/KioskPaymentDeviceCard.spec.ts +97 -0
- package/src/views/kiosk/devices/KioskPaymentDeviceCard.vue +221 -0
- package/src/views/kiosk/settings/KioskPaymentTypeSection.vue +1 -1
- package/src/views/kiosk/settings/KioskSettingView.vue +702 -419
- package/src/views/order-settings/delivery/DeliverySetting.vue +4 -0
- package/src/views/order-settings/dine-in/DineInSetting.vue +4 -0
- package/src/views/order-settings/pickup/PickUpSetting.vue +4 -4
- package/src/views/order-settings/pickup/PickUpSettingDialogContent.vue +0 -23
- package/src/views/order-settings/pos-status/PosOrderingStatus.spec.ts +207 -0
- package/src/views/order-settings/pos-status/PosOrderingStatus.vue +209 -0
- package/src/views/order-settings/pos-status/pos-status.spec.ts +103 -0
- package/src/views/order-settings/pos-status/pos-status.ts +86 -0
- package/src/views/order-settings/queue/QueueSetting.source.spec.ts +43 -0
- package/src/views/order-settings/queue/QueueSetting.vue +289 -15
- package/src/views/order-settings/queue/called-message.spec.ts +29 -1
- package/src/views/order-settings/queue/called-message.ts +18 -0
- package/src/views/order-settings/queue/phone-join-mode.spec.ts +90 -0
- package/src/views/order-settings/queue/phone-join-mode.ts +49 -0
- package/dist/FoodCourtOrdersView-CAPOycT3.js +0 -544
- package/dist/KioskDevicesView-B0U9JxRl.js +0 -4
- package/dist/KioskDevicesView.vue_vue_type_script_setup_true_lang-V3ai4FVI.js +0 -937
- package/dist/KioskSettingView-rdom_aS8.js +0 -880
- package/dist/KioskView-DOON9zR6.js +0 -516
- package/dist/frontend/mf-order/src/views/kiosk/settings/KioskDisplayStandSection.vue.d.ts +0 -10
- package/dist/frontend/mf-order/src/views/kiosk/settings/KioskInstructionSection.vue.d.ts +0 -15
- package/dist/frontend/mf-order/src/views/kiosk/settings/KioskPickAtCounterSection.vue.d.ts +0 -10
- package/dist/index-CaHG3M7C.js +0 -135
- package/src/views/kiosk/settings/KioskDisplayStandSection.vue +0 -189
- package/src/views/kiosk/settings/KioskInstructionSection.vue +0 -40
- package/src/views/kiosk/settings/KioskPickAtCounterSection.vue +0 -68
|
@@ -2,10 +2,15 @@ import { defineStore } from 'pinia'
|
|
|
2
2
|
import { ref } from 'vue'
|
|
3
3
|
import { PaymentApi } from '@/api/payment'
|
|
4
4
|
import type { PaymentCheckoutLoadError, TerminalCheckoutsDto } from '@/modules/payment/interface'
|
|
5
|
+
import type { KioskPaymentDevice } from '@/modules/payment/paymentDevice'
|
|
5
6
|
|
|
6
7
|
interface State {
|
|
7
8
|
terminals: TerminalCheckoutsDto[]
|
|
8
9
|
loadError: PaymentCheckoutLoadError | null
|
|
10
|
+
/** Staff only. Null until loaded (or when the user is not staff). */
|
|
11
|
+
paymentDevices: KioskPaymentDevice[] | null
|
|
12
|
+
paymentDevicesLoading: boolean
|
|
13
|
+
paymentDevicesLoadError: PaymentCheckoutLoadError | null
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
export function terminalDeviceId(restaurantId: string, machineId: string): string {
|
|
@@ -15,7 +20,10 @@ export function terminalDeviceId(restaurantId: string, machineId: string): strin
|
|
|
15
20
|
export const usePaymentStore = defineStore('payment', () => {
|
|
16
21
|
const state = ref<State>({
|
|
17
22
|
terminals: [],
|
|
18
|
-
loadError: null
|
|
23
|
+
loadError: null,
|
|
24
|
+
paymentDevices: null,
|
|
25
|
+
paymentDevicesLoading: false,
|
|
26
|
+
paymentDevicesLoadError: null
|
|
19
27
|
})
|
|
20
28
|
|
|
21
29
|
async function loadCheckouts() {
|
|
@@ -40,9 +48,47 @@ export const usePaymentStore = defineStore('payment', () => {
|
|
|
40
48
|
return state.value.terminals.find((t) => t.deviceId === deviceId) ?? null
|
|
41
49
|
}
|
|
42
50
|
|
|
51
|
+
// Only the latest request may write, so a slow answer for the previous outlet
|
|
52
|
+
// never replaces the current outlet's list.
|
|
53
|
+
let paymentDevicesRequest = 0
|
|
54
|
+
|
|
55
|
+
/** Load the kiosk payment devices with their gateway setup. Call for FeedMe staff only. */
|
|
56
|
+
async function loadPaymentDevices() {
|
|
57
|
+
const request = ++paymentDevicesRequest
|
|
58
|
+
state.value.paymentDevices = null
|
|
59
|
+
state.value.paymentDevicesLoadError = null
|
|
60
|
+
state.value.paymentDevicesLoading = true
|
|
61
|
+
try {
|
|
62
|
+
const devices = await PaymentApi.listKioskPaymentDevices()
|
|
63
|
+
if (request !== paymentDevicesRequest) return
|
|
64
|
+
state.value.paymentDevices = devices
|
|
65
|
+
} catch {
|
|
66
|
+
if (request !== paymentDevicesRequest) return
|
|
67
|
+
state.value.paymentDevicesLoadError = 'error'
|
|
68
|
+
} finally {
|
|
69
|
+
if (request === paymentDevicesRequest) state.value.paymentDevicesLoading = false
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Forget the staff-only list (for example when the user is not staff). */
|
|
74
|
+
function clearPaymentDevices() {
|
|
75
|
+
paymentDevicesRequest++
|
|
76
|
+
state.value.paymentDevices = null
|
|
77
|
+
state.value.paymentDevicesLoading = false
|
|
78
|
+
state.value.paymentDevicesLoadError = null
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function paymentDeviceFor(restaurantId: string, machineId: string): KioskPaymentDevice | null {
|
|
82
|
+
const deviceId = terminalDeviceId(restaurantId, machineId)
|
|
83
|
+
return state.value.paymentDevices?.find((d) => d.deviceId === deviceId) ?? null
|
|
84
|
+
}
|
|
85
|
+
|
|
43
86
|
return {
|
|
44
87
|
state: state.value,
|
|
45
88
|
loadCheckouts,
|
|
46
|
-
terminalForDevice
|
|
89
|
+
terminalForDevice,
|
|
90
|
+
loadPaymentDevices,
|
|
91
|
+
clearPaymentDevices,
|
|
92
|
+
paymentDeviceFor
|
|
47
93
|
}
|
|
48
94
|
})
|
|
@@ -252,14 +252,23 @@ function canRemoveItem(field: BlockEditorField): boolean {
|
|
|
252
252
|
|
|
253
253
|
<section v-if="announceFields.length" class="inspector-section">
|
|
254
254
|
<h4 class="inspector-section-title">{{ t('order.displaySystem.editor.ui.sectionAnnounce') }}</h4>
|
|
255
|
-
<
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
255
|
+
<template v-for="field in announceFields" :key="field.path">
|
|
256
|
+
<FmSwitch
|
|
257
|
+
v-if="field.control === 'switch'"
|
|
258
|
+
:model-value="values[field.path] === true"
|
|
259
|
+
:label="t(field.labelKey)"
|
|
260
|
+
label-placement="right"
|
|
261
|
+
@update:model-value="(value) => emit('set-prop', { path: field.path, control: field.control, value })"
|
|
262
|
+
/>
|
|
263
|
+
<DisplayFieldControl
|
|
264
|
+
v-else
|
|
265
|
+
:field="field"
|
|
266
|
+
:value="values[field.path]"
|
|
267
|
+
:media-enabled="mediaEnabled"
|
|
268
|
+
:image-is-usable="imageIsUsable"
|
|
269
|
+
@update="(value) => emit('set-prop', { path: field.path, control: field.control, value })"
|
|
270
|
+
/>
|
|
271
|
+
</template>
|
|
263
272
|
</section>
|
|
264
273
|
|
|
265
274
|
<FmButton
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
clearBlock,
|
|
26
26
|
DISPLAY_CONTAINER_CHILD_LIMIT,
|
|
27
27
|
defaultBlock,
|
|
28
|
+
setDineInCallMode,
|
|
28
29
|
defaultDisplayTemplateDraft,
|
|
29
30
|
displayTemplateToDraft,
|
|
30
31
|
removeArea,
|
|
@@ -354,7 +355,8 @@ function setProp(payload: { path: string; control: BlockEditorControl; value: un
|
|
|
354
355
|
const target = propHolder(payload.path)
|
|
355
356
|
if (!target) return
|
|
356
357
|
const { control, value } = payload
|
|
357
|
-
if (
|
|
358
|
+
if (payload.path === 'dineInCallMode') setDineInCallMode(draft.value.root, value)
|
|
359
|
+
else if (control === 'switch') target.holder[target.key] = Boolean(value)
|
|
358
360
|
else if (control === 'number' || control === 'slider') {
|
|
359
361
|
target.holder[target.key] = value === null || value === '' ? undefined : Number(value)
|
|
360
362
|
} else target.holder[target.key] = value
|
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
:items="statusItems"
|
|
23
23
|
:placeholder="t('order.foodCourt.orders.allStatuses')"
|
|
24
24
|
/>
|
|
25
|
+
<FmButton
|
|
26
|
+
class="ml-auto"
|
|
27
|
+
variant="secondary"
|
|
28
|
+
prepend-icon="download"
|
|
29
|
+
:label="t('order.foodCourt.orders.export')"
|
|
30
|
+
:loading="isExporting"
|
|
31
|
+
@click="onExport"
|
|
32
|
+
/>
|
|
25
33
|
</div>
|
|
26
34
|
<div v-if="loadFailed" class="py-4 flex flex-col gap-3 items-start">
|
|
27
35
|
<span class="fm-typo-en-body-md-400">{{ t('order.foodCourt.orders.loadFailed') }}</span>
|
|
@@ -103,6 +111,8 @@ import {
|
|
|
103
111
|
orderListWindow
|
|
104
112
|
} from './food-court-order'
|
|
105
113
|
import FoodCourtOrderSheet from './orders/FoodCourtOrderSheet.vue'
|
|
114
|
+
import { downloadExport, exportFileName } from './food-court-export'
|
|
115
|
+
import { SvcCompanyApiError } from '@/api'
|
|
106
116
|
|
|
107
117
|
/**
|
|
108
118
|
* Food Court Operations › Orders (KDI-4941, Figma "PORTAL – Food Court
|
|
@@ -116,7 +126,7 @@ const DETAIL_ROUTE_NAME = 'Food Court Order Detail View'
|
|
|
116
126
|
const LIST_ROUTE_NAME = 'Food Court Orders View'
|
|
117
127
|
|
|
118
128
|
const { t } = useI18n()
|
|
119
|
-
const { showError } = useSnackbarFunctions()
|
|
129
|
+
const { showError, showWarning } = useSnackbarFunctions()
|
|
120
130
|
const foodCourtId = useFoodCourtId()
|
|
121
131
|
const route = useRoute()
|
|
122
132
|
const router = useRouter()
|
|
@@ -185,6 +195,41 @@ async function load(): Promise<void> {
|
|
|
185
195
|
}
|
|
186
196
|
}
|
|
187
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Export (KDI-4942): every order the current filters match, not just this page,
|
|
200
|
+
* one row per stall order, as an xlsx. Nothing to export is a notice, not an
|
|
201
|
+
* error; the backend refuses past 31 days or 50,000 rows.
|
|
202
|
+
*/
|
|
203
|
+
const isExporting = ref(false)
|
|
204
|
+
|
|
205
|
+
async function onExport(): Promise<void> {
|
|
206
|
+
const id = foodCourtId.value
|
|
207
|
+
if (!id || isExporting.value) return
|
|
208
|
+
isExporting.value = true
|
|
209
|
+
// One copy of the filters for the request and the file name: the picker stays usable meanwhile.
|
|
210
|
+
const range = { ...dateRange.value }
|
|
211
|
+
const status = statuses.value.length ? [...statuses.value] : ORDER_LIST_STATUSES
|
|
212
|
+
try {
|
|
213
|
+
const res = await FoodCourtOrderApi.exportOrders(id, { ...orderListWindow(range), status })
|
|
214
|
+
if (!res.rows.length) {
|
|
215
|
+
showWarning(t('order.foodCourt.orders.exportEmpty'))
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
downloadExport(exportFileName(res.courtName, range), res.rows)
|
|
219
|
+
if (res.unreadableStalls?.length)
|
|
220
|
+
showWarning(t('order.foodCourt.orders.exportIncomplete', { count: res.unreadableStalls.length }))
|
|
221
|
+
} catch (e) {
|
|
222
|
+
const code = e instanceof SvcCompanyApiError ? e.code : undefined
|
|
223
|
+
if (code === 'EXPORT_RANGE_TOO_LONG')
|
|
224
|
+
showError(t('order.foodCourt.orders.exportRangeTooLong', { days: 31 }))
|
|
225
|
+
else if (code === 'EXPORT_TOO_MANY_ROWS')
|
|
226
|
+
showError(t('order.foodCourt.orders.exportTooManyRows', { rows: '50,000' }))
|
|
227
|
+
else showError(errorMessage(e))
|
|
228
|
+
} finally {
|
|
229
|
+
isExporting.value = false
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
188
233
|
// A new court or filter starts again from the first page.
|
|
189
234
|
watch(
|
|
190
235
|
[foodCourtId, dateRange, statuses, limit],
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import dayjs from 'dayjs'
|
|
3
|
+
import type { FoodCourtOrderExportRow } from '@/api/food-court'
|
|
4
|
+
import { strFromU8, unzipSync } from 'fflate'
|
|
5
|
+
import {
|
|
6
|
+
buildExportWorkbook,
|
|
7
|
+
columnLetter,
|
|
8
|
+
EXPORT_COLUMNS,
|
|
9
|
+
exportFileName,
|
|
10
|
+
exportSheetRows
|
|
11
|
+
} from './food-court-export'
|
|
12
|
+
|
|
13
|
+
function row(over: Partial<FoodCourtOrderExportRow> = {}): FoodCourtOrderExportRow {
|
|
14
|
+
return {
|
|
15
|
+
mainOrderId: 'main1',
|
|
16
|
+
subOrderId: 'sub1',
|
|
17
|
+
shortOrderId: 'FC-121',
|
|
18
|
+
invoiceNo: null,
|
|
19
|
+
subInvoiceNo: '0012',
|
|
20
|
+
transactionId: 'tx1',
|
|
21
|
+
gatewayId: 'RAZER_MERCHANT_SERVICE',
|
|
22
|
+
gatewayName: 'Razer Merchant Service',
|
|
23
|
+
paymentMethod: 'Visa',
|
|
24
|
+
orderChannel: 'KIOSK',
|
|
25
|
+
transactionTimestamp: '2026-11-05T04:00:00.000Z',
|
|
26
|
+
orderStatus: 'ACCEPTED',
|
|
27
|
+
paymentStatus: 'SUCCESS',
|
|
28
|
+
currency: 'MYR',
|
|
29
|
+
grossAmount: 11,
|
|
30
|
+
sst: 0.6,
|
|
31
|
+
serviceCharge: 0,
|
|
32
|
+
rounding: 0,
|
|
33
|
+
discountApplied: 1,
|
|
34
|
+
nettSalesAmount: 10.6,
|
|
35
|
+
totalSalesAmount: 15.9,
|
|
36
|
+
fcId: 'fc1',
|
|
37
|
+
fcName: 'Main Wesria',
|
|
38
|
+
restaurantId: 'r1',
|
|
39
|
+
restaurantName: 'Nasi Lemak',
|
|
40
|
+
fee: 0.32,
|
|
41
|
+
settlementAmount: 15.58,
|
|
42
|
+
settlementId: 'ST-1',
|
|
43
|
+
...over
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe('the export sheet', () => {
|
|
48
|
+
it("has the sample report's 28 columns, in its order", () => {
|
|
49
|
+
expect(EXPORT_COLUMNS.map((c) => c.header)).toEqual([
|
|
50
|
+
'MAIN_ORDER_ID',
|
|
51
|
+
'SUB_ORDER_ID',
|
|
52
|
+
'SHORT_ORDER_ID',
|
|
53
|
+
'INVOICE_NO',
|
|
54
|
+
'SUB_INVOICE_NO',
|
|
55
|
+
'TRANSACTION_ID',
|
|
56
|
+
'GATEWAY_ID',
|
|
57
|
+
'GATEWAY_NAME',
|
|
58
|
+
'PAYMENT_METHOD',
|
|
59
|
+
'ORDER_CHANNEL',
|
|
60
|
+
'TRANSACTION_TIMESTAMP',
|
|
61
|
+
'ORDER_STATUS',
|
|
62
|
+
'PAYMENT_STATUS',
|
|
63
|
+
'CURRENCY',
|
|
64
|
+
'GROSS_AMOUNT',
|
|
65
|
+
'SST',
|
|
66
|
+
'SERVICE_CHARGE',
|
|
67
|
+
'ROUNDING',
|
|
68
|
+
'DISCOUNT_APPLIED',
|
|
69
|
+
'NETT_SALES_AMOUNT',
|
|
70
|
+
'TOTAL_SALES_AMOUNT',
|
|
71
|
+
'FC_ID',
|
|
72
|
+
'FC_NAME',
|
|
73
|
+
'RESTAURANT_ID',
|
|
74
|
+
'RESTAURANT_NAME',
|
|
75
|
+
'FEE',
|
|
76
|
+
'SETTLEMENT_AMOUNT',
|
|
77
|
+
'SETTLEMENT_ID'
|
|
78
|
+
])
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('puts the header, then the definitions, then one row per stall order', () => {
|
|
82
|
+
const sheet = exportSheetRows([row(), row({ subOrderId: 'sub2', restaurantName: 'Kedai Mee' })])
|
|
83
|
+
expect(sheet).toHaveLength(4)
|
|
84
|
+
expect(sheet[0][0]).toBe('MAIN_ORDER_ID')
|
|
85
|
+
expect(sheet[1][0]).toMatch(/^Unique identifier for every food court order ID/)
|
|
86
|
+
expect(sheet[1].every((d) => typeof d === 'string' && d.length > 0)).toBe(true)
|
|
87
|
+
expect(sheet[2].slice(0, 3)).toEqual(['main1', 'sub1', 'FC-121'])
|
|
88
|
+
expect(sheet[3][1]).toBe('sub2')
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('keeps money as numbers and empty values empty, and shows the paid time in local time', () => {
|
|
92
|
+
const [, , values] = exportSheetRows([row()])
|
|
93
|
+
const at = (header: string) => values[EXPORT_COLUMNS.findIndex((c) => c.header === header)]
|
|
94
|
+
expect(at('NETT_SALES_AMOUNT')).toBe(10.6)
|
|
95
|
+
expect(at('FEE')).toBe(0.32)
|
|
96
|
+
expect(at('INVOICE_NO')).toBeNull()
|
|
97
|
+
expect(at('TRANSACTION_TIMESTAMP')).toBe(dayjs('2026-11-05T04:00:00.000Z').format('YYYY-MM-DD HH:mm:ss'))
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('shows only the header and definitions when there is nothing to export', () => {
|
|
101
|
+
expect(exportSheetRows([])).toHaveLength(2)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('writes an xlsx package with one Orders sheet holding every cell', () => {
|
|
105
|
+
const files = unzipSync(
|
|
106
|
+
buildExportWorkbook([row({ restaurantName: 'Nasi & <Lemak>\u0001 🍜' })])
|
|
107
|
+
)
|
|
108
|
+
expect(Object.keys(files).sort()).toEqual([
|
|
109
|
+
'[Content_Types].xml',
|
|
110
|
+
'_rels/.rels',
|
|
111
|
+
'xl/_rels/workbook.xml.rels',
|
|
112
|
+
'xl/styles.xml',
|
|
113
|
+
'xl/workbook.xml',
|
|
114
|
+
'xl/worksheets/sheet1.xml'
|
|
115
|
+
])
|
|
116
|
+
expect(strFromU8(files['xl/workbook.xml'])).toContain('<sheet name="Orders"')
|
|
117
|
+
const sheet = strFromU8(files['xl/worksheets/sheet1.xml'])
|
|
118
|
+
expect(sheet.match(/<row /g)).toHaveLength(3)
|
|
119
|
+
expect(sheet).toContain('<c r="A1" t="inlineStr"><is><t xml:space="preserve">MAIN_ORDER_ID</t></is></c>')
|
|
120
|
+
expect(sheet).toContain('<c r="AB1" t="inlineStr"><is><t xml:space="preserve">SETTLEMENT_ID</t></is></c>')
|
|
121
|
+
// Money is a number cell, the empty invoice no. has no cell, text is escaped,
|
|
122
|
+
// and a control character XML cannot hold is dropped while emoji survive.
|
|
123
|
+
expect(sheet).toContain('<c r="T3"><v>10.6</v></c>')
|
|
124
|
+
expect(sheet).not.toContain('r="D3"')
|
|
125
|
+
expect(sheet).toContain('Nasi & <Lemak> 🍜')
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('names columns past Z like a spreadsheet', () => {
|
|
129
|
+
expect([0, 25, 26, 27, 51, 52].map(columnLetter)).toEqual(['A', 'Z', 'AA', 'AB', 'AZ', 'BA'])
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
describe('exportFileName', () => {
|
|
134
|
+
it('is the court name and the date range, as in the ticket example', () => {
|
|
135
|
+
expect(
|
|
136
|
+
exportFileName('Main Wesria', { startDate: '2026-06-10', endDate: '2026-06-11' })
|
|
137
|
+
).toBe('Main_Wesria_20260610-20260611.xlsx')
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it('repeats the day for a one-day range and drops characters a file name cannot hold', () => {
|
|
141
|
+
expect(exportFileName(' FC: Demo/Selera 118 ', { startDate: '2026-11-05', endDate: null })).toBe(
|
|
142
|
+
'FC_DemoSelera_118_20261105-20261105.xlsx'
|
|
143
|
+
)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('falls back to a generic name and to today', () => {
|
|
147
|
+
expect(
|
|
148
|
+
exportFileName(null, { startDate: null, endDate: null }, dayjs('2026-11-06T10:00:00'))
|
|
149
|
+
).toBe('Food_Court_20261106-20261106.xlsx')
|
|
150
|
+
})
|
|
151
|
+
})
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import dayjs from 'dayjs'
|
|
2
|
+
import { strToU8, zipSync } from 'fflate'
|
|
3
|
+
import type { FoodCourtOrderExportRow } from '@/api/food-court'
|
|
4
|
+
|
|
5
|
+
type Cell = string | number | null
|
|
6
|
+
|
|
7
|
+
interface ExportColumn {
|
|
8
|
+
header: string
|
|
9
|
+
definition: string
|
|
10
|
+
value: (row: FoodCourtOrderExportRow) => Cell
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** A time as the sheet shows it, in the browser's zone (the court's, for a user on site). */
|
|
14
|
+
export function exportTime(iso: string | null): string | null {
|
|
15
|
+
return iso ? dayjs(iso).format('YYYY-MM-DD HH:mm:ss') : null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The export's columns, headers and definitions exactly as Food Court
|
|
20
|
+
* Operations specified them (KDI-4942 sample report, "Food Court Sample
|
|
21
|
+
* Report.xlsx"). The definitions are the sheet's second row (AC6).
|
|
22
|
+
*/
|
|
23
|
+
export const EXPORT_COLUMNS: ExportColumn[] = [
|
|
24
|
+
{
|
|
25
|
+
header: 'MAIN_ORDER_ID',
|
|
26
|
+
definition:
|
|
27
|
+
'Unique identifier for every food court order ID\nWhen a customer makes a single order from 3 stalls, there will be 1 main food court order ID.',
|
|
28
|
+
value: (r) => r.mainOrderId
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
header: 'SUB_ORDER_ID',
|
|
32
|
+
definition:
|
|
33
|
+
'Unique identifier for every order created when the main order gets split and distributed to individual stalls. \nIf there are 3 stalls, there will be 3 order IDs.',
|
|
34
|
+
value: (r) => r.subOrderId
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
header: 'SHORT_ORDER_ID',
|
|
38
|
+
definition:
|
|
39
|
+
'Customer-facing order ID for food collection, common across all stalls under the same main food court order ID. This is NOT unique and will be recycled. \nPrefix with FC.',
|
|
40
|
+
value: (r) => r.shortOrderId
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
header: 'INVOICE_NO',
|
|
44
|
+
definition: 'Invoice No issued by the food court owner for the main food court order',
|
|
45
|
+
value: (r) => r.invoiceNo
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
header: 'SUB_INVOICE_NO',
|
|
49
|
+
definition: 'Invoice No issued by individual stalls for the sub food court orders',
|
|
50
|
+
value: (r) => r.subInvoiceNo
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
header: 'TRANSACTION_ID',
|
|
54
|
+
definition: 'Payment identifier for the transaction',
|
|
55
|
+
value: (r) => r.transactionId
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
header: 'GATEWAY_ID',
|
|
59
|
+
definition: 'Identifier of the payment gateway used',
|
|
60
|
+
value: (r) => r.gatewayId
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
header: 'GATEWAY_NAME',
|
|
64
|
+
definition: 'Name of the payment gateway used',
|
|
65
|
+
value: (r) => r.gatewayName
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
header: 'PAYMENT_METHOD',
|
|
69
|
+
definition: 'Payment method used by the customer',
|
|
70
|
+
value: (r) => r.paymentMethod
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
header: 'ORDER_CHANNEL',
|
|
74
|
+
definition: 'For identification of whether customer is ordering via kiosk or table QR',
|
|
75
|
+
value: (r) => r.orderChannel
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
header: 'TRANSACTION_TIMESTAMP',
|
|
79
|
+
definition: 'Payment completion timestamp',
|
|
80
|
+
value: (r) => exportTime(r.transactionTimestamp)
|
|
81
|
+
},
|
|
82
|
+
{ header: 'ORDER_STATUS', definition: 'Status of the order', value: (r) => r.orderStatus },
|
|
83
|
+
{
|
|
84
|
+
header: 'PAYMENT_STATUS',
|
|
85
|
+
definition: 'Payment status of the order',
|
|
86
|
+
value: (r) => r.paymentStatus
|
|
87
|
+
},
|
|
88
|
+
{ header: 'CURRENCY', definition: 'Currency of the transaction', value: (r) => r.currency },
|
|
89
|
+
{
|
|
90
|
+
header: 'GROSS_AMOUNT',
|
|
91
|
+
definition: 'Gross amount for the individual stall order',
|
|
92
|
+
value: (r) => r.grossAmount
|
|
93
|
+
},
|
|
94
|
+
{ header: 'SST', definition: 'SST for the individual stall order', value: (r) => r.sst },
|
|
95
|
+
{
|
|
96
|
+
header: 'SERVICE_CHARGE',
|
|
97
|
+
definition: 'Service Charge for the individual stall order',
|
|
98
|
+
value: (r) => r.serviceCharge
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
header: 'ROUNDING',
|
|
102
|
+
definition: 'Rounding for the individual stall order',
|
|
103
|
+
value: (r) => r.rounding
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
header: 'DISCOUNT_APPLIED',
|
|
107
|
+
definition: 'Discount amount applied for a particular stall order ID',
|
|
108
|
+
value: (r) => r.discountApplied
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
header: 'NETT_SALES_AMOUNT',
|
|
112
|
+
definition:
|
|
113
|
+
'Amount paid by customer for the individual stall order, including all applicable taxes and service charges',
|
|
114
|
+
value: (r) => r.nettSalesAmount
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
header: 'TOTAL_SALES_AMOUNT',
|
|
118
|
+
definition:
|
|
119
|
+
'Grand amount paid by customer for all stalls, including all applicable taxes and service charges',
|
|
120
|
+
value: (r) => r.totalSalesAmount
|
|
121
|
+
},
|
|
122
|
+
{ header: 'FC_ID', definition: 'Unique identifier of the food court', value: (r) => r.fcId },
|
|
123
|
+
{ header: 'FC_NAME', definition: 'Name of the food court', value: (r) => r.fcName },
|
|
124
|
+
{
|
|
125
|
+
header: 'RESTAURANT_ID',
|
|
126
|
+
definition: 'Unique identifier of the restaurant or stall',
|
|
127
|
+
value: (r) => r.restaurantId
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
header: 'RESTAURANT_NAME',
|
|
131
|
+
definition: 'Name of the restaurant or stall',
|
|
132
|
+
value: (r) => r.restaurantName
|
|
133
|
+
},
|
|
134
|
+
{ header: 'FEE', definition: 'MDR charged for the transaction', value: (r) => r.fee },
|
|
135
|
+
{
|
|
136
|
+
header: 'SETTLEMENT_AMOUNT',
|
|
137
|
+
definition: 'Amount settled by FeedMe after deducting fees',
|
|
138
|
+
value: (r) => r.settlementAmount
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
header: 'SETTLEMENT_ID',
|
|
142
|
+
definition:
|
|
143
|
+
'Identifier for a batch settlement to the food court owner. Empty if the settlement ID has yet to be generated.',
|
|
144
|
+
value: (r) => r.settlementId
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
/** Header row, definitions row, then one row per stall order. */
|
|
149
|
+
export function exportSheetRows(rows: FoodCourtOrderExportRow[]): Cell[][] {
|
|
150
|
+
return [
|
|
151
|
+
EXPORT_COLUMNS.map((c) => c.header),
|
|
152
|
+
EXPORT_COLUMNS.map((c) => c.definition),
|
|
153
|
+
...rows.map((row) => EXPORT_COLUMNS.map((c) => c.value(row)))
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* `[Food Court Name]_[YYYYMMDD]-[YYYYMMDD].xlsx`, e.g.
|
|
159
|
+
* `Main_Wesria_20260610-20260611.xlsx`: spaces become underscores and
|
|
160
|
+
* characters a file name cannot hold are dropped. A one-day range repeats the day.
|
|
161
|
+
*/
|
|
162
|
+
export function exportFileName(
|
|
163
|
+
courtName: string | null,
|
|
164
|
+
range: { startDate: string | null; endDate: string | null },
|
|
165
|
+
now: dayjs.Dayjs = dayjs()
|
|
166
|
+
): string {
|
|
167
|
+
const name =
|
|
168
|
+
(courtName ?? '')
|
|
169
|
+
.replace(/[\\/:*?"<>|]/g, '')
|
|
170
|
+
.trim()
|
|
171
|
+
.replace(/\s+/g, '_') || 'Food_Court'
|
|
172
|
+
const start = range.startDate ? dayjs(range.startDate) : now
|
|
173
|
+
const end = range.endDate ? dayjs(range.endDate) : start
|
|
174
|
+
return `${name}_${start.format('YYYYMMDD')}-${end.format('YYYYMMDD')}.xlsx`
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** 0 → A, 25 → Z, 26 → AA. */
|
|
178
|
+
export function columnLetter(index: number): string {
|
|
179
|
+
let n = index + 1
|
|
180
|
+
let out = ''
|
|
181
|
+
while (n > 0) {
|
|
182
|
+
const rem = (n - 1) % 26
|
|
183
|
+
out = String.fromCharCode(65 + rem) + out
|
|
184
|
+
n = Math.floor((n - 1) / 26)
|
|
185
|
+
}
|
|
186
|
+
return out
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Text safe inside an XML element: escaped, and without the control characters XML 1.0 forbids. */
|
|
190
|
+
function xmlText(value: string): string {
|
|
191
|
+
return value
|
|
192
|
+
.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDFFF]/gu, '')
|
|
193
|
+
.replace(/&/g, '&')
|
|
194
|
+
.replace(/</g, '<')
|
|
195
|
+
.replace(/>/g, '>')
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function sheetXml(cells: Cell[][]): string {
|
|
199
|
+
const rows = cells.map((row, r) => {
|
|
200
|
+
const ref = (c: number) => `${columnLetter(c)}${r + 1}`
|
|
201
|
+
const cols = row
|
|
202
|
+
.map((value, c) => {
|
|
203
|
+
if (value === null || value === undefined || value === '') return ''
|
|
204
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
205
|
+
return `<c r="${ref(c)}"><v>${value}</v></c>`
|
|
206
|
+
return `<c r="${ref(c)}" t="inlineStr"><is><t xml:space="preserve">${xmlText(String(value))}</t></is></c>`
|
|
207
|
+
})
|
|
208
|
+
.join('')
|
|
209
|
+
return `<row r="${r + 1}">${cols}</row>`
|
|
210
|
+
})
|
|
211
|
+
return (
|
|
212
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
213
|
+
'<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">' +
|
|
214
|
+
`<sheetData>${rows.join('')}</sheetData></worksheet>`
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const XLSX_PARTS: Record<string, string> = {
|
|
219
|
+
'[Content_Types].xml':
|
|
220
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
221
|
+
'<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">' +
|
|
222
|
+
'<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>' +
|
|
223
|
+
'<Default Extension="xml" ContentType="application/xml"/>' +
|
|
224
|
+
'<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>' +
|
|
225
|
+
'<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>' +
|
|
226
|
+
'<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>' +
|
|
227
|
+
'</Types>',
|
|
228
|
+
'_rels/.rels':
|
|
229
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
230
|
+
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' +
|
|
231
|
+
'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>' +
|
|
232
|
+
'</Relationships>',
|
|
233
|
+
'xl/workbook.xml':
|
|
234
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
235
|
+
'<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">' +
|
|
236
|
+
'<sheets><sheet name="Orders" sheetId="1" r:id="rId1"/></sheets></workbook>',
|
|
237
|
+
'xl/_rels/workbook.xml.rels':
|
|
238
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
239
|
+
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' +
|
|
240
|
+
'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>' +
|
|
241
|
+
'<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>' +
|
|
242
|
+
'</Relationships>',
|
|
243
|
+
// The one default style. Optional in the spec, but some readers expect the part.
|
|
244
|
+
'xl/styles.xml':
|
|
245
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
246
|
+
'<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">' +
|
|
247
|
+
'<fonts count="1"><font><sz val="11"/><name val="Calibri"/></font></fonts>' +
|
|
248
|
+
'<fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills>' +
|
|
249
|
+
'<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>' +
|
|
250
|
+
'<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>' +
|
|
251
|
+
'<cellXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/></cellXfs>' +
|
|
252
|
+
'<cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>' +
|
|
253
|
+
'</styleSheet>'
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The workbook bytes: one "Orders" sheet, written directly as SpreadsheetML and
|
|
258
|
+
* zipped with fflate. Not SheetJS: its npm release (0.18.5) carries HIGH CVEs
|
|
259
|
+
* (Trivy, PR #2278) and later releases are only on the vendor's CDN.
|
|
260
|
+
*/
|
|
261
|
+
export function buildExportWorkbook(rows: FoodCourtOrderExportRow[]): Uint8Array {
|
|
262
|
+
const files: Record<string, Uint8Array> = {}
|
|
263
|
+
for (const [path, xml] of Object.entries(XLSX_PARTS)) files[path] = strToU8(xml)
|
|
264
|
+
files['xl/worksheets/sheet1.xml'] = strToU8(sheetXml(exportSheetRows(rows)))
|
|
265
|
+
return zipSync(files, { level: 6 })
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** Build the workbook and hand it to the browser as a download. */
|
|
269
|
+
export function downloadExport(fileName: string, rows: FoodCourtOrderExportRow[]): void {
|
|
270
|
+
// zipSync returns bytes on a plain ArrayBuffer; newer lib types only see ArrayBufferLike.
|
|
271
|
+
const blob = new Blob([buildExportWorkbook(rows) as BlobPart], {
|
|
272
|
+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
273
|
+
})
|
|
274
|
+
const url = URL.createObjectURL(blob)
|
|
275
|
+
const a = document.createElement('a')
|
|
276
|
+
a.href = url
|
|
277
|
+
a.download = fileName
|
|
278
|
+
document.body.appendChild(a)
|
|
279
|
+
a.click()
|
|
280
|
+
a.remove()
|
|
281
|
+
// Some browsers read the blob after click() returns: revoking at once can cancel the download.
|
|
282
|
+
setTimeout(() => URL.revokeObjectURL(url), 30_000)
|
|
283
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="flex flex-col items-center justify-center gap-3 py-16 text-center col-span-
|
|
2
|
+
<div class="flex flex-col items-center justify-center gap-3 py-16 text-center col-span-full">
|
|
3
3
|
<div
|
|
4
4
|
class="flex items-center justify-center w-16 h-16 rounded-full bg-fm-color-surface-secondary"
|
|
5
5
|
>
|
|
6
6
|
<FmIcon :name="icon" size="xl" class="text-fm-color-typo-tertiary" />
|
|
7
7
|
</div>
|
|
8
8
|
<span class="fm-typo-en-title-sm-600 block">{{ title }}</span>
|
|
9
|
-
<span class="fm-typo-en-body-md-400 block text-fm-color-typo-
|
|
9
|
+
<span class="fm-typo-en-body-md-400 block text-fm-color-typo-secondary max-w-[360px]">
|
|
10
10
|
{{ message }}
|
|
11
11
|
</span>
|
|
12
12
|
<div v-if="$slots.default" class="pt-2">
|