From 09bda05e93a063efa4cf3d267e619c217aedf79f Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Fri, 23 Sep 2022 13:16:37 +0400 Subject: [PATCH] fix(#2836): sort tournaments in facr popup --- src/features/AuthStore/helpers.tsx | 2 +- src/features/TournamentsPopup/store/hooks/index.tsx | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/features/AuthStore/helpers.tsx b/src/features/AuthStore/helpers.tsx index 922e1980..4edfec33 100644 --- a/src/features/AuthStore/helpers.tsx +++ b/src/features/AuthStore/helpers.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` diff --git a/src/features/TournamentsPopup/store/hooks/index.tsx b/src/features/TournamentsPopup/store/hooks/index.tsx index a5a01bee..b55ceaa7 100644 --- a/src/features/TournamentsPopup/store/hooks/index.tsx +++ b/src/features/TournamentsPopup/store/hooks/index.tsx @@ -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 | Array) => 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)