Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion apps/site/src/app/(main)/apply/Hacker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const revalidate = 60;
export default async function Hacker({
searchParams,
}: {
searchParams?: {
searchParams: {
prefaceAccepted?: string;
};
}) {
Expand Down
9 changes: 6 additions & 3 deletions apps/site/src/app/(main)/guest-login/GuestLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ import getUserIdentity from "@/lib/utils/getUserIdentity";
async function GuestLogin({
searchParams,
}: {
searchParams?: {
searchParams: {
email?: string;
return_to?: string;
};
}) {
const { email, return_to } = searchParams;

const identity = await getUserIdentity();
if (identity.uid !== null) {
redirect(searchParams?.return_to ?? "/portal");
redirect(return_to ?? "/portal");
}

return (
<div className="min-h-screen flex flex-col items-center justify-center">
<h1 className="font-display text-3xl md:text-5xl mb-20">
Enter Passphrase
</h1>
<GuestLoginVerificationForm />
<GuestLoginVerificationForm email={email} return_to={return_to} />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"use client";

import { useSearchParams } from "next/navigation";
import clsx from "clsx";

import ValidatingForm from "@/lib/components/ValidatingForm/ValidatingForm";
Expand All @@ -11,17 +8,19 @@ import styles from "@/lib/components/ValidatingForm/ValidatingForm.module.scss";
const VERIFICATION_PATH = "/api/guest/verify";
const PASSPHRASE_REGEX = /\w+-\w+-\w+-\w+/;

export default function GuestLoginVerificationForm() {
const searchParams = useSearchParams();
const email = searchParams.get("email");
const return_to = searchParams.get("return_to");

export default function GuestLoginVerificationForm({
email,
return_to,
}: {
email?: string;
return_to?: string;
}) {
if (!email) {
return <p>Error: email was not provided</p>;
}

const newSearchParams = new URLSearchParams();
if (return_to !== null) {
if (return_to) {
newSearchParams.append("return_to", return_to);
}

Expand Down
8 changes: 5 additions & 3 deletions apps/site/src/app/(main)/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ import LoginForm from "./components/LoginForm";
async function Login({
searchParams,
}: {
searchParams?: {
searchParams: {
return_to?: string;
};
}) {
const { return_to } = searchParams;

const identity = await getUserIdentity();
if (identity.uid !== null) {
redirect(searchParams?.return_to ?? "/portal");
redirect(return_to ?? "/portal");
}

return (
<div className="min-h-screen flex flex-col items-center justify-center">
<h1 className="font-display text-3xl md:text-5xl mb-20">
Login to Portal
</h1>
<LoginForm return_to={searchParams?.return_to} />
<LoginForm return_to={return_to} />
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/site/src/app/(main)/mentor/Mentor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const revalidate = 60;
export default async function Mentor({
searchParams,
}: {
searchParams?: {
searchParams: {
prefaceAccepted?: string;
};
}) {
Expand Down
2 changes: 1 addition & 1 deletion apps/site/src/app/(main)/volunteer/Volunteer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const revalidate = 60;
export default async function Volunteer({
searchParams,
}: {
searchParams?: {
searchParams: {
prefaceAccepted?: string;
};
}) {
Expand Down
4 changes: 2 additions & 2 deletions apps/site/src/lib/components/forms/shared/ApplicationFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import getUserIdentity from "@/lib/utils/getUserIdentity";
export const revalidate = 60;

interface ApplicationFlowProps {
searchParams?: {
searchParams: {
prefaceAccepted?: string;
};
applicationType: "Hacker" | "Mentor" | "Volunteer";
Expand All @@ -25,7 +25,7 @@ export default async function ApplicationFlow({
applicationURL,
children,
}: ApplicationFlowProps & PropsWithChildren) {
const hasAcceptedQueryParam = searchParams?.prefaceAccepted === "true";
const hasAcceptedQueryParam = searchParams.prefaceAccepted === "true";
const identity = await getUserIdentity();

if (identity.status !== null) {
Expand Down
Loading