correct navbar

This commit is contained in:
Simon CATANESE 2024-05-07 13:15:21 +02:00
parent 135ab48886
commit 83291c246b
11 changed files with 334 additions and 67 deletions

Binary file not shown.

View File

@ -1,7 +1,64 @@
{ {
"Version": 1, "Version": 1,
"WorkspaceRootPath": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\", "WorkspaceRootPath": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\",
"Documents": [], "Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\nav\\Navbar.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\nav\\Navbar.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\app-layout.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\app-layout.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\contexts\\auth-context.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\contexts\\auth-context.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\authenticated.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\authenticated.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\authentication.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\api\\authentication.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\App.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\App.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\pages\\test.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\pages\\test.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\room.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\api\\room.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\.vs\\2024-DEV-BUT3\\config\\applicationhost.config||{FA3CD31E-987B-443A-9B81-186104E8DAC1}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:.vs\\2024-DEV-BUT3\\config\\applicationhost.config||{FA3CD31E-987B-443A-9B81-186104E8DAC1}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\item\\ItemPage.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\item\\ItemPage.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\package.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:package.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\vitest.config.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:vitest.config.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\vite.config.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:vite.config.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\Source\\Repos\\2024-DEV-BUT3\\src\\hooks\\page-title-context.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\hooks\\page-title-context.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
}
],
"DocumentGroupContainers": [ "DocumentGroupContainers": [
{ {
"Orientation": 0, "Orientation": 0,
@ -9,11 +66,188 @@
"DocumentGroups": [ "DocumentGroups": [
{ {
"DockedWidth": 200, "DockedWidth": 200,
"SelectedChildIndex": -1, "SelectedChildIndex": 3,
"Children": [ "Children": [
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "auth-context.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\contexts\\auth-context.jsx",
"RelativeDocumentMoniker": "src\\contexts\\auth-context.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\contexts\\auth-context.jsx",
"RelativeToolTip": "src\\contexts\\auth-context.jsx",
"ViewState": "AQIAACoAAAAAAAAAAAAAADwAAAAEAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-07T09:38:35.04Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "authenticated.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\authenticated.jsx",
"RelativeDocumentMoniker": "src\\components\\authenticated.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\authenticated.jsx",
"RelativeToolTip": "src\\components\\authenticated.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-07T09:38:15.52Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "authentication.js",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\authentication.js",
"RelativeDocumentMoniker": "src\\api\\authentication.js",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\authentication.js",
"RelativeToolTip": "src\\api\\authentication.js",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAB0AAAACAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001646|",
"WhenOpened": "2024-05-07T09:34:33.928Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Navbar.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\nav\\Navbar.jsx",
"RelativeDocumentMoniker": "src\\components\\nav\\Navbar.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\nav\\Navbar.jsx",
"RelativeToolTip": "src\\components\\nav\\Navbar.jsx",
"ViewState": "AQIAAAsAAAAAAAAAAAAQwBIAAAAgAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-06T21:42:24.983Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "app-layout.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\app-layout.jsx",
"RelativeDocumentMoniker": "src\\components\\app-layout.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\app-layout.jsx",
"RelativeToolTip": "src\\components\\app-layout.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAUAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-07T08:58:37.766Z",
"EditorCaption": ""
},
{ {
"$type": "Bookmark", "$type": "Bookmark",
"Name": "ST:1:0:{d212f56b-c48a-434c-a121-1c5d80b59b9f}" "Name": "ST:1:0:{d212f56b-c48a-434c-a121-1c5d80b59b9f}"
},
{
"$type": "Document",
"DocumentIndex": 8,
"Title": "applicationhost.config",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\.vs\\2024-DEV-BUT3\\config\\applicationhost.config",
"RelativeDocumentMoniker": ".vs\\2024-DEV-BUT3\\config\\applicationhost.config",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\.vs\\2024-DEV-BUT3\\config\\applicationhost.config",
"RelativeToolTip": ".vs\\2024-DEV-BUT3\\config\\applicationhost.config",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000601|",
"WhenOpened": "2024-05-06T23:30:27.125Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 11,
"Title": "vitest.config.js",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\vitest.config.js",
"RelativeDocumentMoniker": "vitest.config.js",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\vitest.config.js",
"RelativeToolTip": "vitest.config.js",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001646|",
"WhenOpened": "2024-05-06T23:20:08.112Z"
},
{
"$type": "Document",
"DocumentIndex": 12,
"Title": "vite.config.js",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\vite.config.js",
"RelativeDocumentMoniker": "vite.config.js",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\vite.config.js",
"RelativeToolTip": "vite.config.js",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001646|",
"WhenOpened": "2024-05-06T23:20:02.873Z"
},
{
"$type": "Document",
"DocumentIndex": 7,
"Title": "room.js",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\room.js",
"RelativeDocumentMoniker": "src\\api\\room.js",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\room.js",
"RelativeToolTip": "src\\api\\room.js",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA4AAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001646|",
"WhenOpened": "2024-05-06T22:06:47.739Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 6,
"Title": "test.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\pages\\test.jsx",
"RelativeDocumentMoniker": "src\\pages\\test.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\pages\\test.jsx",
"RelativeToolTip": "src\\pages\\test.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABMAAAACAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-06T18:36:04.359Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 5,
"Title": "App.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\App.jsx",
"RelativeDocumentMoniker": "src\\App.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\App.jsx",
"RelativeToolTip": "src\\App.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-06T16:40:31.952Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 10,
"Title": "package.json",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\package.json",
"RelativeDocumentMoniker": "package.json",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\package.json",
"RelativeToolTip": "package.json",
"ViewState": "AQIAAAYAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
"WhenOpened": "2024-05-06T23:20:16.656Z"
},
{
"$type": "Document",
"DocumentIndex": 13,
"Title": "page-title-context.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\hooks\\page-title-context.jsx",
"RelativeDocumentMoniker": "src\\hooks\\page-title-context.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\hooks\\page-title-context.jsx",
"RelativeToolTip": "src\\hooks\\page-title-context.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAgAAAAMAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-06T19:10:02.382Z"
},
{
"$type": "Document",
"DocumentIndex": 9,
"Title": "ItemPage.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\item\\ItemPage.jsx",
"RelativeDocumentMoniker": "src\\components\\item\\ItemPage.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\item\\ItemPage.jsx",
"RelativeToolTip": "src\\components\\item\\ItemPage.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAACQAAAApAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-06T18:36:16.712Z"
} }
] ]
} }

View File

@ -1,7 +1,8 @@
{ {
"ExpandedNodes": [ "ExpandedNodes": [
"" "",
"\\src\\assets\\styles"
], ],
"SelectedNode": "\\C:\\Users\\Admin\\Source\\Repos\\2024-DEV-BUT3", "SelectedNode": "\\package.json",
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
} }

Binary file not shown.

View File

@ -7,15 +7,20 @@ import Navbar from "./components/nav/Navbar";
import AppLayout from "./components/app-layout"; import AppLayout from "./components/app-layout";
import { PageTitleProvider } from "./hooks/page-title-context"; import { PageTitleProvider } from "./hooks/page-title-context";
const App = () => ( const App = () => (
<Authenticated>
<PageTitleProvider>
<AppLayout>
</AppLayout> <Authenticated>
</PageTitleProvider> <PageTitleProvider>
<AppLayout>
</AppLayout>
</PageTitleProvider>
</Authenticated> </Authenticated>
); );
export default App; export default App;

View File

@ -1,5 +1,6 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Layout, Menu, theme, Button } from 'antd';
import { Layout, theme, Button } from 'antd';
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'; import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
import { Router } from '../router'; import { Router } from '../router';
import { usePageTitle } from '../hooks/page-title-context'; import { usePageTitle } from '../hooks/page-title-context';
@ -8,20 +9,17 @@ const { Header, Content, Footer, Sider } = Layout;
const AppLayout = ({ footer }) => {
const AppLayout = ({ navbar, footer }) => {
const [collapsed, setCollapsed] = useState(false); const [collapsed, setCollapsed] = useState(false);
const { pageTitle } = usePageTitle(); const { pageTitle } = usePageTitle();
const { const {
token: { colorBgContainer, borderRadiusLG }, token: { colorBgContainer, borderRadiusLG },
} = theme.useToken(); } = theme.useToken();
return ( return (
<Layout > <Layout style={{ height:'100vh' }}>
<Sider breakpoint="lg" collapsible collapsed={collapsed}> <Sider breakpoint="lg" collapsible collapsed={collapsed}>
<div className="demo-logo-vertical" /> <div className="demo-logo-vertical" />
<Navbar/> <Navbar/>
@ -32,9 +30,9 @@ const AppLayout = ({ navbar, footer }) => {
{pageTitle} {pageTitle}
</Header> </Header>
<Content style={{margin: '24px 16px 0'}}> <Content style={{ margin: '24px 16px 0'}}>
<div style={{padding: 24, minHeight: 360, background: colorBgContainer, borderRadius: borderRadiusLG}}> <div style={{ padding: 24, minHeight: 360, background: colorBgContainer, borderRadius: borderRadiusLG }}>
<Router /> <Router />
</div> </div>
</Content> </Content>
<Footer style={{ textAlign: 'center' }}> <Footer style={{ textAlign: 'center' }}>

View File

@ -1,55 +1,85 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { HomeOutlined } from '@ant-design/icons-svg';
import { Menu } from "antd"; import { Menu } from "antd";
import { HomeOutlined } from "@ant-design/icons"
import { Home } from "../../pages"; import { Home } from "../../pages";
import { getRoom } from "../../api/room"; import { getRoom } from "../../api/room";
function getItem(label, key, type, icon, children) { import { isLoggedIn } from "../../api/authentication"
return { import { Test } from "../../pages/test";
key: String(key), import { Link } from "react-router-dom";
icon,
children, function getItem(key, label) {
label, //return {
type, // key: String(key),
}; // icon,
// children,
// label,
// link,
//};
var item = <Menu.Item key={key}>
<Link to="/test">{label}</Link>
</Menu.Item >
return item
} }
const { SubMenu } = Menu;
// Component // Component
const Navbar = () => { const Navbar = () => {
//Hook calls //Hook calls
const [rooms, setRooms] = useState([]); const [rooms, setRooms] = useState([]);
useEffect(() => { useEffect(() => {
if (true) { console.log("NAVBAR EFFECT")
getRoom().then((result) => { isLoggedIn().then((user) => {
setRooms(result); if (user !== "Unauthorized") {
}); getRoom().then((result) => {
} setRooms(result);
}, []); })
}
})
}, []);
const roomItems = rooms.map((room, index) => ( const roomItems = rooms.map((room, index) => (
getItem(room.name, `sub${index}`, <Home />) console.log(index),
getItem(`sub${index}`, room.name)
)); ));
const items = [ const items = [
getItem("Menu principal", "1", <Home />), <Menu.Item key="0">
getItem("Vue d'ensemble", "2", <Home />), <Link to="/">Menu Principal</Link>
{ </Menu.Item>,
key: "3", <Menu.Item key="1" >
label: "Chambres", <Link to="/home">Home</Link>
icon: "", </Menu.Item>,
children: roomItems, // Utilisation des éléments de menu des chambres <Menu.Item key="2" >
}, <Link to="/test">Test</Link>
</Menu.Item>,
<SubMenu key="3" title="Chambres">
{roomItems}
</SubMenu>
]; ];
// Rendu du composant Navbar // Rendu du composant Navbar
return ( try {
<Menu return (
defaultSelectedKeys={["1"]} <Menu
defaultOpenKeys={["sub1"]} defaultSelectedKeys={["1"]}
theme="dark" defaultOpenKeys={["sub1"]}
mode="inline" theme="dark"
items={items} mode="inline"
/> >
); {items}
</Menu>
);
} catch (error) {
console.log(error.stack)
}
}; };
export default Navbar; export default Navbar;

View File

@ -6,6 +6,6 @@ export function useAuth() {
return React.useContext(AuthenticationContext); return React.useContext(AuthenticationContext);
} }
//export function getAuth() { export function useGetAuth() {
// return React.useContext(AuthenticationContext).user; return React.useContext(AuthenticationContext).user;
//} }

View File

@ -9,13 +9,13 @@ import { Layout } from "antd";
setupAxios(); setupAxios();
ReactDOM.createRoot(document.getElementById("root")).render( ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode> <React.StrictMode>
<BrowserRouter> <BrowserRouter>
<CookiesProvider> <CookiesProvider>
<Layout> <App/>
<App />
</Layout>
</CookiesProvider> </CookiesProvider>
</BrowserRouter> </BrowserRouter>
</React.StrictMode>, </React.StrictMode>,

View File

@ -1,7 +1,6 @@
import React from "react"; import React from "react";
import { useAuth } from "../hooks"; import { useAuth } from "../hooks";
import { DatePicker } from "antd";
import { FormCreateItem } from "../components/form/formCreateItem"; import { FormCreateItem } from "../components/form/formCreateItem";
import { FormCreateRoom } from "../components/form/formCreateRoom"; import { FormCreateRoom } from "../components/form/formCreateRoom";
import { RoomItemsList } from "../components/item/RoomItemsList"; import { RoomItemsList } from "../components/item/RoomItemsList";