Ott 952 popup player actions (#340)
* refactor(952): light settings popup refactoring * fix(952): fetch player actions on format selectkeep-around/af30b88d367751c9e05a735e4a0467a96238ef47
parent
de55ca88b0
commit
5869da52fd
@ -1,37 +1,40 @@ |
||||
import { useState } from 'react' |
||||
import { useObjectState } from 'hooks' |
||||
|
||||
import type { |
||||
EpisodeDuration, |
||||
PlayerPlaylistFormats, |
||||
SelectedActions, |
||||
EpisodeDuration, |
||||
} from 'features/MatchPopup' |
||||
import { PlayerPlaylistFormats, useMatchPopupStore } from 'features/MatchPopup' |
||||
|
||||
type Args = { |
||||
episodeDuration: EpisodeDuration, |
||||
selectedActions: SelectedActions, |
||||
selectedPlaylistFormat: PlayerPlaylistFormats, |
||||
} |
||||
export const useSettingsDesktop = () => { |
||||
const { |
||||
actions, |
||||
fetchSportActions, |
||||
settings, |
||||
} = useMatchPopupStore() |
||||
const [localSettings, setSettings] = useObjectState(settings) |
||||
|
||||
const onPlaylistFormatChange = (playlistFormat: PlayerPlaylistFormats) => { |
||||
setSettings({ selectedFormat: playlistFormat }) |
||||
if (playlistFormat === PlayerPlaylistFormats.SELECTED_ACTIONS) { |
||||
fetchSportActions() |
||||
} |
||||
} |
||||
|
||||
const onActionsChange = (selectedActions: SelectedActions) => { |
||||
setSettings({ selectedActions }) |
||||
} |
||||
|
||||
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) |
||||
const onEpisodeDurationsChange = (episodeDuration: EpisodeDuration) => { |
||||
setSettings({ episodeDuration }) |
||||
} |
||||
|
||||
return { |
||||
actionsValue, |
||||
episodeDurationValue, |
||||
selectedPlaylistFormatValue, |
||||
setActionsValue, |
||||
setEpisodeDurationValue, |
||||
setSelectedPlaylistFormatValue, |
||||
actions, |
||||
localSettings, |
||||
onActionsChange, |
||||
onEpisodeDurationsChange, |
||||
onPlaylistFormatChange, |
||||
settings, |
||||
} |
||||
} |
||||
|
||||
Loading…
Reference in new issue