@feedmepos/mf-order-setting 0.0.99 → 0.0.100

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 (46) hide show
  1. package/dist/{DisplaySystemView-Brrexhuz.js → DisplaySystemView-bnG_JNDd.js} +4 -4
  2. package/dist/{FoodCourtInvitationsView-wmZ1J7dm.js → FoodCourtInvitationsView-DbuetF4z.js} +5 -5
  3. package/dist/{FoodCourtOrderSettingsView-CNZs4q-x.js → FoodCourtOrderSettingsView-BXgApCVG.js} +1 -1
  4. package/dist/{FoodCourtOrdersView-DMvZ_Z_C.js → FoodCourtOrdersView-K0iC1arR.js} +4 -4
  5. package/dist/FoodCourtStallsView-DijfdyBw.js +668 -0
  6. package/dist/{FoodCourtStatusView-YdiL94wn.js → FoodCourtStatusView-DTriHcSD.js} +2 -2
  7. package/dist/{KioskDevicesView-DsXy1LWl.js → KioskDevicesView-d2SWWkhC.js} +1 -1
  8. package/dist/{KioskDevicesView.vue_vue_type_script_setup_true_lang-Byoci4Fo.js → KioskDevicesView.vue_vue_type_script_setup_true_lang-DA6c96uZ.js} +5 -5
  9. package/dist/{KioskSettingView-DqUpOq_Y.js → KioskSettingView-I7Hgzrvr.js} +3 -3
  10. package/dist/{KioskView-CdRnNSU0.js → KioskView-B_lLNsaU.js} +6 -6
  11. package/dist/{OrderSettingsView-CjXph68w.js → OrderSettingsView-8OS93YGL.js} +10 -10
  12. package/dist/{RestaurantSelector.vue_vue_type_script_setup_true_lang-BG71fNkx.js → RestaurantSelector.vue_vue_type_script_setup_true_lang-K0oCZMt8.js} +1 -1
  13. package/dist/{app-moKDIx07.js → app-qdN8kXAM.js} +43 -27
  14. package/dist/app.js +1 -1
  15. package/dist/{dayjs.min-DQqlQ2dX.js → dayjs.min-C-IKwmsU.js} +1 -1
  16. package/dist/{featureFlag-qLUdllY9.js → featureFlag-z_-AhzUC.js} +1 -1
  17. package/dist/food-court-member-joC8tmsI.js +234 -0
  18. package/dist/frontend/mf-order/src/api/food-court/index.d.ts +24 -4
  19. package/dist/frontend/mf-order/src/api/food-court/invitation.d.ts +3 -1
  20. package/dist/frontend/mf-order/src/app.d.ts +16 -0
  21. package/dist/frontend/mf-order/src/main.d.ts +16 -0
  22. package/dist/frontend/mf-order/src/views/food-court/food-court-member.d.ts +29 -14
  23. package/dist/frontend/mf-order/src/views/food-court/stalls/EditStallSheet.vue.d.ts +7 -3
  24. package/dist/frontend/mf-order/src/views/food-court/stalls/GenerateJoinCodeSheet.vue.d.ts +2 -2
  25. package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
  26. package/dist/{index-D5T7zJ3M.js → index-BK-RT8YN.js} +1 -1
  27. package/dist/{index-BthRwhFh.js → index-BxK-mqfV.js} +1 -1
  28. package/dist/{index-Dy5GRKwA.js → index-DeUtM1Z8.js} +2 -2
  29. package/dist/{index-C44A5dgm.js → index-DfsaaxdM.js} +1 -1
  30. package/dist/{index-BDgJZqqD.js → index-DjtNAyFp.js} +4 -4
  31. package/dist/{index-By3yKf-8.js → index-WSlqpTW2.js} +55 -42
  32. package/dist/{order.dto-DvP9y_72.js → order.dto-BTF8MlM5.js} +2 -2
  33. package/package.json +1 -1
  34. package/src/api/food-court/index.ts +36 -4
  35. package/src/api/food-court/invitation.ts +3 -0
  36. package/src/locales/en-US.json +8 -4
  37. package/src/locales/ja-JP.json +8 -4
  38. package/src/locales/th-TH.json +8 -4
  39. package/src/locales/zh-CN.json +8 -4
  40. package/src/views/food-court/FoodCourtStallsView.vue +43 -10
  41. package/src/views/food-court/food-court-member.spec.ts +139 -13
  42. package/src/views/food-court/food-court-member.ts +99 -30
  43. package/src/views/food-court/stalls/EditStallSheet.vue +41 -20
  44. package/src/views/food-court/stalls/GenerateJoinCodeSheet.vue +6 -6
  45. package/dist/FoodCourtStallsView-B3egjtKo.js +0 -635
  46. package/dist/food-court-member-CfV5vmHz.js +0 -216
