Skip to content

Commit 7b058d6

Browse files
committed
allow switching of housing community from about menu
1 parent 731d9a0 commit 7b058d6

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

frontend/src/components/challenges/hooks/use-completion-flow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ export function useCompletionFlow({ challenge }: UseCompletionFlowProps) {
113113
setCurrentStep("commemorate");
114114
}
115115
},
116-
onError: () => {
117-
setError("Network error. Please try again.");
116+
onError: (e: { message?: string } | undefined) => {
117+
setError(e?.message || "Network error. Please try again.");
118118
setCurrentStep("commemorate");
119119
},
120120
},

frontend/src/lib/auth.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ function handleAuthSuccess(authContext: AuthContext): AuthContext {
103103

104104
if (user.dorm && window.location.pathname === "/dorm-select") {
105105
const urlParams = new URLSearchParams(window.location.search);
106-
const from = urlParams.get("from") || "/";
107-
throw redirect({ to: from });
106+
if (urlParams.get("from") !== "/about") {
107+
const from = urlParams.get("from") || "/";
108+
throw redirect({ to: from });
109+
}
108110
}
109111

110112
if (!user.dorm && window.location.pathname !== "/dorm-select") {
@@ -130,7 +132,6 @@ function handleRedirectLogic(
130132
// User is authenticated and has a dorm, redirect
131133
const urlParams = new URLSearchParams(window.location.search);
132134
const from = urlParams.get("from") || "/";
133-
134135
throw redirect({ to: from });
135136
}
136137

frontend/src/routes/_layout.about.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createFileRoute, useNavigate } from "@tanstack/react-router";
1+
import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
22
import type { ButtonHTMLAttributes } from "react";
33
import Scotty from "@/assets/about-page-scotty.svg?react";
44
import {
@@ -122,6 +122,18 @@ function About() {
122122
<AboutButton onClick={() => navigate({ to: "/terrier-trade" })}>
123123
Terrier Trade
124124
</AboutButton>
125+
126+
<AboutButton
127+
onClick={() => {
128+
const redirect =
129+
new URL("/dorm-select", window.location.origin).toString() +
130+
"?from=/about";
131+
132+
window.location.href = redirect;
133+
}}
134+
>
135+
Dorm Select
136+
</AboutButton>
125137
</div>
126138
</div>
127139
);

0 commit comments

Comments
 (0)