From b0f62e2472f0e05bf22bf3332b7a8eb823ce7aba Mon Sep 17 00:00:00 2001 From: VividTruthKeeper Date: Sat, 20 Aug 2022 00:36:25 +0500 Subject: [PATCH] api fetch type fixed --- src/helpers/apiRequests.ts | 3 ++- src/pages/Tournaments.tsx | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/helpers/apiRequests.ts b/src/helpers/apiRequests.ts index 14b06c4..4ce44de 100644 --- a/src/helpers/apiRequests.ts +++ b/src/helpers/apiRequests.ts @@ -27,6 +27,7 @@ import { Video } from "../types/video"; import { Player, playerType } from "../types/players"; import { About } from "../types/about"; import { structureType } from "../types/structure"; +import { tournamentType } from "../types/events"; export const getMainSliderData = ( setState: React.Dispatch @@ -146,7 +147,7 @@ export const getTeam = (setState: React.Dispatch) => { .catch(); }; -export const getEvents = (setState: any) => { +export const getEvents = (setState: React.Dispatch) => { axios .get(events) .then((res) => { diff --git a/src/pages/Tournaments.tsx b/src/pages/Tournaments.tsx index 917d959..b2fe1db 100644 --- a/src/pages/Tournaments.tsx +++ b/src/pages/Tournaments.tsx @@ -15,8 +15,36 @@ import Tournament from "../components/tournaments/Tournament"; // Images import match from "../images/match.jpg"; +// Types +import { tournamentType } from "../types/events"; + const Tournaments = () => { - const [tournaments, setTournaments]: [any, React.Dispatch] = useState(); + const [tournaments, setTournaments]: [ + tournamentType[], + React.Dispatch + ] = useState([ + { + id: -1, + current: -1, + header: "", + events: [ + { + start: "", + end: "", + name: "", + place: "", + img: "", + }, + ], + translations: [ + { + model_id: "", + locale: "", + attribute_data: "", + }, + ], + }, + ]); useEffect(() => { window.scrollTo(0, 0); @@ -35,7 +63,7 @@ const Tournaments = () => {
- {tournaments ? ( + {tournaments[0].id !== -1 ? ( tournaments.map((tournament: any) => { if (tournament.current === 1) { return ( @@ -72,7 +100,7 @@ const Tournaments = () => {
- {tournaments + {tournaments[0].id !== -1 ? tournaments.map((tournament: any) => { if (tournament.current !== "1") { return (