Skip to content
Merged
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
38 changes: 37 additions & 1 deletion apps/web/src/routes/_protected/events/$eventId/application.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { createFileRoute } from "@tanstack/react-router";
import { createFileRoute, useRouter } from "@tanstack/react-router";
import { ErrorBoundary } from "react-error-boundary";
import { ApplicationForm } from "@/features/Application/components/ApplicationForm";
import TablerAlertCircle from "~icons/tabler/alert-circle";
import { useEffect } from "react";
import { useEvent } from "@/features/Event/hooks/useEvent";
import { Button } from "@/components/ui/Button";

export const Route = createFileRoute("/_protected/events/$eventId/application")(
{
Expand All @@ -11,7 +13,9 @@ export const Route = createFileRoute("/_protected/events/$eventId/application")(
);

function RouteComponent() {
const router = useRouter();
const { eventId } = Route.useParams();
const event = useEvent(eventId);

// Show a confirmation dialog when the user closes the tab
useEffect(() => {
Expand All @@ -26,6 +30,38 @@ function RouteComponent() {
};
}, []);

if (event.isLoading) {
return null;
}

if (event.isError || event.error || !event.data) {
return (
<div className="w-full h-full bg-surface flex justify-center items-center gap-2 text-red-400">
<TablerAlertCircle />
<p>Something went wrong while loading event info :(</p>
</div>
);
}

if (new Date() > event.data.application_close) {
return (
<div className="max-w-xs mx-auto h-full flex flex-col justify-center items-center gap-8 text-text-secondary">
<div className="flex flex-row items-center justify-center gap-2">
<TablerAlertCircle />
<p>Applications have closed for this event...</p>
</div>

<Button
variant="secondary"
className="w-full"
onPress={() => router.navigate({ to: "/portal" })}
>
Go Back
</Button>
</div>
);
}

return (
<ErrorBoundary FallbackComponent={Fallback}>
<div className="w-full h-screen bg-white dark:bg-background">
Expand Down
Loading