fix(930): subs purchase request proc change (#331)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Mirlan 5 years ago committed by GitHub
parent 7185e83d3b
commit dd9cf5b47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/config/procedures.tsx
  2. 3
      src/features/BuyMatchPopup/store/hooks/index.tsx
  3. 6
      src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx
  4. 2
      src/requests/buyMatchSubscriptions.tsx
  5. 18
      src/requests/getSubscriptions.tsx

@ -3,12 +3,12 @@ export const PROCEDURES = {
create_user: 'create_user', create_user: 'create_user',
get_cities: 'get_cities', get_cities: 'get_cities',
get_match_info: 'get_match_info', get_match_info: 'get_match_info',
get_match_subscriptions: 'get_match_subscriptions',
get_matches: 'get_matches', get_matches: 'get_matches',
get_objects: 'get_objects', get_objects: 'get_objects',
get_player_info: 'get_player_info', get_player_info: 'get_player_info',
get_player_matches: 'get_player_matches', get_player_matches: 'get_player_matches',
get_sport_list: 'get_sport_list', get_sport_list: 'get_sport_list',
get_subscriptions: 'get_subscriptions',
get_team_info: 'get_team_info', get_team_info: 'get_team_info',
get_team_matches: 'get_team_matches', get_team_matches: 'get_team_matches',
get_tournament_info: 'get_tournament_info', get_tournament_info: 'get_tournament_info',

@ -16,6 +16,7 @@ type MatchData = Pick<Match, (
'id' 'id'
| 'team1' | 'team1'
| 'team2' | 'team2'
| 'sportType'
)> | null )> | null
export const useBuyMatchPopup = () => { export const useBuyMatchPopup = () => {
@ -60,7 +61,7 @@ export const useBuyMatchPopup = () => {
useEffect(() => { useEffect(() => {
if (match) { if (match) {
fetchSubscriptions() fetchSubscriptions(match.sportType, match.id)
} }
}, [match, fetchSubscriptions]) }, [match, fetchSubscriptions])

@ -15,6 +15,8 @@ import {
buyMatchSubscriptions, buyMatchSubscriptions,
} from 'requests' } from 'requests'
import { SportTypes } from 'config'
import type { MatchSubscriptions, MatchSubscription } from '../../types' import type { MatchSubscriptions, MatchSubscription } from '../../types'
import { Steps, SubscriptionType } from '../../types' import { Steps, SubscriptionType } from '../../types'
import { transformSubsciptions } from '../helpers' import { transformSubsciptions } from '../helpers'
@ -26,8 +28,8 @@ export const useSubscriptions = (goTo: (step: Steps) => void) => {
const [subscriptionsList, setSubscriptionsList] = useState<MatchSubscriptions>([]) const [subscriptionsList, setSubscriptionsList] = useState<MatchSubscriptions>([])
const [selectedSubscriptions, setSelectedSubscriptions] = useState<MatchSubscriptions>([]) const [selectedSubscriptions, setSelectedSubscriptions] = useState<MatchSubscriptions>([])
const fetchSubscriptions = useCallback(() => { const fetchSubscriptions = useCallback((sport: SportTypes, id: number) => {
getSubscriptions() getSubscriptions(sport, id)
.then(transformSubsciptions) .then(transformSubsciptions)
.then(fetchLexics) .then(fetchLexics)
.then(setSubscriptionsList) .then(setSubscriptionsList)

@ -13,7 +13,7 @@ type Subscription = {
const buyMatchSubscription = ({ id, type }: Subscription) => { const buyMatchSubscription = ({ id, type }: Subscription) => {
const config = { const config = {
body: { body: {
_p_interval: type, interval: type,
is_scheduled: 0, is_scheduled: 0,
subscription_plan: id, subscription_plan: id,
}, },

@ -1,7 +1,11 @@
import { DATA_URL, PROCEDURES } from 'config' import {
DATA_URL,
PROCEDURES,
SportTypes,
} from 'config'
import { callApi } from 'helpers' import { callApi } from 'helpers'
const proc = PROCEDURES.get_subscriptions const proc = PROCEDURES.get_match_subscriptions
type Subscription = { type Subscription = {
id: number, id: number,
@ -12,10 +16,16 @@ type Subscription = {
export type MatchSubscriptionsResponse = Array<Subscription> export type MatchSubscriptionsResponse = Array<Subscription>
export const getSubscriptions = async (): Promise<MatchSubscriptionsResponse> => { export const getSubscriptions = async (
sport: SportTypes,
matchId: number,
): Promise<MatchSubscriptionsResponse> => {
const config = { const config = {
body: { body: {
params: {}, params: {
_p_match_id: matchId,
_p_sport: sport,
},
proc, proc,
}, },
} }

Loading…
Cancel
Save