Skip to content

Commit

Permalink
runs formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
xwilson03 committed Aug 7, 2024
1 parent 209e243 commit 0dff0ea
Show file tree
Hide file tree
Showing 20 changed files with 193 additions and 188 deletions.
2 changes: 1 addition & 1 deletion apps/bot/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ app.post("/api/checkDiscordVerification", async (h) => {
console.log("got here 2");
const user = await db.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, verification.clerkID),
with: { hackerData: true }
with: { hackerData: true },
});
console.log("got here 2 with user", user);
if (!user) {
Expand Down
17 changes: 7 additions & 10 deletions apps/web/src/actions/admin/scanner-admin-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,10 @@ export const getScan = adminAction(
},
);

export const checkInUser = adminAction(
z.string(),
async (user) => {
// Set checkinTimestamp
return await db
.update(userCommonData)
.set({ checkinTimestamp: sql`now()` })
.where(eq(userCommonData.clerkID, user));
},
);
export const checkInUser = adminAction(z.string(), async (user) => {
// Set checkinTimestamp
return await db
.update(userCommonData)
.set({ checkinTimestamp: sql`now()` })
.where(eq(userCommonData.clerkID, user));
});
13 changes: 8 additions & 5 deletions apps/web/src/actions/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export const leaveTeam = authenticatedAction(
throw new Error("User not found");
}

if (user.hackerData.teamID === null || user.hackerData.teamID === undefined) {
if (
user.hackerData.teamID === null ||
user.hackerData.teamID === undefined
) {
revalidatePath("/dash/team");
return {
success: false,
Expand All @@ -38,10 +41,10 @@ export const leaveTeam = authenticatedAction(
where: eq(teams.id, user.hackerData.teamID as string), // Added null check for user.hackerData.teamID. Converted to string since TS does not realise for some reason that we checked above.
with: {
members: {
with: {
commonData: true
}
}
with: {
commonData: true,
},
},
},
});

Expand Down
93 changes: 50 additions & 43 deletions apps/web/src/app/admin/check-in/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,60 @@ export default async function Page({
}: {
searchParams: { [key: string]: string | undefined };
}) {
// Check for missing searchParams
// Check for missing searchParams
if (!searchParams.user) {
return (
<div>
<CheckinScanner
hasScanned={false}
checkedIn={null}
scanUser={null}
hasRSVP={null}
/>
</div>
);
return (
<div>
<CheckinScanner
hasScanned={false}
checkedIn={null}
scanUser={null}
hasRSVP={null}
/>
</div>
);
}

const [isChecked, scanUser, hasRSVPed] = await db.transaction(
async (tx) => {
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({
checkinTimestamp: userCommonData.checkinTimestamp,
hasRSVPed: userCommonData.isRSVPed,
})
.from(userCommonData)
.where(eq(userCommonData.clerkID, searchParams.user!));
if (scan) {
return [scan[0].checkinTimestamp != null, scanUser, scan[0].hasRSVPed];
} else {
return [null, scanUser, null];
}
},
);
const [isChecked, scanUser, hasRSVPed] = await db.transaction(
async (tx) => {
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({
checkinTimestamp: userCommonData.checkinTimestamp,
hasRSVPed: userCommonData.isRSVPed,
})
.from(userCommonData)
.where(eq(userCommonData.clerkID, searchParams.user!));
if (scan) {
return [
scan[0].checkinTimestamp != null,
scanUser,
scan[0].hasRSVPed,
];
} else {
return [null, scanUser, null];
}
},
);

return (
<div>
<CheckinScanner
checkedIn={isChecked}
hasScanned={true}
scanUser={scanUser}
hasRSVP={hasRSVPed}
/>
</div>
);
return (
<div>
<CheckinScanner
checkedIn={isChecked}
hasScanned={true}
scanUser={scanUser}
hasRSVP={hasRSVPed}
/>
</div>
);
}

export const runtime = "edge";
Expand Down
14 changes: 7 additions & 7 deletions apps/web/src/app/admin/scanner/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export default async function Page({
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
}
}
}
with: {
hackerData: {
with: {
team: true,
},
},
},
});
if (!scanUser) {
return [null, null];
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/admin/users/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async function Page({ params }: { params: { slug: string } }) {

const user = await db.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, params.slug),
with: { hackerData: {with: { team: true}} },
with: { hackerData: { with: { team: true } } },
});

