Skip to content

Commit 83f024c

Browse files
Merge pull request #133 from umdevclub/feat/formRedirect
feat!: implemented form redirects
2 parents 7a01a9b + 4eb4d0c commit 83f024c

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

src/resources/data/forms.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const forms: Record<string, string> = {
2+
arewethereyet: "https://forms.gle/TZREGetDcMRtZY7G7",
3+
aurafarming: "https://www.instagram.com/reel/DMg0SvhARRN/",
4+
"councilor-applications":
5+
"https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDdQw4w9WgXcQ&start_radio=1",
6+
"awty-handbook":
7+
"https://docs.google.com/document/d/1UotSzRsbD6umpQfN0rHvS7MDXIfaHf7s1IlC7veRaVs/edit?usp=sharing",
8+
};

src/routes/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import LinkTree from "./LinkTree";
2727
import RootLayout from "./layouts/RootLayout";
2828
import PageNotFound from "./PageNotFound";
2929
import Events from "./Events";
30+
import { formRedirectLoader } from "./FormRedirect";
3031

3132
const router = createBrowserRouter(
3233
createRoutesFromElements(
@@ -66,7 +67,8 @@ const router = createBrowserRouter(
6667
path="/devhacks/2025/gallery"
6768
element={<DevHacks2025ProjectGallery />}
6869
/>
69-
<Route path="*" element={<PageNotFound />} />
70+
{/* always keep this route last, otherwise it will mess with the actual links above */}
71+
<Route path="*" loader={formRedirectLoader} element={<PageNotFound />} />
7072
</Route>
7173
)
7274
);

src/routes/FormRedirect.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { redirect } from "react-router-dom";
2+
import { forms } from "@/resources/data/forms";
3+
4+
const formsNormalized: Record<string, string> = Object.fromEntries(
5+
Object.entries(forms).map(([k, v]) => [k.toLowerCase(), v])
6+
);
7+
8+
export function formRedirectLoader({ request }: { request: Request }) {
9+
const url = new URL(request.url);
10+
const slug = url.pathname.replace(/^\/+|\/+$/g, "").toLowerCase();
11+
const target = formsNormalized[slug];
12+
if (target) return redirect(target);
13+
return null;
14+
}

src/routes/GithubUnix.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function GithubUnix() {
3131

3232
return (
3333
<div className="github-tab-container">
34-
<h1>.DevHack's Guide to Git and Github</h1>
34+
<h1>.devHack's Guide to Git and Github</h1>
3535
<Box display="flex">
3636
<aside
3737
className="github-table-of-contents"

src/routes/GithubWindows.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function GithubWindows() {
3131

3232
return (
3333
<div className="github-tab-container">
34-
<h1>.DevHack's Guide to Git and Github</h1>
34+
<h1>.devHack's Guide to Git and Github</h1>
3535
<Box display="flex">
3636
<aside
3737
className="github-table-of-contents"

src/routes/Home.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import PeopleList from "@/components/PeopleList";
1616
import {
1717
workshopImages,
1818
hackathonImages,
19-
devchampsImages,
19+
// devchampsImages,
2020
} from "@/resources/data/homepage-mission-images";
2121
import { Box, Modal } from "@mui/material";
2222

@@ -172,11 +172,11 @@ function Home() {
172172
</div>
173173
</div>
174174

175-
<div className="mission-container">
175+
{/* <div className="mission-container">
176176
<div className="mission-text-container">
177177
<span className="mission-heading">.devChamps</span>
178178
<p className="mission-content">
179-
.devChamps is a new, official two to three month project-based
179+
.devChamps is a two to three month project-based
180180
programming battle featuring a new challenge every season. The
181181
competition is designed to be approachable for beginners while
182182
also providing a challenge for experienced programmers.
@@ -188,7 +188,7 @@ function Home() {
188188
openFn={handleOpenModal}
189189
/>
190190
</div>
191-
</div>
191+
</div> */}
192192
</div>
193193

194194
<div id="join-club"></div>

0 commit comments

Comments
 (0)