diff --git a/ui/src/locales/helpText.json b/ui/src/locales/helpText.json index 6cfd6e90f..86608bd2b 100644 --- a/ui/src/locales/helpText.json +++ b/ui/src/locales/helpText.json @@ -19,11 +19,13 @@ "uai_formation": "La donnée “UAI Lieu de formation” correspond à l’UAI de l’organisme formateur ou est renseigné par un instructeur en académie si le lieu de formation est différent de celui du formateur.", "academie": "La donnée “Académie” est déduite du Code Académie qui est déduit du Code commune.", "lieu_formation_adresse": "La donnée “Adresse” provient des bases “Carif-Oref”. Si cette information est erronée, merci de le signaler au Carif-Oref de votre région.", + "lieu_formation_geo_coordonnees": "La donnée “Géolocalisation“ provient des bases “Carif-Oref”. Si cette information est erronée, merci de le signaler au Carif-Oref de votre région.", "code_postal": "La donnée “Code postal” provient des bases “Carif-Oref”. Si cette information est erronée, merci de le signaler au Carif-Oref de votre région.", "localite": "La donnée “Commune” provient des bases “Carif-Oref”. Si cette information est erronée, merci de le signaler au Carif-Oref de votre région.", "code_commune_insee": "La donnée “Code commune” provient des bases “Carif-Oref”. Si cette information est erronée, merci de le signaler au Carif-Oref de votre région.", "nom_departement": "La donnée “Département” est déduite du Code postal", "lieu_formation_adresse_computed": "L'adresse est calculée à partir de la géolocalisation. Rapprochez vous de votre Carif-Oref pour préciser cette géolocalisation afin que les jeunes puissent identifier où se situe le lieu de formation.", + "lieu_formation_geo_coordonnees_computed": "Les coordonnées sont calculées à partir de l'adresse transmise. Rapprochez vous de votre Carif-Oref afin qu'elles permettent aux jeunes d'identifier où se situe le lieu de formation.", "parcoursup_published_date": "Date à laquelle la formation est passée à l'état \"Parcoursup - publié\" dans le catalogue (envoi automatique ou rapprochement des bases Parcoursup et Carif-Oref)", "affelnet_published_date": "Date à laquelle la formation est passée à l'état \"Affelnet - publié\" dans le catalogue (rapprochement des bases Affelnet et Carif-Oref)" }, diff --git a/ui/src/pages/Formation/Formation.js b/ui/src/pages/Formation/Formation.js index a26c05abf..dc859eaf0 100644 --- a/ui/src/pages/Formation/Formation.js +++ b/ui/src/pages/Formation/Formation.js @@ -51,10 +51,18 @@ const getLBAUrl = ({ cle_ministere_educatif = "" }) => { )}`; }; +const getGeoPortailUrl = (coordinates) => { + const [lat, lon] = coordinates.split(","); + return `https://www.geoportail.gouv.fr/carte?c=${lon},${lat}&z=19&l0=ORTHOIMAGERY.ORTHOPHOTOS::GEOPORTAIL:OGC:WMTS(1)&permalink=yes`; +}; + const Formation = ({ formation, edition, onEdit, handleChange, handleSubmit, values, hasRightToEdit }) => { const { isOpen: isComputedAdressOpen, onToggle: onComputedAdressToggle } = useDisclosure(); const { isOpen: isComputedGeoCoordOpen, onToggle: onComputedGeoCoordToggle } = useDisclosure(); + // Distance tolérer entre l'adresse et les coordonnées transmise par RCO + const seuilDistance = 100; + const UaiFormationContainer = formation.uai_formation_valide ? React.Fragment : (args) => ( @@ -70,6 +78,22 @@ const Formation = ({ formation, edition, onEdit, handleChange, handleSubmit, val /> ); + const AdresseContainer = + seuilDistance >= formation.distance + ? React.Fragment + : (args) => ( + + ); + return ( @@ -84,7 +108,7 @@ const Formation = ({ formation, edition, onEdit, handleChange, handleSubmit, val - voir sur un plan + voir sur labonnealternance @@ -104,79 +128,104 @@ const Formation = ({ formation, edition, onEdit, handleChange, handleSubmit, val /> - - Adresse :{" "} - - {formation.lieu_formation_adresse} - {" "} - - - - Code postal :{" "} - - {formation.code_postal} - {" "} - - - - Commune :{" "} - - {formation.localite} - {" "} - - - {formation?.lieu_formation_geo_coordonnees_computed && ( - - - - - - {formation.lieu_formation_geo_coordonnees_computed} - {" "} - - - - - )} + + + Adresse :{" "} + + {formation.lieu_formation_adresse} + {" "} + + + + Code postal :{" "} + + {formation.code_postal} + {" "} + + + + Commune :{" "} + + {formation.localite} + {" "} + + + + Département :{" "} + + {formation.nom_departement} ({formation.num_departement}) + {" "} + + + {formation?.lieu_formation_geo_coordonnees_computed && ( + + + + + + + {formation.lieu_formation_geo_coordonnees_computed} + + {" "} + + + + + )} - - Géolocalisation :{" "} - - {formation.lieu_formation_geo_coordonnees} - {" "} - - - {formation?.lieu_formation_adresse_computed && ( - - - - - - {formation.lieu_formation_adresse_computed} - {" "} - - - - - )} + + Géolocalisation :{" "} + + {formation.lieu_formation_geo_coordonnees} + {" "} + + + {formation?.lieu_formation_adresse_computed && ( + + + + + + + {formation.lieu_formation_adresse_computed} + + {" "} + + + + + )} + Code commune :{" "} @@ -185,13 +234,7 @@ const Formation = ({ formation, edition, onEdit, handleChange, handleSubmit, val {" "} - - Département :{" "} - - {formation.nom_departement} ({formation.num_departement}) - {" "} - - + Académie de rattachement :{" "} diff --git a/ui/src/pages/Formation/Formation.test.js b/ui/src/pages/Formation/Formation.test.js index ec580e49e..7fac83b77 100644 --- a/ui/src/pages/Formation/Formation.test.js +++ b/ui/src/pages/Formation/Formation.test.js @@ -264,11 +264,11 @@ const formation = { }; const server = setupMswServer( - rest.get(/\/api\/entity\/formation\/2/, (req, res, ctx) => { - return res(ctx.json({ ...formation, uai_formation_valide: false })); - }), rest.get(/\/api\/entity\/formation\/1/, (req, res, ctx) => { - return res(ctx.json({ ...formation, uai_formation_valide: true })); + return res(ctx.json({ ...formation, uai_formation_valide: true, distance: 0 })); + }), + rest.get(/\/api\/entity\/formation\/2/, (req, res, ctx) => { + return res(ctx.json({ ...formation, uai_formation_valide: false, distance: 150 })); }), rest.get(/\/api\/v1\/entity\/messageScript/, (req, res, ctx) => { return res(ctx.json([])); @@ -288,10 +288,10 @@ test("renders a training page", async () => { expect(title).toBeInTheDocument(); }); -test("display an error when uai is invalid", async () => { +test("don't display an error when uai is valid", async () => { grantAnonymousAccess({ acl: ["page_formation"] }); - const { getByText, queryByText, queryByTestId } = renderWithRouter(); + const { getByText, queryByText, queryByTestId } = renderWithRouter(); await waitFor(() => getByText(/UAI du lieu de formation/)); @@ -299,13 +299,13 @@ test("display an error when uai is invalid", async () => { expect(uai).toBeInTheDocument(); const warning = queryByTestId("uai-warning"); - expect(warning).toBeInTheDocument(); + expect(warning).not.toBeInTheDocument(); }); -test("don't display an error when uai is valid", async () => { +test("display an error when uai is invalid", async () => { grantAnonymousAccess({ acl: ["page_formation"] }); - const { getByText, queryByText, queryByTestId } = renderWithRouter(); + const { getByText, queryByText, queryByTestId } = renderWithRouter(); await waitFor(() => getByText(/UAI du lieu de formation/)); @@ -313,5 +313,27 @@ test("don't display an error when uai is valid", async () => { expect(uai).toBeInTheDocument(); const warning = queryByTestId("uai-warning"); + expect(warning).toBeInTheDocument(); +}); + +test("don't display an error when adress is same as coordinates", async () => { + grantAnonymousAccess({ acl: ["page_formation"] }); + + const { getByText, queryByTestId } = renderWithRouter(); + + await waitFor(() => getByText(/Adresse :/)); + + const warning = queryByTestId("adress-warning"); expect(warning).not.toBeInTheDocument(); }); + +test("display an error when adress is not same as coordinates", async () => { + grantAnonymousAccess({ acl: ["page_formation"] }); + + const { getByText, queryByTestId } = renderWithRouter(); + + await waitFor(() => getByText(/Adresse :/)); + + const warning = queryByTestId("adress-warning"); + expect(warning).toBeInTheDocument(); +});