if (!user) {
Expand Down
20 changes: 10 additions & 10 deletions apps/web/src/app/api/registration/create/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ export async function POST(req: Request) {
lastName: body.lastName,
email: body.email,
hackerTag: body.hackerTag.toLowerCase(),
age: body.age,
gender: body.gender,
race: body.race,
ethnicity: body.ethnicity,
shirtSize: body.shirtSize,
dietRestrictions: body.dietaryRestrictions,
accommodationNote: body.accommodationNote || null,
age: body.age,
gender: body.gender,
race: body.race,
ethnicity: body.ethnicity,
shirtSize: body.shirtSize,
dietRestrictions: body.dietaryRestrictions,
accommodationNote: body.accommodationNote || null,
discord: body.profileDiscordName,
pronouns: body.pronouns,
bio: body.bio,
Expand All @@ -109,9 +109,9 @@ export async function POST(req: Request) {
isFullyRegistered: true,
isSearchable: body.profileIsSearchable,
});

await tx.insert(userHackerData).values({
clerkID: user.id,
clerkID: user.id,
university: body.university,
major: body.major,
schoolID: body.schoolID,
Expand All @@ -123,7 +123,7 @@ export async function POST(req: Request) {
LinkedIn: body.linkedin,
PersonalWebsite: body.personalWebsite,
resume: body.resume,
group: totalUserCount[0].count % Object.keys(c.groups).length,
group: totalUserCount[0].count % Object.keys(c.groups).length,
hasAcceptedMLHCoC: body.hasAcceptedMLHCoC,
hasSharedDataWithMLH: body.hasSharedDataWithMLH,
isEmailable: body.isEmailable,
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 @@ -14,7 +14,7 @@ export async function POST(req: Request) {

const user = await db.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, userId),
with: {hackerData: true}
with: { hackerData: true },
});
if (!user) return new Response("Unauthorized", { status: 401 });

Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/app/api/team/invite/create/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function POST(
if (!userId) return NextResponse.json("Unauthorized", { status: 401 });
const user = await db.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, userId),
with: { hackerData: {with: {team: true }}},
with: { hackerData: { with: { team: true } } },
});
if (!user) return NextResponse.json("Unauthorized", { status: 401 });

Expand Down Expand Up @@ -53,10 +53,10 @@ export async function POST(
where: eq(userCommonData.hackerTag, body.data.inviteeTag),
with: {
hackerData: {
with: {
team: true,
}
},
with: {
team: true,
},
},
invites: {
where: eq(invites.teamID, user.hackerData.teamID),
},
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/dash/pass/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default async function Page() {

const userDbRecord = await db.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, user.id),
with: {hackerData: true}
with: { hackerData: true },
});

if (!userDbRecord) return null;
Expand Down
40 changes: 24 additions & 16 deletions apps/web/src/app/dash/team/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ export default async function Page() {
team: true,
},
},
hackerData: {
with: {
team: {
with: {
members: {
with: {
commonData: true
}
}
},
},
}
},
hackerData: {
with: {
team: {
with: {
members: {
with: {
commonData: true,
},
},
},
},
},
},
},
});
if (!user) return null;
Expand Down Expand Up @@ -164,7 +164,8 @@ export default async function Page() {
<div className="flex h-[75px] w-[200px] items-center justify-center gap-x-2 rounded border-2 border-muted bg-zinc-900 p-2 transition-colors duration-150 hover:border-muted-foreground hover:bg-muted">
<Image
src={
member.commonData.profilePhoto
member.commonData
.profilePhoto
}
alt={`${member.commonData.hackerTag}'s Profile Photo`}
height={40}
Expand All @@ -173,11 +174,18 @@ export default async function Page() {
/>
<div>
<h3>
{member.commonData.firstName}{" "}
{
member.commonData
.firstName
}{" "}
{member.commonData.lastName}
</h3>
<h4 className="max-w-[16ch] overflow-hidden text-ellipsis whitespace-nowrap font-mono text-xs">
@{member.commonData.hackerTag}
@
{
member.commonData
.hackerTag
}
</h4>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/app/team/[tag]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export default async function Page({ params }: { params: { tag: string } }) {
/>
<div className="ml-2 space-y-1">
<p className="leading-none">
{member.commonData.firstName} {member.commonData.lastName}
{member.commonData.firstName}{" "}
{member.commonData.lastName}
</p>
<p className="font-mono text-xs leading-none text-muted-foreground">
@{member.commonData.hackerTag}
Expand Down
18 changes: 5 additions & 13 deletions apps/web/src/app/user/[tag]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export default async function ({ params }: { params: { tag: string } }) {
</Link>
)}
{user.hackerData.PersonalWebsite &&
user.hackerData.PersonalWebsite.length >
0 && (
user.hackerData.PersonalWebsite.length > 0 && (
<Link
href={
user.hackerData.PersonalWebsite.startsWith(
Expand All @@ -80,11 +79,9 @@ export default async function ({ params }: { params: { tag: string } }) {
user.hackerData.PersonalWebsite.startsWith(
"https",
)
? user.hackerData
.PersonalWebsite
? user.hackerData.PersonalWebsite
: "https://" +
user.hackerData
.PersonalWebsite
user.hackerData.PersonalWebsite
}
className="mt-3 flex items-center gap-x-2 leading-none hover:underline"
>
Expand All @@ -101,15 +98,10 @@ export default async function ({ params }: { params: { tag: string } }) {
<p>
<Balancer>{user.bio}</Balancer>
</p>
{user.skills &&
(user.skills as string[]).length > 0 ? (
{user.skills && (user.skills as string[]).length > 0 ? (
<>
<h3 className="mt-4 font-bold">Skills</h3>
<p>
{(user.skills as string[]).join(
", ",
)}
</p>
<p>{(user.skills as string[]).join(", ")}</p>
</>
) : null}
</div>
Expand Down
Loading

0 comments on commit 0dff0ea

Please sign in to comment.