@@ -64,13 +64,20 @@ function joinCode(overrides: Partial<FoodCourtJoinCode> = {}): FoodCourtJoinCode
64
64
  }
65
65
 
66
66
  describe('Stalls list', () => {
67
- it('shows ACTIVE as Active or Inactive by visible, a legacy INVITED row as Invited, and hides ended rows', () => {
67
+ it('shows ACTIVE as Active or Inactive by visible, a legacy INVITED row as Invited, and hides cancelled invitations', () => {
68
68
  expect(stallListStatus({ status: 'ACTIVE', visible: true })).toBe('ACTIVE')
69
69
  expect(stallListStatus({ status: 'ACTIVE', visible: false })).toBe('INACTIVE')
70
70
  expect(stallListStatus({ status: 'INVITED', visible: true })).toBe('INVITED')
71
71
  expect(stallListStatus({ status: 'DECLINED', visible: true })).toBe('DECLINED')
72
72
  expect(stallListStatus({ status: 'REVOKED', visible: true })).toBeNull()
73
- expect(stallListStatus({ status: 'REMOVED', visible: true })).toBeNull()
73
+ })
74
+
75
+ it('shows a REMOVED row as Left when the stall ended it, else Removed', () => {
76
+ expect(stallListStatus({ status: 'REMOVED', visible: true }, 'STALL')).toBe('LEFT')
77
+ expect(stallListStatus({ status: 'REMOVED', visible: true }, 'COURT')).toBe('REMOVED')
78
+ // an older foodcourt-service sends no endedBy
79
+ expect(stallListStatus({ status: 'REMOVED', visible: false })).toBe('REMOVED')
80
+ expect(stallListStatus({ status: 'ACTIVE', visible: true }, 'STALL')).toBe('ACTIVE')
74
81
  })
75
82
 
76
83
  it('lists a PENDING code as Pending approval and an OPEN one as Code issued, and hides the rest', () => {
@@ -82,14 +89,18 @@ describe('Stalls list', () => {
82
89
  expect(joinCodeListStatus('EXPIRED')).toBeNull()
83
90
  })
84
91
 
85
- it('keeps court order, drops REVOKED and REMOVED rows, and reads the stall and outlet name', () => {
92
+ it('keeps court order, drops REVOKED rows, lists ended stalls last, and reads the stall and outlet name', () => {
86
93
  const rows = toStallRows([
87
94
  {
88
95
  member: member({ _id: 'a', stall: { unitNo: 'A1', displayName: 'Court name' } }),
89
96
  restaurant: { _id: RESTAURANT, name: 'Outlet', businessName: 'Biz' }
90
97
  },
91
98
  { member: member({ _id: 'b', status: 'REVOKED' }), restaurant: null },
92
- { member: member({ _id: 'c', status: 'REMOVED' }), restaurant: null },
99
+ {
100
+ member: member({ _id: 'c', status: 'REMOVED', restaurantId: 'r3' }),
101
+ restaurant: null,
102
+ endedBy: 'STALL'
103
+ },
93
104
  { member: member({ _id: 'd', status: 'INVITED', restaurantId: 'r2' }), restaurant: null }
94
105
  ])
95
106
  expect(rows).toEqual([
@@ -114,14 +125,29 @@ describe('Stalls list', () => {
114
125
  listStatus: 'INVITED',
115
126
  unitNo: null,
116
127
  displayName: null
128
+ },
129
+ {
130
+ kind: 'member',
131
+ key: 'member:c',
132
+ memberId: 'c',
133
+ restaurantId: 'r3',
134
+ restaurantName: null,
135
+ status: 'REMOVED',
136
+ listStatus: 'LEFT',
137
+ unitNo: null,
138
+ displayName: null
117
139
  }
118
140
  ])
119
141
  })
120
142
 
121
- it('lists join requests first, then issued codes, then members, and hides used-up codes', () => {
143
+ it('lists join requests, then stalls, then unused codes, then ended stalls, and hides used-up codes', () => {
122
144
  const codes: FoodCourtJoinCodeListItem[] = [
123
145
  {
124
- joinCode: joinCode({ _id: 'open-new', stall: { unitNo: 'G-12', displayName: null } }),
146
+ joinCode: joinCode({
147
+ _id: 'open-new',
148
+ code: 'ABCDE-FGHJK',
149
+ stall: { unitNo: 'G-12', displayName: null }
150
+ }),
125
151
  restaurant: null
126
152
  },
127
153
  {
@@ -143,12 +169,25 @@ describe('Stalls list', () => {
143
169
  { joinCode: joinCode({ _id: 'cancelled', status: 'CANCELLED' }), restaurant: null },
144
170
  { joinCode: joinCode({ _id: 'expired', status: 'EXPIRED' }), restaurant: null }
145
171
  ]
146
- const rows = toStallRows([{ member: member({ _id: 'a' }), restaurant: null }], codes)
172
+ const rows = toStallRows(
173
+ [
174
+ {
175
+ member: member({ _id: 'gone', status: 'REMOVED', restaurantId: 'r7' }),
176
+ restaurant: null,
177
+ endedBy: 'COURT'
178
+ },
179
+ { member: member({ _id: 'a' }), restaurant: null },
180
+ { member: member({ _id: 'paused', visible: false, restaurantId: 'r6' }), restaurant: null }
181
+ ],
182
+ codes
183
+ )
147
184
  expect(rows.map((row) => [row.key, row.listStatus])).toEqual([
148
185
  ['joinCode:pending', 'PENDING_APPROVAL'],
186
+ ['member:a', 'ACTIVE'],
187
+ ['member:paused', 'INACTIVE'],
149
188
  ['joinCode:open-new', 'CODE_ISSUED'],
150
189
  ['joinCode:open-old', 'CODE_ISSUED'],
151
- ['member:a', 'ACTIVE']
190
+ ['member:gone', 'REMOVED']
152
191
  ])
153
192
  expect(rows[0]).toEqual({
154
193
  kind: 'joinCode',
@@ -161,9 +200,84 @@ describe('Stalls list', () => {
161
200
  businessName: 'Kopi Sdn Bhd',
162
201
  unitNo: null,
163
202
  displayName: 'Kopi',
164
- expiresAt: '2026-11-04T00:00:00Z'
203
+ expiresAt: '2026-11-04T00:00:00Z',
204
+ code: null
205
+ })
206
+ expect(rows[3]).toMatchObject({
207
+ restaurantId: null,
208
+ restaurantName: null,
209
+ unitNo: 'G-12',
210
+ code: 'ABCDE-FGHJK'
211
+ })
212
+ // a code from before codes were kept, or from an older foodcourt-service
213
+ expect(rows[4]).toMatchObject({ key: 'joinCode:open-old', code: null })
214
+ })
215
+
216
+ it("shows a returning stall's request with the stall it keeps on approval, unless the code names one", () => {
217
+ const request = (id: string, restaurantId: string, stall: FoodCourtJoinCode['stall'] = null) => ({
218
+ joinCode: joinCode({ _id: id, status: 'PENDING', restaurantId, stall }),
219
+ restaurant: null
165
220
  })
166
- expect(rows[1]).toMatchObject({ restaurantId: null, restaurantName: null, unitNo: 'G-12' })
221
+ const rows = toStallRows(
222
+ [
223
+ {
224
+ member: member({
225
+ _id: 'left',
226
+ status: 'REMOVED',
227
+ restaurantId: 'r1',
228
+ stall: { unitNo: 'L1-02', displayName: 'Kopi' }
229
+ }),
230
+ restaurant: null,
231
+ endedBy: 'STALL'
232
+ },
233
+ {
234
+ member: member({
235
+ _id: 'revoked',
236
+ status: 'REVOKED',
237
+ restaurantId: 'r2',
238
+ stall: { unitNo: 'L1-03', displayName: null }
239
+ }),
240
+ restaurant: null
241
+ },
242
+ {
243
+ member: member({
244
+ _id: 'removed',
245
+ status: 'REMOVED',
246
+ restaurantId: 'r3',
247
+ stall: { unitNo: 'L1-04', displayName: 'Old' }
248
+ }),
249
+ restaurant: null,
250
+ endedBy: 'COURT'
251
+ }
252
+ ],
253
+ [
254
+ request('back', 'r1'),
255
+ request('revoked-back', 'r2'),
256
+ request('relabelled', 'r3', { unitNo: null, displayName: 'New' }),
257
+ request('first-time', 'r4')
258
+ ]
259
+ )
260
+ const stallOf = (key: string) => {
261
+ const row = rows.find((r) => r.key === key)
262
+ return [row?.unitNo, row?.displayName]
263
+ }
264
+ expect(stallOf('joinCode:back')).toEqual(['L1-02', 'Kopi'])
265
+ expect(stallOf('joinCode:revoked-back')).toEqual(['L1-03', null])
266
+ expect(stallOf('joinCode:relabelled')).toEqual([null, 'New'])
267
+ expect(stallOf('joinCode:first-time')).toEqual([null, null])
268
+ })
269
+
270
+ it('shows a code only while it is unused', () => {
271
+ const [pending] = toStallRows(
272
+ [],
273
+ [
274
+ {
275
+ joinCode: joinCode({ status: 'PENDING', code: 'ABCDE-FGHJK', restaurantId: 'r9' }),
276
+ restaurant: null
277
+ }
278
+ ]
279
+ )
280
+ expect(pending).toMatchObject({ listStatus: 'PENDING_APPROVAL', code: null })
167
281
  })
168
282
 
169
283
  it('names a stall by court name, else outlet, else id; an unused code has none', () => {
@@ -184,11 +298,16 @@ describe('Stalls list', () => {
184
298
  expect(requesterName({ ...row, restaurantName: null, businessName: null })).toBe('r9')
185
299
  })
186
300
 
187
- it('offers no invite again: a declined row has no action, a legacy invitation only edit or cancel', () => {
301
+ it('offers no invite again: declined, left and removed rows have no action, a legacy invitation only edit or cancel', () => {
188
302
  expect(STALL_ACTIONS.DECLINED).toEqual([])
303
+ expect(STALL_ACTIONS.LEFT).toEqual([])
304
+ expect(STALL_ACTIONS.REMOVED).toEqual([])
189
305
  expect(STALL_ACTIONS.INVITED).toEqual(['edit', 'cancelInvite'])
190
- expect(STALL_ACTIONS.PENDING_APPROVAL).toEqual(['approve', 'decline'])
191
- expect(STALL_ACTIONS.CODE_ISSUED).toEqual(['cancelCode'])
306
+ })
307
+
308
+ it('lets the owner label a code before approving it', () => {
309
+ expect(STALL_ACTIONS.PENDING_APPROVAL).toEqual(['edit', 'approve', 'decline'])
310
+ expect(STALL_ACTIONS.CODE_ISSUED).toEqual(['edit', 'cancelCode'])
192
311
  })
193
312
 
194
313
  it('sends both stall fields, blank or the outlet name as null', () => {
@@ -335,6 +454,13 @@ describe('Food Courts list, stall side', () => {
335
454
  ['old', 'LEFT'],
336
455
  ['none', 'CANCELLED']
337
456
  ])
457
+ const ended = (endedBy: 'COURT' | 'STALL' | null) =>
458
+ toMembershipViews([{ ...membership('x', 'REMOVED', '2026-10-01T00:00:00Z'), endedBy }])[0]
459
+ .status
460
+ expect(ended('COURT')).toBe('REMOVED')
461
+ expect(ended('STALL')).toBe('LEFT')
462
+ // an older foodcourt-service sends no endedBy: the stall side keeps saying Left
463
+ expect(ended(null)).toBe('LEFT')
338
464
  expect(views[0]).toEqual({
339
465
  foodCourtId: 'code',
340
466
  memberId: 'm-code',
@@ -1,5 +1,6 @@
1
1
  import type { FmChipVariant } from '@feedmepos/ui-library'
2
2
  import type {
3
+ FoodCourtEndedBy,
3
4
  FoodCourtJoinCodeListItem,
4
5
  FoodCourtJoinCodeStatus,
5
6
  FoodCourtMember,
@@ -18,12 +19,20 @@ export interface StatusChip {
18
19
  /**
19
20
  * What the Stalls list shows. A member row: ACTIVE and visible = ACTIVE,
20
21
  * ACTIVE and paused by the owner (`visible: false`) = INACTIVE, a legacy
21
- * INVITED row (from before join codes) = INVITED. A join code: a stall's
22
- * request waiting for the owner = PENDING_APPROVAL, a code no stall has used
23
- * yet = CODE_ISSUED.
22
+ * INVITED row (from before join codes) = INVITED, a REMOVED row = LEFT when
23
+ * the stall left, REMOVED when the court removed it (`endedBy`). A join code:
24
+ * a stall's request waiting for the owner = PENDING_APPROVAL, a code no stall
25
+ * has used yet = CODE_ISSUED.
24
26
  */
25
27
  export type StallListStatus =
26
- 'ACTIVE' | 'INACTIVE' | 'INVITED' | 'DECLINED' | 'PENDING_APPROVAL' | 'CODE_ISSUED'
28
+ | 'ACTIVE'
29
+ | 'INACTIVE'
30
+ | 'INVITED'
31
+ | 'DECLINED'
32
+ | 'LEFT'
33
+ | 'REMOVED'
34
+ | 'PENDING_APPROVAL'
35
+ | 'CODE_ISSUED'
27
36
 
28
37
  interface StallRowBase {
29
38
  /** Unique across member and join code rows. */
@@ -53,13 +62,21 @@ export interface JoinCodeStallRow extends StallRowBase {
53
62
  restaurantId: string | null
54
63
  businessName: string | null
55
64
  expiresAt: string
65
+ /** `ABCDE-FGHJK` while unused, to hand out again; null otherwise and for older codes. */
66
+ code: string | null
56
67
  }
57
68
 
58
69
  export type StallRow = MemberStallRow | JoinCodeStallRow
59
70
 
60
- /** The Stalls list status of a member row, or null for a row the list hides (REVOKED, REMOVED). */
71
+ /**
72
+ * The Stalls list status of a member row, or null for a row the list hides
73
+ * (REVOKED). A REMOVED row is LEFT when the stall ended it and REMOVED when
74
+ * the court did; one with no `endedBy` (an older foodcourt-service, or a step
75
+ * that names nobody) reads REMOVED.
76
+ */
61
77
  export function stallListStatus(
62
- member: Pick<FoodCourtMember, 'status' | 'visible'>
78
+ member: Pick<FoodCourtMember, 'status' | 'visible'>,
79
+ endedBy: FoodCourtEndedBy | null = null
63
80
  ): StallListStatus | null {
64
81
  switch (member.status) {
65
82
  case 'ACTIVE':
@@ -68,11 +85,18 @@ export function stallListStatus(
68
85
  return 'INVITED'
69
86
  case 'DECLINED':
70
87
  return 'DECLINED'
88
+ case 'REMOVED':
89
+ return endedBy === 'STALL' ? 'LEFT' : 'REMOVED'
71
90
  default:
72
91
  return null
73
92
  }
74
93
  }
75
94
 
95
+ /** A stall that is no longer in the court: listed last, with no actions. */
96
+ function isEnded(listStatus: StallListStatus): boolean {
97
+ return listStatus === 'LEFT' || listStatus === 'REMOVED'
98
+ }
99
+
76
100
  /**
77
101
  * The Stalls list status of a join code, or null for a code the list hides:
78
102
  * an approved one is listed as its member row; a declined, cancelled or
@@ -91,8 +115,8 @@ export function joinCodeListStatus(status: FoodCourtJoinCodeStatus): StallListSt
91
115
 
92
116
  function toMemberRows(items: FoodCourtMemberListItem[]): MemberStallRow[] {
93
117
  const rows: MemberStallRow[] = []
94
- for (const { member, restaurant } of items) {
95
- const listStatus = stallListStatus(member)
118
+ for (const { member, restaurant, endedBy } of items) {
119
+ const listStatus = stallListStatus(member, endedBy ?? null)
96
120
  if (!listStatus) continue
97
121
  rows.push({
98
122
  kind: 'member',
@@ -109,11 +133,25 @@ function toMemberRows(items: FoodCourtMemberListItem[]): MemberStallRow[] {
109
133
  return rows
110
134
  }
111
135
 
112
- function toJoinCodeRows(items: FoodCourtJoinCodeListItem[]): JoinCodeStallRow[] {
136
+ /**
137
+ * `rowStalls` is each restaurant's member row stall. Approving a request
138
+ * whose code names no stall keeps the outlet's existing row and its stall, so
139
+ * the request shows (and Edit starts from) that stall; otherwise editing one
140
+ * field would send the other as null and approval would clear it.
141
+ */
142
+ function toJoinCodeRows(
143
+ items: FoodCourtJoinCodeListItem[],
144
+ rowStalls: Map<string, FoodCourtStall | null>
145
+ ): JoinCodeStallRow[] {
113
146
  const rows: JoinCodeStallRow[] = []
114
147
  for (const { joinCode, restaurant } of items) {
115
148
  const listStatus = joinCodeListStatus(joinCode.status)
116
149
  if (!listStatus) continue
150
+ const stall =
151
+ joinCode.stall ??
152
+ (joinCode.status === 'PENDING' && joinCode.restaurantId
153
+ ? rowStalls.get(joinCode.restaurantId)
154
+ : null)
117
155
  rows.push({
118
156
  kind: 'joinCode',
119
157
  key: `joinCode:${joinCode._id}`,
@@ -123,36 +161,48 @@ function toJoinCodeRows(items: FoodCourtJoinCodeListItem[]): JoinCodeStallRow[]
123
161
  restaurantId: joinCode.restaurantId ?? restaurant?._id ?? null,
124
162
  restaurantName: restaurant?.name || null,
125
163
  businessName: restaurant?.businessName || null,
126
- unitNo: joinCode.stall?.unitNo ?? null,
127
- displayName: joinCode.stall?.displayName ?? null,
128
- expiresAt: joinCode.expiresAt
164
+ unitNo: stall?.unitNo ?? null,
165
+ displayName: stall?.displayName ?? null,
166
+ expiresAt: joinCode.expiresAt,
167
+ code: joinCode.status === 'OPEN' ? (joinCode.code ?? null) : null
129
168
  })
130
169
  }
131
- // Requests to approve first, then codes not used yet; each keeps the backend's newest-first order.
132
- return [
133
- ...rows.filter((row) => row.status === 'PENDING'),
134
- ...rows.filter((row) => row.status === 'OPEN')
135
- ]
170
+ return rows
136
171
  }
137
172
 
138
173
  /**
139
- * The owner's Stalls list: join requests to approve, then issued codes, then
140
- * the member rows in court order. Cancelled and removed members are left out,
141
- * and so are approved, declined, cancelled and expired codes.
174
+ * The owner's Stalls list: join requests to approve,
175
+ * then the stalls in court order, then codes not used yet, then stalls that
176
+ * left or were removed. Codes keep the backend's newest-first order. Cancelled
177
+ * invitations are left out, and so are approved, declined, cancelled and
178
+ * expired codes.
142
179
  */
143
180
  export function toStallRows(
144
181
  members: FoodCourtMemberListItem[],
145
182
  joinCodes: FoodCourtJoinCodeListItem[] = []
146
183
  ): StallRow[] {
147
- return [...toJoinCodeRows(joinCodes), ...toMemberRows(members)]
184
+ const rowStalls = new Map(members.map(({ member }) => [member.restaurantId, member.stall]))
185
+ const codes = toJoinCodeRows(joinCodes, rowStalls)
186
+ const memberRows = toMemberRows(members)
187
+ return [
188
+ ...codes.filter((row) => row.status === 'PENDING'),
189
+ ...memberRows.filter((row) => !isEnded(row.listStatus)),
190
+ ...codes.filter((row) => row.status === 'OPEN'),
191
+ ...memberRows.filter((row) => isEnded(row.listStatus))
192
+ ]
148
193
  }
149
194
 
150
- /** Stalls list (Figma 1.20): Active green, Inactive grey, Pending approval orange, Declined red. */
195
+ /**
196
+ * Stalls list (Figma 1.20): Active green, Inactive grey, Pending approval
197
+ * orange, Declined red; Left and Removed grey.
198
+ */
151
199
  export const STALL_STATUS_CHIP: Record<StallListStatus, StatusChip> = {
152
200
  ACTIVE: { variant: 'success', labelKey: 'order.foodCourt.stalls.statusActive' },
153
201
  INACTIVE: { variant: 'neutral', labelKey: 'order.foodCourt.stalls.statusInactive' },
154
202
  INVITED: { variant: 'neutral', labelKey: 'order.foodCourt.stalls.statusInvited' },
155
203
  DECLINED: { variant: 'critical', labelKey: 'order.foodCourt.stalls.statusDeclined' },
204
+ LEFT: { variant: 'neutral', labelKey: 'order.foodCourt.stalls.statusLeft' },
205
+ REMOVED: { variant: 'neutral', labelKey: 'order.foodCourt.stalls.statusRemoved' },
156
206
  PENDING_APPROVAL: {
157
207
  variant: 'warning',
158
208
  labelKey: 'order.foodCourt.stalls.statusPendingApproval'
@@ -190,16 +240,20 @@ export type StallAction =
190
240
 
191
241
  /**
192
242
  * Which actions each Stalls row offers (Figma 1.20-1.32; D1: the owner pauses
193
- * with `visible`). A legacy invitation can only be cancelled; a declined one
194
- * is listed without actions: the stall rejoins with a join code.
243
+ * with `visible`). A legacy invitation can only be cancelled; a declined,
244
+ * left or removed one is listed without actions: the stall rejoins with a
245
+ * join code. A code's Edit sets the stall number and display name the stall
246
+ * joins with.
195
247
  */
196
248
  export const STALL_ACTIONS: Record<StallListStatus, StallAction[]> = {
197
249
  ACTIVE: ['edit', 'deactivate', 'remove'],
198
250
  INACTIVE: ['edit', 'activate', 'remove'],
199
251
  INVITED: ['edit', 'cancelInvite'],
200
252
  DECLINED: [],
201
- PENDING_APPROVAL: ['approve', 'decline'],
202
- CODE_ISSUED: ['cancelCode']
253
+ LEFT: [],
254
+ REMOVED: [],
255
+ PENDING_APPROVAL: ['edit', 'approve', 'decline'],
256
+ CODE_ISSUED: ['edit', 'cancelCode']
203
257
  }
204
258
 
205
259
  export const STALL_ACTION_LABEL_KEY: Record<StallAction, string> = {
@@ -293,7 +347,8 @@ export function isRestaurantNotFound(e: unknown): boolean {
293
347
  }
294
348
 
295
349
  /** A court as the stall's Food Courts list shows its row there. */
296
- export type FoodCourtMembershipStatus = 'INVITED' | 'JOINED' | 'DECLINED' | 'CANCELLED' | 'LEFT'
350
+ export type FoodCourtMembershipStatus =
351
+ 'INVITED' | 'JOINED' | 'DECLINED' | 'CANCELLED' | 'LEFT' | 'REMOVED'
297
352
 
298
353
  /** One court the restaurant has a row in, stall side (KDI-4915). */
299
354
  export interface FoodCourtMembershipView {
@@ -331,14 +386,27 @@ export function formatCourtAddress(address: FoodCourtAddress | null | undefined)
331
386
  return parts.reduce((line, part) => `${line}${line.endsWith(',') ? ' ' : ', '}${part}`)
332
387
  }
333
388
 
389
+ /**
390
+ * The stall's status for a row: a REMOVED row the court ended reads REMOVED
391
+ * ("Removed by food court"); one the stall left, or with no `endedBy`
392
+ * (an older foodcourt-service), reads LEFT.
393
+ */
394
+ function membershipStatus(
395
+ member: Pick<FoodCourtMember, 'status'>,
396
+ endedBy: FoodCourtEndedBy | null | undefined
397
+ ): FoodCourtMembershipStatus {
398
+ if (member.status === 'REMOVED' && endedBy === 'COURT') return 'REMOVED'
399
+ return MEMBERSHIP_STATUS[member.status] ?? 'CANCELLED'
400
+ }
401
+
334
402
  /** The restaurant's courts, one row each, the most recently joined (or invited) first. */
335
403
  export function toMembershipViews(memberships: FoodCourtMembership[]): FoodCourtMembershipView[] {
336
- const views = memberships.map(({ foodCourtId, profile, member }): FoodCourtMembershipView => ({
404
+ const views = memberships.map(({ foodCourtId, profile, member, endedBy }): FoodCourtMembershipView => ({
337
405
  foodCourtId,
338
406
  memberId: member._id,
339
407
  courtName: profile?.name || null,
340
408
  courtAddress: formatCourtAddress(profile?.address),
341
- status: MEMBERSHIP_STATUS[member.status] ?? 'CANCELLED',
409
+ status: membershipStatus(member, endedBy),
342
410
  unitNo: member.stall?.unitNo ?? null,
343
411
  displayName: member.stall?.displayName ?? null,
344
412
  joinedAt: member.joinedAt ?? null,
@@ -354,7 +422,8 @@ export const MEMBERSHIP_STATUS_CHIP: Record<FoodCourtMembershipStatus, StatusChi
354
422
  INVITED: { variant: 'neutral', labelKey: 'order.foodCourt.invitations.statusInvited' },
355
423
  DECLINED: { variant: 'critical', labelKey: 'order.foodCourt.invitations.statusDeclined' },
356
424
  CANCELLED: { variant: 'neutral', labelKey: 'order.foodCourt.invitations.statusCancelled' },
357
- LEFT: { variant: 'neutral', labelKey: 'order.foodCourt.invitations.statusLeft' }
425
+ LEFT: { variant: 'neutral', labelKey: 'order.foodCourt.invitations.statusLeft' },
426
+ REMOVED: { variant: 'neutral', labelKey: 'order.foodCourt.invitations.statusRemoved' }
358
427
  }
359
428
 
360
429
  /** The backend refuses a longer stall number or display name (400). */
@@ -6,10 +6,10 @@
6
6
  :max-width="480"
7
7
  @update:model-value="(v: boolean) => emit('update:modelValue', v)"
8
8
  >
9
- <div v-if="member" class="flex flex-col gap-5">
9
+ <div v-if="row" class="flex flex-col gap-5">
10
10
  <div class="flex flex-col">
11
- <span class="fm-typo-en-body-lg-600">{{ member.restaurantName || member.restaurantId }}</span>
12
- <span class="fm-typo-en-body-sm-400 text-fm-color-typo-tertiary">{{ member.restaurantId }}</span>
11
+ <span class="fm-typo-en-body-lg-600">{{ heading }}</span>
12
+ <span class="fm-typo-en-body-sm-400 text-fm-color-typo-tertiary">{{ subheading }}</span>
13
13
  </div>
14
14
  <StallAssignmentFields v-model:unit-no="unitNo" v-model:display-name="displayName" />
15
15
  </div>
@@ -19,7 +19,7 @@
19
19
  variant="primary"
20
20
  :label="t('order.save')"
21
21
  size="lg"
22
- :disabled="isSaving || !member"
22
+ :disabled="isSaving || !row"
23
23
  @click="save"
24
24
  />
25
25
  <FmButton
@@ -34,18 +34,22 @@
34
34
  </template>
35
35
 
36
36
  <script setup lang="ts">
37
- import { ref, watch } from 'vue'
37
+ import { computed, ref, watch } from 'vue'
38
38
  import { useI18n } from '@feedmepos/mf-common'
39
39
  import { useSnackbarFunctions } from '@/components/snackbar'
40
- import { FoodCourtMemberApi } from '@/api/food-court'
41
- import { errorMessage, stallToSave, type MemberStallRow } from '../food-court-member'
40
+ import { FoodCourtJoinCodeApi, FoodCourtMemberApi } from '@/api/food-court'
41
+ import { errorMessage, requesterName, stallToSave, type StallRow } from '../food-court-member'
42
42
  import StallAssignmentFields from './StallAssignmentFields.vue'
43
43
 
44
- /** Stalls › Edit: the court's stall number and display name for one stall (KDI-4919). */
44
+ /**
45
+ * Stalls › Edit: the court's stall number and display name for one stall
46
+ * (KDI-4919), or for a join code not approved yet, which the stall then joins
47
+ * with (KDI-4915).
48
+ */
45
49
  const props = defineProps<{
46
50
  modelValue: boolean
47
51
  foodCourtId: string
48
- member: MemberStallRow | null
52
+ row: StallRow | null
49
53
  }>()
50
54
  const emit = defineEmits<{
51
55
  (e: 'update:modelValue', value: boolean): void
@@ -59,26 +63,43 @@ const unitNo = ref('')
59
63
  const displayName = ref('')
60
64
  const isSaving = ref(false)
61
65
 
66
+ /** A stall names its outlet; a request names who asked; an unused code shows the code. */
67
+ const heading = computed(() => {
68
+ const row = props.row
69
+ if (!row) return ''
70
+ if (row.kind === 'member') return row.restaurantName || row.restaurantId
71
+ if (row.status === 'PENDING') return requesterName(row)
72
+ return row.code ?? t('order.foodCourt.stalls.joinCode')
73
+ })
74
+ const subheading = computed(() => {
75
+ const row = props.row
76
+ if (!row) return ''
77
+ return row.kind === 'member' ? row.restaurantId : t('order.foodCourt.stalls.editCodeHint')
78
+ })
79
+
62
80
  // Prefill on every open: the court's display name, else the outlet's own name.
63
81
  watch(
64
- () => [props.modelValue, props.member] as const,
65
- ([open, member]) => {
66
- if (!open || !member) return
67
- unitNo.value = member.unitNo ?? ''
68
- displayName.value = member.displayName ?? member.restaurantName ?? ''
82
+ () => [props.modelValue, props.row] as const,
83
+ ([open, row]) => {
84
+ if (!open || !row) return
85
+ unitNo.value = row.unitNo ?? ''
86
+ displayName.value = row.displayName ?? row.restaurantName ?? ''
69
87
  },
70
88
  { immediate: true }
71
89
  )
72
90
 
73
91
  async function save(): Promise<void> {
74
- const member = props.member
75
- if (!member || isSaving.value) return
92
+ const row = props.row
93
+ if (!row || isSaving.value) return
76
94
  isSaving.value = true
77
95
  try {
78
- await FoodCourtMemberApi.updateMember(props.foodCourtId, {
79
- memberId: member.memberId,
80
- stall: stallToSave(unitNo.value, displayName.value, member.restaurantName)
81
- })
96
+ // An unused code has no outlet yet: whatever is typed is kept.
97
+ const stall = stallToSave(unitNo.value, displayName.value, row.restaurantName)
98
+ if (row.kind === 'member') {
99
+ await FoodCourtMemberApi.updateMember(props.foodCourtId, { memberId: row.memberId, stall })
100
+ } else {
101
+ await FoodCourtJoinCodeApi.updateJoinCode(props.foodCourtId, row.joinCodeId, stall)
102
+ }
82
103
  showSuccess(t('order.foodCourt.stalls.updated'))
83
104
  emit('saved')
84
105
  emit('update:modelValue', false)
@@ -37,7 +37,7 @@
37
37
  />
38
38
  </div>
39
39
 
40
- <!-- Step 2, one code: shown this once. -->
40
+ <!-- Step 2, one code. -->
41
41
  <div v-else-if="shownCodes.length === 1" class="flex flex-col gap-16">
42
42
  <div class="flex flex-col items-center gap-3 p-6 rounded-lg bg-fm-color-neutral-gray-100">
43
43
  <span
@@ -64,7 +64,7 @@
64
64
  </span>
65
65
  </div>
66
66
 
67
- <!-- Step 2, several codes: each shown this once, with its own Copy, and Copy all. -->
67
+ <!-- Step 2, several codes: each with its own Copy, and Copy all. -->
68
68
  <div v-else class="flex flex-col gap-16">
69
69
  <ul class="flex flex-col px-16 rounded-lg bg-fm-color-neutral-gray-100">
70
70
  <li
@@ -155,8 +155,8 @@ import StallAssignmentFields from './StallAssignmentFields.vue'
155
155
  * Stalls › Generate join codes (KDI-4915 join by code). The owner picks how
156
156
  * many codes (1 to 50). One code may carry the stall number and display name
157
157
  * the stall will join with; no outlet is known yet, so nothing is prefilled.
158
- * Several codes are made blank, in one request, all or none. Each code is
159
- * shown once, here: the service keeps only its hash. A stall redeems its code
158
+ * Several codes are made blank, in one request, all or none. The Stalls list
159
+ * shows each code again, with Copy, until it is used. A stall redeems its code
160
160
  * in Restaurant Operation › Food Courts, and its request then waits in the
161
161
  * Stalls list for approval.
162
162
  */
@@ -209,8 +209,8 @@ const stallLine = computed(() => {
209
209
  : null
210
210
  })
211
211
 
212
- // Every open starts from an empty form. Closing drops the codes, which are
213
- // shown once and kept nowhere after that.
212
+ // Every open starts from an empty form. Closing drops the codes from the
213
+ // sheet; the Stalls list shows the unused ones.
214
214
  watch(
215
215
  () => props.modelValue,
216
216
  (open) => {