Skip to content

Commit

Permalink
fix: email of a registered user cant be change anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelPelegrina committed Apr 23, 2024
1 parent a29ac52 commit 92acbc9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/app/app-routing-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { ListCustomerComponent } from "./components/sales-statistics/list-custom
import { RevenueCalculatorComponent } from "./components/sales-statistics/revenue-calculator/revenue-calculator.component";
import { BookExcelParserComponent } from "./components/book/book-excel-parser/book-excel-parser.component";


/**
* Generates a route configuration object with optional permissions.
* @param path - The route path.
Expand Down Expand Up @@ -44,8 +43,8 @@ const routes: Routes = [
{ path: 'books/view/:id', component: ViewBookComponent },
{ path: 'cart', component: CartComponent },
{ path: 'catalog', component: CatalogComponent },
{path: 'import-excel', component: BookExcelParserComponent},
{ path: 'profile', component: ProfileComponent },
generateRoute('import-excel', BookExcelParserComponent),
generateRoute('book_formats', ListBookParametersFormatComponent),
generateRoute('orders', ListOrderComponent, ['ADMIN', 'EMPLOYEE', 'CLIENT']),
generateRoute('book_genres', ListBookGenreComponent),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="col-sm">
<mat-form-field class="form-group w-100" appearance="fill">
<mat-label>Email</mat-label>
<input formControlName="email" matInput placeholder="Enter your email" required type="text" >
<input formControlName="email" matInput placeholder="Enter your email" [readonly]="!isAddMode" required type="text" >
<mat-error *ngIf="f['email'].invalid">{{getErrorMessage('email')}}</mat-error>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { AbstractForm } from 'src/app/shared/components/abstract-form';
export class AddEditUserForm extends AbstractForm implements OnDestroy, OnInit {
// Fields
@Input()
formGroupName!: string;
public formGroupName!: string;

@Input()
public isAddMode = false;

protected id?: number;

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/user/profile/profile.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2 class="m-2 p-2 text-center" *ngIf="!isAddMode">Edit your profile</h2>
<mat-spinner></mat-spinner>
</div>
<form [formGroup]="form" *ngIf="form" (ngSubmit)="onSubmit()">
<app-add-edit-user-form formGroupName="personalData"></app-add-edit-user-form>
<app-add-edit-user-form formGroupName="personalData" [isAddMode]="isAddMode"></app-add-edit-user-form>

<app-add-edit-address-form formGroupName="address" [selectedCity]="selectedCity" [selectedCountry]="selectedCountry" [selectedPostalCode]="selectedPostalCode" ></app-add-edit-address-form>

Expand Down
8 changes: 6 additions & 2 deletions src/app/components/user/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ProfileComponent extends AbstractForm implements OnDestroy, OnInit
// Fields
protected id?: number;

protected isAddMode?: boolean;
protected isAddMode: boolean = false;

protected isLoading = true;

Expand Down Expand Up @@ -259,14 +259,18 @@ export class ProfileComponent extends AbstractForm implements OnDestroy, OnInit

/**
* Handles the error response from API calls.
* @param action The action performed when the error occurred (e.g., 'loaded', 'created', 'updated').
* @param action The action performed when the error occurred.
* @param error The error object.
*/
private handleErrorResponse(error: any) {
informUserOfError(error);
this.isLoading = false;
}

/**
* Handles the success response from API calls.
* @param action The action performed when the operation concluded.
*/
private handleSuccessResponse(action: string){
Swal.fire(`User ${action}`,`The user ${this.form.value.personalData.name} has been ${action} successfully`,`success`);

Expand Down

0 comments on commit 92acbc9

Please sign in to comment.