fix(#2836): sort tournaments in facr popup

keep-around/2fd168b18eeebc91eac94ae86d817c12edfe1576
Andrei Dekterev 3 years ago
parent e8873ee8f6
commit 09bda05e93
  1. 2
      src/features/AuthStore/helpers.tsx
  2. 10
      src/features/TournamentsPopup/store/hooks/index.tsx

@ -33,7 +33,7 @@ export const getClientNameByRedirectUri = () => {
const redirectUrl = () => {
const clientName = getClientNameByRedirectUri()
switch (true) {
case (process.env.NODE_ENV === 'development' || client.name === 'lff'):
case (process.env.NODE_ENV === 'development' || client.name === 'lff' || client.name === 'facr'):
return `${window.origin}/redirect`
case (ENV === 'staging' || ENV === 'preproduction'):
return `https://${stageENV}.insports.tv/redirect`

@ -30,6 +30,13 @@ export const useTournamentPopup = () => {
const close = () => setIsOpen(false)
const open = () => setIsOpen(true)
const sortTournaments = (tournamentsData: Tournaments) => {
const data = new Map()
tournamentsData.forEach((tourn) => data.set(tourn.id, tourn))
const result = tournamentsId.map((id) => ({ ...data.get(id) }))
return result
}
const convertData = useCallback(
(data: Array<Tournament> | Array<Team>) => map(
data,
@ -42,7 +49,6 @@ export const useTournamentPopup = () => {
),
[],
)
useEffect(() => {
if (client.name === 'facr') {
(async () => {
@ -52,7 +58,7 @@ export const useTournamentPopup = () => {
])
.then((data) => {
// @ts-expect-error
setTournaments(data[0])
setTournaments(sortTournaments(data[0]))
// @ts-expect-error
setTeams(data[1])
setFetching(false)

Loading…
Cancel
Save