Debut parametres profil
This commit is contained in:
@@ -91,4 +91,12 @@ export class AuthService {
|
||||
this.currentUser.set(null);
|
||||
this.router.navigate(['/login']);
|
||||
}
|
||||
|
||||
updateCurrentUser(partial: Partial<LoggedUser>): void {
|
||||
const user = this.currentUser();
|
||||
if (!user) return;
|
||||
const updated = { ...user, ...partial };
|
||||
localStorage.setItem(this.USER_KEY, JSON.stringify(updated));
|
||||
this.currentUser.set(updated);
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
.modal-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
background: linear-gradient(160deg, #f9e8e8 0%, #f2c4c4 35%, #e89898 70%, #d97070 100%);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20px 20px 12px;
|
||||
border-bottom: 1px solid rgba(189, 90, 90, 0.15);
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
color: #7a2e2e;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.modal-close-btn {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 10px;
|
||||
background: white;
|
||||
border: none;
|
||||
box-shadow: 0 2px 8px rgba(180, 80, 80, 0.12);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #bd5a5a;
|
||||
cursor: pointer;
|
||||
font-size: 1.2rem;
|
||||
transition: transform 0.15s;
|
||||
|
||||
&:active { transform: scale(0.92); }
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
padding: 24px 20px;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.custom-item {
|
||||
--background: white;
|
||||
--border-radius: 12px;
|
||||
--padding-start: 14px;
|
||||
--inner-padding-end: 14px;
|
||||
--color: #7a2e2e;
|
||||
--highlight-color-focused: #bd5a5a;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 10px rgba(180, 80, 80, 0.1);
|
||||
|
||||
&.invalid {
|
||||
--border-color: #d97070;
|
||||
box-shadow: 0 2px 10px rgba(180, 80, 80, 0.25);
|
||||
}
|
||||
}
|
||||
|
||||
.error-msg {
|
||||
color: #7a2e2e;
|
||||
font-size: 0.8rem;
|
||||
padding-left: 4px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
width: 100%;
|
||||
background: white;
|
||||
color: #bd5a5a;
|
||||
border: none;
|
||||
border-radius: 14px;
|
||||
padding: 14px;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 2px 10px rgba(180, 80, 80, 0.15);
|
||||
cursor: pointer;
|
||||
transition: transform 0.15s, box-shadow 0.2s;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.97);
|
||||
box-shadow: 0 1px 5px rgba(180, 80, 80, 0.1);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
height: 100%;
|
||||
}
|
||||
+29
-26
@@ -1,18 +1,17 @@
|
||||
<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>
|
||||
<div class="modal-layout">
|
||||
|
||||
<ion-content class="ion-padding">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title">Modifier les coordonnées</h2>
|
||||
<button class="modal-close-btn" (click)="close.emit()">
|
||||
<ion-icon name="close-outline" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form [formGroup]="coordinatesForm" (ngSubmit)="submitForm()">
|
||||
|
||||
<ion-item [class.invalid]="email.invalid && email.touched">
|
||||
<div class="input-wrapper">
|
||||
<ion-item class="custom-item" [class.invalid]="email.invalid && email.touched">
|
||||
<ion-input
|
||||
label="Email"
|
||||
labelPlacement="floating"
|
||||
@@ -21,11 +20,13 @@
|
||||
placeholder="exemple@email.com"
|
||||
/>
|
||||
</ion-item>
|
||||
<ion-note *ngIf="email.invalid && email.touched" color="danger">
|
||||
Adresse email invalide
|
||||
</ion-note>
|
||||
@if (email.invalid && email.touched) {
|
||||
<p class="error-msg">Adresse email invalide</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<ion-item [class.invalid]="tel.invalid && tel.touched" class="ion-margin-top">
|
||||
<div class="input-wrapper">
|
||||
<ion-item class="custom-item" [class.invalid]="tel.invalid && tel.touched">
|
||||
<ion-input
|
||||
label="Téléphone"
|
||||
labelPlacement="floating"
|
||||
@@ -34,18 +35,20 @@
|
||||
placeholder="0612345678"
|
||||
/>
|
||||
</ion-item>
|
||||
<ion-note *ngIf="tel.invalid && tel.touched" color="danger">
|
||||
Numéro à 10 chiffres requis
|
||||
</ion-note>
|
||||
@if (tel.invalid && tel.touched) {
|
||||
<p class="error-msg">Numéro à 10 chiffres requis</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<ion-button
|
||||
expand="block"
|
||||
class="ion-margin-top"
|
||||
<button
|
||||
class="submit-btn"
|
||||
type="submit"
|
||||
[disabled]="coordinatesForm.invalid"
|
||||
[disabled]="coordinatesForm.invalid || loading()"
|
||||
>
|
||||
Valider
|
||||
</ion-button>
|
||||
{{ loading() ? 'Enregistrement...' : 'Valider' }}
|
||||
</button>
|
||||
|
||||
</form>
|
||||
</ion-content>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
+1
-1
@@ -18,7 +18,7 @@ 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: [IonIcon,ReactiveFormsModule, IonItem, IonInput],
|
||||
templateUrl: './parameters-coordinates-form.component.html',
|
||||
styleUrl: './parameters-coordinates-form.component.css'
|
||||
})
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, ViewEncapsulation} from '@angular/core';
|
||||
import { IonModal, IonButton } from '@ionic/angular/standalone';
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {ParametersCoordinatesFormComponent} from "../parameters-coordinates-form/parameters-coordinates-form.component";
|
||||
|
||||
@Component({
|
||||
selector: 'app-parameters-coordinates',
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
imports: [IonModal, FormsModule, ParametersCoordinatesFormComponent],
|
||||
templateUrl: './parameters-coordinates.component.html',
|
||||
styleUrl: './parameters-coordinates.component.css'
|
||||
|
||||
@@ -34,10 +34,13 @@
|
||||
/>
|
||||
</ng-template>
|
||||
<button class="edit-btn" (click)="toggleEditUsername()" title="Modifier">
|
||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg *ngIf="!editingUsername()" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M13.5 3.5L16.5 6.5L7 16H4V13L13.5 3.5Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>
|
||||
<path d="M11.5 5.5L14.5 8.5" stroke="currentColor" stroke-width="1.6"/>
|
||||
</svg>
|
||||
<svg *ngIf="editingUsername()" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4 10L8 14L16 6" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -50,22 +53,18 @@
|
||||
<span class="field-value bio-value">{{ bio() }}</span>
|
||||
</ng-container>
|
||||
<ng-template #editBioBlock>
|
||||
<textarea
|
||||
class="field-input bio-textarea"
|
||||
[value]="bio()"
|
||||
(input)="bio.set($any($event.target).value)"
|
||||
(blur)="toggleEditBio()"
|
||||
autofocus
|
||||
></textarea>
|
||||
</ng-template>
|
||||
<textarea class="field-input bio-textarea" [value]="bio()" (input)="bio.set($any($event.target).value)" (blur)="toggleEditBio()" autofocus></textarea>
|
||||
<button class="edit-btn" (click)="toggleEditBio()" title="Modifier">
|
||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg *ngIf="!editingBio()" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M13.5 3.5L16.5 6.5L7 16H4V13L13.5 3.5Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>
|
||||
<path d="M11.5 5.5L14.5 8.5" stroke="currentColor" stroke-width="1.6"/>
|
||||
</svg>
|
||||
<svg *ngIf="editingBio()" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4 10L8 14L16 6" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</ng-template>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, inject, signal} from '@angular/core';
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import {firstValueFrom} from "rxjs";
|
||||
@@ -12,7 +12,7 @@ import {AuthService} from "../../../core/auth/auth.service";
|
||||
templateUrl: './parameters-profile.component.html',
|
||||
styleUrl: './parameters-profile.component.css'
|
||||
})
|
||||
export class ParametersProfileComponent {
|
||||
export class ParametersProfileComponent implements OnInit {
|
||||
private usersService = inject(UsersService);
|
||||
private authService = inject(AuthService);
|
||||
|
||||
@@ -33,6 +33,7 @@ export class ParametersProfileComponent {
|
||||
this.bio.set(user?.description ?? null);
|
||||
}
|
||||
|
||||
// --- Username ---
|
||||
|
||||
toggleEditUsername() {
|
||||
if (this.editingUsername()) {
|
||||
@@ -57,9 +58,13 @@ export class ParametersProfileComponent {
|
||||
|
||||
this.loading.set(true);
|
||||
const user = this.authService.currentUser();
|
||||
if (!user) return;
|
||||
|
||||
try {
|
||||
await firstValueFrom(this.usersService.patchUsernameEndpoint(user.id, { username: value }));
|
||||
await firstValueFrom(this.usersService.patchUsernameEndpoint(
|
||||
String(user.id), { username: value }
|
||||
));
|
||||
this.authService.updateCurrentUser({ username: value }); // 👈 maj locale
|
||||
this.usernameError.set(null);
|
||||
this.editingUsername.set(false);
|
||||
} catch (e: any) {
|
||||
@@ -73,7 +78,7 @@ export class ParametersProfileComponent {
|
||||
this.loading.set(false);
|
||||
}
|
||||
|
||||
|
||||
// --- Bio ---
|
||||
|
||||
toggleEditBio() {
|
||||
if (this.editingBio()) {
|
||||
@@ -86,9 +91,13 @@ export class ParametersProfileComponent {
|
||||
async submitBio() {
|
||||
this.loading.set(true);
|
||||
const user = this.authService.currentUser();
|
||||
if (!user) return;
|
||||
|
||||
try {
|
||||
await firstValueFrom(this.usersService.patchUserDescriptionEndpoint(user.id, { description: this.bio() }));
|
||||
await firstValueFrom(this.usersService.patchUserDescriptionEndpoint(
|
||||
String(user.id), { description: this.bio() }
|
||||
));
|
||||
this.authService.updateCurrentUser({ description: this.bio() }); // 👈 maj locale
|
||||
this.editingBio.set(false);
|
||||
} catch (e) {
|
||||
console.error('Erreur lors de la mise à jour de la bio', e);
|
||||
@@ -97,6 +106,7 @@ export class ParametersProfileComponent {
|
||||
this.loading.set(false);
|
||||
}
|
||||
|
||||
// --- Photo ---
|
||||
|
||||
triggerFileInput() {
|
||||
document.getElementById('photoInput')?.click();
|
||||
@@ -113,9 +123,13 @@ export class ParametersProfileComponent {
|
||||
|
||||
this.loading.set(true);
|
||||
const user = this.authService.currentUser();
|
||||
if (!user) return;
|
||||
|
||||
try {
|
||||
await firstValueFrom(this.usersService.patchUserProfilePictureEndpoint(user.id, { profilePicture: base64 }));
|
||||
await firstValueFrom(this.usersService.patchUserProfilePictureEndpoint(
|
||||
String(user.id), { profilePicture: base64 }
|
||||
));
|
||||
this.authService.updateCurrentUser({ profilePicture: base64 }); // 👈 maj locale
|
||||
} catch (e) {
|
||||
console.error('Erreur lors de la mise à jour de la photo', e);
|
||||
}
|
||||
|
||||
@@ -179,10 +179,10 @@ export class DiscussionsService extends BaseService {
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
* @param options additional options
|
||||
*/
|
||||
public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>;
|
||||
public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>;
|
||||
public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>;
|
||||
public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>;
|
||||
public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>;
|
||||
public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>;
|
||||
public getDiscussionEndpoint(id: number, name: string, isGroup: boolean, membersCount?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (id === null || id === undefined) {
|
||||
throw new Error('Required parameter id was null or undefined when calling getDiscussionEndpoint.');
|
||||
}
|
||||
@@ -192,9 +192,6 @@ export class DiscussionsService extends BaseService {
|
||||
if (isGroup === null || isGroup === undefined) {
|
||||
throw new Error('Required parameter isGroup was null or undefined when calling getDiscussionEndpoint.');
|
||||
}
|
||||
if (membersCount === null || membersCount === undefined) {
|
||||
throw new Error('Required parameter membersCount was null or undefined when calling getDiscussionEndpoint.');
|
||||
}
|
||||
|
||||
let localVarQueryParameters = new OpenApiHttpParams(this.encoder);
|
||||
|
||||
@@ -274,4 +271,58 @@ export class DiscussionsService extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @endpoint get /API/discussions/my
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
* @param options additional options
|
||||
*/
|
||||
public getMyDiscussionEndpoint(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<object>>;
|
||||
public getMyDiscussionEndpoint(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<object>>>;
|
||||
public getMyDiscussionEndpoint(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<object>>>;
|
||||
public getMyDiscussionEndpoint(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
// authentication (JWTBearerAuth) required
|
||||
localVarHeaders = this.configuration.addCredentialToHeaders('JWTBearerAuth', 'Authorization', localVarHeaders, 'Bearer ');
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/API/discussions/my`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<Array<object>>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user