import React from 'react'; import './tournament.scss'; import * as I from './../../API/types'; import api from './../../API'; import Ladder from './Ladder'; import { useAction } from '../../API/contexts/actions'; import { useEffect, useState } from 'react'; const Tournament = () => { const [ show, setShow ] = useState(false); const [ teams, setTeams ] = useState([]); const [ matches, setMatches ] = useState([]); const [ tournament, setTournament ] = useState(null); useAction("showTournament", (data) => { setShow(data === "show"); }); useEffect(() => { api.tournaments.get().then(({ tournament }) => { if(tournament){ setTournament(tournament); Promise.allSettled([api.match.get(), api.teams.get()]).then(([matches, teams]) =>{ setTeams(teams.status === "fulfilled" ? teams.value : []); setMatches(matches.status === "fulfilled" ? matches.value : []); }); } }) }, []); if(!tournament) return null; return (
{ tournament.logo ? {tournament.name} : null }
{tournament.name}
); } export default React.memo(Tournament);