feat: migrate contact deletion in ContactFormComponent to Django REST; update phone number input error message
This commit is contained in:
parent
7b028ab843
commit
5da2cc0237
4 changed files with 14 additions and 6 deletions
|
|
@ -113,7 +113,6 @@
|
|||
[(ngModel)]="contactData.phone"
|
||||
pattern="[\d\+\-\(\)\/]{10,15}"
|
||||
autocomplete="off"
|
||||
required
|
||||
/>
|
||||
<div class="error-msg">
|
||||
@if (!phone.valid && phone.touched) {
|
||||
|
|
@ -126,7 +125,7 @@
|
|||
class="btn-delete"
|
||||
type="button"
|
||||
value="{{ 'contactDialogForm.btnDelete' | translate }}"
|
||||
(click)="closeDialog()"
|
||||
(click)="deleteContact(selectedUser.id)"
|
||||
></app-form-btn>
|
||||
} @else {
|
||||
<app-form-btn
|
||||
|
|
@ -149,8 +148,6 @@
|
|||
!contactData.lastName ||
|
||||
email.invalid ||
|
||||
!contactData.email ||
|
||||
phone.invalid ||
|
||||
!contactData.phone ||
|
||||
!checkIfUserEmailIsValid(contactData.email)
|
||||
"
|
||||
></app-form-btn>
|
||||
|
|
|
|||
|
|
@ -273,6 +273,17 @@ export class ContactFormComponent implements OnInit, OnChanges {
|
|||
return newObj;
|
||||
}
|
||||
|
||||
async deleteContact(userId: string) {
|
||||
try {
|
||||
await lastValueFrom(this.apiService.deleteUserById(userId));
|
||||
this.toastNotificationService.deleteContactSuccessToast();
|
||||
this.updateNotifierService.notifyUpdate('contact');
|
||||
this.closeDialog();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.closeDialogEmitter.emit('');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@
|
|||
"invalidMail0": "Sie müssen eine E-Mail Adresse eingeben!",
|
||||
"invalidMail1": "Dies ist kein gültiges E-Mail-Format!",
|
||||
"invalidMail2": "Diese E-Mail existiert bereits!",
|
||||
"invalidPhone": "Eine Telefonnummer ist erforderlich!",
|
||||
"invalidPhone": "Ungültige Telefonnummer (10–15 Zeichen, Ziffern + ()-/ erlaubt)",
|
||||
"firstName": "Vorname",
|
||||
"lastName": "Nachname",
|
||||
"email": "E-Mail",
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@
|
|||
"invalidMail0": "You must enter a mail!",
|
||||
"invalidMail1": "This is not a valid email format!",
|
||||
"invalidMail2": "This email already exists!",
|
||||
"invalidPhone": "A phone number is required!",
|
||||
"invalidPhone": "Invalid phone number (10–15 chars, digits + ()-/ allowed)",
|
||||
"firstName": "First name",
|
||||
"lastName": "Last name",
|
||||
"email": "Email",
|
||||
|
|
|
|||
Loading…
Reference in a new issue