-
Notifications
You must be signed in to change notification settings - Fork 0
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 #32 from filipimiparebine/feature/server_components
Server components
- Loading branch information
Showing
8 changed files
with
79 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NEXT_PUBLIC_API_URL=http://localhost:8000/api |
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,38 @@ | ||
import axios from "axios"; | ||
import { Team, Season, SeasonLeaderboard } from "@/types/league"; | ||
import { FixtureResponse } from "@/types/fixture"; | ||
import { TeamPrediction } from "@/types/prediction"; | ||
|
||
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL; | ||
|
||
const apiClient = axios.create({ | ||
baseURL: API_BASE_URL, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
|
||
export const ApiService = { | ||
getTeams: () => apiClient.get<Team[]>("/teams"), | ||
getSeasons: () => apiClient.get<Season[]>("/seasons"), | ||
startSeason: (teamIds: number[], seasonId: number) => | ||
apiClient.post("/start-season", { | ||
team_ids: teamIds, | ||
season_id: seasonId, | ||
}), | ||
leagueTable: (seasonId: number) => | ||
apiClient.get<SeasonLeaderboard>(`/league-table/${seasonId}`), | ||
fixtures: (seasonId: number, weekNumber: number) => | ||
apiClient.get<FixtureResponse>(`/fixtures/${seasonId}/${weekNumber}`), | ||
predict: (seasonId: number, weekNumber: number) => | ||
apiClient.get<TeamPrediction[]>(`/week/predict/${seasonId}/${weekNumber}`), | ||
simulate: (seasonId: number, weekNumber: number) => | ||
apiClient.get<SeasonLeaderboard>(`/week/simulate/${seasonId}/${weekNumber}`), | ||
updateMatchScore: (matchId: number, homeScore: number, awayScore: number) => | ||
apiClient.put(`/match/${matchId}`, { | ||
home_score: homeScore, | ||
away_score: awayScore, | ||
}), | ||
}; | ||
|
||
export default ApiService; |
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