Skip to content

Commit

Permalink
Merge branch 'liam-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lermatroid committed Feb 23, 2024
2 parents e3bd228 + d53f1b7 commit 66305c9
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 111 deletions.
9 changes: 9 additions & 0 deletions apps/web/src/actions/admin/registration-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ export const toggleSecretRegistrationEnabled = adminAction(
return { success: true, statusSet: enabled };
}
);

export const toggleRSVPs = adminAction(
defaultRegistrationToggleSchema,
async ({ enabled }, { user, userId }) => {
await kv.set("config:registration:allowRSVPs", enabled);
revalidatePath("/admin/toggles/registration");
return { success: true, statusSet: enabled };
}
);
2 changes: 1 addition & 1 deletion apps/web/src/app/admin/toggles/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function Layout({ children }: ToggleLayoutProps) {
<ToggleItem name="Toggles" path="/admin/toggles" />
<ToggleItem name="Landing Page" path="/admin/toggles/landing" />
<ToggleItem name="Tickets" path="/admin/toggles/tickets" />
<ToggleItem name="Registration" path="/admin/toggles/registration" />
<ToggleItem name="Registration & RSVP" path="/admin/toggles/registration" />
<ToggleItem name="User Dashboard" path="/admin/toggles/dashboard" />
</div>
<div className="col-span-4">{children}</div>
Expand Down
14 changes: 9 additions & 5 deletions apps/web/src/app/admin/toggles/registration/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ export default async function Page() {
pipe.get("config:registration:secretRegistrationEnabled");
// const result = await pipe.exec();

const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled]: (string | null)[] =
await kv.mget(
"config:registration:registrationEnabled",
"config:registration:secretRegistrationEnabled"
);
const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled, defaultRSVPsEnabled]: (
| string
| null
)[] = await kv.mget(
"config:registration:registrationEnabled",
"config:registration:secretRegistrationEnabled",
"config:registration:allowRSVPs"
);

return (
<div>
Expand All @@ -25,6 +28,7 @@ export default async function Page() {
defaultSecretRegistrationEnabled,
false
)}
defaultRSVPsEnabled={parseRedisBoolean(defaultRSVPsEnabled, true)}
/>
</div>
);
Expand Down
135 changes: 64 additions & 71 deletions apps/web/src/app/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,86 +12,79 @@ import { parseRedisBoolean } from "@/lib/utils/server/redis";
import { Button } from "@/components/shadcn/ui/button";

export default async function Page() {
const { userId } = auth();
const { userId } = auth();

if (!userId) return redirect("/sign-up");
if (!userId) return redirect("/sign-up");

const user = await currentUser();
const user = await currentUser();

if (!user) return redirect("/sign-up");
if (!user) return redirect("/sign-up");

const registration = await db.query.users.findFirst({
where: eq(users.clerkID, user.id),
});
const registration = await db.query.users.findFirst({
where: eq(users.clerkID, user.id),
});

if (registration) {
return redirect("/dash");
}
if (registration) {
return redirect("/dash");
}

const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled]: (
| string
| null
)[] = await kv.mget(
"config:registration:registrationEnabled",
"config:registration:secretRegistrationEnabled"
);
const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled]: (string | null)[] =
await kv.mget(
"config:registration:registrationEnabled",
"config:registration:secretRegistrationEnabled"
);

