Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved scanning messages #229

Merged
merged 1 commit into from
Oct 25, 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
6 changes: 3 additions & 3 deletions app/dashboard/components/profileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default function ProfileHeader(props: {
<CardTitle>Delayed Entry</CardTitle>
<div>
<CardDescription>
You will be able to check in after 10:45am on a first come
You will be able to check in after 10:30am on a first come
first serve basis. Please be there as soon as possible to
secure your spot.
</CardDescription>
Expand All @@ -241,7 +241,7 @@ export default function ProfileHeader(props: {
<>
<CardTitle>
You are confirmed! You are guaranteed entry if you check in
between 9am to 10:45am. Afterwards, 10:45am will be check in
between 9am to 10:30am. Afterwards, 10:30am will be check in
acceptance on a first come first serve basis.
</CardTitle>
</>
Expand Down Expand Up @@ -282,7 +282,7 @@ export default function ProfileHeader(props: {
<CardTitle>
You have indicated you are coming. If your status
changes to confirmed you are guaranteed entry
between 9am and 10:45am. After 10:45am, check in
between 9am and 10:30am. After 10:30am, check in
will be first come first serve.
</CardTitle>
<Button
Expand Down
63 changes: 25 additions & 38 deletions app/dashboard/views/organizerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function ScanStatus(props: {
Scan QR to {scanType === 'CHECK IN' ? 'check in' : 'scan for an event'}
</p>
<p className="">Status: </p>
<p>{fullName && <p className="text-green-500">Scanned: {fullName}</p>}</p>
<p>{fullName && <p className="text-white">Found User: {fullName}</p>}</p>
<p className="">
{status === 'SUCCESSFUL' && (
<p className="text-green-500">Successful.</p>
Expand Down Expand Up @@ -147,32 +147,21 @@ function OrganizerView() {
setScannedName(userData.first_name + ' ' + userData.last_name);

if (scannerTab === 'CHECK IN') {
if (
userData.registration_status === 'confirmed' ||
userData.registration_status == 'checked_in' ||
userData.registration_status == 'coming' ||
(now > timeWhenAllHackersCanComeThrough &&
userData.registration_status !== 'unregistered')
) {
const resp = await SetUser(
{ registration_status: 'checked_in' },
result,
);

if (resp.error !== '') {
setStatus('FAILED');
setScanResponse(
resp.error +
' : Registration Status: ' +
userData.registration_status,
);
return;
}
const resp = await SetUser({ registration_status: 'checked_in' }, result);

setStatus('SUCCESSFUL');
} else {
setStatus('PENDING');
if (!resp) {
setStatus('FAILED');
setScanResponse('Failed to check in user.');
}

if (resp.error !== '') {
setStatus('FAILED');
setScanResponse(resp.response + '; ' + resp.error);
return;
}

setScanResponse(resp.response);
setStatus('SUCCESSFUL');
} else if (scannerTab === 'EVENT') {
if (selectedEvent == '') {
alert('Please select an event first!');
Expand All @@ -193,14 +182,13 @@ function OrganizerView() {
const multipleAttendanceStatus = 409;

if (resp.status == multipleAttendanceStatus && !forceAttendance) {
console.log('HI');
setShowForceAttendance(true);
return;
}

if (resp.error !== '') {
setStatus('FAILED');
setScanResponse(resp.error);
setScanResponse(resp.error + '; ' + resp.response);
return;
}

Expand Down Expand Up @@ -232,7 +220,7 @@ function OrganizerView() {

if (resp.error !== '') {
setStatus('FAILED');
setScanResponse(resp.error);
setScanResponse(resp.error + '; ' + resp.response);
return;
}

Expand Down Expand Up @@ -262,7 +250,7 @@ function OrganizerView() {

if (resp.error !== '') {
setStatus('FAILED');
setScanResponse(resp.error);
setScanResponse(resp.error + '; ' + resp.response);
return;
}

Expand All @@ -289,13 +277,12 @@ function OrganizerView() {
try {
const data = await getSelf();

const domain = data.response.email.slice(-11)
setIsSponsor(domain == "sponsor.com")
if (domain == "sponsor.com"){
setScannerTab("SPONSOR")
const domain = data.response.email.slice(-11);
setIsSponsor(domain == 'sponsor.com');
if (domain == 'sponsor.com') {
setScannerTab('SPONSOR');
resetScanLog();
}

} catch (error) {
console.log(error);
}
Expand All @@ -312,12 +299,12 @@ function OrganizerView() {
<h1 className="text-center text-3xl">Organizer View</h1>

{/* Two buttons, semi-radio where one button is for the "tab". If active, darken the button */}
<div className="grid md:grid-cols-5 justify-center space-x-4">
<div className="grid justify-center space-x-4 md:grid-cols-5">
<button
disabled={isSponsor}
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${
scannerTab === 'CHECK IN' ? 'bg-blue-700' : ''
} ${isSponsor ? "bg-blue-500 hover:bg-blue-500": ""}`}
} ${isSponsor ? 'bg-blue-500 hover:bg-blue-500' : ''}`}
onClick={() => {
setScannerTab('CHECK IN');
resetScanLog();
Expand All @@ -329,7 +316,7 @@ function OrganizerView() {
disabled={isSponsor}
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${
scannerTab === 'EVENT' ? 'bg-blue-700' : ''
}${isSponsor ? "bg-blue-500 hover:bg-blue-500": ""}`}
}${isSponsor ? 'bg-blue-500 hover:bg-blue-500' : ''}`}
onClick={() => {
setScannerTab('EVENT');
resetScanLog();
Expand All @@ -341,7 +328,7 @@ function OrganizerView() {
disabled={isSponsor}
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${
scannerTab === 'MANUAL' ? 'bg-blue-700' : ''
}${isSponsor ? "bg-blue-500 hover:bg-blue-500": ""}`}
}${isSponsor ? 'bg-blue-500 hover:bg-blue-500' : ''}`}
onClick={() => {
setScannerTab('MANUAL');
resetScanLog();
Expand Down
14 changes: 6 additions & 8 deletions app/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,10 @@ export async function GetUser(email: string) {
})
.then(async (res) => {
let res_json = await res.json();
if (res.status == 200){
resp.response = res_json
}
else{
resp.error = res_json
if (res.status == 200) {
resp.response = res_json;
} else {
resp.error = res_json;
}
})
.catch((error) => {
Expand Down Expand Up @@ -299,9 +298,8 @@ export async function SetUser(data: any, user_email_to_update: string) {
} else {
resp.error = 'Unexpected Error';
}
} else {
resp.response = resJSON.message;
}
resp.response = resJSON.message;
})
.catch((error) => {
resp.error = error + '; An error occurred retrieving data';
Expand Down Expand Up @@ -654,7 +652,7 @@ export async function AttendEventScan(
if (statusCode === 404) {
error_message = `User ${scannedEmail} not found. Please try again.`;
} else if (statusCode === 409) {
error_message = `User ${scannedEmail} is already checked in to ${event}!`;
error_message = json.message;
}

if (statusCode === 200 && typeof jsonBody !== 'string') {
Expand Down
17 changes: 9 additions & 8 deletions app/ui/skeletons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Navbar from "../(pre-dashboard)/(landing)/sections/Hero/Navbar";
import Navbar from '../(pre-dashboard)/(landing)/sections/Hero/Navbar';
import { handleSignOut } from '@/app/lib/actions';
import { Button } from './button';

Expand Down Expand Up @@ -65,27 +65,28 @@ export function InvoiceSkeleton() {

export function HackerDashboardSkeleton() {
return (
<div className={`w-screen h-screen ${shimmer} relative`} >
<div className={`h-screen w-screen ${shimmer} relative`}>
<div className="flex flex-col items-center pt-[10rem] ">
<div className="text-white">Experiencing issues?</div>
<Button
className="my-2 h-8 w-24"
className="my-3 h-fit w-fit border border-white text-black hover:bg-black hover:text-white"
onClick={async () => {
await handleSignOut();
window.location.href = '/';
}}
>
Log Out
Click Here to Log Out
</Button>
<div className="h-[10rem] w-[10rem] rounded-full bg-gray-600 opacity-40" />
<div className="flex flex-col items-center gap-3 w-full h-fit mt-20">
<div className="w-[25rem] h-[10rem] rounded bg-gray-600 opacity-40" />
<div className="w-[25rem] h-[30rem] rounded bg-gray-600 opacity-40" />
<div className="mt-20 flex h-fit w-full flex-col items-center gap-3">
<div className="h-[10rem] w-[25rem] rounded bg-gray-600 opacity-40" />
<div className="h-[30rem] w-[25rem] rounded bg-gray-600 opacity-40" />
</div>
</div>
{/* <CardSkeleton />
<CardSkeleton />
<CardSkeleton /> */}
</div >
</div>
);
}

Expand Down
Loading