Skip to content

Commit

Permalink
outsourced to external api
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-hurst committed Nov 3, 2024
1 parent 3ae85c0 commit ecafd1f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 181 deletions.
177 changes: 0 additions & 177 deletions content/gi/page-content/fachschaft/rollen.json

This file was deleted.

20 changes: 16 additions & 4 deletions src/app/wp/fachschaft/das-sind-wir/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ import styles from "@/app/page.module.css"
import Image from "next/image"
import Fachschaft from "@/img/fachschaft.jpg"

import rollen from "@/../content/gi/page-content/fachschaft/rollen.json"
import error_data from "./rollen_error_data.json"
import { BACKEND_BASE } from "@/app/BACKEND_URL"

export default function Content() {
export default async function Content() {

// rollen variable is importet on top
var rollen = {}
try {
const resp = await fetch(`${BACKEND_BASE}/fachschaft_rollen`, { cache: "no-store" })
if (resp.status != 200) {
throw new Error();
} else {
var rollen = await resp.json()
}
} catch {
var rollen = { ...error_data }
console.log(error_data)
}

return (
<>
Expand All @@ -21,7 +33,7 @@ export default function Content() {
Am {rollen.wahldatum} ist der aktuelle Fachschaftsrat gewählt worden. Das Protokoll
gibt’s <a href={rollen.protokoll}>hier</a>.
</h3>
{rollen.roles.map(role => <Role role={role.role} names={role.names} description={role.description} key={role}/>)}
{rollen.roles.map(role => <Role role={role.role} names={role.names} description={role.description} key={role} />)}
</>
)
}
Expand Down
17 changes: 17 additions & 0 deletions src/app/wp/fachschaft/das-sind-wir/rollen_error_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"_comment": "Mock error data, in case we cannot reach the api",
"wahldatum": "UNKNOWN",
"protokoll": "UNKNWON.URL",
"roles": [
{
"role": "UNKNWON",
"names": "UNKNWON UNKNWON",
"description": "Error fetching data form API"
},
{
"role": "UNKNWON",
"names": "UNKNWON UNKNWON",
"description": "Error fetching data form API"
}
]
}

0 comments on commit ecafd1f

Please sign in to comment.