if (parseRedisBoolean(defaultRegistrationEnabled, true) === true) {
return (
<>
<Navbar />
<main className="dark:bg-zinc-950">
<div className="mx-auto min-h-screen max-w-5xl pb-10 pt-[20vh] font-sans dark:text-white px-5">
<h1 className="md:text-8xl text-6xl font-black">Register</h1>
<p className="mt-5 font-medium">
<span className="font-bold">Welcome Hacker!</span> Please fill out
the form below to complete your registration for {c.hackathonName}
.
</p>
<p className="pt-5 pb-10 text-xs">
Psttt... Running into a issue? Please let us know on{" "}
<Link className="underline" href={c.links.discord}>
Discord
</Link>
!
</p>
<RegisterForm
defaultEmail={user.emailAddresses[0]?.emailAddress || ""}
/>
</div>
</main>
</>
);
}
if (parseRedisBoolean(defaultRegistrationEnabled, true) === true) {
return (
<>
<Navbar />
<main className="dark:bg-zinc-950">
<div className="mx-auto min-h-screen max-w-5xl pb-10 pt-[20vh] font-sans dark:text-white px-5">
<h1 className="md:text-8xl text-6xl font-black">Register</h1>
<p className="mt-5 font-medium">
<span className="font-bold">Welcome Hacker!</span> Please fill out the form below to
complete your registration for {c.hackathonName}.
</p>
<p className="pt-5 pb-10 text-xs">
Psttt... Running into a issue? Please let us know on{" "}
<Link className="underline" href={c.links.discord}>
Discord
</Link>
!
</p>
<RegisterForm defaultEmail={user.emailAddresses[0]?.emailAddress || ""} />
</div>
</main>
</>
);
}

return (
<main className="flex flex-col min-h-screen items-center justify-center px-2">
<div className="fixed left-1/2 top-[calc(50%+7rem)] overflow-x-hidden h-[40vh] w-[800px] max-w-screen -translate-x-1/2 -translate-y-1/2 scale-150 bg-hackathon opacity-30 blur-[100px] will-change-transform" />
<h2 className="text-4xl font-extrabold">{c.hackathonName}</h2>
<h1 className="text-6xl md:text-8xl pb-5 mb-10 font-extrabold text-hackathon dark:text-transparent dark:bg-gradient-to-t dark:from-hackathon/80 dark:to-white dark:bg-clip-text">
Registration
</h1>
<div className="w-full max-w-[500px] flex gap-y-4 flex-col justify-center items-center px-5 dark:bg-white/[0.08] bg-white backdrop-blur transition rounded-xl aspect-video relative z-10 ">
<h2 className="font-black text-2xl">
Registration Is Currently Closed
</h2>
<p className="text-center font-bold">
If you believe this is a mistake or have any questions, feel free to
reach out to us at {c.issueEmail}!
</p>
return (
<main className="flex flex-col min-h-screen items-center justify-center px-2">
<div className="fixed left-1/2 top-[calc(50%+7rem)] overflow-x-hidden h-[40vh] w-[800px] max-w-screen -translate-x-1/2 -translate-y-1/2 scale-150 bg-hackathon opacity-30 blur-[100px] will-change-transform" />
<h2 className="text-4xl font-extrabold">{c.hackathonName}</h2>
<h1 className="text-6xl md:text-8xl pb-5 mb-10 font-extrabold text-hackathon dark:text-transparent dark:bg-gradient-to-t dark:from-hackathon/80 dark:to-white dark:bg-clip-text">
Registration
</h1>
<div className="w-full max-w-[500px] flex gap-y-4 flex-col justify-center items-center px-5 dark:bg-white/[0.08] bg-white backdrop-blur transition rounded-xl aspect-video relative z-10 ">
<h2 className="font-black text-2xl">Registration Is Currently Closed</h2>
<p className="text-center font-bold">
If you believe this is a mistake or have any questions, feel free to reach out to us at{" "}
{c.issueEmail}!
</p>

<Link href={"/"}>
<Button>Return Home</Button>
</Link>
<p className="text-sm absolute bottom-0 text-center pb-2">
Already registered?{" "}
<Link className="underline" href={"/sign-in"}>
Sign-in.
</Link>
</p>
</div>
</main>
);
<Link href={"/"}>
<Button>Return Home</Button>
</Link>
<p className="text-sm absolute bottom-0 text-center pb-2">
Already registered?
<Link className="underline" href={"/sign-in"}>
Sign-in.
</Link>
</p>
</div>
</main>
);
}

