@feedmepos/mf-order-setting 0.0.108 → 0.0.109

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 (57) hide show
  1. package/dist/{DisplaySystemView-ChGTO4v2.js → DisplaySystemView-hHA7fMQR.js} +4 -4
  2. package/dist/{FoodCourtInvitationsView-F1LiGOR8.js → FoodCourtInvitationsView-C_x0pvnB.js} +4 -4
  3. package/dist/{FoodCourtOrderSettingsView-D5M5kFAl.js → FoodCourtOrderSettingsView-BMRJe6tf.js} +1 -1
  4. package/dist/FoodCourtOrdersView-DlGJnMOd.js +1433 -0
  5. package/dist/{FoodCourtStallsView-jz1xnZus.js → FoodCourtStallsView-BAzlMqlj.js} +2 -2
  6. package/dist/{FoodCourtStatusView-DC3qHL1L.js → FoodCourtStatusView-CRkk2f66.js} +1 -1
  7. package/dist/{KioskDevicesView-B9w4izOk.js → KioskDevicesView-COuR39YQ.js} +1 -1
  8. package/dist/{KioskDevicesView.vue_vue_type_script_setup_true_lang-XJm-f2JF.js → KioskDevicesView.vue_vue_type_script_setup_true_lang-CAcDjPbk.js} +5 -5
  9. package/dist/{KioskSettingView-Bmfvz0Kz.js → KioskSettingView-DsIzIbYf.js} +3 -3
  10. package/dist/{KioskView-B0WlDEsG.js → KioskView-B1sn-D6k.js} +8 -8
  11. package/dist/{OrderSettingsView-BF89-eSB.js → OrderSettingsView-BvYGRXfI.js} +10 -10
  12. package/dist/{RestaurantSelector.vue_vue_type_script_setup_true_lang-BqPQnAVb.js → RestaurantSelector.vue_vue_type_script_setup_true_lang-COUKtg5k.js} +1 -1
  13. package/dist/{app-B4ew9SMz.js → app-utsChJtE.js} +71 -15
  14. package/dist/app.js +1 -1
  15. package/dist/{dayjs.min-BsZk4QHK.js → dayjs.min-C9WrpSe-.js} +1 -1
  16. package/dist/{featureFlag-CFlCo4uv.js → featureFlag-CHPFyNAw.js} +1 -1
  17. package/dist/frontend/mf-order/src/api/food-court/index.d.ts +29 -2
  18. package/dist/frontend/mf-order/src/app.d.ts +56 -0
  19. package/dist/frontend/mf-order/src/main.d.ts +56 -0
  20. package/dist/frontend/mf-order/src/views/food-court/food-court-order.d.ts +12 -1
  21. package/dist/frontend/mf-order/src/views/food-court/orders/FoodCourtOrderSheet.vue.d.ts +3 -1
  22. package/dist/frontend/mf-order/src/views/food-court/orders/FoodCourtReceiptDialog.vue.d.ts +17 -0
  23. package/dist/frontend/mf-order/src/views/food-court/orders/food-court-receipt.d.ts +20 -0
  24. package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
  25. package/dist/index--4Q-LHMq.js +6854 -0
  26. package/dist/{index-D0vTvoQN.js → index-BaABuG0J.js} +1 -1
  27. package/dist/{index-Z1ZA897U.js → index-CVxg__RB.js} +1 -1
  28. package/dist/index-Ck6Ef5sR.js +5 -0
  29. package/dist/{index-C6c28uBZ.js → index-D349Zd9k.js} +35 -23
  30. package/dist/{index-DLeX1p1o.js → index-DC8V_7zz.js} +2 -2
  31. package/dist/{index-D4_zVJPi.js → index-DVJkdWEG.js} +4 -4
  32. package/dist/index-iSsU83r4.js +46278 -0
  33. package/dist/{order.dto-DrlhCvYK.js → order.dto-D4yp5hGF.js} +47 -43
  34. package/dist/package/entity/alert/suggestion.dto.d.ts +2 -2
  35. package/dist/package/entity/food-court/order-v2.dto.d.ts +5 -5
  36. package/dist/package/entity/kiosk/kiosk.do.d.ts +16 -16
  37. package/dist/package/entity/kiosk/kiosk.dto.d.ts +19 -19
  38. package/dist/package/entity/order/order.do.d.ts +3 -3
  39. package/dist/package/entity/order/order.dto.d.ts +10 -10
  40. package/dist/package/entity/order/order.enum.d.ts +1 -1
  41. package/dist/package/entity/order-platform/deliveroo/deliveroo.menu.dto.d.ts +30 -30
  42. package/dist/{useInternalUser-BaSqwN4K.js → useInternalUser-CeoNePyw.js} +1 -1
  43. package/package.json +4 -1
  44. package/src/api/food-court/index.ts +42 -4
  45. package/src/locales/en-US.json +15 -1
  46. package/src/locales/ja-JP.json +15 -1
  47. package/src/locales/th-TH.json +15 -1
  48. package/src/locales/zh-CN.json +15 -1
  49. package/src/views/food-court/FoodCourtOrdersView.vue +135 -16
  50. package/src/views/food-court/food-court-order.spec.ts +16 -1
  51. package/src/views/food-court/food-court-order.ts +23 -1
  52. package/src/views/food-court/orders/FoodCourtOrderSheet.vue +29 -11
  53. package/src/views/food-court/orders/FoodCourtReceiptDialog.vue +113 -0
  54. package/src/views/food-court/orders/food-court-receipt.spec.ts +43 -0
  55. package/src/views/food-court/orders/food-court-receipt.ts +49 -0
  56. package/vite.config.ts +13 -0
  57. package/dist/FoodCourtOrdersView-BQrESoTH.js +0 -1190
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <FmDialog
3
+ :model-value="modelValue"
4
+ :max-width="440"
5
+ @update:model-value="(v: boolean) => emit('update:modelValue', v)"
6
+ >
7
+ <template #dialog-header>
8
+ <div class="fm-typo-en-body-lg-600 text-fm-color-typo-primary">
9
+ {{ t('order.foodCourt.orders.receiptTitle') }}
10
+ </div>
11
+ </template>
12
+ <div class="max-h-[70vh] overflow-y-auto flex justify-center">
13
+ <FmCircularProgress v-if="isRendering" size="xl" />
14
+ <span v-else-if="problem" class="fm-typo-en-body-md-400 text-fm-color-typo-secondary">
15
+ {{ problem }}
16
+ </span>
17
+ <div ref="canvasHost" class="flex justify-center"></div>
18
+ </div>
19
+ <template #dialog-footer>
20
+ <div class="flex gap-12 justify-end">
21
+ <FmButton
22
+ v-if="canvas"
23
+ variant="secondary"
24
+ prepend-icon="download"
25
+ :label="t('order.foodCourt.orders.downloadReceipt')"
26
+ @click="download"
27
+ />
28
+ <FmButton
29
+ variant="primary"
30
+ :label="t('order.foodCourt.orders.close')"
31
+ @click="emit('update:modelValue', false)"
32
+ />
33
+ </div>
34
+ </template>
35
+ </FmDialog>
36
+ </template>
37
+
38
+ <script setup lang="ts">
39
+ import { nextTick, ref, watch } from 'vue'
40
+ import { useCoreStore, useI18n } from '@feedmepos/mf-common'
41
+ import type { FoodCourtOrderReceipt } from '@/api/food-court'
42
+ import { foodCourtReceiptProblem, renderFoodCourtReceipt } from './food-court-receipt'
43
+
44
+ /**
45
+ * Orders › View receipt (KDI-4941): the whole-court receipt as the court kiosk
46
+ * prints it (KDI-4934), drawn the same way Restaurant Operation › Receipts
47
+ * previews a bill: the kitchen template compiled to print groups, drawn on a
48
+ * canvas by @feedmepos/printer.
49
+ */
50
+ const props = defineProps<{
51
+ modelValue: boolean
52
+ receipt: FoodCourtOrderReceipt | null
53
+ }>()
54
+ const emit = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>()
55
+
56
+ const { t, locale } = useI18n()
57
+ const core = useCoreStore()
58
+
59
+ const canvasHost = ref<HTMLElement | null>(null)
60
+ const canvas = ref<HTMLCanvasElement | null>(null)
61
+ const isRendering = ref(false)
62
+ const problem = ref<string | null>(null)
63
+
64
+ async function draw(): Promise<void> {
65
+ const order = props.receipt
66
+ canvas.value = null
67
+ problem.value = null
68
+ if (canvasHost.value) canvasHost.value.replaceChildren()
69
+ if (!order) return
70
+ const reason = foodCourtReceiptProblem(order)
71
+ if (reason) {
72
+ problem.value = t('order.foodCourt.orders.receiptUnavailable', { reason })
73
+ return
74
+ }
75
+ isRendering.value = true
76
+ try {
77
+ const drawn = await renderFoodCourtReceipt(
78
+ order,
79
+ String(locale.value ?? 'en-US'),
80
+ (core.currentCountry as { value?: string | null } | undefined)?.value ?? null
81
+ )
82
+ if (props.receipt !== order || !props.modelValue) return
83
+ drawn.style.width = '100%'
84
+ drawn.style.maxWidth = '380px'
85
+ drawn.style.height = 'auto'
86
+ canvas.value = drawn
87
+ await nextTick()
88
+ canvasHost.value?.replaceChildren(drawn)
89
+ } catch (e) {
90
+ problem.value = t('order.foodCourt.orders.receiptUnavailable', {
91
+ reason: e instanceof Error ? e.message : String(e)
92
+ })
93
+ } finally {
94
+ isRendering.value = false
95
+ }
96
+ }
97
+
98
+ function download(): void {
99
+ if (!canvas.value) return
100
+ const link = document.createElement('a')
101
+ link.download = `receipt-${props.receipt?.orderNumber ?? props.receipt?._id ?? 'food-court'}.png`
102
+ link.href = canvas.value.toDataURL('image/png')
103
+ link.click()
104
+ }
105
+
106
+ watch(
107
+ () => [props.modelValue, props.receipt] as const,
108
+ ([open]) => {
109
+ if (open) draw()
110
+ },
111
+ { immediate: true }
112
+ )
113
+ </script>
@@ -0,0 +1,43 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import type { FoodCourtOrderReceipt } from '@/api/food-court'
3
+ import { foodCourtReceiptProblem, kitchenLocale } from './food-court-receipt'
4
+
5
+ const rm = (amount: number) => ({ amount, precision: 2, currency: 'MYR' }) as const
6
+
7
+ const paid = (over: Partial<FoodCourtOrderReceipt> = {}): FoodCourtOrderReceipt => ({
8
+ _id: 'c1',
9
+ foodCourtId: 'f1',
10
+ status: 'PAID',
11
+ orderNumber: 'FC-001',
12
+ total: rm(2620),
13
+ stalls: [
14
+ { orderId: 'o1', restaurantId: 'r1', unitNo: null, displayName: 'Teh Tarik Bar', amount: rm(500) },
15
+ { orderId: 'o2', restaurantId: 'r2', unitNo: '5', displayName: 'Cafe Run', amount: rm(2120) }
16
+ ],
17
+ pf_orders: [
18
+ { _id: 'o1', restaurant: 'r1', status: 'ACCEPTED', orderAt: '2026-11-18T05:12:00.000Z' },
19
+ { _id: 'o2', restaurant: 'r2', status: 'NEW', orderAt: '2026-11-18T05:12:00.000Z' }
20
+ ],
21
+ ...over
22
+ })
23
+
24
+ describe('foodCourtReceiptProblem (KDI-4941 View receipt)', () => {
25
+ it('lets a paid order with every stall order through', () => {
26
+ expect(foodCourtReceiptProblem(paid())).toBeNull()
27
+ })
28
+
29
+ it('names what kitchen would refuse', () => {
30
+ expect(foodCourtReceiptProblem(paid({ status: 'PENDING_PAYMENT' }))).toMatch(/not paid/)
31
+ expect(foodCourtReceiptProblem(paid({ orderNumber: null }))).toMatch(/no FC number/)
32
+ expect(foodCourtReceiptProblem(paid({ stalls: [] }))).toMatch(/no stalls/)
33
+ expect(foodCourtReceiptProblem(paid({ pf_orders: [paid().pf_orders[0]] }))).toMatch(/Cafe Run has no order/)
34
+ })
35
+ })
36
+
37
+ describe('kitchenLocale', () => {
38
+ it('splits the portal locale into kitchen language and country', () => {
39
+ expect(kitchenLocale('en-MY')).toEqual({ languageCode: 'en', countryCode: 'MY' })
40
+ expect(kitchenLocale('zh_CN')).toEqual({ languageCode: 'zh', countryCode: 'CN' })
41
+ expect(kitchenLocale('en')).toEqual({ languageCode: 'en' })
42
+ })
43
+ })
@@ -0,0 +1,49 @@
1
+ import type { FoodCourtOrderReceipt } from '@/api/food-court'
2
+
3
+ /**
4
+ * Why kitchen cannot compile this court order into a receipt, or null when it
5
+ * can: the same checks kitchen makes before it throws (a PAID order with a
6
+ * number and stalls, and a stall order in `pf_orders` for every stall).
7
+ */
8
+ export function foodCourtReceiptProblem(order: FoodCourtOrderReceipt): string | null {
9
+ if (order.status !== 'PAID') return `the order is not paid (${order.status})`
10
+ if (!order.orderNumber) return 'the order has no FC number'
11
+ const stalls = order.stalls ?? []
12
+ if (!stalls.length) return 'the order has no stalls'
13
+ const ids = new Set((order.pf_orders ?? []).map((o) => String(o._id)))
14
+ const missing = stalls.find((s) => !ids.has(String(s.orderId)))
15
+ if (missing) return `stall ${missing.displayName || missing.restaurantId} has no order`
16
+ return null
17
+ }
18
+
19
+ /** `en-MY` → kitchen's locale shape. */
20
+ export function kitchenLocale(locale: string): { languageCode: string; countryCode?: string } {
21
+ const [languageCode, countryCode] = locale.split(/[-_]/)
22
+ return countryCode ? { languageCode, countryCode } : { languageCode }
23
+ }
24
+
25
+ /**
26
+ * The whole-court receipt (KDI-4934) as a canvas: kitchen's court template
27
+ * (`foodCourtReceipt.compile`, the court kiosk's printout, default template)
28
+ * fed the portal's order body as is, drawn by @feedmepos/printer the same way
29
+ * Restaurant Operation › Receipts draws a bill. Both packages are loaded only
30
+ * here, so the Orders page does not carry them until a receipt is opened.
31
+ */
32
+ export async function renderFoodCourtReceipt(
33
+ order: FoodCourtOrderReceipt,
34
+ locale: string,
35
+ country?: string | null
36
+ ): Promise<HTMLCanvasElement> {
37
+ const [kitchenModule, printer] = await Promise.all([
38
+ import('@feedmepos/kitchen'),
39
+ import('@feedmepos/printer')
40
+ ])
41
+ const kitchen = ((kitchenModule as any).default ?? kitchenModule) as typeof import('@feedmepos/kitchen')
42
+ // Money and tax wording follow the country, as Restaurant Operation › Receipts sets it.
43
+ if (country) kitchen.setCountry(country as any)
44
+ const job = kitchen.foodCourtReceipt.compile({
45
+ order: order as unknown as Record<string, unknown>,
46
+ locale: kitchenLocale(locale)
47
+ })
48
+ return printer.render({ groups: job.groups as any, fontSize: job.fontSize })
49
+ }
package/vite.config.ts CHANGED
@@ -96,5 +96,18 @@ export default defineConfig(async (env) => {
96
96
  }
97
97
  }
98
98
 
99
+ // @feedmepos/kitchen is dart2js output: it checks types by each class function's
100
+ // `.name` ("$i" + t.name). The dev server's esbuild pre-bundle renames clashing
101
+ // top-level functions (y -> y2), which breaks every kitchen call with "type 'y2' is not
102
+ // a subtype of type 'y'". keepNames keeps `.name`. The production build wraps the
103
+ // module (strictRequires above) and does not rename, so it needs nothing.
104
+ presetConfig.optimizeDeps = {
105
+ ...presetConfig.optimizeDeps,
106
+ esbuildOptions: {
107
+ ...presetConfig.optimizeDeps?.esbuildOptions,
108
+ keepNames: true
109
+ }
110
+ }
111
+
99
112
  return presetConfig
100
113
  })