diff --git a/.vs/2024-DEV-BUT3/v17/.wsuo b/.vs/2024-DEV-BUT3/v17/.wsuo index e30e1c1..e79653d 100644 Binary files a/.vs/2024-DEV-BUT3/v17/.wsuo and b/.vs/2024-DEV-BUT3/v17/.wsuo differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index dc91451..4387610 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/package-lock.json b/package-lock.json index 0a652ea..d72c1bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "react": "^18.2.0", "react-cookie": "^7.0.2", "react-dom": "^18.2.0", - "react-router-dom": "^6.21.3" + "react-router-dom": "^6.23.1" }, "devDependencies": { "@playwright/test": "^1.42.1", @@ -990,9 +990,9 @@ } }, "node_modules/@remix-run/router": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.14.2.tgz", - "integrity": "sha512-ACXpdMM9hmKZww21yEqWwiLws/UPLhNKvimN8RrYSqPSvB3ov7sLvAcfvaxePeLvccTQKGdkDIhLYApZVDFuKg==", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.16.1.tgz", + "integrity": "sha512-es2g3dq6Nb07iFxGk5GuHN20RwBZOsuDQN7izWIisUcv9r+d2C5jQxqmgkdebXgReWfiyUabcki6Fg77mSNrig==", "engines": { "node": ">=14.0.0" } @@ -5312,11 +5312,11 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/react-router": { - "version": "6.21.3", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.21.3.tgz", - "integrity": "sha512-a0H638ZXULv1OdkmiK6s6itNhoy33ywxmUFT/xtSoVyf9VnC7n7+VT4LjVzdIHSaF5TIh9ylUgxMXksHTgGrKg==", + "version": "6.23.1", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.23.1.tgz", + "integrity": "sha512-fzcOaRF69uvqbbM7OhvQyBTFDVrrGlsFdS3AL+1KfIBtGETibHzi3FkoTRyiDJnWNc2VxrfvR+657ROHjaNjqQ==", "dependencies": { - "@remix-run/router": "1.14.2" + "@remix-run/router": "1.16.1" }, "engines": { "node": ">=14.0.0" @@ -5326,12 +5326,12 @@ } }, "node_modules/react-router-dom": { - "version": "6.21.3", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.21.3.tgz", - "integrity": "sha512-kNzubk7n4YHSrErzjLK72j0B5i969GsuCGazRl3G6j1zqZBLjuSlYBdVdkDOgzGdPIffUOc9nmgiadTEVoq91g==", + "version": "6.23.1", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.23.1.tgz", + "integrity": "sha512-utP+K+aSTtEdbWpC+4gxhdlPFwuEfDKq8ZrPFU65bbRJY+l706qjR7yaidBpo3MSeA/fzwbXWbKBI6ftOnP3OQ==", "dependencies": { - "@remix-run/router": "1.14.2", - "react-router": "6.21.3" + "@remix-run/router": "1.16.1", + "react-router": "6.23.1" }, "engines": { "node": ">=14.0.0" diff --git a/package.json b/package.json index 4e063e2..7971f83 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "react": "^18.2.0", "react-cookie": "^7.0.2", "react-dom": "^18.2.0", - "react-router-dom": "^6.21.3" + "react-router-dom": "^6.23.1" }, "devDependencies": { "@playwright/test": "^1.42.1", diff --git a/src/assets/styles/room-list.css b/src/assets/styles/room-list.css new file mode 100644 index 0000000..6a60e51 --- /dev/null +++ b/src/assets/styles/room-list.css @@ -0,0 +1,38 @@ +.list-container { + width: 100%; + max-height:500px; + overflow-y: auto; /* Activer le défilement vertical si nécessaire */ + padding: 20px; /* Espace intérieur de la liste */ +} + +.room-details { + width: 100%; /* Largeur de chaque boîte */ + background-color: #f9f9f9; + border-radius: 10px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + padding: 20px; + margin-bottom: 20px; /* Espace entre chaque boîte */ + transition: transform 0.3s ease; +} + + .room-details:hover { + transform: translateY(-5px); /* Effet d'élévation au survol */ + } + + .room-details .title { + font-size: 18px; + font-weight: bold; + margin-bottom: 10px; + } + + .room-details .characteristic { + margin-bottom: 10px; + } + + .room-details .label { + font-weight: bold; + } + + .room-details .value { + color: #666; + } diff --git a/src/components/diagram.jsx b/src/components/diagram.jsx index 24dcb57..87fc761 100644 --- a/src/components/diagram.jsx +++ b/src/components/diagram.jsx @@ -14,15 +14,20 @@ const Diagram = ({ data }) => { return (
-

