api fetch type fixed

This commit is contained in:
VividTruthKeeper 2022-08-20 00:36:25 +05:00
parent 3539c01db3
commit b0f62e2472
2 changed files with 33 additions and 4 deletions

View File

@ -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<SlideProps[]>
@ -146,7 +147,7 @@ export const getTeam = (setState: React.Dispatch<Player[]>) => {
.catch();
};
export const getEvents = (setState: any) => {
export const getEvents = (setState: React.Dispatch<tournamentType[]>) => {
axios
.get(events)
.then((res) => {

View File

@ -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<any>] = useState();
const [tournaments, setTournaments]: [
tournamentType[],
React.Dispatch<tournamentType[]>
] = 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 = () => {
</div>
<div className="container">
<div className="tournaments-banner-inner">
{tournaments ? (
{tournaments[0].id !== -1 ? (
tournaments.map((tournament: any) => {
if (tournament.current === 1) {
return (
@ -72,7 +100,7 @@ const Tournaments = () => {
<div className="tournaments-inner">
<div className="tournaments-wrapper">
<div className="tournaments-lower">
{tournaments
{tournaments[0].id !== -1
? tournaments.map((tournament: any) => {
if (tournament.current !== "1") {
return (