diff --git a/package-lock.json b/package-lock.json
index 41fe026..00d3eea 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,6 +18,7 @@
"react-router-dom": "^6.21.3"
},
"devDependencies": {
+ "antd": "^5.15.4",
"@playwright/test": "^1.42.1",
"@testing-library/react": "^14.1.2",
"@types/node": "^20.11.9",
diff --git a/package.json b/package.json
index cfc611a..e201860 100644
--- a/package.json
+++ b/package.json
@@ -24,6 +24,7 @@
"react-router-dom": "^6.21.3"
},
"devDependencies": {
+ "antd": "^5.15.4",
"@playwright/test": "^1.42.1",
"@testing-library/react": "^14.1.2",
"@types/node": "^20.11.9",
diff --git a/src/App copy.jsx b/src/App copy.jsx
deleted file mode 100644
index 0a0016e..0000000
--- a/src/App copy.jsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import React from "react";
-
-import { Authenticated } from "./components";
-
-import { Router } from "./router";
-
-const App = () => (
-
-
-
-);
-
-export default App;
diff --git a/src/App.jsx b/src/App.jsx
index 0a0016e..ff2f13a 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -3,10 +3,12 @@ import React from "react";
import { Authenticated } from "./components";
import { Router } from "./router";
+import Navbar from "./components/nav/Navbar";
const App = () => (
+
);
diff --git a/src/api/room.js b/src/api/room.js
new file mode 100644
index 0000000..2e10903
--- /dev/null
+++ b/src/api/room.js
@@ -0,0 +1,10 @@
+import axios from "axios";
+
+export const getRoom = async () => {
+ try {
+ const response = await axios.get("/room", {});
+ return response.data;
+ } catch (error) {
+ return error.response.data;
+ }
+};
diff --git a/src/components/nav/Navbar.jsx b/src/components/nav/Navbar.jsx
new file mode 100644
index 0000000..9fb8914
--- /dev/null
+++ b/src/components/nav/Navbar.jsx
@@ -0,0 +1,83 @@
+import React, { useState } from "react";
+import { Authenticated } from "..";
+import { Router } from "../../router";
+
+import {
+ AppstoreOutlined,
+ ContainerOutlined,
+ DesktopOutlined,
+ MailOutlined,
+ MenuFoldOutlined,
+ MenuUnfoldOutlined,
+ PieChartOutlined,
+} from "@ant-design/icons";
+import { Button, Menu } from "antd";
+import { Home } from "../../pages";
+import { getRoom } from "../../api/room";
+import { getAuth, useAuth } from "../../hooks";
+function getItem(label, key, icon, children, type) {
+ return {
+ key,
+ icon,
+ children,
+ label,
+ type,
+ };
+}
+
+// Component
+const Navbar = () => {
+ //Hook calls
+ const [collapsed, setCollapsed] = useState(false);
+ const toggleCollapsed = () => {
+ setCollapsed(!collapsed);
+ };
+ const [rooms, setRooms] = useState([]);
+
+ useEffect(() => {
+ if (user) {
+ getRoom().then((result) => {
+ setRooms(result);
+ });
+ }
+ }, []);
+
+ const items = [
+ getItem("Menu principal", "1", ),
+ getItem("Vue d'ensemble", "2", ),
+ getItem("Chambres", "3", , [
+ rooms.forEach((room, i = 0) => {
+ i++;
+ getItem(room.name, `sub${i}`, );
+ }),
+ ]),
+ ];
+
+ // Rendering
+ return (
+
+
+
+
+ );
+};
+export default Navbar;
diff --git a/src/hooks/use-auth.js b/src/hooks/use-auth.js
index 5ef6e0f..aef1ae6 100644
--- a/src/hooks/use-auth.js
+++ b/src/hooks/use-auth.js
@@ -5,3 +5,7 @@ import { AuthenticationContext } from "../contexts";
export function useAuth() {
return React.useContext(AuthenticationContext);
}
+
+export function getAuth() {
+ return React.useContext(AuthenticationContext).user;
+}