Parameters terminés

This commit is contained in:
2026-06-10 11:59:04 +02:00
parent b85d09ee55
commit 60d8e5d588
5 changed files with 16 additions and 30 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ export class AuthService {
localStorage.setItem(this.TOKEN_KEY, response.token);
const user: LoggedUser = {
id: response.id,
id: String(response.id),
username: response.username,
email: response.email,
tel: response.tel,
+1 -1
View File
@@ -1,5 +1,5 @@
export interface LoggedUser {
id: number;
id: string;
username: string;
email: string | null;
tel: string | null;
@@ -10,7 +10,7 @@
</ion-header>
<ion-content class="ion-padding">
<form [formGroup]="form" (ngSubmit)="submit()">
<form [formGroup]="coordinatesForm" (ngSubmit)="submitForm()">
<ion-item [class.invalid]="email.invalid && email.touched">
<ion-input
@@ -42,7 +42,7 @@
expand="block"
class="ion-margin-top"
type="submit"
[disabled]="form.invalid"
[disabled]="coordinatesForm.invalid"
>
Valider
</ion-button>
@@ -14,22 +14,11 @@ import {
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {firstValueFrom} from "rxjs";
import {KnotsDTOUserUpdateUserContactDto, UsersService} from "../../../services/api";
import {AuthService} from "../../../core/auth/auth.service";
@Component({
selector: 'app-parameters-coordinates-form',
imports: [
IonHeader,
IonToolbar,
IonTitle,
IonButtons,
IonButton,
IonIcon,
IonContent,
ReactiveFormsModule,
IonItem,
IonInput,
IonNote
],
imports: [IonHeader, IonToolbar, IonTitle, IonButtons, IonButton, IonIcon, IonContent, ReactiveFormsModule, IonItem, IonInput, IonNote],
templateUrl: './parameters-coordinates-form.component.html',
styleUrl: './parameters-coordinates-form.component.css'
})
@@ -37,7 +26,7 @@ export class ParametersCoordinatesFormComponent {
@Output() close = new EventEmitter<void>();
private userService = inject(UsersService);
//private authService = inject(AuthService);
private authService = inject(AuthService);
loading = signal(false);
@@ -50,15 +39,13 @@ export class ParametersCoordinatesFormComponent {
addIcons({ closeOutline });
}
ngOnInit() {
//const user = this.userService.currentUser();
const user = this.authService.currentUser();
//this.coordinatesForm.patchValue({
//email: user?.email ?? null,
//tel: user?.tel ?? null,
//});
this.coordinatesForm.patchValue({
email: user?.email ?? null,
tel: user?.tel ?? null,
});
}
get email() { return this.coordinatesForm.get('email')!; }
@@ -68,7 +55,8 @@ export class ParametersCoordinatesFormComponent {
if (this.coordinatesForm.invalid) return;
this.loading.set(true);
//const user = this.authService.currentUser();
const user = this.authService.currentUser();
if (!user) return;
const userValue: KnotsDTOUserUpdateUserContactDto = {
email: this.coordinatesForm.value.email,
@@ -76,7 +64,7 @@ export class ParametersCoordinatesFormComponent {
};
try {
//await firstValueFrom(this.userService.patchUserContactEndpoint(user.id, userValue));
await firstValueFrom(this.userService.patchUserContactEndpoint(Number(user.id), userValue));
this.coordinatesForm.reset();
this.close.emit();
} catch (e) {
@@ -33,7 +33,6 @@ export class ParametersProfileComponent {
this.bio.set(user?.description ?? null);
}
// --- Username ---
toggleEditUsername() {
if (this.editingUsername()) {
@@ -74,7 +73,7 @@ export class ParametersProfileComponent {
this.loading.set(false);
}
// --- Bio ---
toggleEditBio() {
if (this.editingBio()) {
@@ -98,7 +97,6 @@ export class ParametersProfileComponent {
this.loading.set(false);
}
// --- Photo ---
triggerFileInput() {
document.getElementById('photoInput')?.click();