Skip to content

Commit

Permalink
ARPA-954 Added button to send e-mail notifications for appointments (#…
Browse files Browse the repository at this point in the history
…296)

* ARPA-954 Added button to send e-mail notifications for appointments
  • Loading branch information
VILLAN3LL3 authored Jan 1, 2024
1 parent de5fbc0 commit 58e3fcf
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ <h3 style="text-align: center" class="appointment-title">
type="submit"
class="p-mr-3"
></button>
<button
[label]="'appointments.SEND_NOTIFICATION' | translate"
[pTooltip]="'appointments.SEND_NOTIFICATION_TOOLTIP' | translate"
*ngIf="!isNew && formGroup.pristine"
(click)="onSendNotification($event)"
pButton
class="p-button-outlined p-button-secondary p-mr-3"
type="button"
icon="pi pi-envelope"
></button>
<button
(click)="onSubmit(true)"
[disabled]="formGroup.pristine || formGroup.invalid"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export class EditAppointmentComponent implements OnInit {
}

private loadData() {
console.log(this.config.data);
this.appointment = this.config.data.appointment;
this.isAllDayEvent = this.config.data.isAllDayEvent;
const sections$ = this.config.data.sections ? of(this.config.data.sections) : this.sectionService.sectionsAll$;
Expand Down Expand Up @@ -589,4 +588,42 @@ export class EditAppointmentComponent implements OnInit {
exportCSV() {
this.table.exportCSV();
}

public onSendNotification(event: Event) {
this.sendNotification(false, event);
}

private sendNotification(force: boolean, event?: Event) {
this.appointmentService
.sendNotification(this.appointment.id, force)
.pipe(first())
.subscribe(
() => {
this.notificationsService.success('appointments.NOTIFICATION_SENT');
},
(error: any) => {
if (error.errors?.ForceSending && !force) {
this.showNotificationConfirmation(error.errors.ForceSending[0], event);
}
if (error.errors?.AppointmentId) {
this.notificationsService.error(error.errors.AppointmentId[0]);
} else {
this.notificationsService.error(error!.title);
}
}
);
}

private showNotificationConfirmation(confirmationMessage: string, event?: Event) {
this.confirmationService.confirm({
target: event?.target || undefined,
message: confirmationMessage,
icon: 'pi pi-exclamation-triangle',
acceptLabel: this.translate.instant('YES'),
rejectLabel: this.translate.instant('NO'),
accept: () => {
this.sendNotification(true);
},
});
}
}
5 changes: 5 additions & 0 deletions src/app/features/appointments/services/appointment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,9 @@ export class AppointmentService {
.put(`${this.baseUrl}/${appointmentId}/participations/${personId}/prediction`, { prediction })
.pipe(shareReplay());
}

sendNotification(appointmentId: string, forceSending = false) {
const params = new HttpParams().set('forceSending', forceSending);
return this.apiService.post(`${this.baseUrl}/${appointmentId}/notification`, params).pipe(shareReplay());
}
}
3 changes: 3 additions & 0 deletions src/assets/i18n/appointments/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"NEW_APPOINTMENT_CONFIRMATION": "Möchtest du einen neuen Termin anlegen für {{value}}?",
"NO_PREDICTION": "Deine Prognose?",
"NORECORDS": "Keine Datensätze gefunden",
"NOTIFICATION_SENT": "Die E-Mail-Benachrichtigungen wurde gesendet",
"PAGE_TITLE": "Kalender",
"PARTICIPATIONSTATUS": "Teilnahmestatus",
"PARTICIPATIONS": "Teilnahmen",
Expand All @@ -41,6 +42,8 @@
"SECTION_ADDED": "Register hinzugefügt",
"SECTION_REMOVED": "Register entfernt",
"SELECT_PREDICTION": "Vorhersage wählen",
"SEND_NOTIFICATION": "E-Mail-Benachrichtigung senden",
"SEND_NOTIFICATION_TOOLTIP": "Eine E-Mail-Benachrichtigung über die Änderung dieses Termins an alle Teilnehmer senden",
"START": "Beginn",
"STATUS": "Status",
"TITLE": "Terminbezeichnung",
Expand Down
3 changes: 3 additions & 0 deletions src/assets/i18n/appointments/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"NEW_APPOINTMENT_CONFIRMATION": "Do you want to create a new appointment for {{value}}?",
"NO_PREDICTION": "Your prediction?",
"NORECORDS": "No records found",
"NOTIFICATION_SENT": "The e-mail notifications have been sent",
"PAGE_TITLE": "Calendar",
"PARTICIPATIONSTATUS": "Participationstatus",
"PARTICIPATIONS": "Participations",
Expand All @@ -41,6 +42,8 @@
"SECTION_ADDED": "Section added",
"SECTION_REMOVED": "Section removed",
"SELECT_PREDICTION": "Select prediction",
"SEND_NOTIFICATION": "Send e-mail notification",
"SEND_NOTIFICATION_TOOLTIP": "Send an e-mail notification to all participants about the change to this appointment",
"START": "Start",
"STATUS": "Status",
"TITLE": "Appointment description",
Expand Down
3 changes: 3 additions & 0 deletions src/assets/i18n/appointments/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"NEW_APPOINTMENT_CONFIRMATION": "Aimerais -tu fixer un nouveau rendez-vous pour {{value}}?",
"NO_PREDICTION": "Aucune prédiction",
"NORECORDS": "Aucun enregistrement n'a été trouvée",
"NOTIFICATION_SENT": "Les notifications par e-mail ont été envoyées",
"PAGE_TITLE": "Calendrier",
"PARTICIPATIONSTATUS": "Statut de participation",
"PARTICIPATIONS": "Participations",
Expand All @@ -40,6 +41,8 @@
"SECTION_ADDED": "Registre ajouté",
"SECTION_REMOVED": "Registre supprimé",
"SELECT_PREDICTION": "Sélectionnez la prédiction",
"SEND_NOTIFICATION": "Envoyer une notification par e-mail",
"SEND_NOTIFICATION_TOOLTIP": "Envoyer une notification par e-mail de la modification de ce rendez-vous à tous les participants",
"START": "Début",
"STATUS": "Statut",
"TITLE": "Nom de l'événement",
Expand Down
3 changes: 3 additions & 0 deletions src/assets/i18n/appointments/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"NEW_APPOINTMENT_CONFIRMATION": "Deseja (re)agendar para {{value}}?",
"NO_PREDICTION": "Sem previsão",
"NORECORDS": "Nenhum registo encontrado",
"NOTIFICATION_SENT": "As notificações por correio eletrónico foram enviadas",
"PAGE_TITLE": "Calendário",
"PARTICIPATIONSTATUS": "Estatuto de participação",
"PARTICIPATIONS": "Participaçãoes",
Expand All @@ -35,6 +36,8 @@
"SALARY": "Remuneração",
"SALARYPATTERN": "Modelo de remuneração",
"SAVECLOSE": "Salvar e fechar",
"SEND_NOTIFICATION": "Enviar notificação por correio eletrónico",
"SEND_NOTIFICATION_TOOLTIP": "Enviar uma notificação por correio eletrónico a todos os participantes sobre a alteração deste compromisso",
"SAVECONTINUE": "Salvar e continuar",
"SECTION_ADDED": "Registo inserido",
"SECTION_REMOVED": "Registo removido",
Expand Down

0 comments on commit 58e3fcf

Please sign in to comment.