From 3c6acdb08b95827404b6d143dbf39b8477c68deb Mon Sep 17 00:00:00 2001 From: jakubmanczak Date: Mon, 26 Dec 2022 23:34:21 +0100 Subject: [PATCH] fetch admincard data from api instead of json --- pages/o-gractwie.tsx | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/pages/o-gractwie.tsx b/pages/o-gractwie.tsx index 8667d78..af60495 100644 --- a/pages/o-gractwie.tsx +++ b/pages/o-gractwie.tsx @@ -4,10 +4,31 @@ import styles from "../styles/oGractwie.module.scss"; import Link from "next/link"; import { Icon } from "../components/Icon"; import { iconselection } from "../components/Icon"; -import administracja from "../data/administracja.json"; import links from "../data/links.json"; +import { useEffect, useState } from "react"; const PageInfo = () => { + const [adminList, setAdminList] = useState([]); + type apiResType = { + Id: string; + Name: string; + Desc: string; + Img: string; + DevBadge: string; + AssignedUser: string; + }; + useEffect(() => { + fetch("https://gractwo.pl/api/v1/admincards") + .then((res) => { + return res.json(); + }) + .then((data) => { + setAdminList(data); + }) + .catch((err) => { + console.log(err); + }); + }, []); return ( <> @@ -48,20 +69,21 @@ const PageInfo = () => {

skład administracji

- {administracja.map((el) => { + {adminList.map((el: apiResType) => { return (
- {`zdjęcie + {`zdjęcie
-

{el.name}

-

{el.desc || "brak opisu."}

- {el.devBadge ? ( +

{el.Name}

+

{el.Desc || "brak opisu."}

+ {el.DevBadge ? ( DEV ) : ( ""