refactor(frontend): rename booklore-ui to frontend
- Frontend path: - rename the tracked Angular app tree from `booklore-ui/` to `frontend/` - preserve file contents during the move so this commit stays focused on the path change itself - Frontend docs: - update the moved frontend README and contribution guide where they refer to the renamed folder - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<ng-container *transloco="let t; prefix: 'shared.changePassword'">
|
||||
<div class="change-password-container">
|
||||
<div class="change-password-card-wrapper">
|
||||
<div class="change-password-card-border">
|
||||
<div class="change-password-card">
|
||||
<div class="change-password-header">
|
||||
<div class="logo-wrapper">
|
||||
<div class="icon-circle">
|
||||
<i class="pi pi-key"></i>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="change-password-title">{{ t('title') }}</h1>
|
||||
<p class="change-password-subtitle">{{ t('subtitle') }}</p>
|
||||
</div>
|
||||
|
||||
<form class="change-password-form" #changePasswordForm="ngForm" (ngSubmit)="changePassword()">
|
||||
<div class="form-field">
|
||||
<label for="currentPassword" class="form-label">
|
||||
<i class="pi pi-lock"></i>
|
||||
<span>{{ t('currentPasswordLabel') }}</span>
|
||||
</label>
|
||||
<p-password
|
||||
id="currentPassword"
|
||||
name="currentPassword"
|
||||
required
|
||||
[(ngModel)]="currentPassword"
|
||||
[feedback]="false"
|
||||
[placeholder]="t('currentPasswordPlaceholder')"
|
||||
[toggleMask]="true"
|
||||
[fluid]="true"
|
||||
autocomplete="current-password"
|
||||
></p-password>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="newPassword" class="form-label">
|
||||
<i class="pi pi-lock-open"></i>
|
||||
<span>{{ t('newPasswordLabel') }}</span>
|
||||
</label>
|
||||
<p-password
|
||||
id="newPassword"
|
||||
name="newPassword"
|
||||
required
|
||||
[(ngModel)]="newPassword"
|
||||
[feedback]="false"
|
||||
[placeholder]="t('newPasswordPlaceholder')"
|
||||
[toggleMask]="true"
|
||||
[fluid]="true"
|
||||
autocomplete="new-password"
|
||||
></p-password>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="confirmNewPassword" class="form-label">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
<span>{{ t('confirmPasswordLabel') }}</span>
|
||||
</label>
|
||||
<p-password
|
||||
id="confirmNewPassword"
|
||||
name="confirmNewPassword"
|
||||
required
|
||||
[(ngModel)]="confirmNewPassword"
|
||||
[feedback]="false"
|
||||
[placeholder]="t('confirmPasswordPlaceholder')"
|
||||
[toggleMask]="true"
|
||||
[fluid]="true"
|
||||
autocomplete="new-password"
|
||||
></p-password>
|
||||
@if (!passwordsMatch && confirmNewPassword) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
{{ t('validation.passwordsMismatch') }}
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<p-button
|
||||
fluid
|
||||
type="submit"
|
||||
[label]="t('updateBtn')"
|
||||
icon="pi pi-check"
|
||||
[disabled]="!changePasswordForm.valid || !passwordsMatch"
|
||||
class="change-password-button"
|
||||
/>
|
||||
|
||||
@if (errorMessage) {
|
||||
<div class="message-container error-message">
|
||||
<p-message severity="error">{{ errorMessage }}</p-message>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (successMessage) {
|
||||
<div class="message-container success-message">
|
||||
<p-message severity="success">{{ successMessage }}</p-message>
|
||||
</div>
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
@@ -0,0 +1,90 @@
|
||||
@use '../../styles/auth-shared' as auth;
|
||||
|
||||
.change-password-container {
|
||||
@include auth.auth-container;
|
||||
}
|
||||
|
||||
.change-password-wrapper {
|
||||
@apply flex flex-col items-center gap-6 absolute top-1/4 transform -translate-y-1/4;
|
||||
}
|
||||
|
||||
.change-password-card-wrapper {
|
||||
@include auth.auth-card-wrapper(500px, -6rem);
|
||||
}
|
||||
|
||||
.change-password-card-border {
|
||||
@include auth.auth-card-border;
|
||||
}
|
||||
|
||||
.change-password-card {
|
||||
@include auth.auth-card;
|
||||
}
|
||||
|
||||
.app-title {
|
||||
@apply text-5xl font-extrabold text-white drop-shadow-lg;
|
||||
text-shadow: 0px 4px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.change-password-header {
|
||||
@include auth.auth-header;
|
||||
}
|
||||
|
||||
.logo-wrapper {
|
||||
@include auth.auth-logo;
|
||||
}
|
||||
|
||||
.icon-circle {
|
||||
@include auth.auth-icon-circle;
|
||||
}
|
||||
|
||||
.change-password-title {
|
||||
@include auth.auth-title;
|
||||
}
|
||||
|
||||
.change-password-subtitle {
|
||||
@include auth.auth-subtitle;
|
||||
}
|
||||
|
||||
form {
|
||||
@apply flex flex-col gap-4;
|
||||
}
|
||||
|
||||
.change-password-form {
|
||||
@include auth.auth-form;
|
||||
}
|
||||
|
||||
.p-field {
|
||||
@apply flex flex-col gap-2;
|
||||
}
|
||||
|
||||
.form-field {
|
||||
@include auth.form-field;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
@include auth.form-label;
|
||||
}
|
||||
|
||||
.field-error {
|
||||
@include auth.field-error;
|
||||
}
|
||||
|
||||
p-button {
|
||||
@apply mt-4;
|
||||
}
|
||||
|
||||
.change-password-button {
|
||||
@include auth.auth-button;
|
||||
}
|
||||
|
||||
.message-container {
|
||||
@include auth.message-container;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
@include auth.error-message;
|
||||
}
|
||||
|
||||
.success-message {
|
||||
@include auth.success-message;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {Button} from 'primeng/button';
|
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Message} from 'primeng/message';
|
||||
|
||||
import {Password} from 'primeng/password';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {UserService} from '../../../features/settings/user-management/user.service';
|
||||
import {AuthService} from '../../service/auth.service';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-change-password',
|
||||
standalone: true,
|
||||
imports: [
|
||||
Button,
|
||||
FormsModule,
|
||||
Message,
|
||||
Password,
|
||||
ReactiveFormsModule,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './change-password.component.html',
|
||||
styleUrl: './change-password.component.scss'
|
||||
})
|
||||
export class ChangePasswordComponent {
|
||||
currentPassword: string = '';
|
||||
newPassword: string = '';
|
||||
confirmNewPassword: string = '';
|
||||
errorMessage: string | null = null;
|
||||
successMessage: string | null = null;
|
||||
|
||||
protected userService = inject(UserService);
|
||||
protected authService = inject(AuthService);
|
||||
protected messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
get passwordsMatch(): boolean {
|
||||
return this.newPassword === this.confirmNewPassword;
|
||||
}
|
||||
|
||||
changePassword() {
|
||||
this.errorMessage = null;
|
||||
this.successMessage = null;
|
||||
|
||||
if (!this.currentPassword || !this.newPassword || !this.confirmNewPassword) {
|
||||
this.errorMessage = this.t.translate('shared.changePassword.validation.allFieldsRequired');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.passwordsMatch) {
|
||||
this.errorMessage = this.t.translate('shared.changePassword.validation.passwordsDoNotMatch');
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.currentPassword === this.newPassword) {
|
||||
this.errorMessage = this.t.translate('shared.changePassword.validation.sameAsCurrentPassword');
|
||||
return;
|
||||
}
|
||||
|
||||
this.userService.changePassword(this.currentPassword, this.newPassword).subscribe({
|
||||
next: () => {
|
||||
this.successMessage = this.t.translate('shared.changePassword.toast.success');
|
||||
this.logout();
|
||||
},
|
||||
error: (err) => {
|
||||
this.errorMessage = err.message;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('shared.changePassword.toast.failedSummary'),
|
||||
detail: this.errorMessage ?? this.t.translate('shared.changePassword.toast.failedDetailDefault')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
logout() {
|
||||
this.authService.logout();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user