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