-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from Sports-day/feature/match-list
試合に関するコンポーネントの修正と一覧表示コンポーネントの作成
- Loading branch information
Showing
9 changed files
with
539 additions
and
467 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {gameFactory} from "@/src/models/GameModel" | ||
import {Match, matchFactory} from "@/src/models/MatchModel" | ||
import MatchList from "@/components/match/matchList" | ||
|
||
export default async function InProgressMatchList() { | ||
// get all games | ||
const games = await gameFactory().index() | ||
const matches = await matchFactory().index() | ||
|
||
const matchList: Match[] = [] | ||
for (const game of games) { | ||
// get all matches | ||
const filteredMatches = matches.filter((match) => match.gameId == game.id) | ||
// filter matches that are not finished | ||
const inProgressMatches = filteredMatches.filter((match) => match.status == "standby" || match.status == "in_progress") | ||
|
||
// sort by start time | ||
inProgressMatches.sort((a, b) => { | ||
return new Date(a.startAt).getTime() - new Date(b.startAt).getTime() | ||
}) | ||
|
||
console.log(inProgressMatches[0]) | ||
|
||
// pick the first match | ||
matchList.push(inProgressMatches[0]) | ||
} | ||
|
||
return ( | ||
<MatchList matches={matchList}/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.