You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
910 B
45 lines
910 B
import {
|
|
API_ROOT,
|
|
PROCEDURES,
|
|
SportTypes,
|
|
} from 'config'
|
|
|
|
import { client } from 'config/clients'
|
|
|
|
import { addSportType } from 'features/Matches/helpers/addSportType'
|
|
|
|
import type { MatchesBySection } from './types'
|
|
import { getMatchesPreviews } from './getPreviews'
|
|
import { requestMatches } from './request'
|
|
|
|
const proc = PROCEDURES.get_team_matches
|
|
|
|
type Args = {
|
|
limit: number,
|
|
offset: number,
|
|
sportType: SportTypes,
|
|
teamId: number,
|
|
}
|
|
|
|
export const getTeamMatches = async ({
|
|
limit,
|
|
offset,
|
|
sportType,
|
|
teamId,
|
|
}: Args): Promise<MatchesBySection> => {
|
|
const url = `${API_ROOT}/v1/data/get-team-matches`
|
|
|
|
const config = {
|
|
body: {
|
|
limit,
|
|
offset,
|
|
sport: sportType,
|
|
team_id: teamId,
|
|
...client.requests?.[proc],
|
|
},
|
|
}
|
|
|
|
return requestMatches(config, url)
|
|
.then((matches) => addSportType(matches, sportType))
|
|
.then(getMatchesPreviews)
|
|
}
|
|
|