From e8f420aa2c8327165f306db21c93ee59615755cd Mon Sep 17 00:00:00 2001 From: Jonas Simoen Date: Sun, 22 Oct 2023 19:08:00 +0200 Subject: [PATCH] fix(team): error null-properties --- src/pages/Team/Team.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/Team/Team.tsx b/src/pages/Team/Team.tsx index 3e900cd..393ef14 100644 --- a/src/pages/Team/Team.tsx +++ b/src/pages/Team/Team.tsx @@ -44,6 +44,9 @@ export const _Team = (props: AbstractTeamType) => { }, [clubsSuccess, teamSuccess, matchesSuccess, deadlineInfoSuccess]); const getTeamInfo = (weekId: number) => { + if(!teamResult) { + return; + } const playerProps = ["id", "name", "short", "positionId", "clubId", "value", "ban", "injury", "form", "forename", "surname", "points", "portraitUrl", "externalId"]; const selectionProps: any[] = []; const starting = teamResult.players.filter((p: Player) => p.selection?.starting === 1) @@ -62,7 +65,7 @@ export const _Team = (props: AbstractTeamType) => { return Object.assign({ inStarting: false, upcomingMatches: displayWeekMatches }, pick(p, playerProps), pick(p.selection, selectionProps)); }); - const teamName = teamResult.team.name; + const teamName = teamResult.team?.name; const captainPlayer = teamResult.players.find((p: Player) => p && p.selection && p.selection.captain === 1); const captainId = captainPlayer && captainPlayer.id; @@ -72,7 +75,7 @@ export const _Team = (props: AbstractTeamType) => { const budget = teamResult.players.reduce((acc: any, player: Player) => acc - player.value, application.competition.budget); // const boosters = undefined; // todo - const isTeamOwner = !!(teamResult.team.userId === user?.id); + const isTeamOwner = !!(teamResult.team?.userId === user?.id); props.initTeamState(starting, bench, teamName, budget, captainId, viceCaptainId, true); };