28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { api as api } from '../../api';
|
|
import { presentLeagueSummaries, presentLeagueStandings } from '../../presenters';
|
|
import { LeagueSummaryViewModel, LeagueStandingsViewModel } from '../../view-models';
|
|
|
|
export async function getAllLeagues(): Promise<LeagueSummaryViewModel[]> {
|
|
const dto = await api.leagues.getAllWithCapacity();
|
|
return presentLeagueSummaries(dto.leagues);
|
|
}
|
|
|
|
export async function getLeagueStandings(leagueId: string, currentUserId?: string): Promise<LeagueStandingsViewModel> {
|
|
const dto = await api.leagues.getStandings(leagueId);
|
|
// TODO: include drivers and memberships in dto
|
|
const dtoWithExtras = {
|
|
...dto,
|
|
drivers: [], // TODO: fetch drivers
|
|
memberships: [], // TODO: fetch memberships
|
|
};
|
|
return presentLeagueStandings(dtoWithExtras, currentUserId || '');
|
|
}
|
|
|
|
export async function createLeague(input: any): Promise<any> {
|
|
return await api.leagues.create(input);
|
|
}
|
|
|
|
export async function getLeagueAdminView(leagueId: string): Promise<any> {
|
|
// TODO: implement
|
|
return {};
|
|
} |