Merge pull request #14 from gractwo/tuco
further work on profiles, patches
This commit is contained in:
@@ -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."]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"href": "/o-gractwie#sklad-administracji",
|
"href": "/o-gractwie#sklad-administracji",
|
||||||
"hrefalias": ["/profile"]
|
"hrefalias": ["/profil"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Kod Źródłowy",
|
"name": "Kod Źródłowy",
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import { SEO } from "../components/SEO";
|
import { SEO } from "../components/SEO";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import Link from "next/link";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
const PageError404 = () => {
|
const PageError404 = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const [badPath, setBadPath] = useState("");
|
||||||
|
useEffect(() => {
|
||||||
|
setBadPath(router.asPath);
|
||||||
|
}, [router.asPath]);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SEO title="404" />
|
<SEO title="404" />
|
||||||
@@ -42,7 +46,7 @@ const PageError404 = () => {
|
|||||||
boxShadow: "var(--shadow0)",
|
boxShadow: "var(--shadow0)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{useRouter().asPath}
|
{badPath}
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
nie jest poprawnym adresem.
|
nie jest poprawnym adresem.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ const PageInfo = () => {
|
|||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
key={el.Id}
|
key={el.Id}
|
||||||
href={`/profile/${el.Name.replaceAll(
|
href={`/profil/${el.Name.replaceAll(
|
||||||
" ",
|
" ",
|
||||||
"-"
|
"-"
|
||||||
).toLocaleLowerCase()}`}
|
).toLocaleLowerCase()}`}
|
||||||
|
|||||||
104
pages/profil/[profname]/index.tsx
Normal file
104
pages/profil/[profname]/index.tsx
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
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/admincards")
|
||||||
|
.then((res) => {
|
||||||
|
return res.json();
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
setPersons(data);
|
||||||
|
setLoading(false);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
if (loading) {
|
||||||
|
return <main style={{ color: "grey" }}>Fetching data...</main>;
|
||||||
|
} 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 (
|
||||||
|
<main>
|
||||||
|
<SEO title={person.Name} />
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "1rem",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={person.Img}
|
||||||
|
alt={`${person.Name} profile image`}
|
||||||
|
style={{
|
||||||
|
width: "128px",
|
||||||
|
aspectRatio: "1/1",
|
||||||
|
objectFit: "cover",
|
||||||
|
borderRadius: "50%",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<h1>{person.Name}</h1>
|
||||||
|
<p>{person.Desc}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* FOR LATER BIGDESC DATASET */}
|
||||||
|
{/* {person.profile?.bigdesc.map((el, index) => {
|
||||||
|
return <p key={index}>{el || <br />}</p>;
|
||||||
|
})} */}
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<main>
|
||||||
|
<SEO title="nieznany profil" />
|
||||||
|
<h1>Sorki!{" :("}</h1>
|
||||||
|
<p style={{ lineHeight: "30px" }}>
|
||||||
|
Sprawdź pisownię:
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
background: "var(--black1)",
|
||||||
|
boxShadow: "var(--shadow0)",
|
||||||
|
padding: "8px",
|
||||||
|
margin: "10px",
|
||||||
|
borderRadius: "4px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{`/profile/${profname}`}
|
||||||
|
</span>
|
||||||
|
nie jest poprawnym lokatorem profilu.
|
||||||
|
</p>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProfilePage;
|
||||||
@@ -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 (
|
|
||||||
<main>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: "1rem",
|
|
||||||
marginBottom: "1rem",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src={person.img}
|
|
||||||
alt={`${person.name} profile image`}
|
|
||||||
style={{
|
|
||||||
width: "128px",
|
|
||||||
aspectRatio: "1/1",
|
|
||||||
objectFit: "cover",
|
|
||||||
borderRadius: "50%",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div>
|
|
||||||
<h1>{person.name}</h1>
|
|
||||||
<p>{person.desc}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{person.profile?.bigdesc.map((el, index) => {
|
|
||||||
return <p key={index}>{el || <br />}</p>;
|
|
||||||
})}
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<main>
|
|
||||||
<h1>Sorki!{" :("}</h1>
|
|
||||||
<p style={{ lineHeight: "30px" }}>
|
|
||||||
Sprawdź pisownię:
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
background: "var(--black1)",
|
|
||||||
boxShadow: "var(--shadow0)",
|
|
||||||
padding: "8px",
|
|
||||||
margin: "10px",
|
|
||||||
borderRadius: "4px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{`/profile/${profname}`}
|
|
||||||
</span>
|
|
||||||
nie jest poprawnym lokatorem profilu.
|
|
||||||
</p>
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ProfilePage;
|
|
||||||
Reference in New Issue
Block a user