Skip to content

Commit

Permalink
updates checkin page
Browse files Browse the repository at this point in the history
  • Loading branch information
xwilson03 committed Aug 5, 2024
1 parent 5e8c1e6 commit 1cb2689
Showing 1 changed file with 9 additions and 34 deletions.
43 changes: 9 additions & 34 deletions apps/web/src/app/admin/check-in/page.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,32 @@
import CheckinScanner from "@/components/admin/scanner/CheckinScanner";
import FullScreenMessage from "@/components/shared/FullScreenMessage";
import { db } from "db";
import { eq, and } from "db/drizzle";
import { events, users, scans } from "db/schema";
import { eq } from "db/drizzle";
import { userCommonData } from "db/schema";

export default async function Page({
searchParams,
}: {
searchParams: { [key: string]: string | undefined };
}) {
// TODO: maybe move event existant check into a layout so it holds state?

// if (!params || !params.id || isNaN(parseInt(params.id))) {
// return (
// <FullScreenMessage
// title={"Invalid ID"}
// message={"The Event ID in the URL is invalid."}
// />
// );
// }

// const event = await db.query.events.findFirst({
// where: eq(events.id, parseInt(params.id)),
// });

// if (!event) {
// return (
// <FullScreenMessage
// title={"Invalid ID"}
// message={"The Event ID in the URL is invalid."}
// />
// );
// }

// Returns only if search params exist
if (searchParams.user) {
const [isChecked, scanUser, hasRSVPed] = await db.transaction(
async (tx) => {
const scanUser = await tx.query.users.findFirst({
where: eq(users.clerkID, searchParams.user ?? "unknown"),
const scanUser = await tx.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, searchParams.user ?? "unknown"),
});
if (!scanUser) {
return [null, null, null];
}
const scan = await tx
.select({
isChecked: users.checkedIn,
hasRSVPed: users.rsvp,
checkinTimestamp: userCommonData.checkinTimestamp,
hasRSVPed: userCommonData.isRSVPed,
})
.from(users)
.where(eq(users.clerkID, searchParams.user!));
.from(userCommonData)
.where(eq(userCommonData.clerkID, searchParams.user!));
if (scan) {
return [scan[0].isChecked, scanUser, scan[0].hasRSVPed];
return [scan[0].checkinTimestamp != null, scanUser, scan[0].hasRSVPed];
} else {
return [null, scanUser, null];
}
Expand Down

0 comments on commit 1cb2689

Please sign in to comment.