api fetch type fixed
This commit is contained in:
parent
3539c01db3
commit
b0f62e2472
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Reference in New Issue