Skip to content

Commit

Permalink
feat(submission): add send to ticket office
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonestla committed Feb 12, 2025
1 parent 0a69c58 commit 3a5734d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
35 changes: 35 additions & 0 deletions src/components/SubmissionForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 3a5734d

Please sign in to comment.