Skip to content

Commit

Permalink
support url result
Browse files Browse the repository at this point in the history
  • Loading branch information
gnehs committed Mar 2, 2024
1 parent d2dd409 commit 7462880
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/app/(game)/scanner/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Page() {
useEffect(() => {
const handleResult = async () => {
if (typeof result !== "string") return;
var boothToken = await getBoothToken(result);
let boothToken = await getBoothToken(result);
setResult(null);
if (boothToken) {
if (!playerToken) {
Expand All @@ -40,13 +40,22 @@ export default function Page() {
setShowInfo(true);
};
handleResult();
});
}, [result]);

return (
<>
<Scanner
onResult={(result) => {
setResult(result);
if (result.startsWith("http")) {
// get token from query string
const url = new URL(result);
const token = url.searchParams.get("token");
if (token) {
setResult(token);
}
} else {
setResult(result);
}
}}
/>
{showInfo && (
Expand Down

0 comments on commit 7462880

Please sign in to comment.