From fc48b0fee2ed1c63a1ef9c583742ef07e193b950 Mon Sep 17 00:00:00 2001 From: Shawn Pradeep Date: Sat, 10 Feb 2024 08:41:01 -0500 Subject: [PATCH] styling --- projects/mybyte/pages/qrRead.tsx | 68 ++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/projects/mybyte/pages/qrRead.tsx b/projects/mybyte/pages/qrRead.tsx index 90408f0..72e7ffe 100644 --- a/projects/mybyte/pages/qrRead.tsx +++ b/projects/mybyte/pages/qrRead.tsx @@ -1,13 +1,12 @@ -import React, {useState} from "react"; +import React, { useState } from "react"; import OrganizerRoute from "../components/OrganizerRoute"; -import {useAuth} from "../context/AuthContext"; -import {QrReader} from 'react-qr-reader'; - +import { useAuth } from "../context/AuthContext"; +import { QrReader } from "react-qr-reader"; const initialUser = { name: "N/A", - shirtSize: "N/A" -} + shirtSize: "N/A", +}; export default function QrRead(props: any) { const { @@ -19,14 +18,19 @@ export default function QrRead(props: any) { getNameOfUser, getRegisteredEventsForUser, getTShirtSizeOfUser, - user_type + user_type, } = useAuth(); const [scannedUID, setScannedUID] = useState(""); const [user, setUser] = useState(initialUser); const [status, setStatus] = useState("Waiting for scan"); const selectWhich: JSX.Element = ( - @@ -49,7 +53,7 @@ export default function QrRead(props: any) { const determineAction = async (uid: string) => { let outcomeMessage = ""; - console.log(user_type) + console.log(user_type); try { if (!uid) throw "No QR Code has been scanned!"; // action state kept resetting to its default state for some reason @@ -62,16 +66,16 @@ export default function QrRead(props: any) { .getElementsByTagName("select") .namedItem("what-for")?.value; - const name = await getNameOfUser(uid) + const name = await getNameOfUser(uid); if (!name) { throw "User not found!"; } - const tShirtSize = await getTShirtSizeOfUser(uid) - setUser({name: name, shirtSize: tShirtSize}) + const tShirtSize = await getTShirtSizeOfUser(uid); + setUser({ name: name, shirtSize: tShirtSize }); outcomeMessage = `Successfully completed ${selectedOption} for ${name}`; switch (selectedOption) { case "checkin-first-day": - if (!("HACKS9" in await getRegisteredEventsForUser(uid))) { + if (!("HACKS9" in (await getRegisteredEventsForUser(uid)))) { throw `${name} is not registered for UGAHacks 9!`; } if (await isUserCheckedIn(uid)) { @@ -82,7 +86,7 @@ export default function QrRead(props: any) { outcomeMessage = `Checked in ${name}!`; break; case "checkin-other": - if (!("HACKS9" in await getRegisteredEventsForUser(uid))) { + if (!("HACKS9" in (await getRegisteredEventsForUser(uid)))) { throw `${name} is not registered for UGAHacks 9!`; } if (await isUserCheckedIn(uid)) { @@ -162,39 +166,51 @@ export default function QrRead(props: any) { } } finally { setStatus(outcomeMessage); - setScannedUID("") + setScannedUID(""); } }; return ( -
+
{ if (!result) return; - setScannedUID(result.getText()) + setScannedUID(result.getText()); }} />
- Scanned UID: {scannedUID}

+ Scanned UID: {scannedUID}

- Name: {user.name}
- Shirt Size: {user.shirtSize}
+ Name: {user.name}
+ Shirt Size: {user.shirtSize}
Previous Status: {status}
- + {selectWhich}