Ott 839 settings players playlists (#319)
* feat: 🎸 OTT-839 useMatchPopupStore * feat: 🎸 OTT-839 add settings * feat: 🎸 OTT-839 add settings * feat: 🎸 OTT-839 fix comments * feat: 🎸 OTT-839-settings-players-playlists fix after code review * feat: 🎸 OTT-839 fix line * feat: 🎸 OTT-839 fix pr comments * feat: 🎸 OTT-839 fix pr comments Co-authored-by: Zoia <zizi2405@yandex.ru>keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
parent
bec9a081f0
commit
a2b2299492
@ -0,0 +1,94 @@ |
|||||||
|
import { Fragment } from 'react' |
||||||
|
|
||||||
|
import styled from 'styled-components/macro' |
||||||
|
|
||||||
|
import type { Actions } from 'requests' |
||||||
|
|
||||||
|
import { |
||||||
|
EpisodeDuration, |
||||||
|
PlayerPlaylistFormats, |
||||||
|
SelectedActions, |
||||||
|
Settings, |
||||||
|
} from 'features/MatchPopup' |
||||||
|
import { ButtonSolid } from 'features/Common' |
||||||
|
import { T9n } from 'features/T9n' |
||||||
|
import { PlaylistFormats } from 'features/MatchPopup/components/PlaylistFormats' |
||||||
|
import { EpisodeDurationInputs } from 'features/MatchPopup/components/EpisodeDurationInputs' |
||||||
|
import { PlayerActions } from 'features/MatchPopup/components/PlayerActions' |
||||||
|
|
||||||
|
import { useSettingsDesktop } from './useDesktopSettings' |
||||||
|
|
||||||
|
const ButtonsWrapper = styled.div` |
||||||
|
display: flex; |
||||||
|
justify-content: center; |
||||||
|
margin: 45px 0 15px 0; |
||||||
|
` |
||||||
|
|
||||||
|
const WatchButton = styled(ButtonSolid)` |
||||||
|
width: auto; |
||||||
|
padding: 0 20px; |
||||||
|
` |
||||||
|
|
||||||
|
type Props = { |
||||||
|
actions: Actions, |
||||||
|
episodeDuration: EpisodeDuration, |
||||||
|
isMatchPlaylist?: boolean, |
||||||
|
onWatchEpisodesClick: (values: Settings) => void, |
||||||
|
selectedActions: SelectedActions, |
||||||
|
selectedPlaylistFormat: PlayerPlaylistFormats, |
||||||
|
} |
||||||
|
|
||||||
|
export const SettingsDesktop = ({ |
||||||
|
actions, |
||||||
|
episodeDuration, |
||||||
|
isMatchPlaylist, |
||||||
|
onWatchEpisodesClick, |
||||||
|
selectedActions, |
||||||
|
selectedPlaylistFormat, |
||||||
|
}: Props) => { |
||||||
|
const { |
||||||
|
actionsValue, |
||||||
|
episodeDurationValue, |
||||||
|
selectedPlaylistFormatValue, |
||||||
|
setActionsValue, |
||||||
|
setEpisodeDurationValue, |
||||||
|
setSelectedPlaylistFormatValue, |
||||||
|
} = useSettingsDesktop({ |
||||||
|
episodeDuration, |
||||||
|
selectedActions, |
||||||
|
selectedPlaylistFormat, |
||||||
|
}) |
||||||
|
const marginTop = isMatchPlaylist ? 0 : 62 |
||||||
|
return ( |
||||||
|
<Fragment> |
||||||
|
<PlaylistFormats |
||||||
|
marginTop={marginTop} |
||||||
|
selectedFormat={selectedPlaylistFormatValue} |
||||||
|
onFormatSelect={setSelectedPlaylistFormatValue} |
||||||
|
/> |
||||||
|
<EpisodeDurationInputs |
||||||
|
value={episodeDurationValue} |
||||||
|
onChange={setEpisodeDurationValue} |
||||||
|
/> |
||||||
|
{selectedPlaylistFormatValue === PlayerPlaylistFormats.SELECTED_ACTIONS && ( |
||||||
|
<PlayerActions |
||||||
|
actions={actions} |
||||||
|
onActionClick={setActionsValue} |
||||||
|
selectedActions={actionsValue} |
||||||
|
/> |
||||||
|
)} |
||||||
|
<ButtonsWrapper> |
||||||
|
<WatchButton onClick={() => onWatchEpisodesClick({ |
||||||
|
episodeDuration: episodeDurationValue, |
||||||
|
selectedActions: actionsValue, |
||||||
|
selectedFormat: selectedPlaylistFormatValue, |
||||||
|
})} |
||||||
|
> |
||||||
|
{isMatchPlaylist |
||||||
|
? <T9n t='save' /> |
||||||
|
: <T9n t='watch_players_episodes' />} |
||||||
|
</WatchButton> |
||||||
|
</ButtonsWrapper> |
||||||
|
</Fragment> |
||||||
|
) |
||||||
|
} |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
import { useState } from 'react' |
||||||
|
|
||||||
|
import type { |
||||||
|
EpisodeDuration, |
||||||
|
PlayerPlaylistFormats, |
||||||
|
SelectedActions, |
||||||
|
} from 'features/MatchPopup' |
||||||
|
|
||||||
|
type Args = { |
||||||
|
episodeDuration: EpisodeDuration, |
||||||
|
selectedActions: SelectedActions, |
||||||
|
selectedPlaylistFormat: PlayerPlaylistFormats, |
||||||
|
} |
||||||
|
|
||||||
|
export const useSettingsDesktop = ({ |
||||||
|
episodeDuration, |
||||||
|
selectedActions, |
||||||
|
selectedPlaylistFormat, |
||||||
|
}: Args) => { |
||||||
|
const [actionsValue, setActionsValue] = useState<SelectedActions>(selectedActions) |
||||||
|
const [ |
||||||
|
episodeDurationValue, |
||||||
|
setEpisodeDurationValue] = useState<EpisodeDuration>(episodeDuration) |
||||||
|
const [ |
||||||
|
selectedPlaylistFormatValue, |
||||||
|
setSelectedPlaylistFormatValue, |
||||||
|
] = useState<PlayerPlaylistFormats>(selectedPlaylistFormat) |
||||||
|
|
||||||
|
return { |
||||||
|
actionsValue, |
||||||
|
episodeDurationValue, |
||||||
|
selectedPlaylistFormatValue, |
||||||
|
setActionsValue, |
||||||
|
setEpisodeDurationValue, |
||||||
|
setSelectedPlaylistFormatValue, |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,103 @@ |
|||||||
|
import { MDASH } from 'config' |
||||||
|
|
||||||
|
import styled from 'styled-components/macro' |
||||||
|
|
||||||
|
import type { Actions, MatchInfo } from 'requests' |
||||||
|
import type { PlaylistOption } from 'features/MatchPage/types' |
||||||
|
import type { Settings } from 'features/MatchPopup' |
||||||
|
import { PlaylistTypes } from 'features/MatchPage/types' |
||||||
|
import { MediaQuery } from 'features/MediaQuery' |
||||||
|
import { Name } from 'features/Name' |
||||||
|
import { T9n } from 'features/T9n' |
||||||
|
import { |
||||||
|
CloseButton, |
||||||
|
Header, |
||||||
|
HeaderActions, |
||||||
|
HeaderTitle, |
||||||
|
} from 'features/PopupComponents' |
||||||
|
|
||||||
|
import { SettingsDesktop } from '../SettingsDesktop' |
||||||
|
|
||||||
|
const TitleWrapper = styled(HeaderTitle)` |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
line-height: 32px; |
||||||
|
` |
||||||
|
|
||||||
|
const TeamNames = styled.span` |
||||||
|
font-weight: normal; |
||||||
|
` |
||||||
|
|
||||||
|
type ContentProps = { |
||||||
|
height?: number, |
||||||
|
} |
||||||
|
|
||||||
|
const Content = styled.div<ContentProps>` |
||||||
|
width: 100%; |
||||||
|
` |
||||||
|
|
||||||
|
type Props = { |
||||||
|
actions: Actions, |
||||||
|
closePopup: () => void, |
||||||
|
onWatchEpisodesClick: (values: Settings) => void, |
||||||
|
profile: MatchInfo, |
||||||
|
selectedPlaylist?: PlaylistOption, |
||||||
|
settings: Settings, |
||||||
|
} |
||||||
|
export const SettingsPopup = ({ |
||||||
|
actions, |
||||||
|
closePopup, |
||||||
|
onWatchEpisodesClick, |
||||||
|
profile, |
||||||
|
selectedPlaylist, |
||||||
|
settings, |
||||||
|
}: Props) => { |
||||||
|
if (!profile || !selectedPlaylist) return null |
||||||
|
|
||||||
|
const isMatchPlaylist = selectedPlaylist.type === PlaylistTypes.MATCH |
||||||
|
|
||||||
|
return ( |
||||||
|
<Content> |
||||||
|
{!isMatchPlaylist |
||||||
|
? ( |
||||||
|
<Header> |
||||||
|
<MediaQuery maxDevice='mobile'> |
||||||
|
<HeaderTitle> |
||||||
|
<T9n t='match_settings' /> |
||||||
|
</HeaderTitle> |
||||||
|
</MediaQuery> |
||||||
|
<MediaQuery minDevice='tablet'> |
||||||
|
<HeaderActions position='right'> |
||||||
|
<CloseButton onClick={closePopup} /> |
||||||
|
</HeaderActions> |
||||||
|
<TitleWrapper> |
||||||
|
{selectedPlaylist && <Name nameObj={selectedPlaylist} />} |
||||||
|
<TeamNames> |
||||||
|
<Name nameObj={profile.team1} /> |
||||||
|
{` ${MDASH} `} |
||||||
|
<Name nameObj={profile.team2} /> |
||||||
|
</TeamNames> |
||||||
|
</TitleWrapper> |
||||||
|
</MediaQuery> |
||||||
|
</Header> |
||||||
|
) |
||||||
|
: ( |
||||||
|
<Header> |
||||||
|
<HeaderActions position='right'> |
||||||
|
<CloseButton onClick={closePopup} /> |
||||||
|
</HeaderActions> |
||||||
|
</Header> |
||||||
|
)} |
||||||
|
<MediaQuery minDevice='tablet'> |
||||||
|
<SettingsDesktop |
||||||
|
actions={actions} |
||||||
|
episodeDuration={settings.episodeDuration} |
||||||
|
onWatchEpisodesClick={onWatchEpisodesClick} |
||||||
|
isMatchPlaylist={isMatchPlaylist} |
||||||
|
selectedActions={settings.selectedActions} |
||||||
|
selectedPlaylistFormat={settings.selectedFormat} |
||||||
|
/> |
||||||
|
</MediaQuery> |
||||||
|
</Content> |
||||||
|
) |
||||||
|
} |
||||||
Loading…
Reference in new issue