Skip to content

Commit

Permalink
feat: update checks demandeur and add condition email (#516)
Browse files Browse the repository at this point in the history
* feat: update checks for other convention

* feat: add condition to send email

* feat: update description for email and remove console.log
  • Loading branch information
FredericNumericite authored Apr 14, 2023
1 parent a7fd7ab commit 6ff2bef
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 38 deletions.
2 changes: 1 addition & 1 deletion formulaire/src/components/Dossier/DemandeurForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const DemandeurForm: React.FC<Props> = ({ allowChanges }) => {
htmlFor="otherConventionCollective"
className="mb-2 italic"
>
Nom de la convention
Nom de la convention *
</label>
<input
onChange={(e: React.FormEvent<HTMLInputElement>) => {
Expand Down
10 changes: 10 additions & 0 deletions formulaire/src/components/Dossier/DossierForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ const DossierForm: React.FC<Props> = ({ dossier, docs, comments }) => {
);
verif = false;
}
if (
contextDossier.demandeur.conventionCollectiveCode === "0000" &&
!contextDossier.demandeur.otherConventionCollective
) {
setTodisplay(entity.entity as "Demandeur" | "Projet" | "Enfants");
setMessageError(
`Le champ 'Nom de la convention' est necessaire sur l'onglet Demandeur`
);
verif = false;
}
if (
!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(
contextDossier.demandeur.email ?? ""
Expand Down
2 changes: 0 additions & 2 deletions formulaire/src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const CHECKS = [
{label : 'Mail', code: 'email'},
{label : 'Fonction', code: 'fonction'},
{label : 'Convention collective applicable', code: 'conventionCollectiveCode'},
{label : 'Autre convention collective applicable', code: 'otherConventionCollective'},
]
},
{
Expand Down Expand Up @@ -185,7 +184,6 @@ const WORDING_MAILING = [
type: "share_dossier",
},
{
button: "Télécharger",
bye: "N'hésitez pas à nous contacter pour toute information complémentaire.",
subject: "Décision d'autorisation Enfants du spectacle",
title: "Bonjour, vous avez été invité à télécharger la décision d'autorisation",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChangeStatutDossierButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const ChangeStatutDossierButton: React.FC<Props> = ({ dossier, demandeur }) => {
if (transition.name === "passerAccepte") {
const attachment = generateDA([dossier as DossierData], true);
sendEmail(
"dl_decision",
"auth_access",
attachment as string,
dossier,
demandeur.email
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dossier.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ const Dossier: React.FC<Props> = ({ dossierId, dataLinks }) => {
onClick={() => {
const attachment = generateDA([dossier], true);
sendEmail(
"dl_decision",
"auth_access",
attachment as string,
dossier,
dossier.demandeur.email
Expand Down
92 changes: 60 additions & 32 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function getFormatedTypeDossier(type: string): string {
"Enregistrement doublage": "DOUBLAGE",
"Enregistrement musique en studio": "MUSIQUE_STUDIO",
"Film institutionnel": "FILM_INSTITUTIONNEL",
"Documentaire fictionnel": "DOCUMENTAIRE_FICTIONNEL",
"Film long métrage": "LONG_METRAGE",
"Film moyen ou court métrage": "COURT_METRAGE",
Opéra: "OPERA",
Expand All @@ -153,7 +154,6 @@ function getFormatedTypeDossier(type: string): string {
Téléfilm: "TELEFILM",
"Émission radio": "RADIO",
"Émission télé": "EMISSION_TV",
"Documentaire fictionnel": "DOCUMENTAIRE_FICTIONNEL",
}[type] ?? "AUTRE"
);
}
Expand Down Expand Up @@ -191,41 +191,67 @@ const ROLES_USERS = [
{ label: "Médecin travail", value: "MEDECIN" },
];

const TYPE_CONSULTATION_MEDECIN: {label: string, value: TypeConsultationMedecin, labelCol2: string, typeJustif: JustificatifEnfant}[] = [
{ label: "En physique ou en téléconsultation", value: "PHYSIQUE", labelCol2: 'Date du rdv ', typeJustif: 'AVIS_MEDICAL'},
{ label: "Sur pièce", value: "PIECE", labelCol2: 'Avis médical', typeJustif: 'AVIS_MEDICAL'},
{ label: "Bon de prise en charge", value: "PRISE_EN_CHARGE", labelCol2: 'Bon de prise en charge', typeJustif: 'BON_PRISE_EN_CHARGE'},
{ label: "Par le médecin traitant", value: "MEDECIN_TRAITANT", labelCol2: 'Autorisation de prise en charge', typeJustif: 'AUTORISATION_PRISE_EN_CHARGE'},
]
const TYPE_CONSULTATION_MEDECIN: {
label: string;
value: TypeConsultationMedecin;
labelCol2: string;
typeJustif: JustificatifEnfant;
}[] = [
{
label: "En physique ou en téléconsultation",
labelCol2: "Date du rdv ",
typeJustif: "AVIS_MEDICAL",
value: "PHYSIQUE",
},
{
label: "Sur pièce",
labelCol2: "Avis médical",
typeJustif: "AVIS_MEDICAL",
value: "PIECE",
},
{
label: "Bon de prise en charge",
labelCol2: "Bon de prise en charge",
typeJustif: "BON_PRISE_EN_CHARGE",
value: "PRISE_EN_CHARGE",
},
{
label: "Par le médecin traitant",
labelCol2: "Autorisation de prise en charge",
typeJustif: "AUTORISATION_PRISE_EN_CHARGE",
value: "MEDECIN_TRAITANT",
},
];

const INFOS_REPRESENTANTS: {col: string, rows: {label: string, value: keyof Enfant}[]}[] = [
const INFOS_REPRESENTANTS: {
col: string;
rows: { label: string; value: keyof Enfant }[];
}[] = [
{
col: 'ENFANT',
rows: [
{label: 'Adresse', value: 'adresseEnfant'}
]
col: "ENFANT",
rows: [{ label: "Adresse", value: "adresseEnfant" }],
},
{
col: 'REPRÉSENTANT LÉGAL 1',
col: "REPRÉSENTANT LÉGAL 1",
rows: [
{label: 'Nom', value: 'nomRepresentant1'},
{label: 'Prénom', value: 'prenomRepresentant1'},
{label: 'Adresse', value: 'adresseRepresentant1'},
{label: 'Email', value: 'mailRepresentant1'},
{label: 'Téléphone', value: 'telRepresentant1'},
]
{ label: "Nom", value: "nomRepresentant1" },
{ label: "Prénom", value: "prenomRepresentant1" },
{ label: "Adresse", value: "adresseRepresentant1" },
{ label: "Email", value: "mailRepresentant1" },
{ label: "Téléphone", value: "telRepresentant1" },
],
},
{
col: 'REPRÉSENTANT LÉGAL 2',
col: "REPRÉSENTANT LÉGAL 2",
rows: [
{label: 'Nom', value: 'nomRepresentant2'},
{label: 'Prénom', value: 'prenomRepresentant2'},
{label: 'Adresse', value: 'adresseRepresentant2'},
{label: 'Email', value: 'mailRepresentant2'},
{label: 'Téléphone', value: 'telRepresentant2'},
]
{ label: "Nom", value: "nomRepresentant2" },
{ label: "Prénom", value: "prenomRepresentant2" },
{ label: "Adresse", value: "adresseRepresentant2" },
{ label: "Email", value: "mailRepresentant2" },
{ label: "Téléphone", value: "telRepresentant2" },
],
},
]
];

const ALL_DEPARTEMENTS = ["75", "92", "93", "94", "78", "77", "91", "95", ""];

Expand Down Expand Up @@ -266,14 +292,16 @@ const WORDING_MAILING = [
bye: "Ce lien sera valide pendant cinq jours après réception de cet email.",
subject: "Téléchargement commission Enfants du spectacle",
text: "Cliquez sur le bouton ci-dessous pour télécharger les dossiers de la commission via un lien sécurisé.",
title: "Bonjour,",
type: "dl_commission",
},
{
button: "Télécharger",
button: "Accéder à la plate-forme",
bye: "N'hésitez pas à nous contacter pour toute information complémentaire.",
subject: "Décision d'autorisation Enfants du spectacle",
text: "Votre dossier a été accepté. Vous trouverez en pièce jointe de ce mail la décision d'autorisation.",
type: "dl_decision",
text: "Votre dossier a été accepté. Vous trouverez la décision d'autorisation en pièce jointe. Vous pouvez également accéder à la plate-forme afin d'y télécharger la décision d'autorisation.",
title: "Bonjour,",
type: "auth_access",
},

{
Expand Down Expand Up @@ -374,15 +402,14 @@ export {
compact,
delay,
EMPLOIS_CATEGORIES,
TYPE_CONSULTATION_MEDECIN,
INFOS_REPRESENTANTS,
filterCommissions,
filterSearchResults,
frenchDateHour,
frenchDateText,
frenchDepartementName,
getFilterableSocietesProductions,
getFormatedTypeDossier,
INFOS_REPRESENTANTS,
JUSTIFS_DOSSIER,
JUSTIFS_ENFANT,
ROLES_USERS,
Expand All @@ -391,6 +418,7 @@ export {
STATUS_ODJ,
stringToNumberOrNull,
strNoAccent,
TYPE_CONSULTATION_MEDECIN,
typeEmploiLabel,
typeEmploiValue,
TYPES_EMPLOI,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/api/mail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ const sendMail: NextApiHandler = async (req, res) => {
}

try {
const url = `${req.headers.host}`;
const url =
type === "auth_access"
? `${process.env.URL_SDP}`
: `${process.env.NEXTAUTH_URL}`;

const transporter: Transporter = nodemailer.createTransport({
auth: {
Expand Down

0 comments on commit 6ff2bef

Please sign in to comment.