feature/init-tailwind-daisyui #13

Merged
igorpropisnov merged 10 commits from feature/init-tailwind-daisyui into main 2024-06-26 19:22:33 +02:00
2 changed files with 180 additions and 159 deletions
Showing only changes of commit 8a1ab8b11e - Show all commits

View File

@ -1,4 +1,3 @@
@if (!userSignupSuccess()) {
<div class="flex h-screen w-screen"> <div class="flex h-screen w-screen">
<div <div
[ngStyle]="leftBackgroundStyle" [ngStyle]="leftBackgroundStyle"
@ -57,21 +56,23 @@
</button> </button>
} }
@if (isSigninSignal()) { @if (isSigninSignal()) {
@if (displaySkeleton()) {
<div class="skeleton w-36 h-12"></div>
} @else {
<button <button
(click)="toggleAction('signup')" (click)="toggleAction('signup')"
class="btn btn-primary btn-outline no-animation animate-shake animate-thrice animate-duration-[250ms] animate-delay-[5000ms] animate-ease-in-out animate-normal animate-fill-forwards"> class="btn btn-primary btn-outline no-animation">
New User? Register Now! Register
</button> </button>
} }
}
</div> </div>
</div> </div>
@if (isSignupSignal()) { @if (isSignupSignal()) {
<div <div
class="animate-fade-down animate-once animate-duration-1000 animate-ease-in-out flex-1 flex flex-col justify-center items-center px-12"> class="animate-fade-down animate-once animate-duration-1000 animate-ease-in-out flex-1 flex flex-col justify-center items-center px-12">
<h1 class="text-3xl font-semibold text-center">Create an Account</h1> <h1 class="text-3xl font-semibold text-center">Create an Account</h1>
<p class="text-center"> <p class="text-center">Enter your email below to create your Account</p>
Enter your email below to create your Account
</p>
<form <form
[formGroup]="form" [formGroup]="form"
(ngSubmit)="onSubmit()" (ngSubmit)="onSubmit()"
@ -108,8 +109,7 @@
'w-full': true, 'w-full': true,
'border-error focus:border-error': 'border-error focus:border-error':
form.get('password')?.invalid && form.get('password')?.invalid &&
(form.get('password')?.dirty || (form.get('password')?.dirty || form.get('password')?.touched)
form.get('password')?.touched)
}" }"
class="input input-bordered flex items-center gap-2"> class="input input-bordered flex items-center gap-2">
<svg <svg
@ -148,6 +148,15 @@
@if (isSigninSignal()) { @if (isSigninSignal()) {
<div <div
class="animate-fade-down animate-once animate-duration-1000 animate-ease-in-out flex-1 flex flex-col justify-center items-center px-12"> class="animate-fade-down animate-once animate-duration-1000 animate-ease-in-out flex-1 flex flex-col justify-center items-center px-12">
@if (displaySkeleton()) {
<div class="flex items-center w-full flex-col max-w-md gap-4">
<div class="skeleton w-36 h-10"></div>
<div class="skeleton w-full h-10 max-w-md"></div>
<div class="skeleton w-full h-10 max-w-md"></div>
<div class="skeleton w-full h-10 max-w-md"></div>
<div class="skeleton w-full h-10 max-w-md"></div>
</div>
} @else {
<h1 class="text-3xl font-semibold text-center">Login</h1> <h1 class="text-3xl font-semibold text-center">Login</h1>
<form <form
[formGroup]="form" [formGroup]="form"
@ -238,6 +247,7 @@
</a> </a>
</div> </div>
</form> </form>
}
</div> </div>
} }
<div class="flex flex-col items-center justify-center py-12"> <div class="flex flex-col items-center justify-center py-12">
@ -247,11 +257,7 @@
</div> </div>
</div> </div>
</div> </div>
} @else {
<div class="flex h-screen w-screen">
<div class="hidden md:flex md:flex-col md:w-full bg-primary"></div>
</div>
}
<div class="modal modal-open" *ngIf="isDialogOpen()"> <div class="modal modal-open" *ngIf="isDialogOpen()">
<div <div
[ngStyle]="dialogBackgroundStyle" [ngStyle]="dialogBackgroundStyle"

View File

@ -85,6 +85,7 @@ export class RegisterRootComponent implements OnInit {
public userSignupSuccess: WritableSignal<boolean> = signal(false); public userSignupSuccess: WritableSignal<boolean> = signal(false);
public isDialogOpen: WritableSignal<boolean> = signal(false); public isDialogOpen: WritableSignal<boolean> = signal(false);
public isLoading: WritableSignal<boolean> = signal(false); public isLoading: WritableSignal<boolean> = signal(false);
public displaySkeleton: WritableSignal<boolean> = signal(true);
private removeQueryParams: WritableSignal<boolean> = signal(false); private removeQueryParams: WritableSignal<boolean> = signal(false);
public get isDarkMode(): boolean { public get isDarkMode(): boolean {
@ -105,6 +106,20 @@ export class RegisterRootComponent implements OnInit {
this.clearRouteParams(); this.clearRouteParams();
} }
}); });
const rememberMe = this.localStorageService.getItem<boolean>('remember-me');
if (rememberMe === true) {
this.authService
.status()
.pipe(delay(1500))
.subscribe((response: SuccessDtoApiModel) => {
if (response.success) {
this.router.navigate(['/dashboard']);
} else {
this.displaySkeleton.set(false);
}
});
}
} }
public ngOnInit(): void { public ngOnInit(): void {
@ -199,8 +214,8 @@ export class RegisterRootComponent implements OnInit {
} }
private handlePreselect(): void { private handlePreselect(): void {
const rememberMe = this.localStorageService.getItem('remember-me'); const rememberMe = this.localStorageService.getItem<boolean>('remember-me');
const email = this.localStorageService.getItem('email'); const email = this.localStorageService.getItem<string>('email');
if (rememberMe) { if (rememberMe) {
this.isSigninSignal.set(true); this.isSigninSignal.set(true);
@ -215,8 +230,9 @@ export class RegisterRootComponent implements OnInit {
} }
private initializeForm(): void { private initializeForm(): void {
const rememberMeValue = this.localStorageService.getItem('remember-me'); const rememberMeValue =
const email = this.localStorageService.getItem('email'); this.localStorageService.getItem<boolean>('remember-me');
const email = this.localStorageService.getItem<string>('email');
if (rememberMeValue) { if (rememberMeValue) {
this.isSigninSignal.set(true); this.isSigninSignal.set(true);
@ -331,11 +347,11 @@ export class RegisterRootComponent implements OnInit {
} }
private signin(logiCredentials: UserCredentialsDtoApiModel): void { private signin(logiCredentials: UserCredentialsDtoApiModel): void {
const rememberMe = this.rememberMe.value; const rememberMe: boolean = this.rememberMe.value;
if (rememberMe) { if (rememberMe) {
this.localStorageService.setItem('email', logiCredentials.email); this.localStorageService.setItem<string>('email', logiCredentials.email);
this.localStorageService.setItem('remember-me', rememberMe); this.localStorageService.setItem<boolean>('remember-me', rememberMe);
} }
this.authService this.authService
@ -364,7 +380,6 @@ export class RegisterRootComponent implements OnInit {
.subscribe((response: SuccessDtoApiModel) => { .subscribe((response: SuccessDtoApiModel) => {
if (response.success) { if (response.success) {
this.openModal(); this.openModal();
this.userSignupSuccess.set(true);
} }
}); });
} }