diff --git a/data/administracja.json b/data/administracja.json deleted file mode 100644 index a6b4c85..0000000 --- a/data/administracja.json +++ /dev/null @@ -1,58 +0,0 @@ -[ - { - "name": "jamesen", - "desc": "project pioneer.", - "img": "https://i.imgur.com/CBRxP3Z.png", - "devBadge": true, - "profile": { - "bigdesc": ["Tutaj będzie kiedyś opis profilu."], - "links": [ - { - "resname": "Website", - "href": "https://manczak.net" - } - ] - } - }, - { - "name": "Mollin", - "desc": "porucznik essy.", - "img": "https://i.imgur.com/64sHQjM.jpg", - "profile": { - "bigdesc": ["Tutaj będzie kiedyś opis profilu."] - } - }, - { - "name": "Elephant", - "desc": "osobnik demencyjny.", - "img": "https://i.imgur.com/INQM1Cd.png", - "profile": { - "bigdesc": ["Tutaj będzie kiedyś opis profilu."] - } - }, - { - "name": "Dzioba", - "desc": "backend bastard.", - "img": "https://i.imgur.com/0gUirZH.png", - "devBadge": true, - "profile": { - "bigdesc": ["Tutaj będzie kiedyś opis profilu."] - } - }, - { - "name": "KuOlek", - "desc": "duch. (bo go nie ma)", - "img": "https://i.imgur.com/SCTXTtz.png", - "profile": { - "bigdesc": ["Tutaj będzie kiedyś opis profilu."] - } - }, - { - "name": "Bavil Gravlax", - "desc": "śpiący rękawek.", - "img": "https://i.imgur.com/6bxpBgK.png", - "profile": { - "bigdesc": ["Tutaj będzie kiedyś opis profilu."] - } - } -] diff --git a/data/links.json b/data/links.json index ccb77c2..3739a8f 100644 --- a/data/links.json +++ b/data/links.json @@ -29,7 +29,7 @@ }, { "href": "/o-gractwie#sklad-administracji", - "hrefalias": ["/profile"] + "hrefalias": ["/profil"] }, { "name": "Kod Źródłowy", diff --git a/pages/404.tsx b/pages/404.tsx index 4b89920..a8698f3 100644 --- a/pages/404.tsx +++ b/pages/404.tsx @@ -1,9 +1,13 @@ import { SEO } from "../components/SEO"; import { useRouter } from "next/router"; -import Link from "next/link"; +import { useEffect, useState } from "react"; const PageError404 = () => { const router = useRouter(); + const [badPath, setBadPath] = useState(""); + useEffect(() => { + setBadPath(router.asPath); + }, [router.asPath]); return ( <> @@ -42,7 +46,7 @@ const PageError404 = () => { boxShadow: "var(--shadow0)", }} > - {useRouter().asPath} + {badPath} {" "} nie jest poprawnym adresem.

diff --git a/pages/o-gractwie.tsx b/pages/o-gractwie.tsx index af60495..55dde0f 100644 --- a/pages/o-gractwie.tsx +++ b/pages/o-gractwie.tsx @@ -73,7 +73,7 @@ const PageInfo = () => { return ( { + 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/admincards") + .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.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; diff --git a/pages/profile/[profname]/index.tsx b/pages/profile/[profname]/index.tsx deleted file mode 100644 index 21f684d..0000000 --- a/pages/profile/[profname]/index.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { useRouter } from "next/router"; -import administracja from "../../../data/administracja.json"; - -const ProfilePage = () => { - const router = useRouter(); - const profname = router.query.profname as string; - if ( - administracja - .map((el) => { - return el.name.replaceAll(" ", "-").toLocaleLowerCase(); - }) - .includes(profname) - ) { - const person = administracja.filter((wpis) => { - return wpis.name.replaceAll(" ", "-").toLocaleLowerCase() === profname; - })[0]; - return ( -
-
- {`${person.name} -
-

{person.name}

-

{person.desc}

-
-
- {person.profile?.bigdesc.map((el, index) => { - return

{el ||
}

; - })} -
- ); - } else { - return ( -
-

Sorki!{" :("}

-

- Sprawdź pisownię: - - {`/profile/${profname}`} - - nie jest poprawnym lokatorem profilu. -

-
- ); - } -}; - -export default ProfilePage;