import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import { SEO } from "../../../components/SEO"; const ProfilePage = () => { const router = useRouter(); const profname = router.query.profname as string; type personsSchema = { Id: string; Name: string; Desc?: string; Img?: string; IsAdmin?: boolean; DevBadge?: boolean; AssignedUser?: string; }; const [persons, setPersons] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetch("https://gractwo.pl/api/v1/persons-of-note") .then((res) => { return res.json(); }) .then((data) => { setPersons(data); setLoading(false); }) .catch((err) => { console.log(err); }); }, []); if (loading) { return Fetching data...; } else { if ( persons .map((el: personsSchema) => { return el.Name.replaceAll(" ", "-").toLocaleLowerCase(); }) .includes(profname) ) { const person: personsSchema = persons.filter((wpis: personsSchema) => { return wpis.Name.replaceAll(" ", "-").toLocaleLowerCase() === profname; })[0]; return ( {person.Name} {person.Desc} {/* FOR LATER BIGDESC DATASET */} {/* {person.profile?.bigdesc.map((el, index) => { return {el || }; })} */} ); } else { return ( Sorki!{" :("} Sprawdź pisownię: {`/profile/${profname}`} nie jest poprawnym lokatorem profilu. ); } } }; export default ProfilePage;
{person.Desc}
{el || }
Sprawdź pisownię: {`/profile/${profname}`} nie jest poprawnym lokatorem profilu.