Prix total par an

- {diagramData.map(({ name, value }) => ( -
-
{name}
-
-
{value}
+

Prix total par an

+ {diagramData.map(({ name, value }) => { + // Appliquer l'échelle logarithmique à la valeur + const scaledValue = Math.log(value + 1); // Ajouter 1 pour éviter le logarithme de zéro + const scaledMaxValue = Math.log(maxValue + 1); + return ( +
+
{name}
+
+
{value}
+
-
- ))} + ); + })}
); }; diff --git a/src/components/item/ItemBox.jsx b/src/components/item/ItemBox.jsx index eca0972..1cc87da 100644 --- a/src/components/item/ItemBox.jsx +++ b/src/components/item/ItemBox.jsx @@ -3,28 +3,14 @@ import '../../assets/styles/modal.css' import '../../assets/styles/itembox.css' import FormUpdateItem from '../form/formUpdateItem'; import {Image } from '../parts/image' +import {Description } from '../parts/description' +import {Characteristic } from '../parts/characteristic' + -// Composant Description -const Description = ({ title, children }) => { - return ( -
-

{title}

- {children} -
- ); -}; -// Composant Caractéristique -const Characteristic = ({ label, value }) => { - return ( -
- {label}: {value} -
- ); -}; diff --git a/src/components/nav/Navbar.jsx b/src/components/nav/Navbar.jsx index da78d9a..f6921b7 100644 --- a/src/components/nav/Navbar.jsx +++ b/src/components/nav/Navbar.jsx @@ -42,10 +42,10 @@ const Navbar = () => { const items = [ - Menu Principal + Login / Logout , - Home + Menu Principal , Tous les articles diff --git a/src/components/parts/characteristic.jsx b/src/components/parts/characteristic.jsx new file mode 100644 index 0000000..95aed96 --- /dev/null +++ b/src/components/parts/characteristic.jsx @@ -0,0 +1,11 @@ +import React, { useEffect, useState } from 'react'; + +// Composant Caractéristique +export const Characteristic = ({ label, value }) => { + + return ( +
+ {label}: {value} +
+ ); +}; \ No newline at end of file diff --git a/src/components/parts/description.jsx b/src/components/parts/description.jsx new file mode 100644 index 0000000..e86edd4 --- /dev/null +++ b/src/components/parts/description.jsx @@ -0,0 +1,11 @@ +import React, { useEffect, useState } from 'react'; + +// Composant Description +export const Description = ({ title, children }) => { + return ( +
+

{title}

