diff --git a/src/features/MatchPage/components/SubscriptionGuard/index.tsx b/src/features/MatchPage/components/SubscriptionGuard/index.tsx index 01286d17..61278d03 100644 --- a/src/features/MatchPage/components/SubscriptionGuard/index.tsx +++ b/src/features/MatchPage/components/SubscriptionGuard/index.tsx @@ -7,6 +7,7 @@ import { useBuyMatchPopupStore } from 'features/BuyMatchPopup' import { useMatchPageStore } from 'features/MatchPage/store' import { prepareMatchProfile } from '../../helpers/prepareMatchProfile' +import { checkUrlParams, getAllUrlParams } from '../../../../helpers/parseUrlParams/parseUrlParams' type Props = { children: ReactNode, @@ -18,7 +19,10 @@ export const SubscriptionGuard = ({ children }: Props) => { const { profileId: matchId, sportType } = usePageParams() useEffect(() => { - if (matchProfile && !matchProfile.sub) { + if (matchProfile && ( + !matchProfile.sub + || (checkUrlParams('subscribe') + && getAllUrlParams('id')))) { const profile = prepareMatchProfile({ matchId, profile: matchProfile, diff --git a/src/helpers/parseUrlParams/parseUrlParams.tsx b/src/helpers/parseUrlParams/parseUrlParams.tsx index f960c546..2d02baef 100644 --- a/src/helpers/parseUrlParams/parseUrlParams.tsx +++ b/src/helpers/parseUrlParams/parseUrlParams.tsx @@ -7,3 +7,8 @@ export const checkUrlParams = (key: string) => { const params = new URLSearchParams(window.location.search) return params.get(key) } + +export const getAllUrlParams = (key: string) => { + const params = new URLSearchParams(window.location.search) + return params.getAll(key) +} diff --git a/src/requests/getSelectedSubscriptions.tsx b/src/requests/getSelectedSubscriptions.tsx new file mode 100644 index 00000000..95050c6a --- /dev/null +++ b/src/requests/getSelectedSubscriptions.tsx @@ -0,0 +1,15 @@ +import { callApi } from 'helpers' +import { Subscriptions } from './getSubscriptions' +import { API_ROOT } from '../config' + +export const getSelectedSubscriptions = async ( +): Promise => { + const config = { + method: 'GET', + } + + return callApi({ + config, + url: `${API_ROOT}/v1/subscriptions${window.location.search}`, + }) +}