api fetch type fixed

This commit is contained in:
VividTruthKeeper 2022-08-20 00:25:01 +05:00
parent 4bb48e59fc
commit 517b8d43b1
2 changed files with 27 additions and 5 deletions

View File

@ -26,6 +26,7 @@ import { ContactData, Contact } from "../types/contact";
import { Video } from "../types/video";
import { Player, playerType } from "../types/players";
import { About } from "../types/about";
import { Structure } from "../types/structure";
export const getMainSliderData = (
setState: React.Dispatch<SlideProps[]>
@ -109,7 +110,7 @@ export const getVideos = (
.catch();
};
export const getStructure = (setState: any) => {
export const getStructure = (setState: React.Dispatch<Structure[]>) => {
axios
.get(structure)
.then((res) => {

View File

@ -14,11 +14,31 @@ import { highlightColor } from "../helpers/otherVariables";
// Links
import { hosting } from "../links";
// Link: /structure
// Types
import { Structure } from "../types/structure";
const Structure = () => {
const [structureData, setStructureData]: [any, React.Dispatch<any>] =
useState();
const [structureData, setStructureData]: [
Structure[],
React.Dispatch<Structure[]>
] = useState([
{
id: -1,
job: "",
name: "",
email: "",
phone: "",
facebook: "",
img: "",
translations: [
{
model_id: "",
locale: "",
attribute_data: "",
},
],
},
]);
useEffect(() => {
window.scrollTo(0, 0);
@ -27,12 +47,13 @@ const Structure = () => {
useEffect(() => {
getStructure(setStructureData);
}, []);
return (
<main className="structure">
<div className="container">
<div className="structure-inner">
<SectionTitle title={"Структура федерации"} />
{structureData ? (
{structureData[0].id !== -1 ? (
<div className="structure-content">
{structureData.map((person: any) => {
return (