diff --git a/server/src/http/routes/sendApplication.controller.ts b/server/src/http/routes/sendApplication.controller.ts index 66b3c9daf7..58aa5dec15 100644 --- a/server/src/http/routes/sendApplication.controller.ts +++ b/server/src/http/routes/sendApplication.controller.ts @@ -59,6 +59,25 @@ export default function (server: Server) { } ) + server.post( + "/application/intention", + { + schema: zRoutes.post["/application/intention"], + config: rateLimitConfig, + }, + async (req, res) => { + const decryptedId = decryptWithIV(req.body.id, req.body.iv) + + const application = await Application.findOneAndUpdate( + { _id: new mongoose.Types.ObjectId(decryptedId) }, + { company_recruitment_intention: req.body.intention, company_feedback_date: new Date() } + ) + if (!application) throw new Error("application not found") + + return res.status(200).send({ result: "ok" }) + } + ) + server.post( "/application/webhook", { diff --git a/shared/routes/application.routes.ts b/shared/routes/application.routes.ts index 4b86fd28ef..eefc1b1234 100644 --- a/shared/routes/application.routes.ts +++ b/shared/routes/application.routes.ts @@ -35,6 +35,26 @@ export const zApplicationRoutes = { "Envoi d'un email de candidature à une offre postée sur La bonne alternance recruteur ou une candidature spontanée à une entreprise identifiée par La bonne alternance.\nL'email est envoyé depuis l'adresse générique \"Ne pas répondre\" de La bonne alternance.\n", }, }, + "/application/intention": { + // TODO_SECURITY_FIX + path: "/application/intention", + method: "post", + body: z + .object({ + id: z.string(), // inutile de chiffrer l'id, rajouter un champ token qui contiendra l'id + iv: z.string(), + intention: z.string(), + }) + .strict(), + response: { + "200": z + .object({ + result: z.literal("ok"), + }) + .strict(), + }, + securityScheme: null, + }, "/application/intentionComment": { // TODO_SECURITY_FIX path: "/application/intentionComment", diff --git a/shared/routes/v1Formations.routes.ts b/shared/routes/v1Formations.routes.ts index eae9ec3327..46805ffefe 100644 --- a/shared/routes/v1Formations.routes.ts +++ b/shared/routes/v1Formations.routes.ts @@ -85,24 +85,8 @@ export const zV1FormationsRoutes = { }) .strict(), response: { - // Strip souhaité. Appel à une API décommissionnée en attente de remplacement // eslint-disable-next-line zod/require-strict "200": z.any(), - // .object({ - // // eslint-disable-next-line zod/require-strict - // organisme: z - // .object({ - // // eslint-disable-next-line zod/require-strict - // contact: z - // .object({ - // tel: z.string().nullish(), - // url: z.string().nullish(), - // }) - // .strip(), - // }) - // .strip(), - // }) - // .strip(), "400": z.union([ZResError, ZLbacError]).openapi({ description: "Bad Request", }), diff --git a/ui/components/SatisfactionForm/SatisfactionForm.tsx b/ui/components/SatisfactionForm/SatisfactionForm.tsx index fe0dd36dd5..e628841af9 100644 --- a/ui/components/SatisfactionForm/SatisfactionForm.tsx +++ b/ui/components/SatisfactionForm/SatisfactionForm.tsx @@ -10,6 +10,7 @@ import { getValueFromPath } from "../../utils/tools" import SatisfactionFormNavigation from "./SatisfactionFormNavigation" import SatisfactionFormSuccess from "./SatisfactionFormSuccess" +import postIntention from "./services/postIntention" import submitCommentaire from "./services/submitCommentaire" let iv = null @@ -102,9 +103,18 @@ const SatisfactionForm = ({ formType }) => { return text } + const sendIntention = async () => { + await postIntention({ + id, + intention, + iv, + }) + } + useEffect(() => { // enregistrement en state des params provenant du path initParametersFromPath() + sendIntention() }, []) const [sendingState, setSendingState] = useState("not_sent")