38 lines
968 B
TypeScript
38 lines
968 B
TypeScript
import type { Manager, Team } from './apiResponseTypes'
|
|
import type { Player } from './playersService'
|
|
import { SITE_URL } from './utilities'
|
|
|
|
export interface Award {
|
|
id: number,
|
|
name: string,
|
|
season: number,
|
|
timing: string,
|
|
manager1: Manager | null,
|
|
manager2: Manager | null,
|
|
player: Player | null,
|
|
team: Team | null,
|
|
image: string
|
|
}
|
|
|
|
export async function fetchAwardsByPlayerName(playerName: string): Promise<Award[]> {
|
|
const response = await fetch(`${SITE_URL}/api/v3/awards?player_name=${playerName}&timing=off-season`)
|
|
|
|
const awardsResponse: {
|
|
count: number
|
|
awards: Award[]
|
|
} = await response.json()
|
|
|
|
return awardsResponse.awards
|
|
}
|
|
|
|
export async function fetchAwardsByManagerId(managerId: number): Promise<Award[]> {
|
|
const response = await fetch(`${SITE_URL}/api/v3/awards?manager_id=${managerId}`)
|
|
|
|
const awardsResponse: {
|
|
count: number
|
|
awards: Award[]
|
|
} = await response.json()
|
|
|
|
return awardsResponse.awards
|
|
}
|