feat(ott-296): team matches (#89)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Ruslan Khayrullin 5 years ago committed by GitHub
parent 4b5b278b92
commit 6460d0cc2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/features/HeaderFilters/store/hooks/index.tsx
  2. 29
      src/features/TeamPage/hooks.tsx
  3. 27
      src/features/TeamPage/index.tsx
  4. 5
      src/features/TeamPage/styled.tsx
  5. 16
      src/features/TournamentPage/hooks.tsx
  6. 3
      src/requests/getMatches.tsx

@ -53,6 +53,7 @@ export const useFilters = () => {
const [selectedMatchStatus, setSelectedMatchStatus] = useState<MatchStatuses>(MatchStatuses.Live) const [selectedMatchStatus, setSelectedMatchStatus] = useState<MatchStatuses>(MatchStatuses.Live)
const [selectedSportTypeId, setSelectedSportTypeId] = useState<SportTypes | null>(null) const [selectedSportTypeId, setSelectedSportTypeId] = useState<SportTypes | null>(null)
const [selectedTournamentId, setSelectedTournamentId] = useState<number | null>(null) const [selectedTournamentId, setSelectedTournamentId] = useState<number | null>(null)
const [teamId, setTeamId] = useState<number | null>(null)
const [matches, setMatches] = useState<Matches>({ const [matches, setMatches] = useState<Matches>({
broadcast: [], broadcast: [],
features: [], features: [],
@ -68,6 +69,7 @@ export const useFilters = () => {
date: formattedDate, date: formattedDate,
matchStatus: selectedMatchStatus, matchStatus: selectedMatchStatus,
sportType: selectedSportTypeId, sportType: selectedSportTypeId,
teamId,
tournamentId: selectedTournamentId, tournamentId: selectedTournamentId,
}).then(setMatches) }).then(setMatches)
}, [ }, [
@ -75,6 +77,7 @@ export const useFilters = () => {
selectedMatchStatus, selectedMatchStatus,
selectedSportTypeId, selectedSportTypeId,
selectedTournamentId, selectedTournamentId,
teamId,
]) ])
const prepareMatches = useCallback((content: Array<Content>) => pipe( const prepareMatches = useCallback((content: Array<Content>) => pipe(
@ -132,12 +135,14 @@ export const useFilters = () => {
setSelectedMatchStatus, setSelectedMatchStatus,
setSelectedSportTypeId, setSelectedSportTypeId,
setSelectedTournamentId, setSelectedTournamentId,
setTeamId,
}), [ }), [
selectedDate, selectedDate,
selectedMatchStatus, selectedMatchStatus,
selectedSportTypeId, selectedSportTypeId,
selectedTournamentId, selectedTournamentId,
setSelectedTournamentId, setSelectedTournamentId,
setTeamId,
preparedMatches, preparedMatches,
]) ])

@ -0,0 +1,29 @@
import { useEffect } from 'react'
import { useHeaderFiltersStore } from 'features/HeaderFilters'
import { useSportNameParam, usePageId } from 'hooks'
export const useTeamPage = () => {
const { sportType } = useSportNameParam()
const teamId = usePageId()
const {
setSelectedSportTypeId,
setTeamId,
} = useHeaderFiltersStore()
useEffect(() => {
setSelectedSportTypeId(sportType)
setTeamId(teamId)
return () => {
setSelectedSportTypeId(null)
setTeamId(null)
}
}, [
setSelectedSportTypeId,
setTeamId,
sportType,
teamId,
])
}

@ -1,12 +1,21 @@
import React from 'react' import React from 'react'
import styled from 'styled-components'
const TempPageTitle = styled.span` import { UserFavorites } from 'features/UserFavorites'
padding: 20px; import { Matches } from 'features/Matches'
font-size: 20px; import { UserFavoritesStore } from 'features/UserFavorites/store'
color: white;
`
export const TeamPage = () => ( import { useTeamPage } from './hooks'
<TempPageTitle>TEAM PAGE</TempPageTitle> import { Content } from './styled'
)
export const TeamPage = () => {
useTeamPage()
return (
<UserFavoritesStore>
<UserFavorites />
<Content>
<Matches />
</Content>
</UserFavoritesStore>
)
}

@ -0,0 +1,5 @@
import styled from 'styled-components/macro'
export const Content = styled.main`
padding: 0 16px;
`

@ -22,9 +22,6 @@ export const useTournamentPage = () => {
setSelectedTournamentId, setSelectedTournamentId,
} = useHeaderFiltersStore() } = useHeaderFiltersStore()
setSelectedSportTypeId(sportType)
setSelectedTournamentId(pageId)
const { const {
[`name_${suffix}` as Name]: name = '', [`name_${suffix}` as Name]: name = '',
} = tournamentProfile || {} } = tournamentProfile || {}
@ -36,7 +33,18 @@ export const useTournamentPage = () => {
useEffect(() => { useEffect(() => {
getTournamentInfo(sportType, pageId) getTournamentInfo(sportType, pageId)
.then(setTournamentProfile) .then(setTournamentProfile)
}, [pageId, sportType]) setSelectedSportTypeId(sportType)
setSelectedTournamentId(pageId)
return () => {
setSelectedSportTypeId(null)
setSelectedTournamentId(null)
}
}, [pageId,
setSelectedSportTypeId,
setSelectedTournamentId,
sportType,
])
return { return {
infoItems: [country], infoItems: [country],

@ -53,6 +53,7 @@ type Args = {
date: string, date: string,
matchStatus: MatchStatuses, matchStatus: MatchStatuses,
sportType: SportTypes | null, sportType: SportTypes | null,
teamId: number | null,
tournamentId: number | null, tournamentId: number | null,
} }
@ -67,6 +68,7 @@ export const getMatches = async ({
date, date,
matchStatus, matchStatus,
sportType, sportType,
teamId,
tournamentId, tournamentId,
}: Args) => { }: Args) => {
const config = { const config = {
@ -75,6 +77,7 @@ export const getMatches = async ({
_p_date: date, _p_date: date,
_p_sport: sportType, _p_sport: sportType,
_p_stream_status: matchStatus, _p_stream_status: matchStatus,
_p_team_id: teamId,
_p_tournament_id: tournamentId, _p_tournament_id: tournamentId,
}, },
proc, proc,

Loading…
Cancel
Save