diff --git a/frontend/src/components/dashboard/header/EpisodePollution.js b/frontend/src/components/dashboard/header/EpisodePollution.js
index 9df8288a3..ed165fa43 100644
--- a/frontend/src/components/dashboard/header/EpisodePollution.js
+++ b/frontend/src/components/dashboard/header/EpisodePollution.js
@@ -1,43 +1,30 @@
import React, { useContext } from "react";
-import styled from "styled-components";
-import Button from "components/base/Button";
import useIndicators from "hooks/useIndicators";
import ModalContext from "utils/ModalContext";
-const Wrapper = styled.div`
- display: flex;
- flex-direction: column;
- align-items: center;
- max-width: 18rem;
- margin: 0 auto 2rem;
- padding: 1.5rem 2rem 1.5rem;
- background: ${(props) => props.theme.colors.error};
- border-radius: 1.5rem;
- box-shadow: 0.25rem 0.25rem 1rem 0
- rgba(${(props) => props.theme.colors.backgroundAlpha}, 0.4);
-
- ${(props) => props.theme.mq.small} {
- padding: 1.5rem 1rem 1rem;
- }
-`;
-const Title = styled.p`
- margin-bottom: 1rem;
- color: ${(props) => props.theme.colors.background};
- text-align: center;
-`;
-export default function EpisodePollution(props) {
- const { data } = useIndicators(props.place.code, props.date);
+export default function EpisodePollution({ place, date }) {
+ const { data } = useIndicators(place.code, date);
const { setEpisodePollution } = useContext(ModalContext);
- return data?.episodes_pollution?.advice ? (
-
-
- Un épisode de pollution est prévu{" "}
- {props.date ? "demain" : "aujourd’hui"}
-
-
-
- ) : null;
+ if (!data?.episodes_pollution?.advice) return null;
+
+ return (
+
+
+ ⚠️ Avertissement
+
+
+ Un épisode de pollution est prévu {date ? "demain" : "aujourd’hui"}
+
+
+
+ );
}
diff --git a/frontend/src/components/dashboard/indicators/Baignades.js b/frontend/src/components/dashboard/indicators/Baignades.js
index c44c76bc2..d57818203 100644
--- a/frontend/src/components/dashboard/indicators/Baignades.js
+++ b/frontend/src/components/dashboard/indicators/Baignades.js
@@ -6,7 +6,6 @@ import React, {
useEffect,
} from "react";
-import Chart from "./baignades/Chart";
import useBaignades from "hooks/useBaignades";
import ModalContext from "utils/ModalContext";
@@ -267,3 +266,61 @@ export default function Baignades(props) {
);
}
+
+function Chart({ visible, summary, value }) {
+ const getStrokeColor = useCallback(
+ (index) => {
+ if (!visible) return "stroke-disabled";
+ if (value < index) return "stroke-disabled";
+ if (value < 2) return `stroke-baignades-${value}`;
+ if (summary[index] > 0) return `stroke-baignades-${index}`;
+ return "stroke-disabled";
+ },
+ [visible, value, summary]
+ );
+
+ return (
+
+ );
+}
diff --git a/frontend/src/components/dashboard/indicators/IndiceUv.js b/frontend/src/components/dashboard/indicators/IndiceUv.js
index aed080f7d..a8a0de59f 100644
--- a/frontend/src/components/dashboard/indicators/IndiceUv.js
+++ b/frontend/src/components/dashboard/indicators/IndiceUv.js
@@ -1,10 +1,10 @@
import React, { useContext, useCallback, useRef, useState } from "react";
import useIndicators from "hooks/useIndicators";
-import Chart from "./indiceUv/Chart";
import ModalContext from "utils/ModalContext";
-export default function IndiceAtmo(props) {
+const maxValue = 11;
+export default function IndiceUv(props) {
const { data, isError, isLoading } = useIndicators(
props.place.code,
props.date
@@ -41,7 +41,7 @@ export default function IndiceAtmo(props) {
onClick={() => setModal("indice_uv")}
>
- Indice UV (de 1 à 11)
+ Indice UV (de 1 à {maxValue})
);
}
+
+function Chart({ value }) {
+ value = Math.min(value, maxValue);
+ return (
+
+ );
+}
diff --git a/frontend/src/components/dashboard/indicators/PotentielRadon.js b/frontend/src/components/dashboard/indicators/PotentielRadon.js
index ae4db6c37..c40488cb3 100644
--- a/frontend/src/components/dashboard/indicators/PotentielRadon.js
+++ b/frontend/src/components/dashboard/indicators/PotentielRadon.js
@@ -1,7 +1,6 @@
import React, { useContext, useCallback, useRef, useState } from "react";
import useIndicators from "hooks/useIndicators";
-import Chart from "./potentielRadon/Chart";
import ModalContext from "utils/ModalContext";
export default function IndiceAtmo(props) {
@@ -178,3 +177,53 @@ export default function IndiceAtmo(props) {
);
}
+
+function Chart({ value, visible, onlyValue, className }) {
+ return (
+
+ );
+}
diff --git a/frontend/src/components/dashboard/indicators/Raep.js b/frontend/src/components/dashboard/indicators/Raep.js
index d68db605b..d0c6b7612 100644
--- a/frontend/src/components/dashboard/indicators/Raep.js
+++ b/frontend/src/components/dashboard/indicators/Raep.js
@@ -7,7 +7,6 @@ import React, {
} from "react";
import useIndicators from "hooks/useIndicators";
-import Chart from "./raep/Chart";
import ModalContext from "utils/ModalContext";
export default function Raep(props) {
@@ -251,3 +250,53 @@ const labels = {
urticacees: "Urticacées",
armoises: "Armoises",
};
+
+function Chart({ value, visible }) {
+ return (
+
+ );
+}
diff --git a/frontend/src/components/dashboard/indicators/VigilanceMeteo.js b/frontend/src/components/dashboard/indicators/VigilanceMeteo.js
index ce8013f93..106cd4bed 100644
--- a/frontend/src/components/dashboard/indicators/VigilanceMeteo.js
+++ b/frontend/src/components/dashboard/indicators/VigilanceMeteo.js
@@ -1,7 +1,6 @@
import React, { useContext, useCallback, useRef, useState } from "react";
import useIndicators from "hooks/useIndicators";
-import Chart from "./vigilanceMeteo/Chart";
import ModalContext from "utils/ModalContext";
export default function IndiceAtmo(props) {
@@ -193,101 +192,53 @@ export default function IndiceAtmo(props) {
);
}
-// import React from "react";
-
-// import MagicLink from "components/base/MagicLink";
-// import Card from "components/misc/Card";
-// import useIndicators from "hooks/useIndicators";
-// import Chart from "./vigilanceMeteo/Chart";
-// import Details from "./vigilanceMeteo/Details";
-
-// export default function VigilanceMeteo(props) {
-// const { data, isError, isLoading } = useIndicators(
-// props.place.code,
-// props.date
-// );
-
-// return (
-//
-//
-//
-//
-//
-// Vigilance météo
-//
-//
-// {isError
-// ? "Arf 🦖"
-// : data &&
-// (data.vigilance_meteo.indice?.label
-// ? data.vigilance_meteo.indice.label
-// : "Pas de données")}
-//
-//
-//
-//
-//
-//
-//
-//
-// Nous ne sommes malheureusement pas en mesure d'afficher la vigilance météo pour l'instant. Veuillez réessayer dans quelques instants.`
-// : data &&
-// (data.vigilance_meteo.error
-// ? `Les données ne sont pas disponibles pour cette commune.
`
-// : data.vigilance_meteo.advice &&
-// data.vigilance_meteo.advice.main),
-// }}
-// />
-//
-//
-//
-//
-//
-// {data &&
-// data.vigilance_meteo &&
-// data.vigilance_meteo.validity &&
-// data.vigilance_meteo.sources && (
-//
-//
-// Prévision{" "}
-// {data.vigilance_meteo.validity.start ? (
-// <>
-// du{" "}
-// {new Date(
-// data.vigilance_meteo.validity.start
-// ).toLocaleDateString("fr", {
-// year: "numeric",
-// month: "long",
-// day: "numeric",
-// hour: "2-digit",
-// })}{" "}
-// au{" "}
-// {new Date(
-// data.vigilance_meteo.validity.end
-// ).toLocaleDateString("fr", {
-// year: "numeric",
-// month: "long",
-// day: "numeric",
-// hour: "2-digit",
-// })}{" "}
-// dans
-// >
-// ) : (
-// <> dans >
-// )}{" "}
-// {data.vigilance_meteo.validity.area}
-//
-//
-// Données fournies par{" "}
-//
-// {data.vigilance_meteo.sources[0].label}
-//
-//
-//
-// )}
-//
-// );
-// }
+function Chart({ visible, value }) {
+ return (
+
+ );
+}
diff --git a/frontend/src/components/dashboard/indicators/baignades/Chart.js b/frontend/src/components/dashboard/indicators/baignades/Chart.js
deleted file mode 100644
index 809d4d165..000000000
--- a/frontend/src/components/dashboard/indicators/baignades/Chart.js
+++ /dev/null
@@ -1,59 +0,0 @@
-import React, { useCallback } from "react";
-
-export default function Chart({ visible, summary, value }) {
- const getStrokeColor = useCallback(
- (index) => {
- if (!visible) return "stroke-disabled";
- if (value < index) return "stroke-disabled";
- if (value < 2) return `stroke-baignades-${value}`;
- if (summary[index] > 0) return `stroke-baignades-${index}`;
- return "stroke-disabled";
- },
- [visible, value, summary]
- );
-
- return (
-
- );
-}
diff --git a/frontend/src/components/dashboard/indicators/baignades/Details.js b/frontend/src/components/dashboard/indicators/baignades/Details.js
deleted file mode 100644
index efb912769..000000000
--- a/frontend/src/components/dashboard/indicators/baignades/Details.js
+++ /dev/null
@@ -1,57 +0,0 @@
-import React, { useEffect, useState } from "react";
-import styled from "styled-components";
-
-import Button from "components/base/Button";
-import Element from "./details/Element";
-
-const Wrapper = styled.div`
- display: flex;
- justify-content: space-between;
- flex-direction: column;
-`;
-export default function Details(props) {
- const offSeason = props.data?.baignades?.indice?.label === "Hors-saison";
- const allDetails = props.data?.baignades?.indice?.details;
- const threshold = 5;
- const [details, setDetails] = useState(null);
- const [loadAll, setLoadAll] = useState(false);
- const [hasMore, setHasMore] = useState(false);
- const handleLoadAll = () => {
- setLoadAll(true);
- };
- useEffect(() => {
- if (loadAll && hasMore) {
- setDetails(allDetails);
- setLoadAll(false);
- }
- }, [loadAll, hasMore]); //eslint-disable-line
- useEffect(() => {
- if (details) {
- const hasMore = details.length < allDetails.length;
- setHasMore(hasMore);
- }
- }, [details]); //eslint-disable-line
- useEffect(() => {
- allDetails && setDetails([...allDetails.slice(0, threshold)]);
- }, [allDetails]); //eslint-disable-line
-
- return details ? (
-
- {details.map((element) => (
-
- ))}
- {hasMore && (
-
-
-
- )}
-
- ) : null;
-}
diff --git a/frontend/src/components/dashboard/indicators/baignades/details/Element.js b/frontend/src/components/dashboard/indicators/baignades/details/Element.js
deleted file mode 100644
index eb700cec7..000000000
--- a/frontend/src/components/dashboard/indicators/baignades/details/Element.js
+++ /dev/null
@@ -1,178 +0,0 @@
-import MagicLink from "components/base/MagicLink";
-import React from "react";
-import styled from "styled-components";
-import Bon from "./images/Bon.png";
-import Excellent from "./images/Excellent.png";
-import Insuffisant from "./images/Insuffisant.png";
-import InterdictionImage from "./images/Interdiction.png";
-import Suffisant from "./images/Suffisant.png";
-
-const ranking_images = {
- Excellent: Excellent,
- Bon: Bon,
- Suffisant: Suffisant,
- Insuffisant: Insuffisant,
-};
-
-const Wrapper = styled.div`
- margin-bottom: 2rem;
- &:last-child {
- margin-bottom: 0;
- }
-`;
-const Title = styled.h3`
- font-weight: normal;
- line-height: 0.75;
- margin-bottom: 1rem;
- color: ${(props) => props.theme.colors.text};
- font-size: inherit;
-`;
-const StyledMagicLink = styled(MagicLink)`
- text-decoration: none;
- &:hover {
- text-decoration: underline;
- }
-`;
-const Interdiction = styled.div`
- position: relative;
- margin-top: 0.5rem;
- padding-left: 3.5rem;
- line-height: 3rem;
- color: ${(props) => props.theme.colors.error};
-
- &:before {
- content: "";
- position: absolute;
- top: 0;
- left: 0;
- width: 3rem;
- height: 3rem;
- background: ${(props) => "url(" + InterdictionImage + ")"};
- background-repeat: no-repeat;
- background-size: 100% auto;
- background-position: center;
- }
-
- > div {
- display: inline-block;
- vertical-align: middle;
- line-height: 1.25rem;
- }
-`;
-const Sample = styled.div`
- position: relative;
- padding-left: 3.5rem;
- transition: color 300ms ease-out;
- line-height: 1.5rem;
-
- &:before {
- content: "";
- position: absolute;
- top: 0;
- left: 0;
- width: 3rem;
- height: 1.5rem;
- background-color: ${(props) => props.theme.colors.main};
- opacity: ${(props) => 0.15};
- border-radius: 0.25rem;
- }
-
- &:after {
- content: "";
- position: absolute;
- top: 0;
- left: 0;
- width: ${(props) =>
- props.value >= 0 ? ((props.value + 1) / 3) * 3 : 0}rem;
- height: 1.5rem;
- background-color: ${(props) =>
- props.value >= 0
- ? props.theme.colors.baignades[props.value]
- : props.theme.colors.main};
- border-radius: ${(props) =>
- props.value < 2 ? "0.25rem 0 0 0.25rem" : "0.25rem"};
- }
-`;
-const Date = styled.span`
- font-weight: lighter;
-`;
-const Ranking = styled.div`
- position: relative;
- margin-top: 0.5rem;
- padding-left: 3.5rem;
- line-height: 3rem;
-
- &:before {
- content: "";
- position: absolute;
- top: 0;
- left: 0;
- width: 3rem;
- height: 3rem;
- background: ${(props) => "url(" + ranking_images[props.label] + ")"};
- background-repeat: no-repeat;
- background-size: 100% auto;
- background-position: center;
- }
-`;
-const Year = styled.span`
- font-weight: lighter;
-`;
-
-export default function Element(props) {
- const value = ["Bon résultat", "Résultat moyen", "Mauvais résultat"].indexOf(
- props?.sample?.label
- );
- return props?.label ? (
-
-
- {props?.url ? (
- {props.label}
- ) : (
- props.label
- )}
-
- {props?.sample && (
-
- {props.sample.label
- ? `${props.sample.label}`
- : "Pas de résultats de prélèvements"}
- {props.sample.date && (
- <>
- (prélèvement du {props.sample.date})
- >
- )}
-
- )}
- {["Excellent", "Bon", "Suffisant", "Insuffisant"].includes(
- props?.ranking?.label
- ) && (
-
- {props.ranking.label}
- {props.ranking.year && (
- <>
- (classement de {props.ranking.year})
- >
- )}
-
- )}
- {props?.interdiction && (
-
-
- Interdiction{" "}
- {props.interdiction.type ? `${props.interdiction.type}` : ""} de
- baignade
- {props.interdiction.reason && (
- <> pour raison {props.interdiction.reason}>
- )}
- {props.interdiction.date && (
- <>
- ({props.interdiction.date})
- >
- )}
-
-
- )}
-
- ) : null;
-}
diff --git a/frontend/src/components/dashboard/indicators/baignades/details/images/Bon.png b/frontend/src/components/dashboard/indicators/baignades/details/images/Bon.png
deleted file mode 100644
index b4e9bb76e..000000000
Binary files a/frontend/src/components/dashboard/indicators/baignades/details/images/Bon.png and /dev/null differ
diff --git a/frontend/src/components/dashboard/indicators/baignades/details/images/Excellent.png b/frontend/src/components/dashboard/indicators/baignades/details/images/Excellent.png
deleted file mode 100644
index 94f823255..000000000
Binary files a/frontend/src/components/dashboard/indicators/baignades/details/images/Excellent.png and /dev/null differ
diff --git a/frontend/src/components/dashboard/indicators/baignades/details/images/Insuffisant.png b/frontend/src/components/dashboard/indicators/baignades/details/images/Insuffisant.png
deleted file mode 100644
index e3254d78a..000000000
Binary files a/frontend/src/components/dashboard/indicators/baignades/details/images/Insuffisant.png and /dev/null differ
diff --git a/frontend/src/components/dashboard/indicators/baignades/details/images/Interdiction.png b/frontend/src/components/dashboard/indicators/baignades/details/images/Interdiction.png
deleted file mode 100644
index 5ee2384ca..000000000
Binary files a/frontend/src/components/dashboard/indicators/baignades/details/images/Interdiction.png and /dev/null differ
diff --git a/frontend/src/components/dashboard/indicators/baignades/details/images/Suffisant.png b/frontend/src/components/dashboard/indicators/baignades/details/images/Suffisant.png
deleted file mode 100644
index 1cdb99d10..000000000
Binary files a/frontend/src/components/dashboard/indicators/baignades/details/images/Suffisant.png and /dev/null differ
diff --git a/frontend/src/components/dashboard/indicators/indiceAtmo/Details.js b/frontend/src/components/dashboard/indicators/indiceAtmo/Details.js
deleted file mode 100644
index f375c2fe2..000000000
--- a/frontend/src/components/dashboard/indicators/indiceAtmo/Details.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import React from "react";
-import styled from "styled-components";
-
-import Element from "./details/Element";
-
-const Wrapper = styled.ul`
- display: flex;
- justify-content: space-between;
- margin: 0;
- padding: 0;
- font-size: inherit;
-
- ${(props) => props.theme.mq.small} {
- flex-direction: column;
- align-items: center;
- }
-
- li {
- list-style: none;
- }
-`;
-export default function Details(props) {
- if (!props.data?.indice_atmo?.indice?.details) return null;
- return (
-
- {props.data.indice_atmo.indice.details.map((element) => (
-
-
-
- ))}
-
- );
-}
diff --git a/frontend/src/components/dashboard/indicators/indiceUv/Chart.js b/frontend/src/components/dashboard/indicators/indiceUv/Chart.js
deleted file mode 100644
index 30bafb79b..000000000
--- a/frontend/src/components/dashboard/indicators/indiceUv/Chart.js
+++ /dev/null
@@ -1,160 +0,0 @@
-import React from "react";
-
-const maxValue = 11;
-export default function Chart({ value }) {
- value = Math.min(value, maxValue);
- return (
-
- );
-}
diff --git a/frontend/src/components/dashboard/indicators/potentielRadon/Chart.js b/frontend/src/components/dashboard/indicators/potentielRadon/Chart.js
deleted file mode 100644
index 7ff16693d..000000000
--- a/frontend/src/components/dashboard/indicators/potentielRadon/Chart.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import React from "react";
-
-export default function Chart({ value, visible, onlyValue, className }) {
- return (
-
- );
-}
diff --git a/frontend/src/components/dashboard/indicators/raep/Chart.js b/frontend/src/components/dashboard/indicators/raep/Chart.js
deleted file mode 100644
index ba663a2f5..000000000
--- a/frontend/src/components/dashboard/indicators/raep/Chart.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import React from "react";
-
-export default function Chart({ value, visible }) {
- return (
-
- );
-}
diff --git a/frontend/src/components/dashboard/indicators/raep/Details.js b/frontend/src/components/dashboard/indicators/raep/Details.js
deleted file mode 100644
index a36695ff2..000000000
--- a/frontend/src/components/dashboard/indicators/raep/Details.js
+++ /dev/null
@@ -1,43 +0,0 @@
-import React from "react";
-import styled from "styled-components";
-
-import Element from "./details/Element";
-
-const Wrapper = styled.div`
- display: flex;
- justify-content: center;
- overflow: hidden;
-`;
-const Elements = styled.ul`
- margin: 0;
- padding: 0;
- font-size: inherit;
-
- li {
- list-style: none;
-
- &:last-child > * {
- margin-bottom: 0;
- }
- }
-`;
-export default function Details(props) {
- return props.data ? (
-
-
- {props.data.raep.indice.details
- .filter((allergen) => allergen.indice.value)
- .sort((a, b) => (a.indice.value > b.indice.value ? 1 : -1))
- .map((allergen, index) => (
-
-
-
- ))}
-
-
- ) : null;
-}
diff --git a/frontend/src/components/dashboard/indicators/raep/details/Element.js b/frontend/src/components/dashboard/indicators/raep/details/Element.js
deleted file mode 100644
index 872c2596c..000000000
--- a/frontend/src/components/dashboard/indicators/raep/details/Element.js
+++ /dev/null
@@ -1,97 +0,0 @@
-import React, { useContext } from "react";
-import styled from "styled-components";
-
-import ModalContext from "utils/ModalContext";
-
-const Wrapper = styled.div`
- position: relative;
- margin-bottom: 1.5rem;
- padding-right: 13.25rem;
- line-height: 1.5;
- text-align: right;
-
- ${(props) => props.theme.mq.small} {
- margin-bottom: 1rem;
- padding-right: 7rem;
- }
-
- &:before {
- content: "";
- position: absolute;
- top: 50%;
- right: 0;
- transform: translateY(-50%);
- width: 12.5rem;
- height: 1.125rem;
- background-color: ${(props) => props.theme.colors.main};
- border-radius: 0.5rem;
- opacity: 0.15;
-
- ${(props) => props.theme.mq.small} {
- width: 6rem;
- }
- }
- &:after {
- content: "";
- position: absolute;
- top: 50%;
- right: ${(props) => 12.5 - (props.value / 5) * 12.5}rem;
- transform: translateY(-50%) scaleX(1);
- transform-origin: left;
- width: ${(props) => (props.value / 5) * 12.5}rem;
- height: 1.125rem;
- background-color: ${(props) => props.theme.colors.raep[props.value]};
- border-radius: ${(props) =>
- props.value < 5 ? "0.5rem 0 0 0.5rem" : "0.5rem"};
- transition: transform ${(props) => 150 * props.value}ms
- ${(props) => props.index * 100}ms ease-out;
-
- ${(props) => props.theme.mq.small} {
- right: ${(props) => 6 - (props.value / 5) * 6}rem;
- width: ${(props) => (props.value / 5) * 6}rem;
- }
- }
- &:hover {
- color: ${(props) => props.theme.colors.main};
- }
-`;
-const Superscript = styled.sup`
- font-size: 0.625rem;
- color: ${(props) => props.theme.colors.main};
-`;
-const labels = {
- ambroisies: "Ambroisies",
- cypres: "Cupressacées",
- noisetier: "Noisetier",
- aulne: "Aulne",
- peuplier: "Peuplier",
- saule: "Saule",
- frene: "Frêne",
- charme: "Charme",
- bouleau: "Bouleau",
- platane: "Platane",
- chene: "Chêne",
- olivier: "Olivier",
- tilleul: "Tilleul",
- chataignier: "Châtaignier",
- rumex: "Rumex",
- graminees: "Graminées",
- plantain: "Plantain",
- urticacees: "Urticacées",
- armoises: "Armoises",
-};
-export default function Element(props) {
- const { setModal } = useContext(ModalContext);
-
- return (
- setModal(props.label)}
- >
- {labels[props.label]}
- (?)
-
- );
-}
diff --git a/frontend/src/components/dashboard/indicators/vigilanceMeteo/Chart.js b/frontend/src/components/dashboard/indicators/vigilanceMeteo/Chart.js
index a61de36bb..01dea7e52 100644
--- a/frontend/src/components/dashboard/indicators/vigilanceMeteo/Chart.js
+++ b/frontend/src/components/dashboard/indicators/vigilanceMeteo/Chart.js
@@ -1,20 +1,5 @@
import React from "react";
-import styled from "styled-components";
-const Path = styled.path`
- fill: ${(props) =>
- props.visible && props.index < props["data-value"]
- ? props.theme.colors.vigilancemeteo[props["data-value"]]
- : props.theme.colors.disabled};
- transition: opacity ${(props) => (props.visible ? 1200 : 0)}ms
- ${(props) => (props.visible ? props.index * 300 + 300 : 0)}ms,
- fill ${(props) => (props.visible ? 400 : 0)}ms
- ${(props) => (props.visible ? props.index * 300 + 300 : 0)}ms;
-
- ${(props) => props.theme.mq.medium} {
- transition: none;
- }
-`;
export default function Chart({ visible, value }) {
return (