generated from gitea_admin/default
Formulaire academie
This commit is contained in:
@@ -189,3 +189,121 @@ export async function sendProjetLyceeEmails(payload) {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function formatAcademieDiploma(diploma, index) {
|
||||
if (!diploma?.type && !diploma?.discipline && !diploma?.year && !diploma?.establishment) {
|
||||
return `Diplome ${index + 1} : Non renseigne`
|
||||
}
|
||||
|
||||
return [
|
||||
`Diplome ${index + 1} :`,
|
||||
`Type : ${diploma.type || "Non renseigne"}`,
|
||||
diploma.type === "Autre" ? `Autre type : ${diploma.otherType || "Non renseigne"}` : null,
|
||||
`Discipline : ${diploma.discipline || "Non renseignee"}`,
|
||||
`Annee : ${diploma.year || "Non renseignee"}`,
|
||||
`Etablissement : ${diploma.establishment || "Non renseigne"}`,
|
||||
].filter(Boolean).join("\n")
|
||||
}
|
||||
|
||||
function getProjetAcademieSummary(payload) {
|
||||
return [
|
||||
"Identite :",
|
||||
`Nom : ${payload.lastName}`,
|
||||
`Prenom : ${payload.firstName}`,
|
||||
`Genre : ${payload.gender}`,
|
||||
`Date de naissance : ${payload.birthDate}`,
|
||||
`Lieu de naissance : ${payload.birthPlace}`,
|
||||
`Nationalite : ${payload.nationality}`,
|
||||
"",
|
||||
"Coordonnees :",
|
||||
`Email : ${payload.email}`,
|
||||
`Telephone : ${payload.phone}`,
|
||||
`Adresse : ${payload.address}`,
|
||||
`Ville : ${payload.city}`,
|
||||
`Code postal : ${payload.postalCode}`,
|
||||
`Pays de residence : ${payload.country}`,
|
||||
"",
|
||||
"Parcours musical :",
|
||||
`Instrument : ${payload.instrument}`,
|
||||
`A deja participe a l'academie : ${payload.previousAcademyParticipation}`,
|
||||
payload.previousAcademyParticipation === "oui"
|
||||
? `Nombre de participations : ${payload.previousAcademyParticipationCount}`
|
||||
: null,
|
||||
"",
|
||||
"Formation :",
|
||||
`Niveau - cycle actuel 2026-2027 : ${payload.trainingLevel}`,
|
||||
payload.trainingLevel === "Autre" ? `Autre formation : ${payload.otherTrainingLevel}` : null,
|
||||
`Conservatoire 2026-2027 : ${payload.conservatory}`,
|
||||
payload.conservatory === "Autre" ? `Autre conservatoire : ${payload.otherConservatory}` : null,
|
||||
`Professeur d'instrument : ${payload.teacherName}`,
|
||||
"",
|
||||
"Diplomes musicaux :",
|
||||
...payload.diplomas.map(formatAcademieDiploma),
|
||||
"",
|
||||
"Contact d'urgence :",
|
||||
`Nom : ${payload.emergencyLastName}`,
|
||||
`Prenom : ${payload.emergencyFirstName}`,
|
||||
`Lien : ${payload.emergencyRelation}`,
|
||||
`Telephone : ${payload.emergencyPhone}`,
|
||||
`Mail : ${payload.emergencyEmail}`,
|
||||
"",
|
||||
`Reglement accepte : ${payload.acceptRules ? "Oui" : "Non"}`,
|
||||
].filter((line) => line !== null).join("\n")
|
||||
}
|
||||
|
||||
export async function sendProjetAcademieEmails(payload) {
|
||||
const config = useRuntimeConfig()
|
||||
const mailer = getTransporter()
|
||||
|
||||
if (!mailer) {
|
||||
console.warn("Email projet académie non envoyé: configuration SMTP incomplète.")
|
||||
return false
|
||||
}
|
||||
|
||||
if (!config.academieRequestRecipientEmail) {
|
||||
console.warn("Email projet académie non envoyé: destinataire académie manquant.")
|
||||
return false
|
||||
}
|
||||
|
||||
const from = config.smtpFromName
|
||||
? `"${config.smtpFromName}" <${config.smtpFromEmail}>`
|
||||
: config.smtpFromEmail
|
||||
|
||||
const summary = getProjetAcademieSummary(payload)
|
||||
const fullName = `${payload.lastName} ${payload.firstName}`
|
||||
|
||||
const adminSubject = `WONDIF - Candidature Academie d'orchestre - ${fullName}`
|
||||
const adminText = [
|
||||
"Une nouvelle candidature a été envoyée depuis le formulaire Académie d'orchestre.",
|
||||
"",
|
||||
summary,
|
||||
].join("\n")
|
||||
|
||||
const userSubject = "ONDIF - Confirmation de votre candidature - Académie d'orchestre"
|
||||
const userText = [
|
||||
`Bonjour ${payload.firstName} ${payload.lastName},`,
|
||||
"",
|
||||
"Votre candidature à l'Académie d'orchestre de l'Orchestre national d'Île-de-France a bien été transmise.",
|
||||
"",
|
||||
"Recapitulatif :",
|
||||
summary,
|
||||
].join("\n")
|
||||
|
||||
await Promise.all([
|
||||
mailer.sendMail({
|
||||
from,
|
||||
to: config.academieRequestRecipientEmail,
|
||||
replyTo: payload.email,
|
||||
subject: adminSubject,
|
||||
text: adminText,
|
||||
}),
|
||||
mailer.sendMail({
|
||||
from,
|
||||
to: payload.email,
|
||||
subject: userSubject,
|
||||
text: userText,
|
||||
}),
|
||||
])
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user