Skip to content

Commit

Permalink
fix: corrections liées au calcul de distance, d'adresse et de coordon…
Browse files Browse the repository at this point in the history
…nées
  • Loading branch information
QuentinPetel committed Mar 1, 2022
1 parent cd72ae1 commit 60cd8ad
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 19 deletions.
2 changes: 1 addition & 1 deletion server/src/logic/mappers/codePostalMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const codePostalMapper = async (codePostal = null, codeInsee = null) => {
messages,
};
} catch (e) {
logger.debug(e?.message);
logger.error(e?.message);
return {
result: null,
messages: {
Expand Down
4 changes: 2 additions & 2 deletions server/src/logic/updaters/mnaFormationUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ const mnaFormationUpdater = async (formation, { withCodePostalUpdate = true, cfd
const [lat, lon] = geoCoords.split(",");
const [computedLat, computedLon] = coordinates.geo_coordonnees.split(",");
computedFields.distance = distanceBetweenCoordinates(lat, lon, computedLat, computedLon);
computedFields.lieu_formation_adresse_computed = coordinates.geo_coordonnees;
computedFields.lieu_formation_geo_coordonnees_computed = coordinates.geo_coordonnees;
} else {
computedFields.distance = null;
computedFields.lieu_formation_adresse_computed = null;
computedFields.lieu_formation_geo_coordonnees_computed = null;
}
}

Expand Down
61 changes: 45 additions & 16 deletions ui/src/pages/Formation/Formation.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const getLBAUrl = ({ cle_ministere_educatif = "" }) => {

const Formation = ({ formation, edition, onEdit, handleChange, handleSubmit, values, hasRightToEdit }) => {
const { isOpen: isComputedAdressOpen, onToggle: onComputedAdressToggle } = useDisclosure();
const { isOpen: isComputedGeoCoordOpen, onToggle: onComputedGeoCoordToggle } = useDisclosure();

const UaiFormationContainer = formation.uai_formation_valide
? React.Fragment
Expand Down Expand Up @@ -103,14 +104,57 @@ const Formation = ({ formation, edition, onEdit, handleChange, handleSubmit, val
/>
</UaiFormationContainer>

<Text mb={formation?.lieu_formation_adresse_computed ? 0 : 4}>
<Text mb={4}>
Adresse :{" "}
<Text as="span" variant="highlight">
{formation.lieu_formation_adresse}
</Text>{" "}
<InfoTooltip description={helpText.formation.lieu_formation_adresse} />
</Text>
<Text mb={4}>
Code postal :{" "}
<Text as="span" variant="highlight">
{formation.code_postal}
</Text>{" "}
<InfoTooltip description={helpText.formation.code_postal} />
</Text>
<Text mb={formation?.lieu_formation_adresse_computed ? 0 : 4}>
Commune :{" "}
<Text as="span" variant="highlight">
{formation.localite}
</Text>{" "}
<InfoTooltip description={helpText.formation.localite} />
</Text>
{formation?.lieu_formation_geo_coordonnees_computed && (
<Box mb={4}>
<Button
onClick={onComputedGeoCoordToggle}
variant={"unstyled"}
fontSize={"zeta"}
fontStyle={"italic"}
color={"grey.600"}
>
Géolocalisation calculée depuis l'adresse{" "}
<ArrowDownLine boxSize={5} transform={isComputedGeoCoordOpen ? "rotate(180deg)" : "none"} />
</Button>
<Collapse in={isComputedGeoCoordOpen} animateOpacity>
<Text mb={4}>
<Text fontSize={"zeta"} color={"grey.600"} as="span">
{formation.lieu_formation_geo_coordonnees_computed}
</Text>{" "}
<InfoTooltip description={helpText.formation.lieu_formation_geo_coordonnees_computed} />
</Text>
</Collapse>
</Box>
)}

<Text mb={formation?.lieu_formation_adresse_computed ? 0 : 4}>
Géolocalisation :{" "}
<Text as="span" variant="highlight">
{formation.lieu_formation_geo_coordonnees}
</Text>{" "}
<InfoTooltip description={helpText.formation.lieu_formation_geo_coordonnees} />
</Text>
{formation?.lieu_formation_adresse_computed && (
<Box mb={4}>
<Button
Expand All @@ -134,21 +178,6 @@ const Formation = ({ formation, edition, onEdit, handleChange, handleSubmit, val
</Box>
)}

<Text mb={4}>
Code postal :{" "}
<Text as="span" variant="highlight">
{formation.code_postal}
</Text>{" "}
<InfoTooltip description={helpText.formation.code_postal} />
</Text>

<Text mb={4}>
Commune :{" "}
<Text as="span" variant="highlight">
{formation.localite}
</Text>{" "}
<InfoTooltip description={helpText.formation.localite} />
</Text>
<Text mb={4}>
Code commune :{" "}
<Text as="span" variant="highlight">
Expand Down

0 comments on commit 60cd8ad

Please sign in to comment.