+ Applications for {hackathon.displayName} open on {applicationOpen}. +
++ Check back then to submit your hacker application. +
++ Applications for {hackathon.displayName} are closed. +
++ Existing applicants can still view their application status here. +
+Register for {hackathon.displayName} today!
- Your dashboard will show your current application status. + Your hackathon dashboard will show your current + application status.
Stay on the lookout for the next one by joining our{" "} diff --git a/apps/blade/src/app/hacker/application/[hackathon-id]/page.tsx b/apps/blade/src/app/hacker/application/[hackathon-id]/page.tsx index bbba1cc54..bdb42dfe7 100644 --- a/apps/blade/src/app/hacker/application/[hackathon-id]/page.tsx +++ b/apps/blade/src/app/hacker/application/[hackathon-id]/page.tsx @@ -51,7 +51,7 @@ export default async function HackerApplicationPage(props: { }); if (isHacker != null) { - return redirect("/dashboard"); + return redirect(`/hackathon/${params["hackathon-id"]}`); } } catch { return redirect("/dashboard"); diff --git a/packages/api/src/routers/hackathon.ts b/packages/api/src/routers/hackathon.ts index d83d80a8a..08eb58ccb 100644 --- a/packages/api/src/routers/hackathon.ts +++ b/packages/api/src/routers/hackathon.ts @@ -139,8 +139,15 @@ export const hackathonRouter = { getCurrentHackathon: publicProcedure.query(async () => { const now = new Date(); const hackathon = await db.query.Hackathon.findFirst({ - orderBy: (t, { asc }) => asc(t.endDate), - where: and(lte(Hackathon.startDate, now), gte(Hackathon.endDate, now)), + orderBy: (t, { asc }) => [ + asc(t.applicationOpen), + asc(t.startDate), + asc(t.endDate), + ], + where: and( + lte(Hackathon.applicationOpen, now), + gte(Hackathon.endDate, now), + ), }); return hackathon ?? null; diff --git a/packages/api/src/routers/hackers/queries.ts b/packages/api/src/routers/hackers/queries.ts index ffca18b8a..bf99ba031 100644 --- a/packages/api/src/routers/hackers/queries.ts +++ b/packages/api/src/routers/hackers/queries.ts @@ -28,14 +28,19 @@ export const hackerQueryRouter = { }); } } else { - // If not provided, grab a FUTURE hackathon with a start date CLOSEST to now + // Match the participant lifecycle used by getCurrentHackathon. const now = new Date(); - const futureHackathons = await db.query.Hackathon.findMany({ - where: (t, { gt }) => gt(t.endDate, now), - orderBy: (t, { asc }) => [asc(t.startDate)], + const currentHackathons = await db.query.Hackathon.findMany({ + where: (t, { and, gte, lte }) => + and(lte(t.applicationOpen, now), gte(t.endDate, now)), + orderBy: (t, { asc }) => [ + asc(t.applicationOpen), + asc(t.startDate), + asc(t.endDate), + ], limit: 1, }); - hackathon = futureHackathons[0]; + hackathon = currentHackathons[0]; if (!hackathon) { return null;