aboutsummaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2023-03-28 19:26:30 +0200
committerMaksymilian Jopek <maks@jopek.eu>2023-03-28 19:26:30 +0200
commitc3c90d575182d64b0e679e8da81a6d4f3559cf1f (patch)
treee1ad938d658e6c80c1392bca86d0755f47064882 /pages
downloadnext-list-app-master.tar.gz
next-list-app-master.tar.zst
next-list-app-master.zip
Working appHEADmaster
Diffstat (limited to 'pages')
-rw-r--r--pages/api/avatars/[id].js10
-rw-r--r--pages/api/avatars/avatars.json37
-rw-r--r--pages/api/avatars/index.js6
-rw-r--r--pages/av/[id].js30
-rw-r--r--pages/index.js20
5 files changed, 103 insertions, 0 deletions
diff --git a/pages/api/avatars/[id].js b/pages/api/avatars/[id].js
new file mode 100644
index 0000000..cacdedd
--- /dev/null
+++ b/pages/api/avatars/[id].js
@@ -0,0 +1,10 @@
+import avatars from "./avatars.json"
+
+export default function(req, res) {
+ let id = req.query.id;
+ const result = avatars.filter(av => av.id == id)
+ if (result.length > 0)
+ res.status(200).json(result[0])
+ else
+ res.status(404).json({ message: 'brak avatara o takim id' })
+}
diff --git a/pages/api/avatars/avatars.json b/pages/api/avatars/avatars.json
new file mode 100644
index 0000000..b5a9cd7
--- /dev/null
+++ b/pages/api/avatars/avatars.json
@@ -0,0 +1,37 @@
+[
+ {
+ "id": "aatrox",
+ "name": "Aatrox",
+ "title": "the Darkin Blade",
+ "icon": "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/Aatrox.png",
+ "description": "Once honored defenders of Shurima against the Void, Aatrox and his brethren would eventually become an even greater threat to Runeterra, and were defeated only by cunning mortal sorcery. But after centuries of imprisonment, Aatrox was the first to find..."
+ },
+ {
+ "id": "ahri",
+ "name": "Ahri",
+ "title": "the Nine-Tailed Fox",
+ "icon": "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/Ahri.png",
+ "description": "Innately connected to the latent power of Runeterra, Ahri is a vastaya who can reshape magic into orbs of raw energy. She revels in toying with her prey by manipulating their emotions before devouring their life essence. Despite her predatory nature..."
+ },
+ {
+ "id": "akali",
+ "name": "Akali",
+ "title": "the Rogue Assassin",
+ "icon": "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/Akali.png",
+ "description": "Abandoning the Kinkou Order and her title of the Fist of Shadow, Akali now strikes alone, ready to be the deadly weapon her people need. Though she holds onto all she learned from her master Shen, she has pledged to defend Ionia from its enemies, one..."
+ },
+ {
+ "id": "alistar",
+ "name": "Alistar",
+ "title": "the Minotaur",
+ "icon": "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/Alistar.png",
+ "description": "Always a mighty warrior with a fearsome reputation, Alistar seeks revenge for the death of his clan at the hands of the Noxian empire. Though he was enslaved and forced into the life of a gladiator, his unbreakable will was what kept him from truly..."
+ },
+ {
+ "id": "amumu",
+ "name": "Amumu",
+ "title": "the Sad Mummy",
+ "icon": "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/Amumu.png",
+ "description": "Legend claims that Amumu is a lonely and melancholy soul from ancient Shurima, roaming the world in search of a friend. Doomed by an ancient curse to remain alone forever, his touch is death, his affection ruin. Those who claim to have seen him describe..."
+ }
+] \ No newline at end of file
diff --git a/pages/api/avatars/index.js b/pages/api/avatars/index.js
new file mode 100644
index 0000000..b14d180
--- /dev/null
+++ b/pages/api/avatars/index.js
@@ -0,0 +1,6 @@
+import avatars from "./avatars.json"
+console.log(avatars);
+
+export default function(req, res) {
+ res.status(200).json(avatars)
+}
diff --git a/pages/av/[id].js b/pages/av/[id].js
new file mode 100644
index 0000000..36db22d
--- /dev/null
+++ b/pages/av/[id].js
@@ -0,0 +1,30 @@
+import Link from "next/link";
+import Avatar from "../../components/Avatar"
+
+export default function Av(props) {
+ console.log(props)
+ return (
+ <>
+ <h1><Link href="/">Go back home</Link></h1>
+ {<Avatar data={props.av} full={true} key={props.av.id} />}
+ </>
+ )
+}
+
+export async function getStaticProps({ params }) {
+ const av = await fetch(`http://localhost:3000/api/avatars/${params.id}`).then(res => res.json());
+ return {
+ props: {
+ av
+ }
+ }
+}
+
+export async function getStaticPaths() {
+ const res = await fetch(`http://localhost:3000/api/avatars`).then(res => res.json());
+ console.log("getStaticPaths ", res)
+ return {
+ paths: res.map(av => `/av/${av.id}`),
+ fallback: true,
+ }
+}
diff --git a/pages/index.js b/pages/index.js
new file mode 100644
index 0000000..9974583
--- /dev/null
+++ b/pages/index.js
@@ -0,0 +1,20 @@
+import Avatar from "../components/Avatar"
+
+export default function Avs(props) {
+ return (
+ <>
+ <h1>Avatars</h1>
+ {props.avs.map(data => <Avatar data={data} key={data.id} />)}
+ </>
+ )
+}
+
+export const getStaticProps = async () => {
+ const res = await fetch(`http://localhost:3000/api/avatars`);
+ const avs = await res.json();
+ return {
+ props: {
+ avs
+ }
+ }
+}