fix(#2556): additional fixes

keep-around/1e28a34fbd392900c7a7d1e084705d08070e1034
Rakov Roman 3 years ago
parent c9029648d0
commit a25bc3d3f5
  1. 5
      src/features/Background/styled.tsx
  2. 4
      src/features/Common/customScrollbar/index.tsx
  3. 28
      src/features/MatchSidePlaylists/components/TabVideo/components/VideoDate/index.tsx
  4. 32
      src/features/MatchSidePlaylists/components/TabVideo/index.tsx
  5. 22
      src/features/MatchSidePlaylists/hooks.tsx

@ -7,9 +7,12 @@ const Container = styled.div`
min-height: 100vh;
overflow-x: hidden;
&::-webkit-scrollbar {
&::-webkit-scrollbar {
display: none;
}
// отображение в firefox
scrollbar-width: none;
`
export const ImageBackground = styled(Container)`

@ -24,4 +24,8 @@ export const customScrollbar = css`
::-webkit-scrollbar-corner {
background: transparent;
}
// firefox поддерживает только эти 2 параметра
scrollbar-color: #3F3F3F transparent;
scrollbar-width: thin;
`

@ -8,15 +8,19 @@ import { format } from 'date-fns'
import { WeekDay, Wrapper } from './styled'
export type Props = {
isInitialDateHidden: boolean,
matchDates: Array<string>,
onDateClick: (date: string) => void,
profileDate: string,
selectedDate: string,
}
export const VideoDate = (props: Props) => {
const {
isInitialDateHidden,
matchDates,
onDateClick,
profileDate,
selectedDate,
} = props
@ -24,23 +28,37 @@ export const VideoDate = (props: Props) => {
matchDates.findIndex((date) => date === selectedDate)
), [matchDates, selectedDate])
const lastDateIndex = matchDates.length - 1
const initialDateIndex = useMemo(() => (
matchDates.findIndex((date) => date === profileDate)
), [matchDates, profileDate])
const currentDay = useMemo(() => (
matchDates.length ? matchDates[selectedDateIndex] : null
), [matchDates, selectedDateIndex])
matchDates.length && !(isInitialDateHidden && selectedDateIndex === initialDateIndex)
? matchDates[selectedDateIndex]
: null
), [initialDateIndex, isInitialDateHidden, matchDates, selectedDateIndex])
const previousDay = useMemo(() => {
if (selectedDateIndex !== 0) {
if (isInitialDateHidden && selectedDateIndex - 1 === initialDateIndex) {
return selectedDateIndex - 1 !== lastDateIndex ? matchDates[selectedDateIndex - 2] : null
}
return matchDates[selectedDateIndex - 1]
}
return null
}, [matchDates, selectedDateIndex])
}, [initialDateIndex, isInitialDateHidden, lastDateIndex, matchDates, selectedDateIndex])
const nextDay = useMemo(() => {
if (selectedDateIndex !== matchDates.length - 1) {
if (selectedDateIndex !== lastDateIndex) {
if (isInitialDateHidden && selectedDateIndex + 1 === initialDateIndex) {
return selectedDateIndex + 1 !== lastDateIndex ? matchDates[selectedDateIndex + 2] : null
}
return matchDates[selectedDateIndex + 1]
}
return null
}, [matchDates, selectedDateIndex])
}, [initialDateIndex, isInitialDateHidden, lastDateIndex, matchDates, selectedDateIndex])
const onDayClick = (date: string) => {
onDateClick?.(date)

@ -16,7 +16,7 @@ import { parseDate } from 'helpers/parseDate'
import { usePageParams } from 'hooks/usePageParams'
import { VideoDate } from './components/VideoDate/VideoDate'
import { VideoDate } from './components/VideoDate'
import { MatchesWrapper } from './styled'
type Props = {
@ -24,24 +24,50 @@ type Props = {
tournamentData: TournamentData,
}
const formatDate = (date: Date) => format(date, 'yyyy-MM-dd')
export const TabVideo = ({
profile,
tournamentData,
}: Props) => {
const { profileId } = usePageParams()
const [selectedDate, setSelectedDate] = useState(format(parseDate(profile?.date!), 'yyyy-MM-dd'))
const profileDate = useMemo(() => (
format(parseDate(profile?.date!), 'yyyy-MM-dd')
), [profile?.date])
const [selectedDate, setSelectedDate] = useState(profileDate)
const matches = useMemo(() => (
tournamentData.matches.filter((match) => (
format(match.date, 'yyyy-MM-dd') === selectedDate && match.id !== profileId
formatDate(match.date) === selectedDate && match.id !== profileId
))
), [profileId, selectedDate, tournamentData.matches])
const isInitialDateHidden = useMemo(() => {
const someProfileMatch = tournamentData.matches.find((match) => (
formatDate(match.date) === profileDate && match.id !== profileId))
if (!someProfileMatch) {
const profileDateIndex = tournamentData.matchDates.findIndex((date) => date === profileDate)
if (profileDateIndex !== 0) {
setSelectedDate(tournamentData.matchDates[profileDateIndex - 1])
} else {
setSelectedDate(tournamentData.matchDates[profileDateIndex + 1])
}
}
return !someProfileMatch
}, [tournamentData, profileId, profileDate])
return (
<Fragment>
<VideoDate
isInitialDateHidden={isInitialDateHidden}
matchDates={tournamentData.matchDates}
selectedDate={selectedDate}
profileDate={profileDate}
onDateClick={setSelectedDate}
/>
<MatchesWrapper>

@ -25,7 +25,7 @@ export const useMatchSidePlaylists = (props: Props) => {
tournamentData,
} = props
const [selectedTab, setSelectedTab] = useState<Tabs>(Tabs.VIDEO)
const [selectedTab, setSelectedTab] = useState<Tabs>(Tabs.WATCH)
const isWatchTabVisible = useMemo(() => {
const playListFilter = reduce(
@ -40,21 +40,13 @@ export const useMatchSidePlaylists = (props: Props) => {
return playListFilter > 1
}, [playlists])
const isEventTabVisible = useMemo(() => {
if (events.length > 0) {
setSelectedTab(Tabs.EVENTS)
return true
}
return false
}, [events])
const isEventTabVisible = useMemo(() => (
events.length > 0
), [events])
const isVideoTabVisible = useMemo(() => {
if (tournamentData.matches.length > 0) {
setSelectedTab(Tabs.EVENTS)
return true
}
return false
}, [tournamentData])
const isVideoTabVisible = useMemo(() => (
tournamentData.matches.length > 1
), [tournamentData])
useEffect(() => {
switch (true) {

Loading…
Cancel
Save