From f41bd3dccd9c32ca5f3f8c42d8ccdf68259bcea3 Mon Sep 17 00:00:00 2001 From: Mirlan Date: Fri, 30 Oct 2020 13:16:51 +0600 Subject: [PATCH] refactor: removed proc object layer in responses (#202) --- src/helpers/callApi/getResponseData.tsx | 3 --- src/helpers/index.tsx | 1 - src/requests/getCountries.tsx | 4 ++-- src/requests/getCountryCities.tsx | 4 ++-- src/requests/getLexics.tsx | 4 ++-- src/requests/getMatchInfo.tsx | 4 ++-- src/requests/getMatchLastWatchSeconds.tsx | 4 ++-- src/requests/getMatches/request.tsx | 4 ++-- src/requests/getPlayerInfo.tsx | 4 ++-- src/requests/getSearchItems.tsx | 4 ++-- src/requests/getSportList.tsx | 4 ++-- src/requests/getSportTournaments.tsx | 4 ++-- src/requests/getTeamInfo.tsx | 4 ++-- src/requests/getTournamentInfo.tsx | 4 ++-- src/requests/getUserInfo.tsx | 4 ++-- src/requests/getUserSportFavs.tsx | 4 ++-- src/requests/getUserSubscriptions.tsx | 4 ++-- 17 files changed, 30 insertions(+), 34 deletions(-) delete mode 100644 src/helpers/callApi/getResponseData.tsx diff --git a/src/helpers/callApi/getResponseData.tsx b/src/helpers/callApi/getResponseData.tsx deleted file mode 100644 index 2aa97ed1..00000000 --- a/src/helpers/callApi/getResponseData.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export const getResponseData = (proc: string) => (response: any) => ( - response?.[proc] -) diff --git a/src/helpers/index.tsx b/src/helpers/index.tsx index b1e98fb4..1fef96c5 100644 --- a/src/helpers/index.tsx +++ b/src/helpers/index.tsx @@ -1,5 +1,4 @@ export * from './callApi' -export * from './callApi/getResponseData' export * from './token' export * from './getProfileLogo' export * from './getProfileFallbackLogo' diff --git a/src/requests/getCountries.tsx b/src/requests/getCountries.tsx index a0790b6b..545356f5 100644 --- a/src/requests/getCountries.tsx +++ b/src/requests/getCountries.tsx @@ -1,5 +1,5 @@ import { DATA_URL, PROCEDURES } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.lst_c_country @@ -25,5 +25,5 @@ export const getCountries = (): Promise => { return callApi({ config, url: DATA_URL, - }).then(getResponseData(proc)) + }) } diff --git a/src/requests/getCountryCities.tsx b/src/requests/getCountryCities.tsx index 801d59de..24155d8d 100644 --- a/src/requests/getCountryCities.tsx +++ b/src/requests/getCountryCities.tsx @@ -1,5 +1,5 @@ import { DATA_URL, PROCEDURES } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.get_cities @@ -24,5 +24,5 @@ export const getCountryCities = (query: string, countryId: number): Promise): Promise }: MatchesResponse = await callApi({ config, url: DATA_URL, - }).then(getResponseData(config.body.proc)) + }) return { broadcast: data.broadcast || [], diff --git a/src/requests/getPlayerInfo.tsx b/src/requests/getPlayerInfo.tsx index 1a72c3ce..4906be80 100644 --- a/src/requests/getPlayerInfo.tsx +++ b/src/requests/getPlayerInfo.tsx @@ -3,7 +3,7 @@ import { PROCEDURES, SportTypes, } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.get_player_info @@ -44,5 +44,5 @@ export const getPlayerInfo = ( return callApi({ config, url: DATA_URL, - }).then(getResponseData(proc)) + }) } diff --git a/src/requests/getSearchItems.tsx b/src/requests/getSearchItems.tsx index 8569955e..cae7e272 100644 --- a/src/requests/getSearchItems.tsx +++ b/src/requests/getSearchItems.tsx @@ -3,7 +3,7 @@ import { PROCEDURES, SportTypes, } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.get_players_teams_tournaments @@ -76,5 +76,5 @@ export const getSearchItems = ( abortSignal, config, url: DATA_URL, - }).then(getResponseData(proc)) + }) } diff --git a/src/requests/getSportList.tsx b/src/requests/getSportList.tsx index 7778907f..0f915faa 100644 --- a/src/requests/getSportList.tsx +++ b/src/requests/getSportList.tsx @@ -3,7 +3,7 @@ import { PROCEDURES, SportTypes, } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.get_sport_list @@ -23,5 +23,5 @@ export const getSportList = (): Promise => { return callApi({ config, url: DATA_URL, - }).then(getResponseData(proc)) + }) } diff --git a/src/requests/getSportTournaments.tsx b/src/requests/getSportTournaments.tsx index ab2eb751..fbf6e2e1 100644 --- a/src/requests/getSportTournaments.tsx +++ b/src/requests/getSportTournaments.tsx @@ -3,7 +3,7 @@ import { PROCEDURES, SportTypes, } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.get_tournament_list @@ -47,5 +47,5 @@ export const getSportTournaments = ( return callApi({ config, url: DATA_URL, - }).then(getResponseData(proc)) + }) } diff --git a/src/requests/getTeamInfo.tsx b/src/requests/getTeamInfo.tsx index 4744d5b6..139de8d7 100644 --- a/src/requests/getTeamInfo.tsx +++ b/src/requests/getTeamInfo.tsx @@ -3,7 +3,7 @@ import { PROCEDURES, } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.get_team_info @@ -36,5 +36,5 @@ export const getTeamInfo = (sportId: number, teamId: number) return callApi({ config, url: DATA_URL, - }).then(getResponseData(proc)) + }) } diff --git a/src/requests/getTournamentInfo.tsx b/src/requests/getTournamentInfo.tsx index 904da37e..c689380f 100644 --- a/src/requests/getTournamentInfo.tsx +++ b/src/requests/getTournamentInfo.tsx @@ -2,7 +2,7 @@ import { DATA_URL, PROCEDURES, } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.get_tournament_info @@ -35,5 +35,5 @@ export const getTournamentInfo = (sportId: number, tournamentId: number) return callApi({ config, url: DATA_URL, - }).then(getResponseData(proc)) + }) } diff --git a/src/requests/getUserInfo.tsx b/src/requests/getUserInfo.tsx index 44a67c8b..1c5f27d8 100644 --- a/src/requests/getUserInfo.tsx +++ b/src/requests/getUserInfo.tsx @@ -2,7 +2,7 @@ import { DATA_URL, PROCEDURES, } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' import type { UserInfo } from 'requests/saveUserInfo' const proc = PROCEDURES.get_user_info @@ -15,5 +15,5 @@ export const getUserInfo = (): Promise => { return callApi({ config, url: DATA_URL, - }).then(getResponseData(proc)) + }) } diff --git a/src/requests/getUserSportFavs.tsx b/src/requests/getUserSportFavs.tsx index c7bc6c53..a238b348 100644 --- a/src/requests/getUserSportFavs.tsx +++ b/src/requests/getUserSportFavs.tsx @@ -4,7 +4,7 @@ import { SportTypes, ProfileTypes, } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.get_user_favorites @@ -51,5 +51,5 @@ export const getUserFavorites = (): Promise => { return callApi({ config, url: DATA_URL, - }).then(getResponseData(proc)) + }) } diff --git a/src/requests/getUserSubscriptions.tsx b/src/requests/getUserSubscriptions.tsx index 8f407ddb..f5175d62 100644 --- a/src/requests/getUserSubscriptions.tsx +++ b/src/requests/getUserSubscriptions.tsx @@ -2,7 +2,7 @@ import { DATA_URL, PROCEDURES, } from 'config' -import { callApi, getResponseData } from 'helpers' +import { callApi } from 'helpers' const proc = PROCEDURES.get_user_subscriptions @@ -34,5 +34,5 @@ export const getUserSubscriptions = (): Promise => { return callApi({ config, url: DATA_URL, - }).then(getResponseData(proc)) + }) }