Skip to content

Commit 85bd265

Browse files
First instance of upgrading QR scanner (#159)
1 parent 45177d1 commit 85bd265

File tree

4 files changed

+63
-46
lines changed

4 files changed

+63
-46
lines changed

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@vercel/blob": "^0.10.0",
4343
"@vercel/kv": "^2.0.0",
4444
"@vercel/postgres": "^0.9.0",
45-
"@yudiel/react-qr-scanner": "^1.1.9",
45+
"@yudiel/react-qr-scanner": "^2.1.0",
4646
"autoprefixer": "10.4.19",
4747
"axios": "^1.7.2",
4848
"class-variance-authority": "^0.7.0",

apps/web/src/components/admin/scanner/CheckinScanner.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useState, useEffect } from "react";
4-
import { QrScanner } from "@yudiel/react-qr-scanner";
4+
import { Scanner } from "@yudiel/react-qr-scanner";
55
import superjson from "superjson";
66
import { checkInUserToHackathon } from "@/actions/admin/scanner-admin-actions";
77
import { type QRDataInterface } from "@/lib/utils/shared/qr";
@@ -130,16 +130,16 @@ export default function CheckinScanner({
130130
<div className="flex h-dvh flex-col items-center justify-center pt-32">
131131
<div className="flex w-screen flex-col items-center justify-center gap-5">
132132
<div className="mx-auto aspect-square w-screen max-w-[500px] overflow-hidden">
133-
<QrScanner
134-
onDecode={(result) => {
133+
<Scanner
134+
onScan={(result) => {
135135
const params = new URLSearchParams(
136136
searchParams.toString(),
137137
);
138138
if (!params.has("user")) {
139139
setScanLoading(true);
140140
const qrParsedData =
141141
superjson.parse<QRDataInterface>(
142-
result,
142+
result[0].rawValue,
143143
);
144144
params.set("user", qrParsedData.userID);
145145
params.set(
@@ -153,11 +153,13 @@ export default function CheckinScanner({
153153
);
154154
}
155155
}}
156-
onError={(error) => console.log(error?.message)}
157-
containerStyle={{
158-
width: "100vw",
159-
maxWidth: "500px",
160-
margin: "0",
156+
onError={(error) => console.log(error)}
157+
styles={{
158+
container: {
159+
width: "100vw",
160+
maxWidth: "500px",
161+
margin: "0",
162+
},
161163
}}
162164
/>
163165
</div>

apps/web/src/components/admin/scanner/PassScanner.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useState, useEffect } from "react";
4-
import { QrScanner } from "@yudiel/react-qr-scanner";
4+
import { Scanner } from "@yudiel/react-qr-scanner";
55
import superjson from "superjson";
66
import { createScan } from "@/actions/admin/scanner-admin-actions";
77
import { useAction } from "next-safe-action/hooks";
@@ -99,16 +99,16 @@ export default function PassScanner({
9999
<div className="flex h-dvh flex-col items-center justify-center pt-32">
100100
<div className="flex w-screen flex-col items-center justify-center gap-5">
101101
<div className="mx-auto aspect-square w-screen max-w-[500px] overflow-hidden">
102-
<QrScanner
103-
onDecode={(result) => {
102+
<Scanner
103+
onScan={(result) => {
104104
const params = new URLSearchParams(
105105
searchParams.toString(),
106106
);
107107
if (!params.has("user")) {
108108
setScanLoading(true);
109109
const qrParsedData =
110110
superjson.parse<QRDataInterface>(
111-
result,
111+
result[0].rawValue,
112112
);
113113
params.set("user", qrParsedData.userID);
114114
params.set(
@@ -122,11 +122,13 @@ export default function PassScanner({
122122
);
123123
}
124124
}}
125-
onError={(error) => console.log(error?.message)}
126-
containerStyle={{
127-
width: "100vw",
128-
maxWidth: "500px",
129-
margin: "0",
125+
onError={(error) => console.log(error)}
126+
styles={{
127+
container: {
128+
width: "100vw",
129+
maxWidth: "500px",
130+
margin: "0",
131+
},
130132
}}
131133
/>
132134
</div>

pnpm-lock.yaml

Lines changed: 40 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)