Début du login + parametres
This commit is contained in:
+51
@@ -0,0 +1,51 @@
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Modifier les coordonnées</ion-title>
|
||||
<ion-buttons slot="end">
|
||||
<ion-button (click)="close.emit()">
|
||||
<ion-icon name="close-outline" />
|
||||
</ion-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content class="ion-padding">
|
||||
<form [formGroup]="form" (ngSubmit)="submit()">
|
||||
|
||||
<ion-item [class.invalid]="email.invalid && email.touched">
|
||||
<ion-input
|
||||
label="Email"
|
||||
labelPlacement="floating"
|
||||
type="email"
|
||||
formControlName="email"
|
||||
placeholder="exemple@email.com"
|
||||
/>
|
||||
</ion-item>
|
||||
<ion-note *ngIf="email.invalid && email.touched" color="danger">
|
||||
Adresse email invalide
|
||||
</ion-note>
|
||||
|
||||
<ion-item [class.invalid]="tel.invalid && tel.touched" class="ion-margin-top">
|
||||
<ion-input
|
||||
label="Téléphone"
|
||||
labelPlacement="floating"
|
||||
type="tel"
|
||||
formControlName="tel"
|
||||
placeholder="0612345678"
|
||||
/>
|
||||
</ion-item>
|
||||
<ion-note *ngIf="tel.invalid && tel.touched" color="danger">
|
||||
Numéro à 10 chiffres requis
|
||||
</ion-note>
|
||||
|
||||
<ion-button
|
||||
expand="block"
|
||||
class="ion-margin-top"
|
||||
type="submit"
|
||||
[disabled]="form.invalid"
|
||||
>
|
||||
Valider
|
||||
</ion-button>
|
||||
|
||||
</form>
|
||||
</ion-content>
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
import {Component, EventEmitter, inject, Output, signal} from '@angular/core';
|
||||
import { addIcons } from 'ionicons';
|
||||
import { closeOutline } from 'ionicons/icons';
|
||||
import {
|
||||
IonButton,
|
||||
IonButtons,
|
||||
IonContent,
|
||||
IonHeader,
|
||||
IonIcon, IonInput,
|
||||
IonItem, IonNote,
|
||||
IonTitle,
|
||||
IonToolbar
|
||||
} from "@ionic/angular/standalone";
|
||||
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {KnotsDTOUserUpdateUserContactDto, UsersService} from "../../../services/api";
|
||||
|
||||
@Component({
|
||||
selector: 'app-parameters-coordinates-form',
|
||||
imports: [
|
||||
IonHeader,
|
||||
IonToolbar,
|
||||
IonTitle,
|
||||
IonButtons,
|
||||
IonButton,
|
||||
IonIcon,
|
||||
IonContent,
|
||||
ReactiveFormsModule,
|
||||
IonItem,
|
||||
IonInput,
|
||||
IonNote
|
||||
],
|
||||
templateUrl: './parameters-coordinates-form.component.html',
|
||||
styleUrl: './parameters-coordinates-form.component.css'
|
||||
})
|
||||
export class ParametersCoordinatesFormComponent {
|
||||
@Output() close = new EventEmitter<void>();
|
||||
|
||||
private userService = inject(UsersService);
|
||||
//private authService = inject(AuthService);
|
||||
|
||||
loading = signal(false);
|
||||
|
||||
coordinatesForm = new FormGroup({
|
||||
email: new FormControl<string>(null, [Validators.required, Validators.email]),
|
||||
tel: new FormControl<string>(null, [Validators.required, Validators.pattern(/^\d{10}$/)]),
|
||||
});
|
||||
|
||||
constructor() {
|
||||
addIcons({ closeOutline });
|
||||
}
|
||||
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
//const user = this.userService.currentUser();
|
||||
|
||||
//this.coordinatesForm.patchValue({
|
||||
//email: user?.email ?? null,
|
||||
//tel: user?.tel ?? null,
|
||||
//});
|
||||
}
|
||||
|
||||
get email() { return this.coordinatesForm.get('email')!; }
|
||||
get tel() { return this.coordinatesForm.get('tel')!; }
|
||||
|
||||
async submitForm() {
|
||||
if (this.coordinatesForm.invalid) return;
|
||||
this.loading.set(true);
|
||||
|
||||
//const user = this.authService.currentUser();
|
||||
|
||||
const userValue: KnotsDTOUserUpdateUserContactDto = {
|
||||
email: this.coordinatesForm.value.email,
|
||||
tel: this.coordinatesForm.value.tel,
|
||||
};
|
||||
|
||||
try {
|
||||
//await firstValueFrom(this.userService.patchUserContactEndpoint(user.id, userValue));
|
||||
this.coordinatesForm.reset();
|
||||
this.close.emit();
|
||||
} catch (e) {
|
||||
console.error('Erreur lors de la mise à jour des coordonnées', e);
|
||||
}
|
||||
|
||||
this.loading.set(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user