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

Registration quality of life additions #131

Open
wants to merge 56 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0c1f7fc
adds zod and drizzle-zod
christianhelp Sep 14, 2024
2831ceb
removes uneeded types file
christianhelp Sep 14, 2024
c921ad6
creates db zod
christianhelp Sep 20, 2024
fe8e76f
adds new registration validator
christianhelp Sep 20, 2024
6088fe3
adds new helpers
christianhelp Sep 20, 2024
b2fdb9f
chore: renames configurables
christianhelp Sep 20, 2024
69a7ce5
exports zod
christianhelp Sep 20, 2024
78a893a
adds register form to registration
christianhelp Sep 20, 2024
200ce38
Merge remote-tracking branch 'origin/dev' into feat/registration-qual…
christianhelp Sep 20, 2024
698da73
updates gender options
christianhelp Sep 20, 2024
51a6841
adds dynamic listing for all form fields
christianhelp Sep 20, 2024
791c1cd
updates regist validator
christianhelp Sep 20, 2024
56ef4a8
adds alert dialog
christianhelp Sep 23, 2024
2457df9
adds registration new configs
christianhelp Sep 23, 2024
5760825
adds new registration form
christianhelp Sep 23, 2024
749b32b
updates for configs
christianhelp Sep 23, 2024
107a27b
updates loading for registration
christianhelp Sep 23, 2024
0dcde18
adds user id to props
christianhelp Sep 23, 2024
c04e4cc
updates for config
christianhelp Sep 23, 2024
570b6f7
runs format
christianhelp Sep 23, 2024
5287623
updates registration form
christianhelp Sep 26, 2024
ec584ee
adds feedback alert
christianhelp Sep 26, 2024
d0bfdb6
updates university id regex
christianhelp Sep 26, 2024
f8dde4e
updates registration route
christianhelp Sep 26, 2024
1812221
updates creating registration
christianhelp Sep 26, 2024
c06c04a
updates registration schema
christianhelp Sep 26, 2024
f57a9ff
updates registration form
christianhelp Sep 26, 2024
b91e17d
runs formatter
christianhelp Sep 26, 2024
777d4f3
moves regex to constants
christianhelp Oct 1, 2024
6104b69
updates dietary restrictions
christianhelp Oct 5, 2024
c87ab6e
Merge remote-tracking branch 'origin/dev' into feat/registration-qual…
christianhelp Oct 5, 2024
c4ac3e7
commit for the night
christianhelp Oct 6, 2024
64d1212
adds constants
christianhelp Oct 19, 2024
ad7598a
adds register form w/ action
christianhelp Oct 19, 2024
5a5cf7d
updates
christianhelp Oct 21, 2024
85901f4
this is broken rn lol
christianhelp Nov 12, 2024
6e14cca
commits
christianhelp Dec 25, 2024
65fdb22
Merge remote-tracking branch 'origin/dev' into feat/registration-qual…
christianhelp Feb 2, 2025
08fbba6
sync with dev
christianhelp Feb 2, 2025
a8fe816
Merge remote-tracking branch 'origin/dev' into feat/registration-qual…
christianhelp Feb 2, 2025
454d3cf
adjust user schema references
christianhelp Feb 2, 2025
cffc4a8
add user registration types
christianhelp Feb 2, 2025
3a2a9f5
formatter
christianhelp Feb 2, 2025
2b6db05
removes old registration route
christianhelp Feb 2, 2025
32c5cd3
adds tabling as heard from option
christianhelp Feb 2, 2025
d39b190
fix creating registration padding
christianhelp Feb 2, 2025
2849932
adds local storage to registration
christianhelp Feb 3, 2025
ea6513b
fix resume check
christianhelp Feb 3, 2025
4adb777
update skills cap
christianhelp Feb 3, 2025
b1249d2
fixes
christianhelp Feb 3, 2025
84a20d7
update constants
christianhelp Feb 3, 2025
3cb67d7
make redirect time smaller
christianhelp Feb 4, 2025
2bd7f24
lower confirmation time
christianhelp Feb 4, 2025
e2b3557
exports popover close
christianhelp Feb 6, 2025
13e2be2
fixes small bugs
christianhelp Feb 6, 2025
b677285
lower router push time
christianhelp Feb 7, 2025
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
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@internationalized/date": "^3.5.4",
"@planetscale/database": "^1.18.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.4",
Expand Down
115 changes: 115 additions & 0 deletions apps/web/src/actions/registration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"use server";
import { authenticatedAction } from "@/lib/safe-action";
import { db, sql } from "db";
import { del } from "@vercel/blob";
import z from "zod";
import { returnValidationErrors } from "next-safe-action";
import { hackerRegistrationFormValidator } from "@/validators/shared/registration";
import { userCommonData, userHackerData } from "db/schema";
import { currentUser } from "@clerk/nextjs/server";
import c from "config";
import { DatabaseError } from "db/types";
import {
UNIQUE_KEY_CONSTRAINT_VIOLATION_CODE,
UNIQUE_KEY_MAPPER_DEFAULT_KEY,
} from "@/lib/constants";

const registerUserSchema = hackerRegistrationFormValidator;

