Skip to content

Commit b61b5d7

Browse files
committed
chore(visitor-kiosk): tweak visitor beverage flow
1 parent 2a4b065 commit b61b5d7

File tree

3 files changed

+52
-24
lines changed

3 files changed

+52
-24
lines changed

apps/visitor-kiosk/src/app/checkin/checkin-preferences.component.ts

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { Component, inject, OnInit, signal } from '@angular/core';
22
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
3-
import { setToken, showMetadata } from '@placeos/ts-client';
4-
import { lastValueFrom, of } from 'rxjs';
3+
import {
4+
listChildMetadata,
5+
PlaceZoneMetadata,
6+
setToken,
7+
} from '@placeos/ts-client';
8+
import { BehaviorSubject, lastValueFrom, of } from 'rxjs';
59
import {
610
catchError,
711
filter,
@@ -31,6 +35,7 @@ import {
3135
notifyError,
3236
notifySuccess,
3337
OrganisationService,
38+
parseJWT,
3439
SettingsService,
3540
} from '@placeos/common';
3641
import { IconComponent, TranslatePipe } from '@placeos/components';
@@ -145,13 +150,28 @@ export class CheckinPreferencesComponent
145150
public type = signal<'save' | 'menu'>('menu');
146151
public beverage: CateringItem;
147152
public readonly event = this._checkin.event;
153+
public readonly bld_id = new BehaviorSubject('');
148154

149-
public readonly menu = this._org.active_building.pipe(
155+
public readonly menu = this.bld_id.pipe(
150156
filter((_) => !!_),
151157
switchMap((bld) =>
152-
showMetadata(bld.id, 'catering').pipe(
153-
catchError(() => of({ details: [] })),
154-
map(({ details }) => (details instanceof Array ? details : [])),
158+
listChildMetadata(bld, {
159+
name: 'catering',
160+
include_parent: true,
161+
}).pipe(
162+
catchError(() => of([] as PlaceZoneMetadata[])),
163+
map((list) => {
164+
const details = [];
165+
for (const zone of list) {
166+
if (zone.keys.includes('catering')) {
167+
const catering = zone.metadata.catering;
168+
if (catering.details instanceof Array) {
169+
details.push(...catering.details);
170+
}
171+
}
172+
}
173+
return details;
174+
}),
155175
map((menu) => menu.map((i) => new CateringItem(i))),
156176
),
157177
),
@@ -171,23 +191,34 @@ export class CheckinPreferencesComponent
171191

172192
public ngOnInit(): void {
173193
this.loading.set(true);
174-
this._org.limit_init = true;
194+
this.subscription(
195+
'bld',
196+
this._org.active_building.subscribe((v) =>
197+
v ? this.bld_id.next(v.id) : '',
198+
),
199+
);
175200
this.subscription(
176201
'',
177202
this._route.queryParamMap.subscribe(async (params) => {
178-
if (params.has('jwt')) setToken(params.get('jwt'));
179-
if (params.has('email')) {
180-
await this._checkin
181-
.loadGuestAndEvent(
182-
params.get('email'),
183-
params.get('event_id'),
184-
)
185-
.catch((err) => {
186-
this.handleError(
187-
'Unable to find visitor or a meeting associated with the given email address.',
188-
);
189-
throw err;
190-
});
203+
const jwt = params.get('jwt');
204+
if (jwt) {
205+
setToken(jwt);
206+
const data = parseJWT(jwt);
207+
const user = data.u;
208+
if (user) {
209+
const email = user.e;
210+
const [event_id, , bld_zone] = user.r || [];
211+
this.bld_id.next(bld_zone);
212+
213+
await this._checkin
214+
.loadGuestAndEvent(email, event_id)
215+
.catch((err) => {
216+
this.handleError(
217+
'Unable to find visitor or a meeting associated with the given email address.',
218+
);
219+
throw err;
220+
});
221+
}
191222
}
192223
}),
193224
);

libs/bookings/src/lib/new-parking-select-modal/new-parking-filters-display.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
SettingsService,
99
} from '@placeos/common';
1010
import { IconComponent } from 'libs/components/src/lib/icon.component';
11-
import { TranslatePipe } from 'libs/components/src/lib/translate.pipe';
1211
import { BookingFormService } from '../booking-form.service';
1312

1413
@Component({
@@ -67,7 +66,7 @@ import { BookingFormService } from '../booking-form.service';
6766
}
6867
`,
6968
],
70-
imports: [CommonModule, IconComponent, TranslatePipe, MatRippleModule],
69+
imports: [CommonModule, IconComponent, MatRippleModule],
7170
})
7271
export class NewParkingFiltersDisplayComponent extends AsyncHandler {
7372
private _event_form = inject(BookingFormService);

libs/form-fields/src/lib/user-list-field.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import { searchGuests } from 'libs/users/src/lib/guests.fn';
5050
import { NewUserModalComponent } from 'libs/users/src/lib/new-user-modal.component';
5151
import { searchStaff } from 'libs/users/src/lib/staff.fn';
5252
import { USER_DOMAIN } from 'libs/users/src/lib/user.utilities';
53-
import { PlaceUserPipe } from './place-user.pipe';
5453

5554
function validateEmail(email) {
5655
const re =
@@ -237,7 +236,6 @@ const DENIED_FILE_TYPES = [
237236
MatRippleModule,
238237
TranslatePipe,
239238
IconComponent,
240-
PlaceUserPipe,
241239
MatTooltipModule,
242240
UserAvatarComponent,
243241
],

0 commit comments

Comments
 (0)