diff --git a/frontend/src/ProPage.jsx b/frontend/src/ProPage.jsx
index dcd7b17..dc9d713 100644
--- a/frontend/src/ProPage.jsx
+++ b/frontend/src/ProPage.jsx
@@ -1,13 +1,180 @@
-
import './App.css';
-import WeatherGraph from './WeatherGraph';
+import { LineChart } from '@mui/x-charts/LineChart';
+import React, { useState, useEffect } from 'react';
+import dayjs from 'dayjs';
+import Icon from '@mdi/react';
+import { mdiWeatherSunsetDown } from '@mdi/js';
+import { mdiWeatherSunsetUp } from '@mdi/js';
+import Navbar from './components/Navbar';
+import Footer from './components/Footer';
function ProPage() {
- return (
- <>
-
- >
- )
+ const [searchQuery, setSearchQuery] = useState('');
+ const [data, setData] = useState([]);
+ const [error, setError] = useState(null);
+ const [chartData, setChartData] = useState([]);
+ const [dates, setDates] = useState([]);
+
+ useEffect(() => {
+ fetch('http://localhost:5984/helios/_find', {
+ method: 'POST',
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ selector: {
+ "_id": {
+ "$gt": null
+ }
+ },
+ fields: ["_id", "city", "date", "morningTemperature", "afternoonTemperature", "eveningTemperature", "sunrise", "sunset"],
+ limit: 2000
+
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ throw new Error(`Erreur HTTP! statut: ${response.status}`);
+ }
+ return response.json();
+ })
+ .then((data) => {
+ if (data.docs && data.docs.length > 0) {
+ setData(data.docs);
+ } else {
+ setError(new Error('Aucun résultat trouvé'));
+ }
+ })
+ .catch((error) => {
+ setError(error);
+ console.error('Erreur lors du chargement des données:', error);
+ });
+ }, []);
+
+ function parseDate(dateString) {
+ return dayjs(dateString).format('MDD');
+ }
+
+ useEffect(() => {
+ if (searchQuery && data.length > 0) {
+ const filteredData = data.filter((doc) => doc.city.toLowerCase() === searchQuery.toLowerCase());
+
+ if (filteredData.length > 0) {
+ // Sort by date
+ const sortedData = filteredData.sort((a, b) => new Date(a.date) - new Date(b.date));
+
+ // Define the start and end dates for the week of November 11, 2024
+ const startDate = new Date('2024-11-10');
+ const endDate = new Date('2024-11-16');
+
+ // Filter the data to include only dates within the specified week
+ const weekData = sortedData.filter((doc) => {
+ const docDate = new Date(doc.date);
+ return docDate >= startDate && docDate <= endDate;
+ });
+
+ // Prepare chart data
+ const dates = weekData.map((doc) => parseDate(doc.date));
+ const morningTemps = weekData.map((doc) => parseFloat(doc.morningTemperature));
+ const afternoonTemps = weekData.map((doc) => parseFloat(doc.afternoonTemperature));
+ const eveningTemps = weekData.map((doc) => parseFloat(doc.eveningTemperature));
+
+ setDates(dates);
+ setChartData([
+ { name: 'Matin', data: morningTemps },
+ { name: 'Après-Midi', data: afternoonTemps },
+ { name: 'Soir', data: eveningTemps },
+ ]);
+ } else {
+ setChartData([]);
+ }
+ }
+ }, [searchQuery, data]);
+
+
+ function findSunrizeofToday(data) {
+ const filteredData = data.filter((doc) => doc.city.toLowerCase() === searchQuery.toLowerCase());
+
+ const today = new Date();
+ const todayString = "2024-11-02"
+ console.log(filteredData.filter((doc) => doc.date === todayString))
+ const todayData = filteredData.filter((doc) => doc.date === todayString);
+ if (todayData.length > 0) {
+ return todayData[0].sunrise;
+ }
+ return null;
+ }
+
+
+ function findSunsetofToday(data) {
+ const filteredData = data.filter((doc) => doc.city.toLowerCase() === searchQuery.toLowerCase());
+ const today = new Date();
+ const todayString = "2024-11-02"
+ console.log(filteredData.filter((doc) => doc.date === todayString))
+ const todayData = filteredData.filter((doc) => doc.date === todayString);
+ if (todayData.length > 0) {
+ return todayData[0].sunset;
+ }
+ return null;
+ }
+
+ return (
+
+ < Navbar />
+
+
+
Température des prochains jours
+
setSearchQuery(e.target.value)}
+ />
+
+ {error &&
{error.message}
}
+
+ {chartData.length > 0 ? (
+
{
+ if (context.location === 'tick') {
+ // On formate chaque valeur de date ici en prenant les 3 premiers caractères
+ return `${String(value).slice(0, 2)}/${String(value).slice(2, 4)}`
+ } else {
+ return value;
+ }
+ },
+
+ }]}
+ series={chartData.map((serie) => (
+ console.log(dates), {
+ data: serie.data,
+ showMark: true,
+ label: serie.name,
+ }))}
+ height={600}
+ />) : (
+ Aucun résultat trouvé
+ )}
+
+
+
+
Ephéméride
+
+ {findSunrizeofToday(data)}
+
+
+
+ {findSunsetofToday(data)}
+
+
+
+
+
+
+ < Footer />
+
+ );
}
-export default ProPage;
\ No newline at end of file
+export default ProPage;
diff --git a/frontend/src/WeatherGraph.jsx b/frontend/src/WeatherGraph.jsx
deleted file mode 100644
index c3ed263..0000000
--- a/frontend/src/WeatherGraph.jsx
+++ /dev/null
@@ -1,185 +0,0 @@
-import './App.css';
-import { LineChart } from '@mui/x-charts/LineChart';
-import React, { useState, useEffect } from 'react';
-import dayjs from 'dayjs';
-import Icon from '@mdi/react';
-import { mdiWeatherSunsetDown } from '@mdi/js';
-import { mdiWeatherSunsetUp } from '@mdi/js';
-import Navbar from './components/Navbar';
-import Footer from './components/Footer';
-
-function ProPage() {
- const [searchQuery, setSearchQuery] = useState('');
- const [data, setData] = useState([]);
- const [error, setError] = useState(null);
- const [chartData, setChartData] = useState([]);
- const [dates, setDates] = useState([]);
-
- useEffect(() => {
- fetch('http://localhost:5984/helios/_find', {
- method: 'POST',
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({
- selector: {
- "_id": {
- "$gt": null
- }
- },
- fields: ["_id", "city", "date", "morningTemperature", "afternoonTemperature", "eveningTemperature", "sunrise", "sunset"],
- limit: 2000
-
- })
- })
- .then((response) => {
- if (!response.ok) {
- throw new Error(`HTTP error! status: ${response.status}`);
- }
- return response.json();
- })
- .then((data) => {
- if (data.docs && data.docs.length > 0) {
- setData(data.docs);
- } else {
- setError(new Error('No matching documents found'));
- }
- })
- .catch((error) => {
- setError(error);
- console.error('Error fetching data:', error);
- });
- }, []);
-
- function parseDate(dateString) {
- return dayjs(dateString).format('MDD');
- }
-
- useEffect(() => {
- if (searchQuery && data.length > 0) {
- const filteredData = data.filter((doc) => doc.city.toLowerCase() === searchQuery.toLowerCase());
-
- if (filteredData.length > 0) {
- // Sort by date
- const sortedData = filteredData.sort((a, b) => new Date(a.date) - new Date(b.date));
-
- // Define the start and end dates for the week of November 11, 2024
- const startDate = new Date('2024-11-10');
- const endDate = new Date('2024-11-16');
-
- // Filter the data to include only dates within the specified week
- const weekData = sortedData.filter((doc) => {
- const docDate = new Date(doc.date);
- return docDate >= startDate && docDate <= endDate;
- });
-
-
- // Prepare chart data
- const dates = weekData.map((doc) => parseDate(doc.date));
- const morningTemps = weekData.map((doc) => parseFloat(doc.morningTemperature));
- const afternoonTemps = weekData.map((doc) => parseFloat(doc.afternoonTemperature));
- const eveningTemps = weekData.map((doc) => parseFloat(doc.eveningTemperature));
-
- setDates(dates);
- setChartData([
- { name: 'Matin', data: morningTemps },
- { name: 'Après-Midi', data: afternoonTemps },
- { name: 'Soir', data: eveningTemps },
- ]);
- } else {
- setChartData([]);
- }
- }
- }, [searchQuery, data]);
-
-
- function findSunrizeofToday(data) {
- const filteredData = data.filter((doc) => doc.city.toLowerCase() === searchQuery.toLowerCase());
-
- const today = new Date();
- // const todayString = today.toISOString().split('T')[0];
- const todayString = "2024-11-02"
- console.log(filteredData.filter((doc) => doc.date === todayString))
- const todayData = filteredData.filter((doc) => doc.date === todayString);
- if (todayData.length > 0) {
- return todayData[0].sunrise;
- }
- return null;
- }
-
-
- function findSunsetofToday(data) {
- const filteredData = data.filter((doc) => doc.city.toLowerCase() === searchQuery.toLowerCase());
-
- const today = new Date();
- // const todayString = today.toISOString().split('T')[0];
- const todayString = "2024-11-02"
- console.log(filteredData.filter((doc) => doc.date === todayString))
- const todayData = filteredData.filter((doc) => doc.date === todayString);
- if (todayData.length > 0) {
- return todayData[0].sunset;
- }
- return null;
- }
-
- return (
-
- < Navbar />
-
-
-
Température des prochains jours
-
setSearchQuery(e.target.value)}
- />
-
- {error &&
{error.message}
}
-
- {chartData.length > 0 ? (
-
{
- if (context.location === 'tick') {
- // On formate chaque valeur de date ici en prenant les 3 premiers caractères
- return `${String(value).slice(0, 2)}/${String(value).slice(2, 4)} ` // Exemple de format MDD => Mois-Jour
- } else {
- return value; // Retourne la valeur brute si ce n'est pas un tick
- }
- },
-
- }]}
- series={chartData.map((serie) => (
- console.log(dates), {
- data: serie.data,
- showMark: true,
- label: serie.name,
- }))}
- height={600}
- />) : (
- No data to display
- )}
-
-
-
-
-
Ephéméride
-
- {findSunrizeofToday(data)}
-
-
-
- {findSunsetofToday(data)}
-
-
-
-
-
-
- < Footer />
-
- );
-}
-
-export default ProPage;
diff --git a/frontend/src/assets/favicon.svg b/frontend/src/assets/favicon.svg
index 56f24da..604e41d 100644
--- a/frontend/src/assets/favicon.svg
+++ b/frontend/src/assets/favicon.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file