From c1efaab359c0e63f87ba228d18929c39eecf4936 Mon Sep 17 00:00:00 2001 From: VividTruthKeeper Date: Wed, 27 Jul 2022 15:39:14 +0500 Subject: [PATCH] structure page api integrated --- src/components/global/Nav.tsx | 2 +- src/helpers/apiRequests.ts | 10 +++ src/links.ts | 2 + src/pages/Structure.tsx | 119 ++++++++++++++++++---------------- 4 files changed, 77 insertions(+), 56 deletions(-) diff --git a/src/components/global/Nav.tsx b/src/components/global/Nav.tsx index 2ea0b48..f8ab669 100644 --- a/src/components/global/Nav.tsx +++ b/src/components/global/Nav.tsx @@ -43,7 +43,7 @@ const Nav = ({ dropdown, setDropdown }: dropdown) => { О федерации
  • - Структура федерации + Структура федерации
  • О федерации diff --git a/src/helpers/apiRequests.ts b/src/helpers/apiRequests.ts index c44871e..7dcaef9 100644 --- a/src/helpers/apiRequests.ts +++ b/src/helpers/apiRequests.ts @@ -12,6 +12,7 @@ import { postsAside, post, videos, + structure, } from "../links"; import React from "react"; @@ -92,3 +93,12 @@ export const getVideos = (setState: any) => { }) .catch(); }; + +export const getStructure = (setState: any) => { + axios + .get(structure) + .then((res) => { + setState(res.data.data); + }) + .catch(); +}; diff --git a/src/links.ts b/src/links.ts index 019f6f0..1bb1c2a 100644 --- a/src/links.ts +++ b/src/links.ts @@ -13,3 +13,5 @@ export const postsAside: string = export const post: string = hosting + "/api/v1/posts"; // /id ? locale export const videos: string = hosting + "/api/v1/videos"; + +export const structure: string = hosting + "/api/v1/structure"; diff --git a/src/pages/Structure.tsx b/src/pages/Structure.tsx index 91270cd..103413e 100644 --- a/src/pages/Structure.tsx +++ b/src/pages/Structure.tsx @@ -1,79 +1,88 @@ // Modules -import { useEffect } from "react"; +import React, { useEffect, useState } from "react"; +import Skeleton from "react-loading-skeleton"; import { v4 as uuidv4 } from "uuid"; // Components import PersonInfo from "../components/structure/PersonInfo"; import SectionTitle from "../components/global/SectionTitle"; -// Images -import arkady from "../images/arkady.jpg"; -import sasha from "../images/sasha.jpg"; +// Helpers +import { getStructure } from "../helpers/apiRequests"; -// Types -import { personProps } from "../types/personProps"; - -const personData: personProps[] = [ - { - img: arkady, - position: "Assistant to the FIDE President", - name: "Kiselev, Konstantin", - email: "fidepresident@fide.com", - tel: "+993 65 65-65-65", - facebook: "@fidepresident", - }, - { - img: sasha, - position: "FIDE President", - name: "Dvorkovich, Arkady", - email: "fidepresident@fide.com", - tel: "+993 65 65-65-65", - facebook: "@fidepresident", - }, - { - img: arkady, - position: "Assistant to the FIDE President", - name: "Kiselev, Konstantin", - email: "fidepresident@fide.com", - tel: "+993 65 65-65-65", - facebook: "@fidepresident", - }, - { - img: sasha, - position: "FIDE President", - name: "Dvorkovich, Arkady", - email: "fidepresident@fide.com", - tel: "+993 65 65-65-65", - facebook: "@fidepresident", - }, -]; +// Links +import { hosting } from "../links"; // Link: /structure const Structure = () => { + const [structureData, setStructureData]: [any, React.Dispatch] = + useState(); + useEffect(() => { window.scrollTo(0, 0); }, []); + + useEffect(() => { + getStructure(setStructureData); + }, []); return (
    -
    - {personData.map((person) => { - return ( - + {structureData.map((person: any) => { + return ( + + ); + })} +
    + ) : ( +
    + {["", "", "", "", "", ""].map(() => ( +
    - ); - })} -
    + style={{ width: "100%" }} + > +
    + +
    +
    + + +
    + + + +
    +
    +
    + ))} +
    + )}