Skip to content

Commit

Permalink
reruns formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
xwilson03 committed Aug 15, 2024
1 parent 2179bdb commit fc1e67a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 62 deletions.
96 changes: 48 additions & 48 deletions apps/web/src/app/admin/scanner/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,55 +36,55 @@ export default async function Page({
}

if (!searchParams.user) {
return (
<div>
<PassScanner
event={event}
hasScanned={false}
scan={null}
scanUser={null}
/>
</div>
);
}

const [scan, scanUser] = await db.transaction(async (tx) => {
const scanUser = await tx.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, searchParams.user!),
with: {
hackerData: {
with: {
team: true,
},
},
},
});
if (!scanUser) {
return [null, null];
}
const scan = await tx.query.scans.findFirst({
where: and(
eq(scans.eventID, event.id),
eq(scans.userID, scanUser.clerkID),
),
});
if (scan) {
return [scan, scanUser];
} else {
return [null, scanUser];
}
});
return (
<div>
<PassScanner
event={event}
hasScanned={false}
scan={null}
scanUser={null}
/>
</div>
);
}

return (
<div>
<PassScanner
event={event}
hasScanned={true}
scan={scan}
scanUser={scanUser}
/>
</div>
);
const [scan, scanUser] = await db.transaction(async (tx) => {
const scanUser = await tx.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, searchParams.user!),
with: {
hackerData: {
with: {
team: true,
},
},
},
});
if (!scanUser) {
return [null, null];
}
const scan = await tx.query.scans.findFirst({
where: and(
eq(scans.eventID, event.id),
eq(scans.userID, scanUser.clerkID),
),
});
if (scan) {
return [scan, scanUser];
} else {
return [null, scanUser];
}
});

return (
<div>
<PassScanner
event={event}
hasScanned={true}
scan={scan}
scanUser={scanUser}
/>
</div>
);
}

export const runtime = "edge";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/admin/export/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function GET() {
...user,
...user.hackerData,
};
delete toRet.hackerData;
delete toRet.hackerData;
return toRet;
});

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/team/create/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function POST(req: Request) {
});
await tx
.update(userHackerData)
.set({teamID})
.set({ teamID })
.where(eq(userHackerData.clerkID, userId));
});
return NextResponse.json({
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/team/invite/accept/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function POST(
.update(userHackerData)
.set({ teamID: user.invites[0].teamID })
.where(eq(userHackerData.clerkID, userId));

// TODO: would be interesting to see if the and() could be removed here in favor of directly looking up the composite key.
await db
.update(invites)
Expand Down
24 changes: 13 additions & 11 deletions apps/web/src/components/admin/users/ServerSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,23 @@ export function ProfileInfo({ user }: { user: UserWithAllData }) {
}

export async function AccountInfo({ user }: { user: UserWithAllData }) {
const clerkUser = await clerkClient.users.getUser(user.clerkID).catch(() => {});
const clerkUser = await clerkClient.users
.getUser(user.clerkID)
.catch(() => {});

return (
<UserInfoSection title="Account Info">
<div className="flex flex-wrap gap-x-10 gap-y-5">
{ clerkUser ?
<>
<Cell title="Email" value={user.email} />
<Cell title="Clerk ID" value={user.clerkID} />
</>
:
<div className="text-yellow-500">
Failed to find Clerk authentication data.
</div>
}
{clerkUser ? (
<>
<Cell title="Email" value={user.email} />
<Cell title="Clerk ID" value={user.clerkID} />
</>
) : (
<div className="text-yellow-500">
Failed to find Clerk authentication data.
</div>
)}
</div>
</UserInfoSection>
);
Expand Down

0 comments on commit fc1e67a

Please sign in to comment.