feat: add logo image and RTL support styles
- Added logo image to assets. - Implemented RTL support styles in rtlSupport.scss for various components including breadcrumb, datatable, and tree node toggle button. chore: configure environment files for production, staging, and development - Created environment.prod.ts for production settings. - Created environment.staging.ts for staging settings. - Created environment.ts for local development settings. feat: define custom theme preset - Added presets.ts to define a custom theme preset using PrimeUIX with specific component styles and semantic colors. chore: set up proxy configuration for local development
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import { IAuthResponse, TRoles } from '@/core';
|
||||
import { ToastService } from '@/core/services/toast.service';
|
||||
import { Component, EventEmitter, inject, Input, Output, signal } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import images from 'src/assets/images';
|
||||
import { LoginComponent } from './login/login.component';
|
||||
import { ModifyLoginInfoComponent } from './modifyLoginInfo/modify-login-info.component';
|
||||
import { OTPComponent } from './otp/otp.component';
|
||||
import { SignupComponent } from './signup/signup.component';
|
||||
|
||||
type TSteps = 'login' | 'otp' | 'modifyLoginInfo' | 'signup';
|
||||
|
||||
@Component({
|
||||
selector: 'app-auth',
|
||||
templateUrl: './auth.component.html',
|
||||
imports: [LoginComponent, OTPComponent, ModifyLoginInfoComponent, SignupComponent],
|
||||
})
|
||||
export class AuthComponent {
|
||||
@Input() redirectUrl!: string;
|
||||
@Input() loginApiUrl!: string;
|
||||
@Input() role?: TRoles;
|
||||
@Input() defaultStep: TSteps = 'login';
|
||||
|
||||
@Output() submit = new EventEmitter<Promise<boolean>>();
|
||||
|
||||
private readonly toastService = inject(ToastService);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
readonly logo = images.logo;
|
||||
readonly authVector = images.login;
|
||||
|
||||
activeStep = signal<TSteps>(this.defaultStep);
|
||||
|
||||
selectedRole = signal<TRoles | undefined>(this.role);
|
||||
|
||||
toSignUp = () => {
|
||||
this.activeStep.set('signup');
|
||||
};
|
||||
|
||||
onLoggedIn = (data: IAuthResponse) => {
|
||||
this.toastService.success({ text: 'شما با موفقیت وارد شدید.' });
|
||||
this.selectedRole.set(data.role.toUpperCase() as TRoles);
|
||||
if (data.mustChangePassword) {
|
||||
this.activeStep.set('modifyLoginInfo');
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.submit.observed) {
|
||||
return this.submit.emit(Promise.resolve(true));
|
||||
}
|
||||
this.redirectToDashboard();
|
||||
};
|
||||
|
||||
onModifyLoginInfo = () => {
|
||||
if (this.submit.observed) {
|
||||
return this.submit.emit(Promise.resolve(true));
|
||||
}
|
||||
this.redirectToDashboard();
|
||||
};
|
||||
|
||||
private redirectToDashboard() {
|
||||
let redirectUrl = this.redirectUrl;
|
||||
|
||||
if (!redirectUrl) {
|
||||
switch (this.selectedRole()) {
|
||||
case 'SCHOOL':
|
||||
redirectUrl = '/schools';
|
||||
break;
|
||||
case 'ADMIN':
|
||||
redirectUrl = '/admin';
|
||||
break;
|
||||
case 'TEACHER':
|
||||
redirectUrl = '/teachers';
|
||||
break;
|
||||
case 'STUDENTS':
|
||||
redirectUrl = '/students';
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.router.navigateByUrl(redirectUrl);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user