mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-08 08:34:20 +02:00
Remove double team list
This commit is contained in:
parent
9469a670d6
commit
e1b39f246d
@ -1,10 +1,8 @@
|
||||
import { FC, useEffect, memo } from "react"
|
||||
import { FC, memo } from "react"
|
||||
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 { Team } from "../../services/teams"
|
||||
import { AppThunk } from "../../store"
|
||||
import { fetchTeamListIfNeed } from "../../store/teamList"
|
||||
import styles from "./styles.module.scss"
|
||||
import TeamList from "../../components/Teams/TeamList"
|
||||
@ -12,52 +10,12 @@ import TeamIntro from "../../components/Teams/TeamIntro"
|
||||
|
||||
export type Props = RouteComponentProps
|
||||
|
||||
function useList(
|
||||
stateToProp: (state: AppState) => EntitiesRequest<Team>,
|
||||
fetchDataIfNeed: () => AppThunk
|
||||
) {
|
||||
const dispatch = useDispatch()
|
||||
const { ids, entities, readyStatus } = useSelector(stateToProp, shallowEqual)
|
||||
|
||||
// Fetch client-side data here
|
||||
useEffect(() => {
|
||||
dispatch(fetchDataIfNeed())
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [dispatch])
|
||||
|
||||
return () => {
|
||||
if (!readyStatus || readyStatus === "idle" || readyStatus === "request")
|
||||
return <p>Loading...</p>
|
||||
|
||||
if (readyStatus === "failure") return <p>Oops, Failed to load!</p>
|
||||
|
||||
return ids.map((id) => {
|
||||
const team = entities[id]
|
||||
return team === undefined ? null : (
|
||||
<div key={id}>
|
||||
<b>{team.name}</b>:{team.description}
|
||||
<br />
|
||||
Avant: {team.before}
|
||||
<br />
|
||||
Pendant: {team.during}
|
||||
<br />
|
||||
Après: {team.after}
|
||||
<br />
|
||||
<br />
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const TeamsPage: FC<Props> = (): JSX.Element => (
|
||||
<div className={styles.teamsPage}>
|
||||
<div className={styles.teamsContent}>
|
||||
<Helmet title="TeamsPage" />
|
||||
<TeamIntro />
|
||||
<TeamList />
|
||||
<hr />
|
||||
{useList((state: AppState) => state.teamList, fetchTeamListIfNeed)()}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user