@@ -4,6 +4,8 @@ import { Box, useMediaQuery } from '@mui/system';
44import PageLayout from '../../components/PageLayout' ;
55import GuestSubteamCard from './GuestSubteamCard' ;
66import { useAllTeams } from '../../hooks/teams.hooks' ;
7+ import { useAllTeamTypes } from '../../hooks/team-types.hooks' ;
8+ import { Typography } from '@mui/material' ;
79
810interface GuestTeamPageProps {
911 teamTypeId : string ;
@@ -12,15 +14,39 @@ interface GuestTeamPageProps {
1214const GuestTeamPage : React . FC < GuestTeamPageProps > = ( { teamTypeId } ) => {
1315 const isMobilePortrait = useMediaQuery ( '(max-width:480px)' ) ;
1416 const { isLoading : teamsIsLoading , isError : teamsIsError , data : allTeams , error : teamsError } = useAllTeams ( ) ;
15- const teams = allTeams ?. filter ( ( team ) => team . teamType ?. teamTypeId === teamTypeId ) ;
17+ const {
18+ isLoading : teamTypesIsLoading ,
19+ isError : teamTypesIsError ,
20+ data : allTeamTypes ,
21+ error : teamTypesError
22+ } = useAllTeamTypes ( ) ;
1623
17- if ( teamsIsLoading || ! teams ) return < LoadingIndicator /> ;
24+ if ( teamsIsLoading || ! allTeams || teamTypesIsLoading || ! allTeamTypes ) return < LoadingIndicator /> ;
1825 if ( teamsIsError ) return < ErrorPage message = { teamsError . message } /> ;
26+ if ( teamTypesIsError ) return < ErrorPage message = { teamTypesError . message } /> ;
1927
20- if ( teams . length === 0 ) return < ErrorPage message = "No teams found for this division" /> ;
28+ const teams = allTeams . filter ( ( team ) => team . teamType ?. teamTypeId === teamTypeId ) ;
29+ const teamTypeName = allTeamTypes . find ( ( tt ) => tt . teamTypeId === teamTypeId ) ?. name ?? '' ;
30+
31+ if ( teams . length === 0 ) {
32+ return (
33+ < PageLayout title = { teamTypeName } >
34+ < Box
35+ sx = { {
36+ display : 'flex' ,
37+ justifyContent : 'center' ,
38+ alignItems : 'center' ,
39+ height : '70vh'
40+ } }
41+ >
42+ < Typography > No Teams found for this Division</ Typography >
43+ </ Box >
44+ </ PageLayout >
45+ ) ;
46+ }
2147
2248 return (
23- < PageLayout title = { teams [ 0 ] . teamType ! . name } >
49+ < PageLayout title = { teamTypeName } >
2450 < Box
2551 sx = { {
2652 display : 'grid' ,
0 commit comments