@@ -3,27 +3,25 @@ import ErrorPage from '../ErrorPage';
33import { Box , useMediaQuery } from '@mui/system' ;
44import PageLayout from '../../components/PageLayout' ;
55import GuestSubteamCard from './GuestSubteamCard' ;
6- import { useAllTeams } from '../../hooks/teams.hooks' ;
6+ import { useTeamsByTypeId } from '../../hooks/teams.hooks' ;
77import { useParams } from 'react-router-dom' ;
88
99interface ParamTypes {
10- teamId : string ;
10+ teamTypeId : string ;
1111}
1212
1313const GuestTeamPage : React . FC = ( ) => {
1414 const isMobilePortrait = useMediaQuery ( '(max-width:480px)' ) ;
15- const { teamId } = useParams < ParamTypes > ( ) ;
16- const { isLoading : teamsIsLoading , isError : teamsIsError , data : allTeams , error : teamsError } = useAllTeams ( ) ;
15+ const { teamTypeId } = useParams < ParamTypes > ( ) ;
16+ const { isLoading : teamsIsLoading , isError : teamsIsError , data : teams , error : teamsError } = useTeamsByTypeId ( teamTypeId ) ;
1717
18- if ( teamsIsLoading || ! allTeams ) return < LoadingIndicator /> ;
18+ if ( teamsIsLoading || ! teams ) return < LoadingIndicator /> ;
1919 if ( teamsIsError ) return < ErrorPage message = { teamsError . message } /> ;
2020
21- const filteredTeams = allTeams . filter ( ( team ) => team . teamType ?. teamTypeId === teamId ) ;
22-
23- if ( filteredTeams . length === 0 ) return < ErrorPage message = "No teams found for this division" /> ;
21+ if ( teams . length === 0 ) return < ErrorPage message = "No teams found for this division" /> ;
2422
2523 return (
26- < PageLayout title = { filteredTeams [ 0 ] . teamType ! . name } >
24+ < PageLayout title = { teams [ 0 ] . teamType ! . name } >
2725 < Box
2826 sx = { {
2927 display : 'grid' ,
@@ -33,7 +31,7 @@ const GuestTeamPage: React.FC = () => {
3331 px : isMobilePortrait ? 1 : 0
3432 } }
3533 >
36- { filteredTeams . map ( ( team ) => (
34+ { teams . map ( ( team ) => (
3735 < GuestSubteamCard key = { team . teamId } team = { team } />
3836 ) ) }
3937 </ Box >
0 commit comments