Skip to content

Commit

Permalink
fix: remove hard-coded path and add NotFound in Forum
Browse files Browse the repository at this point in the history
  • Loading branch information
YHhaoareyou committed Sep 23, 2023
1 parent a2032a4 commit 4fea30d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 11 additions & 6 deletions apps/forum/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SearchTags from "./SearchTags";
import FeedBackBox from "./FeedBackBox";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import { API } from "@aws-amplify/api";
import { getUserAttr, getIdToken } from "wasedatime-ui";
import { getUserAttr, getIdToken, LoadingSpinner } from "wasedatime-ui";

const App = () => {
return (
Expand All @@ -25,6 +25,14 @@ const App = () => {

export default App;

const NotFound = () => {
const { theme } = React.useContext(ThemeContext)
const navigate = useNavigate()
useEffect(() => navigate("/"))

return <LoadingSpinner theme={theme} message="Not found! Redirecting..." />
}

const InnerApp = () => {
const { t, i18n } = useTranslation();

Expand Down Expand Up @@ -103,15 +111,12 @@ const InnerApp = () => {
element={<Board triggerRefresh={refresh} setBoard={setBoard} />}
path="forum"
/>
<Route
element={<Board triggerRefresh={refresh} setBoard={setBoard} />}
path="forum/academic"
/>
<Route
element={<Board triggerRefresh={refresh} setBoard={setBoard} />}
path="forum/:boardSlug"
/>
<Route element={<Thread />} path="forum/:boardSlug/:threadUuid" />
<Route element={<NotFound />} path="*" />
</Routes>
</div>
<div className="flex flex-col sm:w-1/5 ">
Expand All @@ -123,4 +128,4 @@ const InnerApp = () => {
</div>
</>
);
};
};
2 changes: 0 additions & 2 deletions apps/root/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ const AppRoutes = () => {
<Route element={<Redirect to="/courses/timetable" />} path="/timetable" />
<Route element={<Redirect to="/courses/syllabus" />} path="/syllabus" />
<Route element={<></>} path="/forum" />
<Route element={<></>} path="/forum/academic" />
<Route element={<></>} path="/forum/*" />
<Route element={<></>} path="/campus" />
{/* <Route element={<></>} path="/career" /> */}
<Route element={<NotFound />} path="*" />
Expand Down

0 comments on commit 4fea30d

Please sign in to comment.