Skip to content

Commit

Permalink
Patch Release v1.2.4a
Browse files Browse the repository at this point in the history
fix: Fix hardware ticket scanner (#755)
  • Loading branch information
HappyNTH committed Nov 21, 2024
1 parent bb6ba17 commit f622a75
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
3 changes: 1 addition & 2 deletions classes/Ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ export default class {
return ticket;
}

static dataFromQRCode(detectedCodes: [string]) {
static dataFromQRCode(rawValue: string) {
try {
const rawValue = JSON.parse(JSON.stringify(detectedCodes[0])).rawValue;
const result = JSON.parse(atob(rawValue));
return {
bookingReference: result[0],
Expand Down
3 changes: 2 additions & 1 deletion components/ui/Input/UiInputTicketScanner.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ function onDetect(string: [string]) {
new Audio('/audio/beep_single.mp3').play();
try {
const ticketData = Ticket.dataFromQRCode(string);
const rawValue = JSON.parse(JSON.stringify(string[0])).rawValue;
const ticketData = Ticket.dataFromQRCode(rawValue);
if (props.pauseOnDecode) {
cameraReset.value = true;
}
Expand Down
2 changes: 1 addition & 1 deletion composables/useHardwareTicketScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function useHardwareTicketScanner() {
if (!value) return (ticketDetails.value = undefined);

try {
ticketDetails.value = Ticket.dataFromQRCode([value]);
ticketDetails.value = Ticket.dataFromQRCode(value);
} catch (e) {
if (e instanceof InvalidTicketQRCodeException) {
return (isInvalid.value = true);
Expand Down
5 changes: 4 additions & 1 deletion pages/box-office/[performanceId]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ watch([searchText, searchFilter], () => {
});
watch(scannedCode, async (newValue) => {
// Handles QR code scanning with physical scanners
// Mobile scanning is handled by the UiInputTicketScanner component
// If the newly scaned code is undefined (i.e. telling us a new code is about to be scanned) reset the state
if (!newValue) {
setCheckInState();
Expand All @@ -149,7 +152,7 @@ watch(scannedCode, async (newValue) => {
try {
// Convert the scanned text into ticket data
const ticketDetails = Ticket.dataFromQRCode([newValue]);
const ticketDetails = Ticket.dataFromQRCode(newValue);
// Do the scan action as appropriate
let state = await handleTicketScan(
Expand Down
8 changes: 1 addition & 7 deletions tests/unit/classes/Ticket.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,7 @@ describe('Ticket Class', () => {
});

it('can get data from a QR code', () => {
expect(
Ticket.dataFromQRCode([
{
rawValue: 'WyJhYmNkMTIzNCIsMl0='
}
])
).to.include({
expect(Ticket.dataFromQRCode('WyJhYmNkMTIzNCIsMl0=')).to.include({
bookingReference: 'abcd1234',
ticketId: 2
});
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5968,10 +5968,10 @@ [email protected]:
dependencies:
tslib "^2.4.0"

cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
cross-spawn@^7.0.0, cross-spawn@^7.0.3, cross-spawn@^7.0.5:
version "7.0.6"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f"
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"
Expand Down

0 comments on commit f622a75

Please sign in to comment.