Ott 583 inaccessable match in users country (#232)

* feat(579): added message if match is not accessible in user's country

* refactor(583): removed React imports

* refactor(583): fix review comments
keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Mirlan 5 years ago committed by GitHub
parent 94684184e3
commit d8c1e7b2bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/config/lexics/indexLexics.tsx
  2. 2
      src/features/MatchCard/CardFinished/index.tsx
  3. 2
      src/features/MatchCard/CardLive/index.tsx
  4. 22
      src/features/MatchCard/CardSoon/index.tsx
  5. 22
      src/features/MatchCard/MatchInfoCard/index.tsx
  6. 46
      src/features/MatchCard/NoAccessMessage/index.tsx
  7. 26
      src/features/MatchCard/hooks.tsx
  8. 4
      src/features/Matches/helpers/prepareMatches.tsx
  9. 2
      src/features/MediaQuery/index.tsx
  10. 1
      src/requests/getMatches/types.tsx

@ -32,6 +32,8 @@ export const indexLexics = {
match_status_live: 12984,
match_status_soon: 12986,
match_video: 13025,
no_match_access_body: 13419,
no_match_access_title: 13418,
player: 630,
players_video: 13032,
round_highilights: 13050,

@ -18,7 +18,7 @@ export const CardFinished = ({
flipCard,
isOpen,
onKeyPress,
} = useCard(match.hasVideo)
} = useCard(match)
if (isOpen) {
return (

@ -18,7 +18,7 @@ export const CardLive = ({
flipCard,
isOpen,
onKeyPress,
} = useCard(match.hasVideo)
} = useCard(match)
if (isOpen) {
return (

@ -6,6 +6,7 @@ import type { Match } from 'features/Matches'
import { SportName } from 'features/Common'
import { useName } from 'features/Name'
import { NoAccessMessage } from '../NoAccessMessage'
import {
MatchDate,
CardWrapper as CommonCardWrapper,
@ -36,7 +37,8 @@ type CardSoonProps = {
export const CardSoon = ({
match: {
availableBySubscription,
accessibleBySubscription,
accessibleInUsersCountry,
date,
sportType,
team1,
@ -49,12 +51,6 @@ export const CardSoon = ({
const tournamentName = useName(tournament)
return (
<CardWrapper>
<MatchDate>
{date}
<Time>
{time}
</Time>
</MatchDate>
<PreviewWrapper>
<TeamLogos>
<TeamLogo
@ -72,7 +68,17 @@ export const CardSoon = ({
profileType={ProfileTypes.TEAMS}
/>
</TeamLogos>
{!availableBySubscription && <BuyMatchButton />}
{!accessibleBySubscription && <BuyMatchButton />}
{(accessibleBySubscription && !accessibleInUsersCountry)
? <NoAccessMessage />
: (
<MatchDate>
{date}
<Time>
{time}
</Time>
</MatchDate>
)}
</PreviewWrapper>
<Info>
{showSportName && <SportName sport={sportType} />}

@ -7,6 +7,7 @@ import { SportName } from 'features/Common'
import { useMatchSwitchesStore } from 'features/MatchSwitches'
import { useName } from 'features/Name'
import { NoAccessMessage } from '../NoAccessMessage'
import {
CardWrapper,
Info,
@ -33,7 +34,8 @@ type Props = {
export const MatchInfoCard = ({
match: {
availableBySubscription,
accessibleBySubscription,
accessibleInUsersCountry,
date,
hasVideo,
preview,
@ -55,12 +57,6 @@ export const MatchInfoCard = ({
onClick={onClick}
onKeyPress={onKeyPress}
>
<MatchDate>
{date}
<Time>
{time}
</Time>
</MatchDate>
<PreviewWrapper>
{
hasVideo
@ -90,7 +86,17 @@ export const MatchInfoCard = ({
</TeamLogos>
)
}
{!availableBySubscription && <BuyMatchButton />}
{!accessibleBySubscription && <BuyMatchButton />}
{(accessibleBySubscription && !accessibleInUsersCountry)
? <NoAccessMessage />
: (
<MatchDate>
{date}
<Time>
{time}
</Time>
</MatchDate>
)}
</PreviewWrapper>
<Info>
{showSportName && <SportName sport={sportType} />}

@ -0,0 +1,46 @@
import styled from 'styled-components/macro'
import { T9n } from 'features/T9n'
const Wrapper = styled.div`
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
`
const Message = styled.div`
width: 240px;
padding: 12px;
color: #fff;
background-color: #EB5757;
box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.25);
border-radius: 10px;
`
const Title = styled.h3`
font-weight: bold;
font-size: 16px;
line-height: 20px;
`
const Text = styled.p`
font-size: 13px;
line-height: 16px;
`
export const NoAccessMessage = () => (
<Wrapper>
<Message>
<Title>
<T9n t='no_match_access_title' />
</Title>
<Text>
<T9n t='no_match_access_body' />
</Text>
</Message>
</Wrapper>
)

@ -3,24 +3,34 @@ import { useCallback } from 'react'
import { useToggle } from 'hooks'
export const useCard = (hasVideo: boolean) => {
import type { Match } from 'features/Matches'
export const useCard = ({
accessibleInUsersCountry,
hasVideo,
}: Match) => {
const {
close,
isOpen,
open,
} = useToggle()
const onKeyPress = useCallback((e: KeyboardEvent<HTMLLIElement>) => {
if (e.key === 'Enter' && hasVideo) {
const isClickable = (
hasVideo
&& accessibleInUsersCountry
)
const flipCard = useCallback(() => {
if (isClickable) {
open()
}
}, [hasVideo, open])
}, [isClickable, open])
const flipCard = () => {
if (hasVideo) {
open()
const onKeyPress = useCallback((e: KeyboardEvent<HTMLLIElement>) => {
if (e.key === 'Enter') {
flipCard()
}
}
}, [flipCard])
return {
close,

@ -6,6 +6,7 @@ import type { Match } from 'requests'
import { getSportLexic } from 'helpers'
const prepareMatch = ({
access,
date,
has_video,
id,
@ -16,7 +17,8 @@ const prepareMatch = ({
team2,
tournament,
}: Match) => ({
availableBySubscription: sub,
accessibleBySubscription: sub,
accessibleInUsersCountry: access,
date: format(new Date(date), 'dd.MM.yy'),
hasVideo: has_video,
id,

@ -1,5 +1,5 @@
import type { ReactNode } from 'react'
import React, { Fragment } from 'react'
import { Fragment } from 'react'
import type { Devices } from 'config'

@ -16,6 +16,7 @@ export type Team = {
}
export type Match = {
access: boolean,
date: string,
has_video: boolean,
id: number,

Loading…
Cancel
Save