Skip to content

Commit

Permalink
Fix navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
infhyroyage committed Apr 14, 2024
1 parent 5307b25 commit 3dbb286
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
6 changes: 5 additions & 1 deletion src/components/TestDoing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ function TestDoing({
const onClickNextQuestionButton = async () => {
if (questionNumber === getTestRes.length) {
// 結果へ遷移
navigate(`/result`);
navigate(
import.meta.env.VITE_API_URI === "http://localhost:9229"
? "/result"
: "/QuestionAnswerPortal/result"
);
} else {
// 次問題へ遷移
setSecondTranslation(INIT_2ND_TRANSLATION);
Expand Down
33 changes: 23 additions & 10 deletions src/components/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ function TopBar() {

const onClickBackspaceButton = () => {
setTopBarTitle("Question Answer Portal");
navigate("/");
navigate(
import.meta.env.VITE_API_URI === "http://localhost:9229"
? "/"
: "/QuestionAnswerPortal/"
);
};

return (
Expand All @@ -54,21 +58,30 @@ function TopBar() {
{topBarTitle}
</Typography>
<Stack direction="row" spacing={3}>
{location.pathname === "/" && <ThemeSwitch />}
{location.pathname !== "/" ? (
<Tooltip title="タイトルへ">
<IconButton onClick={onClickBackspaceButton}>
<BackspaceIcon sx={{ color: "white" }} />
</IconButton>
</Tooltip>
<ThemeSwitch />
{import.meta.env.VITE_API_URI === "http://localhost:9229" ? (
location.pathname !== "/" && (
<Tooltip title="タイトルへ">
<IconButton onClick={onClickBackspaceButton}>
<BackspaceIcon sx={{ color: "white" }} />
</IconButton>
</Tooltip>
)
) : (
import.meta.env.VITE_API_URI !== "http://localhost:9229" && (
<>
{location.pathname !== "/QuestionAnswerPortal/" && (
<Tooltip title="タイトルへ">
<IconButton onClick={onClickBackspaceButton}>
<BackspaceIcon sx={{ color: "white" }} />
</IconButton>
</Tooltip>
)}
<Tooltip title="ログアウト">
<IconButton onClick={onClickLogoutButton}>
<LogoutIcon sx={{ color: "white" }} />
</IconButton>
</Tooltip>
)
</>
)}
</Stack>
</Toolbar>
Expand Down
11 changes: 10 additions & 1 deletion src/pages/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,16 @@ export default function Result() {
return (
<Box p={2}>
<Box display="flex" justifyContent="center" alignItems="center" pb={1}>
<Button variant="contained" onClick={() => navigate("/")}>
<Button
variant="contained"
onClick={() =>
navigate(
import.meta.env.VITE_API_URI === "http://localhost:9229"
? "/"
: "/QuestionAnswerPortal/"
)
}
>
タイトルへ
</Button>
</Box>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ export default function Root() {
{getTestsRes[course].map((test: Test) => (
<ListItemButton
key={test.id}
onClick={() => navigate(`/tests/${test.id}`)}
onClick={() =>
navigate(
import.meta.env.VITE_API_URI === "http://localhost:9229"
? `/tests/${test.id}`
: `/QuestionAnswerPortal/tests/${test.id}`
)
}
>
<ListItemIcon sx={{ ml: 2 }}>
<ArticleIcon />
Expand Down

0 comments on commit 3dbb286

Please sign in to comment.