diff --git a/nginx/templates/default.conf.template b/nginx/templates/default.conf.template index 80a9d9cd..026fadcb 100644 --- a/nginx/templates/default.conf.template +++ b/nginx/templates/default.conf.template @@ -13,4 +13,11 @@ server { proxy_pass https://api.brevo.com/v3/smtp/email; client_max_body_size 10M; } + location ~ ^/ticket/(.*)$ { + proxy_pass https://ticket-office.dataesr.ovh/$1; + proxy_set_header Authorization 'Basic $TICKET_OFFICE_API_KEY'; + proxy_set_header Accept application/json; + proxy_set_header Content-Type application/json; + client_max_body_size 10M; + } } \ No newline at end of file diff --git a/src/components/SubmissionForm/index.js b/src/components/SubmissionForm/index.js index 00fc57f1..9e4b25c0 100644 --- a/src/components/SubmissionForm/index.js +++ b/src/components/SubmissionForm/index.js @@ -76,6 +76,39 @@ const SubmissionForm = () => { setNntIdCount(undefined); }; + const sendTicketOffice = (content) => { + const data = { + contact: { + email, + }, + structure: { + name, + ...(acronym && { acronym }), + ...(id && { siren: id }), + ...(ror && { ror }), + }, + csv: content, + }; + + const options = { + method: 'POST', + url: `${window.location.origin}/ticket/variations`, + headers: { + 'Content-Type': 'application/json', + }, + data, + }; + + Axios.request(options) + .then(() => { + console.log('success'); + }) + .catch((e) => { + // eslint-disable-next-line no-console + console.error(e); + }); + }; + const sendEmail = (event) => { event.preventDefault(); const txt = Papa.unparse(dataFile, { @@ -153,6 +186,8 @@ const SubmissionForm = () => { "Erreur lors de l'envoi de votre fichier, merci de contacter bso@recherche.gouv.fr.", ); }); + + sendTicketOffice(content); }; const readCSV = (input) => {