11import { FC , useEffect , useMemo } from "react" ;
22import { RouteComponentProps , Link } from "react-router-dom" ;
33import { TPropsFromRedux } from "./TeamsContainer" ;
4+ import EmptyState from "components/ui/EmptyState/EmptyState" ;
45import Hero from "components/layouts/Hero/Hero" ;
56import Article from "components/layouts/Article" ;
67import Loader from "components/ui/Loader" ;
7- import { FormattedMessage } from "react-intl" ;
8+ import { FormattedMessage , useIntl } from "react-intl" ;
89import TeamsListing from "components/teams-listing/TeamsListing" ;
910import Button from "components/ui/Button/Button" ;
1011import useGetUserId from "hooks/useGetUserId" ;
1112import CreateTeam from "./actions/CreateTeam" ;
1213import PlusIcon from "assets/images/icons/PlusWhite.svg" ;
14+ import EmptyStateIcon from "assets/images/icons/EmptyTeams.svg" ;
1315
1416interface IProps extends TPropsFromRedux , RouteComponentProps {
1517 isCreatingTeam : boolean ;
@@ -18,6 +20,7 @@ interface IProps extends TPropsFromRedux, RouteComponentProps {
1820const Teams : FC < IProps > = props => {
1921 const { teams, myInvites, getUserTeams, getMyTeamInvites, numOfActiveFetches, isCreatingTeam = false , match } = props ;
2022
23+ const intl = useIntl ( ) ;
2124 const userId = useGetUserId ( ) ;
2225
2326 useEffect ( ( ) => {
@@ -62,32 +65,51 @@ const Teams: FC<IProps> = props => {
6265 </ div >
6366 </ div >
6467 ) }
65- < div className = "l-content c-teams" >
66- < Article
67- className = "c-teams__heading"
68- title = "teams.managedByMe"
69- titleValues = { { num : managedTeams . length . toString ( ) } }
70- actions = {
71- < Link to = { `${ match . path } /create` } >
72- < Button variant = "primary" >
73- < img src = { PlusIcon } alt = "" role = "presentation" className = "c-button__inline-icon" />
74- < FormattedMessage id = "teams.create" />
75- </ Button >
76- </ Link >
77- }
78- >
79- < TeamsListing teams = { managedTeams } />
80- </ Article >
81- </ div >
82- < div className = "l-content l-content--neutral-400 c-teams" >
83- < Article
84- className = "c-teams__heading"
85- title = "teams.joinedByMe"
86- titleValues = { { num : joinedTeams . length . toString ( ) } }
87- >
88- < TeamsListing teams = { joinedTeams } />
89- </ Article >
90- </ div >
68+ { /* No teams are in state but fetches are being made - show nothing to the user */ }
69+ { /* No teams are in state and fetches have finished - show empty state to the user */ }
70+ { /* Teams are in state - show the teams to the user */ }
71+ { ! teams . length && numOfActiveFetches > 0 ? null : ! teams . length && numOfActiveFetches === 0 ? (
72+ < div className = "l-content l-content--neutral-400" >
73+ < div className = "row column" >
74+ < EmptyState
75+ iconUrl = { EmptyStateIcon }
76+ title = { intl . formatMessage ( { id : "teams.empty.state.title" } ) }
77+ text = { intl . formatMessage ( { id : "teams.empty.state.subTitle" } ) }
78+ ctaText = { intl . formatMessage ( { id : "teams.create" } ) }
79+ ctaTo = { `${ match . path } /create` }
80+ />
81+ </ div >
82+ </ div >
83+ ) : (
84+ < >
85+ < div className = "l-content c-teams" >
86+ < Article
87+ className = "c-teams__heading"
88+ title = "teams.managedByMe"
89+ titleValues = { { num : managedTeams . length . toString ( ) } }
90+ actions = {
91+ < Link to = { `${ match . path } /create` } >
92+ < Button variant = "primary" >
93+ < img src = { PlusIcon } alt = "" role = "presentation" className = "c-button__inline-icon" />
94+ < FormattedMessage id = "teams.create" />
95+ </ Button >
96+ </ Link >
97+ }
98+ >
99+ < TeamsListing teams = { managedTeams } />
100+ </ Article >
101+ </ div >
102+ < div className = "l-content l-content--neutral-400 c-teams" >
103+ < Article
104+ className = "c-teams__heading"
105+ title = "teams.joinedByMe"
106+ titleValues = { { num : joinedTeams . length . toString ( ) } }
107+ >
108+ < TeamsListing teams = { joinedTeams } />
109+ </ Article >
110+ </ div >
111+ </ >
112+ ) }
91113
92114 < CreateTeam isOpen = { isCreatingTeam } />
93115 </ div >
0 commit comments