Skip to content

Commit

Permalink
Revert "fix: subpath removal"
Browse files Browse the repository at this point in the history
This reverts commit 2e89ef7.
  • Loading branch information
lsegg committed Oct 24, 2024
1 parent 2e89ef7 commit 74d0ef8
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 28 deletions.
22 changes: 11 additions & 11 deletions docs/assets/index-C8kJS1VA.js → docs/assets/index-VBkLQ-qs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"
/>
<script type="module" crossorigin src="./assets/index-C8kJS1VA.js"></script>
<script type="module" crossorigin src="./assets/index-VBkLQ-qs.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DgD5xdTU.css" />
</head>
<body>
Expand Down
3 changes: 2 additions & 1 deletion src/auth/pages/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const LoginPage = () => {
const navigate = useNavigate();

const handleLogin = () => {
const lastPath = localStorage.getItem("lastPath") || "/home/search";
const lastPath =
localStorage.getItem("lastPath") || "/heroes-spa/home/search";
login("Jane Doe");
navigate(lastPath, { replace: true });
};
Expand Down
5 changes: 4 additions & 1 deletion src/heroes/components/HeroCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export const HeroCard = ({
<p className="card-text">
<small className="text-muted">{first_appearance}</small>
</p>
<Link to={`/home/hero/${id}`} className="btn btn-outline-dark">
<Link
to={`/heroes-spa/home/hero/${id}`}
className="btn btn-outline-dark"
>
More info
</Link>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/heroes/pages/HeroPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const HeroPage = () => {
navigate(-1);
};

if (!hero) return <Navigate to="/home" />;
if (!hero) return <Navigate to="/heroes-spa/home" />;
return (
<div className="row mt-5">
<div className="col-4">
Expand Down
12 changes: 6 additions & 6 deletions src/router/AppRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PublicRouter } from "./PublicRouter";

const router = createHashRouter([
{
path: "/",
path: "/heroes-spa",
element: (
<PublicRouter>
<LoginPage />
Expand All @@ -17,7 +17,7 @@ const router = createHashRouter([
errorElement: <ErrorPage />,
},
{
path: "home",
path: "/heroes-spa/home",
element: (
<PrivateRouter>
<HeroesApp />
Expand All @@ -26,19 +26,19 @@ const router = createHashRouter([
errorElement: <ErrorPage />,
children: [
{
path: "marvel",
path: "/heroes-spa/home/marvel",
element: <MarvelPage />,
},
{
path: "dc",
path: "/heroes-spa/home/dc",
element: <DcPage />,
},
{
path: "search",
path: "/heroes-spa/home/search",
element: <SearchPage />,
},
{
path: "hero/:id",
path: "/heroes-spa/home/hero/:id",
element: <HeroPage />,
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/router/PrivateRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export const PrivateRouter = ({ children }) => {
const lastPath = pathname + search;
localStorage.setItem("lastPath", lastPath);

return logged ? children : <Navigate to={"/login"} />;
return logged ? children : <Navigate to={"/heroes-spa/login"} />;
};
2 changes: 1 addition & 1 deletion src/router/PublicRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { AuthContext } from "../auth";

export const PublicRouter = ({ children }) => {
const { logged } = useContext(AuthContext);
return !logged ? children : <Navigate to={"/home/search"} />;
return !logged ? children : <Navigate to={"/heroes-spa/home/search"} />;
};
10 changes: 5 additions & 5 deletions src/ui/components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export const NavBar = () => {
const navigate = useNavigate();
const handleLogout = () => {
logout();
navigate("/", { replace: true });
navigate("/heroes-spa", { replace: true });
};

return (
<nav className="navbar navbar-expand-lg navbar-dark bg-dark p-2">
<div className="container-fluid">
<Link className="navbar-brand" to="/home/search">
<Link className="navbar-brand" to="/heroes-spa/home/search">
Heroes
</Link>
<div className="collapse navbar-collapse" id="navbarNav">
Expand All @@ -22,23 +22,23 @@ export const NavBar = () => {
className={({ isActive }) =>
`nav-link ${isActive ? "active" : ""}`
}
to="marvel"
to="/heroes-spa/home/marvel"
>
Marvel
</NavLink>
<NavLink
className={({ isActive }) =>
`nav-link ${isActive ? "active" : ""}`
}
to="/home/dc"
to="/heroes-spa/home/dc"
>
DC
</NavLink>
<NavLink
className={({ isActive }) =>
`nav-link ${isActive ? "active" : ""}`
}
to="/home/search"
to="/heroes-spa/home/search"
>
Search
</NavLink>
Expand Down

0 comments on commit 74d0ef8

Please sign in to comment.