chore: rename folders

This commit is contained in:
Steven
2023-06-23 11:57:15 +08:00
parent 591edfc62d
commit 4d0bdc9b97
15 changed files with 13 additions and 13 deletions

56
web/src/routers/index.tsx Normal file
View File

@ -0,0 +1,56 @@
import { createBrowserRouter, redirect } from "react-router-dom";
import { isNullorUndefined } from "../helpers/utils";
import { userService } from "../services";
import Root from "../layouts/Root";
import Auth from "../pages/Auth";
import Home from "../pages/Home";
import UserDetail from "../pages/UserDetail";
const router = createBrowserRouter([
{
path: "/user/auth",
element: <Auth />,
},
{
path: "/",
element: <Root />,
children: [
{
path: "",
element: <Home />,
loader: async () => {
try {
await userService.initialState();
} catch (error) {
// do nth
}
const { user } = userService.getState();
if (isNullorUndefined(user)) {
return redirect("/user/auth");
}
return null;
},
},
{
path: "/account",
element: <UserDetail />,
loader: async () => {
try {
await userService.initialState();
} catch (error) {
// do nth
}
const { user } = userService.getState();
if (isNullorUndefined(user)) {
return redirect("/user/auth");
}
return null;
},
},
],
},
]);
export default router;