export const registerHacker = authenticatedAction
.schema(registerUserSchema)
.action(async ({ ctx: { userId }, parsedInput }) => {
const {
resume,
hackerTag,
email,
university,
major,
schoolID,
levelOfStudy,
hackathonsAttended,
softwareExperience,
heardFrom,
GitHub,
LinkedIn,
PersonalWebsite,
hasAcceptedMLHCoC,
hasSharedDataWithMLH,
isEmailable,
...userData
} = parsedInput;

const currUser = await currentUser();
if (!currUser) {
return returnValidationErrors(z.null(), {
_errors: ["Unauthorized (No User ID)"],
});
}
const totalUserCount = await db
.select({ count: sql<number>`count(*)`.mapWith(Number) })
.from(userCommonData);

try {
await db.transaction(async (tx) => {
await tx.insert(userCommonData).values({
clerkID: userId,
hackerTag: hackerTag.toLocaleLowerCase(),
email,
...userData,
profilePhoto: currUser.imageUrl,
skills: userData.skills.map((v) => v.text.toLowerCase()),
isFullyRegistered: true,
dietRestrictions: userData.dietRestrictions,
});

await tx.insert(userHackerData).values({
clerkID: userId,
university,
major,
schoolID,
levelOfStudy,
hackathonsAttended,
softwareExperience,
heardFrom,
GitHub,
LinkedIn,
PersonalWebsite,
resume,
group:
totalUserCount[0].count % Object.keys(c.groups).length,
hasAcceptedMLHCoC,
hasSharedDataWithMLH,
isEmailable,
});
});
} catch (e) {
// Catch duplicates because they will be based off of the error code 23505
if (resume != null && resume != c.noResumeProvidedURL) {
console.log(resume);
console.log("deleting resume");
await del(resume);
}
if (
e instanceof DatabaseError &&
e.code === UNIQUE_KEY_CONSTRAINT_VIOLATION_CODE
) {
console.error(e);
const constraintKeyIndex =
e.constraint as keyof typeof c.db.uniqueKeyMapper;
return {
success: false,
message:
c.db.uniqueKeyMapper[
constraintKeyIndex ?? UNIQUE_KEY_MAPPER_DEFAULT_KEY
] ?? e.detail,
};
} else {
throw e;
}
}

return {
success: true,
message: "Registration created successfully",
};
});
130 changes: 0 additions & 130 deletions apps/web/src/app/api/registration/create/route.ts

This file was deleted.

3 changes: 1 addition & 2 deletions apps/web/src/app/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default async function Page() {
return (
<>
<Navbar />
<main className="dark:bg-zinc-950">
<main className="overflow-x-hidden dark:bg-zinc-950">
<div className="mx-auto min-h-screen max-w-5xl px-5 pb-10 pt-[20vh] font-sans dark:text-white">
<h1 className="text-6xl font-black md:text-8xl">
Register
Expand Down Expand Up @@ -63,7 +63,6 @@ export default async function Page() {
<main className="flex min-h-screen flex-col items-center justify-center px-2">
<div className="max-w-screen fixed left-1/2 top-[calc(50%+7rem)] h-[40vh] w-[800px] -translate-x-1/2 -translate-y-1/2 scale-150 overflow-x-hidden bg-hackathon opacity-30 blur-[100px] will-change-transform" />
<h2 className="text-4xl font-extrabold">{c.hackathonName}</h2>
{/* Why is this not a component? This same code is in here and insideo of sign-up */}
<h1 className="mb-10 pb-5 text-6xl font-extrabold text-hackathon dark:bg-gradient-to-t dark:from-hackathon/80 dark:to-white dark:bg-clip-text dark:text-transparent md:text-8xl">
Registration
</h1>
Expand Down
46 changes: 34 additions & 12 deletions apps/web/src/components/registration/CreatingRegistration.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
import { Bars } from "react-loader-spinner";
import { ThreeCircles } from "react-loader-spinner";
import { CircleCheckBig } from "lucide-react";

interface CreatingRegistrationProps {
hasSuccess: boolean | undefined;
isLoading: boolean;
}
export default function CreatingRegistration(props: CreatingRegistrationProps) {
const { hasSuccess, isLoading } = props;

const isLoadingState = isLoading && !hasSuccess;
const hasSuccessState = hasSuccess && isLoading;

const message = isLoadingState
? "Creating Your Registration..."
: hasSuccessState
? "Registration successfully created! Redirecting to the dashboard..."
: "Something Went Wrong. Please Try Again.";

export default function CreatingRegistration() {
return (
<main className="absolute bottom-0 left-0 z-10 flex min-h-screen w-screen flex-col items-center justify-center gap-y-20 bg-background">
<h1 className="text-3xl font-black">Creating Your Registration!</h1>
<Bars
height="80"
width="80"
color="hsl(var(--primary))"
ariaLabel="bars-loading"
wrapperStyle={{}}
wrapperClass=""
visible={true}
/>
<h1 className="w-full px-2 text-center text-3xl font-black md:px-0">
{message}
</h1>
{hasSuccessState ? (
<CircleCheckBig size={80} color="#16a34a" />
) : (
<ThreeCircles
height="80"
width="80"
color="hsl(var(--primary))"
ariaLabel="bars-loading"
wrapperStyle={{}}
wrapperClass=""
visible={true}
/>
)}
</main>
);
}
Loading