+ {children} +
+ ); +}; \ No newline at end of file diff --git a/src/components/rooms/room-detail.jsx b/src/components/rooms/room-detail.jsx new file mode 100644 index 0000000..e955ace --- /dev/null +++ b/src/components/rooms/room-detail.jsx @@ -0,0 +1,45 @@ +import React, { useEffect, useState } from 'react'; +import { FormCreateRoom } from '../../components/form/formCreateRoom'; +//import { RoomUpdateForm } from './RoomUpdateForm'; + +export const RoomDetail = ({ selectedRoom, onCreateFormSubmit, onUpdateFormSubmit, onBack }) => { + const [isUpdateFormVisible, setIsUpdateFormVisible] = useState(false); + + useEffect(() => { + if (selectedRoom) { + setIsUpdateFormVisible(true) + } + }, [selectedRoom]); + + + // Afficher le formulaire de mise à jour lorsqu'une chambre est sélectionnée + const handleRoomClick = () => { + setIsUpdateFormVisible(true); + }; + + // Afficher le formulaire de création lorsqu'on revient en arrière + const handleBackClick = () => { + setIsUpdateFormVisible(false); + onBack(null); + }; + + return ( +
+ {isUpdateFormVisible + ? ( +
+

Modifier une chambre

+ + +
+ ) + : ( +
+

Ajouter une chambre

+ +
+ ) + } +
+ ); +}; \ No newline at end of file diff --git a/src/components/rooms/room-list.jsx b/src/components/rooms/room-list.jsx index e2a1ed6..3b45d4d 100644 --- a/src/components/rooms/room-list.jsx +++ b/src/components/rooms/room-list.jsx @@ -1,17 +1,9 @@ import React, { useState, useEffect } from "react"; -import axios from 'axios'; // Assurez-vous que le chemin d'importation soit correct -import { ItemBox } from './ItemBox'; -import { Space, DatePicker, Row, Col, Select, Input, InputNumber } from 'antd'; -import '../../assets/styles/item-page.css' +import '../../assets/styles/room-list.css' +import { RoomBox } from '../../components/rooms/roomBox' +import { formatRoomStats } from "../../api/room"; - -const { RangePicker } = DatePicker; -const { Option } = Select; - -const itemsPerPage = 8; // Nombre total d'items par page -const itemsPerRow = 4; // Nombre d'items par rangée - // Fonction pour diviser le tableau d'items en rangées const chunkArray = (arr, size) => { const chunkedArr = []; @@ -22,25 +14,32 @@ const chunkArray = (arr, size) => { }; // Composant d'affichage de la page -export const RoomList = (roomsParam) => { - const [rooms, setRooms] = useState([]); - const [selectedRoom, setSelectedRoom] = useState('all'); +export const RoomList = ({ statsParam, onRoomClick }) => { + const [rooms, setRooms] = useState([]); + const [selectedRoom, setSelectedRoom] = useState('all'); useEffect(() => { - setRooms(roomsParam) - }, [roomsParam]); + if (statsParam.rooms) { + console.log(statsParam.rooms) + let formatedStats = formatRoomStats(statsParam) + setRooms(formatedStats.rooms) + } + }, [statsParam]); - const handleRoomChange = (value) => { - setSelectedRoom(value); - }; - return ( -
-
- {rooms.forEach((room) => { - -
- ); + const handleRoomClick = (roomId) => { + onRoomClick(roomId); + }; + + return ( +
+

Liste des chambres

+
+ {rooms && rooms.map((room) => ( + + ))} +
+
+ + ); }; \ No newline at end of file diff --git a/src/components/rooms/roomBox.jsx b/src/components/rooms/roomBox.jsx index f5d0626..1e8889e 100644 --- a/src/components/rooms/roomBox.jsx +++ b/src/components/rooms/roomBox.jsx @@ -1,22 +1,19 @@ -import React, { useEffect, useState } from 'react'; -import '../../assets/styles/itembox.css' -import { } from '../item/ItemBox' +import React from 'react'; +import '../../assets/styles/room-list.css'; +import { Description } from '../parts/description'; +import { Characteristic } from '../parts/characteristic'; +export const RoomBox = ({ room, onRoomClick }) => { -// Composant Détails du Produit -export const RoomBox = ({ name, itemCount, roomPrice, _id }) => { - const [roomData, setRoomData] = useState(); - - useEffect(() => { - setRoomData({name, itemCount, roomPrice, _id}) - }, [name, itemCount, roomPrice, _id]); - + const handleBoxClick = () => { + onRoomClick(room._id); + }; return ( -
- - - +
+ + +
); diff --git a/src/pages/rooms.jsx b/src/pages/rooms.jsx index 7e472c9..9d9bba2 100644 --- a/src/pages/rooms.jsx +++ b/src/pages/rooms.jsx @@ -2,21 +2,24 @@ import React, { useEffect, useState } from 'react'; import '../assets/styles/room-page.css' import { useAuth } from "../hooks"; -import { formatRoomStats, getRooms, getRoomStats } from "../api/room"; +import { getRoomStats } from "../api/room"; import { usePageTitle } from '../hooks/page-title-context'; import RoomStats from '../components/rooms/room-stats'; +import { RoomList } from '../components/rooms/room-list'; +import { RoomDetail } from '../components/rooms/room-detail'; export const Rooms = () => { const { user } = useAuth(); const { setPageTitle } = usePageTitle(); const [stats, setStats] = useState({}); + const [selectedRoom, setSelectedRoom] = useState(); - // Mettre à jour le titre de la page dans le contexte useEffect(() => { setPageTitle("Toutes les rooms :"); }, [setPageTitle]); + useEffect(() => { const fetchData = async () => { const roomsStatsResponse = await getRoomStats(); @@ -26,20 +29,24 @@ export const Rooms = () => { fetchData(); }, []); + const handleRoomClick = (roomId) => { + console.log('Clicked room ID:', roomId); + setSelectedRoom(roomId); + }; return (
- +
-
+
+
- - +
);