Rename home route to wish and create an empty home route

This commit is contained in:
memeriau 2021-12-26 18:33:12 +01:00
parent fe06b2d45c
commit 2e2442bb7a
7 changed files with 68 additions and 11 deletions

27
src/pages/Home/HomePage.tsx Executable file
View File

@ -0,0 +1,27 @@
import { FC, memo } from "react"
import { RouteComponentProps } from "react-router-dom"
import { Helmet } from "react-helmet"
import { AppThunk } from "../../store"
import styles from "./styles.module.scss"
export type Props = RouteComponentProps
const fetchUserData = () => () => Promise.resolve()
const HomePage: FC<Props> = (): JSX.Element => (
<div className={styles.homePage}>
<div className={styles.homeContent}>
<Helmet title="Home" />
<div>Tableau de bord</div>
</div>
</div>
)
// Fetch server-side data here
export const loadData = (): AppThunk[] => [
fetchUserData(),
// More pre-fetched actions...
]
export default memo(HomePage)

View File

@ -1,9 +1,9 @@
import loadable from "@loadable/component"
import { Loading, ErrorBoundary } from "../../components"
import { Props, loadData } from "./Home"
import { Props, loadData } from "./HomePage"
const Home = loadable(() => import("./Home"), {
const Home = loadable(() => import("./HomePage"), {
fallback: <Loading />,
})

View File

@ -1,3 +1,9 @@
.home {
padding: 0 15px;
@import "../../theme/mixins";
.homePage {
@include page-wrapper-center;
}
.homeContent {
@include page-content-wrapper(600px);
}

View File

@ -3,7 +3,7 @@ import { RouteComponentProps } from "react-router-dom"
import { useDispatch, useSelector, shallowEqual } from "react-redux"
import { Helmet } from "react-helmet"
import { AppState, AppThunk, EntitiesRequest } from "../../store"
import { AppDispatch, AppState, AppThunk, EntitiesRequest } from "../../store"
import { fetchJavGameListIfNeed } from "../../store/javGameList"
import { fetchWishListIfNeed } from "../../store/wishList"
import { JavGameList, WishAdd } from "../../components"
@ -34,11 +34,11 @@ function useList<Entity>(
}
}
const Home: FC<Props> = (): JSX.Element => {
const dispatch = useDispatch()
const Wish: FC<Props> = (): JSX.Element => {
const dispatch = useDispatch<AppDispatch>()
return (
<div className={styles.home}>
<Helmet title="Home" />
<div className={styles.wish}>
<Helmet title="Wish" />
<WishAdd dispatch={dispatch} />
{/* {useList((state: AppState) => state.wishList, fetchWishListifNeed)()} */}
{useList((state: AppState) => state.javGameList, fetchJavGameListIfNeed)()}
@ -56,4 +56,4 @@ export const loadData = (): AppThunk[] => [
// More pre-fetched actions...
]
export default memo(Home)
export default memo(Wish)

15
src/pages/Wish/index.tsx Executable file
View File

@ -0,0 +1,15 @@
import loadable from "@loadable/component"
import { Loading, ErrorBoundary } from "../../components"
import { Props, loadData } from "./Wish"
const Wish = loadable(() => import("./Wish"), {
fallback: <Loading />,
})
export default (props: Props): JSX.Element => (
<ErrorBoundary>
<Wish {...props} />
</ErrorBoundary>
)
export { loadData }

View File

@ -0,0 +1,3 @@
.wish {
padding: 0 15px;
}

View File

@ -2,6 +2,7 @@ import { RouteConfig } from "react-router-config"
import App from "../app"
import AsyncHome, { loadData as loadHomeData } from "../pages/Home"
import AsyncWish, { loadData as loadWishData } from "../pages/Wish"
import AsyncVolunteerPage, { loadData as loadVolunteerPageData } from "../pages/VolunteerPage"
import Login from "../pages/Login"
import Register from "../pages/Register"
@ -26,10 +27,15 @@ export default [
component: Login,
},
{
path: "/register",
path: "/home",
component: AsyncHome,
loadData: loadHomeData,
},
{
path: "/wish",
component: AsyncWish,
loadData: loadWishData,
},
{
component: NotFound,
},