parent
96ab8c588f
commit
9990d8eec6
|
After Width: | Height: | Size: 568 B |
|
After Width: | Height: | Size: 624 B |
|
After Width: | Height: | Size: 755 B |
@ -0,0 +1,8 @@ |
|||||||
|
export const matchDownload = { |
||||||
|
choose_what_to_download: 20193, |
||||||
|
download_files_for_periods: 20197, |
||||||
|
download_full_match: 9435, |
||||||
|
download_single_file: 20196, |
||||||
|
entire_record: 20195, |
||||||
|
in_game_time_only: 20194, |
||||||
|
} |
||||||
@ -0,0 +1,73 @@ |
|||||||
|
import { useState } from 'react' |
||||||
|
|
||||||
|
import { T9n } from 'features/T9n' |
||||||
|
|
||||||
|
import { |
||||||
|
Header, |
||||||
|
Footer, |
||||||
|
Modal, |
||||||
|
ScApplyButton, |
||||||
|
HeaderTitle, |
||||||
|
Wrapper, |
||||||
|
DownloadIcon, |
||||||
|
FirstTitle, |
||||||
|
SecondTitle, |
||||||
|
RadioButtonsWrapper, |
||||||
|
Input, |
||||||
|
Label, |
||||||
|
} from './styled' |
||||||
|
|
||||||
|
type Props = { |
||||||
|
closePopup: () => void, |
||||||
|
isModalOpen: boolean, |
||||||
|
} |
||||||
|
|
||||||
|
export const MatchDownloadPopup = ({ |
||||||
|
closePopup, |
||||||
|
isModalOpen, |
||||||
|
}: Props) => { |
||||||
|
const [selected, setSelected] = useState(true) |
||||||
|
|
||||||
|
return ( |
||||||
|
<Modal |
||||||
|
close={closePopup} |
||||||
|
isOpen={isModalOpen} |
||||||
|
> |
||||||
|
<Wrapper> |
||||||
|
<Header> |
||||||
|
<DownloadIcon src='/images/downloadIcon.png' /> |
||||||
|
<HeaderTitle> |
||||||
|
<FirstTitle t='download_full_match' /> |
||||||
|
<SecondTitle t='choose_what_to_download' /> |
||||||
|
</HeaderTitle> |
||||||
|
</Header> |
||||||
|
<RadioButtonsWrapper> |
||||||
|
<Label> |
||||||
|
<Input |
||||||
|
defaultChecked={selected} |
||||||
|
name='in_game_time_only' |
||||||
|
onClick={() => setSelected(true)} |
||||||
|
/> |
||||||
|
<T9n t='in_game_time_only' /> |
||||||
|
</Label> |
||||||
|
<Label> |
||||||
|
<Input |
||||||
|
name='entire_record' |
||||||
|
defaultChecked={!selected} |
||||||
|
onClick={() => setSelected(false)} |
||||||
|
/> |
||||||
|
<T9n t='entire_record' /> |
||||||
|
</Label> |
||||||
|
</RadioButtonsWrapper> |
||||||
|
<Footer> |
||||||
|
<ScApplyButton> |
||||||
|
<T9n t='download_single_file' /> |
||||||
|
</ScApplyButton> |
||||||
|
<ScApplyButton disabled={!selected}> |
||||||
|
<T9n t='download_files_for_periods' /> |
||||||
|
</ScApplyButton> |
||||||
|
</Footer> |
||||||
|
</Wrapper> |
||||||
|
</Modal> |
||||||
|
) |
||||||
|
} |
||||||
@ -0,0 +1,158 @@ |
|||||||
|
import styled, { css } from 'styled-components/macro' |
||||||
|
|
||||||
|
import { isMobileDevice } from 'config' |
||||||
|
|
||||||
|
import { T9n } from 'features/T9n' |
||||||
|
import { ModalWindow, ModalCloseButton } from 'features/Modal/styled' |
||||||
|
import { Header as BaseHeader } from 'features/PopupComponents' |
||||||
|
import { |
||||||
|
ApplyButton, |
||||||
|
Modal as BaseModal, |
||||||
|
} from 'features/AuthServiceApp/components/RegisterPopup/styled' |
||||||
|
|
||||||
|
export const Modal = styled(BaseModal)` |
||||||
|
|
||||||
|
${ModalWindow} { |
||||||
|
width: 577px; |
||||||
|
height: 490px; |
||||||
|
padding: 80px 90px 65px; |
||||||
|
min-height: auto; |
||||||
|
|
||||||
|
${ModalCloseButton} { |
||||||
|
height: 28px; |
||||||
|
width: 28px; |
||||||
|
|
||||||
|
svg { |
||||||
|
width: 20px; |
||||||
|
height: 12px; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
${isMobileDevice |
||||||
|
? css` |
||||||
|
max-width: 95vw; |
||||||
|
max-height: 75vh; |
||||||
|
top: -3vh; |
||||||
|
padding: 60px 14px 20px;` |
||||||
|
: ''}; |
||||||
|
` |
||||||
|
|
||||||
|
export const Wrapper = styled.div`` |
||||||
|
|
||||||
|
export const Header = styled(BaseHeader)` |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
height: 100%; |
||||||
|
` |
||||||
|
|
||||||
|
export const DownloadIcon = styled.img` |
||||||
|
margin-right: 25px; |
||||||
|
|
||||||
|
${isMobileDevice |
||||||
|
? css` |
||||||
|
height: 55px; |
||||||
|
width: 44px;` |
||||||
|
: ''}; |
||||||
|
` |
||||||
|
|
||||||
|
export const HeaderTitle = styled.div` |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
` |
||||||
|
|
||||||
|
export const FirstTitle = styled(T9n)` |
||||||
|
font-weight: 700; |
||||||
|
font-size: 24px; |
||||||
|
line-height: 24px; |
||||||
|
margin-bottom: 10px; |
||||||
|
|
||||||
|
${isMobileDevice |
||||||
|
? css` |
||||||
|
font-size: 20px;` |
||||||
|
: ''}; |
||||||
|
` |
||||||
|
|
||||||
|
export const SecondTitle = styled(T9n)` |
||||||
|
font-weight: 400; |
||||||
|
font-size: 20px; |
||||||
|
line-height: 28px; |
||||||
|
|
||||||
|
${isMobileDevice |
||||||
|
? css` |
||||||
|
font-size: 14px; |
||||||
|
line-height: 17px;` |
||||||
|
: ''}; |
||||||
|
` |
||||||
|
|
||||||
|
export const RadioButtonsWrapper = styled.div` |
||||||
|
margin: 25px 0; |
||||||
|
` |
||||||
|
|
||||||
|
export const Label = styled.label` |
||||||
|
display: flex; |
||||||
|
cursor: pointer; |
||||||
|
font-size: 18px; |
||||||
|
line-height: 50px; |
||||||
|
align-items: center; |
||||||
|
|
||||||
|
${isMobileDevice |
||||||
|
? css` |
||||||
|
font-size: 14px;` |
||||||
|
: ''}; |
||||||
|
` |
||||||
|
|
||||||
|
export const Input = styled.input.attrs(() => ({ |
||||||
|
type: 'radio', |
||||||
|
}))` |
||||||
|
margin: 0 25px 0 0; |
||||||
|
appearance: none; |
||||||
|
width: 25px; |
||||||
|
height: 25px; |
||||||
|
cursor: pointer; |
||||||
|
background-image: url(/images/${({ defaultChecked }) => ( |
||||||
|
defaultChecked |
||||||
|
? 'checkedRadiobutton.png' |
||||||
|
: 'radiobutton.png' |
||||||
|
)}); |
||||||
|
|
||||||
|
|
||||||
|
${isMobileDevice |
||||||
|
? css` |
||||||
|
margin-right: 10px;` |
||||||
|
: ''}; |
||||||
|
|
||||||
|
` |
||||||
|
|
||||||
|
export const Footer = styled.div`` |
||||||
|
|
||||||
|
export const ScApplyButton = styled(ApplyButton)` |
||||||
|
width: 400px; |
||||||
|
height: 50px; |
||||||
|
margin: 0; |
||||||
|
background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%), #3F3F3F; |
||||||
|
transition: background-color 0.3s; |
||||||
|
|
||||||
|
:first-child { |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
&:hover { |
||||||
|
background-color: ${({ theme: { colors } }) => colors.button}; |
||||||
|
} |
||||||
|
|
||||||
|
:disabled { |
||||||
|
pointer-events: none; |
||||||
|
} |
||||||
|
|
||||||
|
${isMobileDevice |
||||||
|
? css` |
||||||
|
font-size: 14px; |
||||||
|
width: 100%; |
||||||
|
height: 50px; |
||||||
|
|
||||||
|
:first-child { |
||||||
|
margin-bottom: 10px; |
||||||
|
}` |
||||||
|
: ''}; |
||||||
|
` |
||||||
|
|
||||||
@ -0,0 +1,67 @@ |
|||||||
|
import some from 'lodash/some' |
||||||
|
|
||||||
|
import type { TeamsAndTournaments } from 'requests' |
||||||
|
|
||||||
|
import { useToggle } from 'hooks/useToggle' |
||||||
|
|
||||||
|
import { T9n } from 'features/T9n' |
||||||
|
import { useMatchPageStore } from 'features/MatchPage/store' |
||||||
|
import { useAuthStore } from 'features/AuthStore' |
||||||
|
import { MatchDownloadPopup } from 'features/MatchPage/components/MatchDownloadPopup' |
||||||
|
|
||||||
|
import { usePageParams } from 'hooks/usePageParams' |
||||||
|
|
||||||
|
import { Item } from '../MatchPlaylists' |
||||||
|
import { DownloadButton, Title } from '../../styled' |
||||||
|
|
||||||
|
export const MatchDownloadButton = () => { |
||||||
|
const { user, userInfo } = useAuthStore() |
||||||
|
const { profile } = useMatchPageStore() |
||||||
|
const { sportType } = usePageParams() |
||||||
|
|
||||||
|
const { |
||||||
|
close, |
||||||
|
isOpen, |
||||||
|
open, |
||||||
|
} = useToggle() |
||||||
|
|
||||||
|
const checkDownloadData = ( |
||||||
|
checkArray: Array<TeamsAndTournaments>, |
||||||
|
id?: number, |
||||||
|
) => some(checkArray, (['c_sport', sportType] && ['id', id])) |
||||||
|
|
||||||
|
const teams = userInfo?.download.teams |
||||||
|
const tournaments = userInfo?.download.tournaments |
||||||
|
|
||||||
|
const isAvailableTeams = () => { |
||||||
|
if (teams) { |
||||||
|
return checkDownloadData(teams, profile?.team1.id) |
||||||
|
|| checkDownloadData(teams, profile?.team2.id) |
||||||
|
} |
||||||
|
|
||||||
|
return null |
||||||
|
} |
||||||
|
|
||||||
|
const isAvailableTournaments = () => { |
||||||
|
if (tournaments) return checkDownloadData(tournaments, profile?.tournament.id) |
||||||
|
return null |
||||||
|
} |
||||||
|
|
||||||
|
const isNeedDownloadButton = user && (isAvailableTournaments() || isAvailableTeams()) |
||||||
|
|
||||||
|
if (!isNeedDownloadButton) return null |
||||||
|
|
||||||
|
return ( |
||||||
|
<Item> |
||||||
|
<MatchDownloadPopup |
||||||
|
isModalOpen={isOpen} |
||||||
|
closePopup={close} |
||||||
|
/> |
||||||
|
<DownloadButton onClick={open}> |
||||||
|
<Title> |
||||||
|
<T9n t='download_full_match' /> |
||||||
|
</Title> |
||||||
|
</DownloadButton> |
||||||
|
</Item> |
||||||
|
) |
||||||
|
} |
||||||
Loading…
Reference in new issue