From 97419d790c25b2d7e5cd7fa4cb2f4d13decb378d Mon Sep 17 00:00:00 2001 From: testusuke Date: Tue, 21 May 2024 13:32:05 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A5=E3=81=AE=E3=83=AA=E3=83=BC?= =?UTF-8?q?=E3=82=B0=E3=81=AB=E3=82=A8=E3=83=B3=E3=83=88=E3=83=AA=E3=83=BC?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B=E3=81=AE=E5=AF=A9=E5=88=A4?= =?UTF-8?q?=E3=81=8C=E8=A6=8B=E3=81=88=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7?= =?UTF-8?q?=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/match/matchEditor.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/match/matchEditor.tsx b/components/match/matchEditor.tsx index 34a490e..4336355 100644 --- a/components/match/matchEditor.tsx +++ b/components/match/matchEditor.tsx @@ -24,7 +24,7 @@ import CardBackground from "@/components/layout/cardBackground" import {HiCheck, HiChevronDown, HiArrowPath, HiFlag, HiMapPin, HiClock, HiMiniNoSymbol} from "react-icons/hi2" import {Sport} from "@/src/models/SportModel" -import {Game} from "@/src/models/GameModel" +import {Game, gameFactory} from "@/src/models/GameModel" import {Match, matchFactory, MatchResult, MatchStatus} from "@/src/models/MatchModel" import {Team, teamFactory} from "@/src/models/TeamModel" import {Location, locationFactory} from "@/src/models/LocationModel" @@ -65,9 +65,13 @@ export default function MatchEditor(props: MatchEditorProps) { const fetchedLocations = await locationFactory().index() setLocations(fetchedLocations) + const fetchedGames = await gameFactory().index() + const sportGames = fetchedGames.filter(game => game.sportId === props.sport.id) + const sportGameIds = sportGames.map(game => game.id) + const fetchedTeams = await teamFactory().index() // filter by game id - const filteredTeams = fetchedTeams.filter(team => team.enteredGameIds.includes(props.game.id)) + const filteredTeams = fetchedTeams.filter(team => team.enteredGameIds.some(id => sportGameIds.includes(id))) setTeams(filteredTeams) // finish loading