Skip to content

Commit 8ef1f06

Browse files
committed
✨(feature) add config data to homepage
1 parent 9ce67ed commit 8ef1f06

File tree

16 files changed

+244
-188
lines changed

16 files changed

+244
-188
lines changed

backend/app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
lifespan=lifespan,
2626
)
2727

28-
app.include_router(api_router, dependencies=[Depends(get_current_user)], prefix=settings.API_V1_STR)
28+
app.include_router(api_router, prefix=settings.API_V1_STR)
2929
app.include_router(root_router, tags=["health"])
3030

3131
app.add_middleware(

compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ services:
1919
build:
2020
context: backend
2121
dockerfile: Dockerfile
22+
env_file:
23+
- ./backend/.env
2224
healthcheck:
2325
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
2426
interval: 5s
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use client";
2+
import React from "react";
3+
4+
function DynamicIcon({ name }) {
5+
const [Icon, setIcon] = React.useState(null);
6+
7+
React.useEffect(() => {
8+
import("@ant-design/icons")
9+
.then((icons) => {
10+
const ImportedIcon = icons[name];
11+
if (ImportedIcon) {
12+
setIcon(() => ImportedIcon);
13+
} else {
14+
setIcon(null);
15+
}
16+
})
17+
.catch(() => setIcon(null));
18+
}, [name]);
19+
20+
return Icon ? <Icon /> : null;
21+
}
22+
23+
export default DynamicIcon
24+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import DynamicIcon from "./DynamicIcon";
2+
3+
export const menuItem = (sideBarLinks) => [
4+
{
5+
key: "1",
6+
label: "Homepagina",
7+
icon: <DynamicIcon name={"HomeOutlined"} />,
8+
},
9+
{
10+
type: "divider",
11+
},
12+
{
13+
key: "grp",
14+
label: "Mijn Favoriete Apps",
15+
type: "group",
16+
children: sideBarLinks?.map((value) => ({
17+
key: value?.title,
18+
label: value?.title,
19+
icon: <DynamicIcon name={value?.icon} />,
20+
})),
21+
},
22+
];
23+
24+
export function valueOrEmptyString(textContent) {
25+
if (textContent) {
26+
return textContent;
27+
}
28+
return "";
29+
}
30+
31+
export const baseUrl = valueOrEmptyString(
32+
process.env.NEXT_PUBLIC_BACKEND_BASE_URL
33+
);

frontend/src/app/Common/pageConfig.tsx

Lines changed: 0 additions & 70 deletions
This file was deleted.

frontend/src/app/Components/PageLayout.tsx

Lines changed: 0 additions & 86 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"use client";
2+
3+
import React, { createContext, useContext, useState, useEffect } from "react";
4+
import { baseUrl } from "../Common/pageConfig";
5+
6+
const AppContext = createContext();
7+
8+
export function AppProvider({ children }) {
9+
const [items, setitems] = useState(null);
10+
11+
useEffect(() => {
12+
fetch(baseUrl + "/api/v1/config", {
13+
method: "GET",
14+
mode: "cors",
15+
headers: {
16+
Accept: "application/json",
17+
"Content-Type": "application/json",
18+
// Authorization: `Bearer ${keycloak.token}`,
19+
},
20+
})
21+
.then((res) => res.json())
22+
.then((json) => setitems(json))
23+
.catch((err) => console.error("Fetch error:", err));
24+
}, []);
25+
26+
return <AppContext.Provider value={{ items }}>{children}</AppContext.Provider>;
27+
}
28+
29+
export function useAppContext() {
30+
const ctx = useContext(AppContext);
31+
if (!ctx) throw new Error("useAppContext must be used within AppProvider");
32+
return ctx;
33+
}
File renamed without changes.

frontend/src/app/auth/keycloak.tsx renamed to frontend/src/app/Context/auth/keycloak.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Keycloak from 'keycloak-js';
2-
import { valueOrEmptyString } from '../Common/pageConfig';
2+
import { valueOrEmptyString } from '../../Common/pageConfig';
33

44

55
let keycloak: Keycloak;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"use client";
2+
import React from "react";
3+
import { Avatar, Flex, Layout } from "antd";
4+
import { UserOutlined } from "@ant-design/icons";
5+
import Link from "next/link";
6+
import Image from "next/image";
7+
8+
const { Header } = Layout;
9+
10+
function HeaderLayout() {
11+
return (
12+
<Header>
13+
<Flex justify={"space-between"}>
14+
<div>
15+
<Image
16+
src="/mijnbureau.svg"
17+
alt="logo"
18+
width="50"
19+
height="50"
20+
style={{ marginTop: 5 }}
21+
/>
22+
<span style={{ color: "white" }}>Mijn Bureau</span>
23+
</div>
24+
<div>
25+
<Link href="/#">
26+
<Avatar icon={<UserOutlined />} />
27+
</Link>
28+
</div>
29+
</Flex>
30+
</Header>
31+
);
32+
}
33+
34+
export default HeaderLayout;

0 commit comments

Comments
 (0)