From dd9cf5b47d0e3689048440203b9506c27accc064 Mon Sep 17 00:00:00 2001 From: Mirlan Date: Thu, 18 Mar 2021 14:08:23 +0600 Subject: [PATCH] fix(930): subs purchase request proc change (#331) --- src/config/procedures.tsx | 2 +- .../BuyMatchPopup/store/hooks/index.tsx | 3 ++- .../store/hooks/useSubscriptions.tsx | 6 ++++-- src/requests/buyMatchSubscriptions.tsx | 2 +- src/requests/getSubscriptions.tsx | 18 ++++++++++++++---- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/config/procedures.tsx b/src/config/procedures.tsx index f52c6f62..46377231 100644 --- a/src/config/procedures.tsx +++ b/src/config/procedures.tsx @@ -3,12 +3,12 @@ export const PROCEDURES = { create_user: 'create_user', get_cities: 'get_cities', get_match_info: 'get_match_info', + get_match_subscriptions: 'get_match_subscriptions', get_matches: 'get_matches', get_objects: 'get_objects', get_player_info: 'get_player_info', get_player_matches: 'get_player_matches', get_sport_list: 'get_sport_list', - get_subscriptions: 'get_subscriptions', get_team_info: 'get_team_info', get_team_matches: 'get_team_matches', get_tournament_info: 'get_tournament_info', diff --git a/src/features/BuyMatchPopup/store/hooks/index.tsx b/src/features/BuyMatchPopup/store/hooks/index.tsx index cfe146db..9bc61ae1 100644 --- a/src/features/BuyMatchPopup/store/hooks/index.tsx +++ b/src/features/BuyMatchPopup/store/hooks/index.tsx @@ -16,6 +16,7 @@ type MatchData = Pick | null export const useBuyMatchPopup = () => { @@ -60,7 +61,7 @@ export const useBuyMatchPopup = () => { useEffect(() => { if (match) { - fetchSubscriptions() + fetchSubscriptions(match.sportType, match.id) } }, [match, fetchSubscriptions]) diff --git a/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx b/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx index 9b48c2c2..c26b4c55 100644 --- a/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx +++ b/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx @@ -15,6 +15,8 @@ import { buyMatchSubscriptions, } from 'requests' +import { SportTypes } from 'config' + import type { MatchSubscriptions, MatchSubscription } from '../../types' import { Steps, SubscriptionType } from '../../types' import { transformSubsciptions } from '../helpers' @@ -26,8 +28,8 @@ export const useSubscriptions = (goTo: (step: Steps) => void) => { const [subscriptionsList, setSubscriptionsList] = useState([]) const [selectedSubscriptions, setSelectedSubscriptions] = useState([]) - const fetchSubscriptions = useCallback(() => { - getSubscriptions() + const fetchSubscriptions = useCallback((sport: SportTypes, id: number) => { + getSubscriptions(sport, id) .then(transformSubsciptions) .then(fetchLexics) .then(setSubscriptionsList) diff --git a/src/requests/buyMatchSubscriptions.tsx b/src/requests/buyMatchSubscriptions.tsx index 77ccf96b..723949a2 100644 --- a/src/requests/buyMatchSubscriptions.tsx +++ b/src/requests/buyMatchSubscriptions.tsx @@ -13,7 +13,7 @@ type Subscription = { const buyMatchSubscription = ({ id, type }: Subscription) => { const config = { body: { - _p_interval: type, + interval: type, is_scheduled: 0, subscription_plan: id, }, diff --git a/src/requests/getSubscriptions.tsx b/src/requests/getSubscriptions.tsx index 3a3781bf..94fd1938 100644 --- a/src/requests/getSubscriptions.tsx +++ b/src/requests/getSubscriptions.tsx @@ -1,7 +1,11 @@ -import { DATA_URL, PROCEDURES } from 'config' +import { + DATA_URL, + PROCEDURES, + SportTypes, +} from 'config' import { callApi } from 'helpers' -const proc = PROCEDURES.get_subscriptions +const proc = PROCEDURES.get_match_subscriptions type Subscription = { id: number, @@ -12,10 +16,16 @@ type Subscription = { export type MatchSubscriptionsResponse = Array -export const getSubscriptions = async (): Promise => { +export const getSubscriptions = async ( + sport: SportTypes, + matchId: number, +): Promise => { const config = { body: { - params: {}, + params: { + _p_match_id: matchId, + _p_sport: sport, + }, proc, }, }