Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Bugfix/allow scan only current event #2

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PORT=3004
REACT_APP_APP_ID=2095
REACT_APP_APP_TENANT_ID=davinci
REACT_APP_RXB_SDK_ENV=prod
REACT_APP_API_IDENTITY_URL=https://prod-identity-service.core.aws.cere.io
REACT_APP_API_BFF_URL=https://prod-davinci-api-service.core.aws.cere.io
REACT_APP_API_FREEPORT_URL=https://prod-freeport-api.network.aws.cere.io
6 changes: 3 additions & 3 deletions src/pages/event-scanner.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const EventScannerPage = observer(() => {
}, [eventId, navigate, eventStore.allowedEvents, eventStore.events, location]);

const onQRCodeScan = async (result: Record<string, any>) => {
console.log('onQRCodeScan', result);
scannerStore.scan({...result, eventId: result?.eventId !== eventId ? eventId : undefined});
console.log('onQRCodeScan', eventId, result);
scannerStore.scan(eventId, result);
};

const backHandler = () => {
Expand Down Expand Up @@ -129,7 +129,7 @@ export const EventScannerPage = observer(() => {
<div className="flex flex-col aspect-square justify-center bg-red-100 items-center rounded-2xl border-[3px] border-red-500 corner-only-border">
<img className="w-[150px] h-[150px]" src="/images/scan-error.png" alt="" />
</div>
<div className="flex flex-row justify-between bg-red-100 rounded-xl p-3 items-center gap-2">
<div className="flex flex-row bg-red-100 rounded-xl p-3 items-center gap-2">
<CloseIcon className="w-6" />
<Typography variant="body1">{scannerStore.errorMessage}</Typography>
</div>
Expand Down
24 changes: 15 additions & 9 deletions src/stores/scanner.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,19 @@ export class ScannerStore {
if (response?.data?.result === true) {
this._status = ScannerStatusEnum.SUCCESS;
} else if (response?.data?.result === false) {
this._status = ScannerStatusEnum.ERROR;
this._errorMessage = response?.data?.errorMessage;
this._throwError(response?.data?.errorMessage);
} else {
this._status = ScannerStatusEnum.ERROR;
this._errorMessage = 'Wrong response structure in RXB response';
this._throwError('Wrong response structure in RXB response');
console.error(response);
}
}
if (response.trigger === SdkTriggerEnum.TICKET_USE) {
if (response?.data?.result === true) {
this.ready();
} else if (response?.data?.result === false) {
this._status = ScannerStatusEnum.ERROR;
this._errorMessage = response?.data?.errorMessage;
this._throwError(response?.data?.errorMessage);
} else {
this._status = ScannerStatusEnum.ERROR;
this._errorMessage = 'Wrong response structure in RXB response';
this._throwError('Wrong response structure in RXB response');
console.error(response);
}
}
Expand All @@ -65,7 +61,12 @@ export class ScannerStore {
);
}

public scan(data: Record<string, any>): void {
public scan(eventId: string | undefined, data: Record<string, any>): void {
if (!eventId || data?.eventId !== eventId) {
this._throwError('Different event');
return;
}

const trigger = SdkTriggerEnum.TICKET_CHECK;
this.userStore.sdkInstance.sendEvent(trigger, {...data, trigger});
this._status = ScannerStatusEnum.PROCESSING;
Expand All @@ -92,4 +93,9 @@ export class ScannerStore {
public get errorMessage(): string | undefined {
return this._errorMessage;
}

private _throwError(errorMessage: string) {
this._status = ScannerStatusEnum.ERROR;
this._errorMessage = errorMessage;
}
}
Loading