export const runtime = "edge";
61 changes: 53 additions & 8 deletions apps/web/src/app/rsvp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import { db } from "db";
import { eq } from "db/drizzle";
import { users } from "db/schema";
import ClientToast from "@/components/shared/ClientToast";
import { SignedOut, RedirectToSignIn } from "@clerk/nextjs";
import { kv } from "@vercel/kv";
import { parseRedisBoolean } from "@/lib/utils/server/redis";
import Link from "next/link";
import { Button } from "@/components/shadcn/ui/button";
import { CheckCircleIcon } from "lucide-react";

export default async function RsvpPage({
searchParams,
Expand All @@ -15,30 +21,69 @@ export default async function RsvpPage({
const { userId } = auth();

if (!userId) {
return redirect("/");
console.error("No user id");
return (
<SignedOut>
<RedirectToSignIn afterSignInUrl={"/rsvp"} />
</SignedOut>
);
}

const user = await db.query.users.findFirst({
where: eq(users.clerkID, userId),
});

if (!user) {
return <div>loading...</div>;
return redirect("/register");
}

return (
<>
<ClientToast />
const rsvpEnabled = await kv.get("config:registration:allowRSVPs");

// TODO: fix type jank here
if (
parseRedisBoolean(rsvpEnabled as string | boolean | null | undefined, true) === true ||
user.rsvp === true
) {
return (
<>
<ClientToast />
<main className="max-w-5xl min-h-screen mx-auto w-full flex flex-col items-center justify-center">
<div className="fixed left-1/2 top-[calc(50%+7rem)] overflow-x-hidden h-[40vh] w-[800px] max-w-screen -translate-x-1/2 -translate-y-1/2 scale-150 bg-hackathon opacity-30 blur-[100px] will-change-transform"></div>
<h2 className="text-4xl font-extrabold">{c.hackathonName}</h2>
<h1 className="text-6xl md:text-8xl mb-10 font-extrabold text-hackathon dark:text-transparent dark:bg-gradient-to-t dark:from-hackathon/80 dark:to-white dark:bg-clip-text">
RSVP
</h1>
<ConfirmDialogue hasRsvped={user.rsvp} />
</main>
</>
);
} else {
return (
<main className="max-w-5xl min-h-screen mx-auto w-full flex flex-col items-center justify-center">
<div className="fixed left-1/2 top-[calc(50%+7rem)] overflow-x-hidden h-[40vh] w-[800px] max-w-screen -translate-x-1/2 -translate-y-1/2 scale-150 bg-hackathon opacity-30 blur-[100px] will-change-transform"></div>
<h2 className="text-4xl font-extrabold">{c.hackathonName}</h2>
<h1 className="text-6xl md:text-8xl mb-10 font-extrabold text-hackathon dark:text-transparent dark:bg-gradient-to-t dark:from-hackathon/80 dark:to-white dark:bg-clip-text">
RSVP
</h1>
<ConfirmDialogue hasRsvped={user.rsvp} />
<div className="w-full max-w-[500px] aspect-video relative dark:bg-white/[0.08] bg-white backdrop-blur transition rounded-xl p-5 flex flex-col items-center justify-center">
<h1 className="flex items-center gap-x-2 font-bold text-2xl text-red-500 text-center">
RSVPs Are Currently Closed
</h1>
<p className="pt-5 pb-10 text-center">
We have currently reached capacity for RSVPs. However, we still encourage you to show up
for walk-ins! If you have any questions or concerns, feel free to ask on{" "}
<Link href={c.links.discord} className="underline">
Discord
</Link>{" "}
or email us at {c.issueEmail}!
</p>
<Link href={"/dash"}>
<Button>Go To Dashboard</Button>
</Link>
</div>
</main>
</>
);
);
}
}

export const runtime = "edge";
Loading

0 comments on commit 66305c9

Please sign in to comment.