fix(#242): add packages from backend

pull/82/head
Andrei Dekterev 3 years ago
parent d0bcb49a29
commit 40369dcded
  1. 14
      src/features/BuyMatchPopup/components/PackagesList/index.tsx
  2. 3
      src/features/BuyMatchPopup/components/SelectSubscription/index.tsx
  3. 2
      src/features/BuyMatchPopup/store/hooks/index.tsx
  4. 10
      src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx
  5. 6
      src/features/TournamentPage/hooks.tsx

@ -67,13 +67,13 @@ export const PackagesList = ({
/>
{
subPackage.type === SubscriptionType.Month
&& (
<ScAutoRenewal>
<T9n
t='auto_renewal'
/>
</ScAutoRenewal>
)
&& (
<ScAutoRenewal>
<T9n
t='auto_renewal'
/>
</ScAutoRenewal>
)
}
</ScPriceContainer>
</Item>

@ -17,6 +17,8 @@ import {
Wrapper,
} from 'features/BuyMatchPopup/styled'
import { checkUrlParams, getAllUrlParams } from 'helpers/parseUrlParams/parseUrlParams'
import { MatchPackage, SubscriptionType } from '../../types'
import {
@ -32,7 +34,6 @@ import {
ChooseSubItem,
ChooseSubList,
} from './styled'
import { checkUrlParams, getAllUrlParams } from '../../../../helpers/parseUrlParams/parseUrlParams'
export const SelectSubscriptionStep = () => {
const {

@ -89,7 +89,7 @@ export const useBuyMatchPopup = () => {
const onNext = (e: MouseEvent<HTMLButtonElement>) => goTo(Steps.SelectPackage, e)
const openPopup = useCallback((matchData: Match) => {
const openPopup = useCallback((matchData: Match | null) => {
setMatch(matchData)
setSteps([])
}, [])

@ -10,6 +10,7 @@ import first from 'lodash/first'
import size from 'lodash/size'
import { getSubscriptions } from 'requests/getSubscriptions'
import { getSelectedSubscriptions } from 'requests/getSelectedSubscriptions'
import { useLexicsStore } from 'features/LexicsStore'
@ -63,7 +64,14 @@ export const useSubscriptions = () => {
const fetchSubscriptions = useCallback(async (match: Match) => {
let subscriptions
if (checkUrlParams('id') && checkUrlParams('subscribe')) {
subscriptions = await getSubscriptions(MATCH_CONFIG.sportId, MATCH_CONFIG.matchId)
const subs = await getSelectedSubscriptions()
subscriptions = {
data: subs,
season: {
id: 0,
name: `${new Date().getFullYear()}`,
},
}
} else {
subscriptions = await getSubscriptions(match.sportType, match.id)
}

@ -18,13 +18,12 @@ import { checkUrlParams, getAllUrlParams } from 'helpers/parseUrlParams/parseUrl
import { usePageParams } from 'hooks/usePageParams'
import { useName } from 'features/Name'
import { useAuthStore } from 'features/AuthStore'
import { isPermittedTournament } from '../../helpers/isPermittedTournament'
import { useProfileCard } from '../ProfileCard/hooks'
import { useBuyMatchPopupStore } from '../BuyMatchPopup'
import { MATCH_CONFIG } from '../BuyMatchPopup/store/hooks/useSubscriptions'
import { prepareMatchProfile } from '../MatchPage/helpers/prepareMatchProfile'
import { useAuthStore } from '../AuthStore'
export const useTournamentPage = () => {
const [tournamentProfile, setTournamentProfile] = useState<TournamentInfo>(null)
@ -32,6 +31,7 @@ export const useTournamentPage = () => {
const { open: openBuyMatchPopup } = useBuyMatchPopupStore()
const country = useName(tournamentProfile?.country || {})
const history = useHistory()
const { user } = useAuthStore()
const { isFavorite, toggleFavorites } = useProfileCard()
@ -77,7 +77,7 @@ export const useTournamentPage = () => {
useEffect(() => {
if ((checkUrlParams('subscribe')
&& getAllUrlParams('id'))) {
&& getAllUrlParams('id'))) {
getMatchInfo(MATCH_CONFIG.sportId, MATCH_CONFIG.matchId)
.then((match: MatchInfo) => {
const matchProfile = match && prepareMatchProfile({

Loading…
Cancel
Save