|
|
|
|
@ -1,8 +1,7 @@ |
|
|
|
|
import uniq from 'lodash/uniq' |
|
|
|
|
import map from 'lodash/map' |
|
|
|
|
import isEmpty from 'lodash/isEmpty' |
|
|
|
|
import includes from 'lodash/includes' |
|
|
|
|
import filter from 'lodash/filter' |
|
|
|
|
|
|
|
|
|
import { isMobileDevice } from 'config/userAgent' |
|
|
|
|
|
|
|
|
|
import { T9n } from 'features/T9n' |
|
|
|
|
import { useMatchPageStore } from 'features/MatchPage/store' |
|
|
|
|
@ -28,14 +27,18 @@ import { |
|
|
|
|
} from './styled' |
|
|
|
|
|
|
|
|
|
type TLabelProps = { |
|
|
|
|
checked: boolean, |
|
|
|
|
player: PlayerPlaylistOption, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const Label = ({ player }: TLabelProps) => { |
|
|
|
|
const Label = ({ |
|
|
|
|
checked, |
|
|
|
|
player, |
|
|
|
|
}: TLabelProps) => { |
|
|
|
|
const { num } = player |
|
|
|
|
return ( |
|
|
|
|
<ItemText> |
|
|
|
|
<PlayerNumber> |
|
|
|
|
<PlayerNumber checked={checked}> |
|
|
|
|
{num} |
|
|
|
|
</PlayerNumber> |
|
|
|
|
<Name nameObj={player} /> |
|
|
|
|
@ -48,20 +51,19 @@ export const FiltersPopup = () => { |
|
|
|
|
activeEvents, |
|
|
|
|
activeFirstTeamPlayers, |
|
|
|
|
activeSecondTeamPlayers, |
|
|
|
|
allActionsToggle, |
|
|
|
|
allPlayersToggle, |
|
|
|
|
applyFilters, |
|
|
|
|
closePopup, |
|
|
|
|
events, |
|
|
|
|
isAllActionsChecked, |
|
|
|
|
isFirstTeamPlayersChecked, |
|
|
|
|
isSecondTeamPlayersChecked, |
|
|
|
|
matchPlaylists, |
|
|
|
|
profile, |
|
|
|
|
resetEvents, |
|
|
|
|
resetPlayers, |
|
|
|
|
toggleActiveEvents, |
|
|
|
|
toggleActivePlayers, |
|
|
|
|
uniqEvents, |
|
|
|
|
} = useMatchPageStore() |
|
|
|
|
const currentEvents = filter(events, (event) => event.pl !== undefined |
|
|
|
|
&& event.t !== undefined) |
|
|
|
|
|
|
|
|
|
const uniqEvents = uniq(map(currentEvents, ({ l }) => l)) |
|
|
|
|
|
|
|
|
|
const team1Name = useName(profile!.team1) |
|
|
|
|
const team2Name = useName(profile!.team2) |
|
|
|
|
@ -70,7 +72,10 @@ export const FiltersPopup = () => { |
|
|
|
|
<PopupContainer> |
|
|
|
|
<PopupInner> |
|
|
|
|
<CloseButtonContainer> |
|
|
|
|
<CloseButton onClick={closePopup} /> |
|
|
|
|
<CloseButton |
|
|
|
|
size={isMobileDevice ? 8 : 16} |
|
|
|
|
onClick={closePopup} |
|
|
|
|
/> |
|
|
|
|
</CloseButtonContainer> |
|
|
|
|
<PopupHeader> |
|
|
|
|
<HeaderText> |
|
|
|
|
@ -80,8 +85,9 @@ export const FiltersPopup = () => { |
|
|
|
|
<PartBlock> |
|
|
|
|
<MainCheckboxContainer> |
|
|
|
|
<Checkbox |
|
|
|
|
onChange={resetEvents} |
|
|
|
|
checked={isEmpty(activeEvents)} |
|
|
|
|
isMainCheckbox |
|
|
|
|
onChange={allActionsToggle} |
|
|
|
|
checked={isAllActionsChecked} |
|
|
|
|
labelLexic='all_actions' |
|
|
|
|
/> |
|
|
|
|
</MainCheckboxContainer> |
|
|
|
|
@ -100,41 +106,49 @@ export const FiltersPopup = () => { |
|
|
|
|
<PartBlock> |
|
|
|
|
<MainCheckboxContainer> |
|
|
|
|
<Checkbox |
|
|
|
|
checked={isEmpty(activeFirstTeamPlayers)} |
|
|
|
|
isMainCheckbox |
|
|
|
|
checked={isFirstTeamPlayersChecked} |
|
|
|
|
label={team1Name} |
|
|
|
|
onChange={resetPlayers('team1')} |
|
|
|
|
onChange={allPlayersToggle('team1')} |
|
|
|
|
/> |
|
|
|
|
</MainCheckboxContainer> |
|
|
|
|
<ItemsContainer> |
|
|
|
|
{map(matchPlaylists.players.team1, ((player) => ( |
|
|
|
|
<ItemBlock key={player.id}> |
|
|
|
|
<Checkbox |
|
|
|
|
onChange={toggleActivePlayers({ id: player.id, team: 'team1' })} |
|
|
|
|
checked={includes(activeFirstTeamPlayers, player.id)} |
|
|
|
|
label={(<Label player={player} />)} |
|
|
|
|
/> |
|
|
|
|
</ItemBlock> |
|
|
|
|
)))} |
|
|
|
|
{map(matchPlaylists.players.team1, ((player) => { |
|
|
|
|
const isCheckboxChecked = includes(activeFirstTeamPlayers, player.id) |
|
|
|
|
return ( |
|
|
|
|
<ItemBlock key={player.id}> |
|
|
|
|
<Checkbox |
|
|
|
|
onChange={toggleActivePlayers({ id: player.id, team: 'team1' })} |
|
|
|
|
checked={isCheckboxChecked} |
|
|
|
|
label={(<Label checked={isCheckboxChecked} player={player} />)} |
|
|
|
|
/> |
|
|
|
|
</ItemBlock> |
|
|
|
|
) |
|
|
|
|
}))} |
|
|
|
|
</ItemsContainer> |
|
|
|
|
</PartBlock> |
|
|
|
|
<PartBlock> |
|
|
|
|
<MainCheckboxContainer> |
|
|
|
|
<Checkbox |
|
|
|
|
checked={isEmpty(activeSecondTeamPlayers)} |
|
|
|
|
isMainCheckbox |
|
|
|
|
checked={isSecondTeamPlayersChecked} |
|
|
|
|
label={team2Name} |
|
|
|
|
onChange={resetPlayers('team2')} |
|
|
|
|
onChange={allPlayersToggle('team2')} |
|
|
|
|
/> |
|
|
|
|
</MainCheckboxContainer> |
|
|
|
|
<ItemsContainer> |
|
|
|
|
{map(matchPlaylists.players.team2, ((player) => ( |
|
|
|
|
<ItemBlock key={player.id}> |
|
|
|
|
<Checkbox |
|
|
|
|
onChange={toggleActivePlayers({ id: player.id, team: 'team2' })} |
|
|
|
|
checked={includes(activeSecondTeamPlayers, player.id)} |
|
|
|
|
label={(<Label player={player} />)} |
|
|
|
|
/> |
|
|
|
|
</ItemBlock> |
|
|
|
|
)))} |
|
|
|
|
{map(matchPlaylists.players.team2, ((player) => { |
|
|
|
|
const isCheckboxChecked = includes(activeSecondTeamPlayers, player.id) |
|
|
|
|
return ( |
|
|
|
|
<ItemBlock key={player.id}> |
|
|
|
|
<Checkbox |
|
|
|
|
onChange={toggleActivePlayers({ id: player.id, team: 'team2' })} |
|
|
|
|
checked={isCheckboxChecked} |
|
|
|
|
label={(<Label checked={isCheckboxChecked} player={player} />)} |
|
|
|
|
/> |
|
|
|
|
</ItemBlock> |
|
|
|
|
) |
|
|
|
|
}))} |
|
|
|
|
</ItemsContainer> |
|
|
|
|
</PartBlock> |
|
|
|
|
</PopupInner> |
|
|
|
|
|