This repository has been archived on 2025-06-18. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
casino/frontend/src/app/feature/landing/landing.component.ts
Phan Huy Tran ed83097b6b
All checks were successful
CI / Get Changed Files (pull_request) Successful in 10s
Label PRs based on size / Check PR size (pull_request) Successful in 19s
Claude PR Review / claude-code (pull_request) Successful in 35s
CI / Backend Tests (pull_request) Has been skipped
CI / Checkstyle Main (pull_request) Has been skipped
Pull Request Labeler / labeler (pull_request_target) Successful in 14s
CI / Docker backend validation (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 44s
CI / prettier (pull_request) Successful in 52s
CI / eslint (pull_request) Successful in 1m6s
CI / test-build (pull_request) Successful in 1m31s
CI / Docker frontend validation (pull_request) Successful in 1m15s
feat: open login form when accessing restricted links
2025-06-04 14:27:11 +02:00

83 lines
2.3 KiB
TypeScript

import {
ChangeDetectionStrategy,
Component,
inject,
OnDestroy,
OnInit,
signal,
} from '@angular/core';
import { NgFor } from '@angular/common';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { AuthService } from '@service/auth.service';
import { LoginComponent } from '../auth/login/login.component';
import { RegisterComponent } from '../auth/register/register.component';
import '../auth/recover-password/recover-password.component';
import RecoverPasswordComponent from '../auth/recover-password/recover-password.component';
@Component({
selector: 'app-landing-page',
standalone: true,
imports: [NgFor, RouterLink, LoginComponent, RegisterComponent, RecoverPasswordComponent],
templateUrl: './landing.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LandingComponent implements OnInit, OnDestroy {
currentSlide = 0;
authService: AuthService = inject(AuthService);
route: ActivatedRoute = inject(ActivatedRoute);
showLogin = signal(false);
showRegister = signal(false);
showRecoverPassword = signal(false);
isLoggedIn = signal(this.authService.isLoggedIn());
ngOnInit() {
document.body.style.overflow = 'auto';
if (this.route.snapshot.queryParamMap.get('login') === 'true') {
this.showLoginForm();
}
}
ngOnDestroy() {
document.body.style.overflow = 'auto';
}
showLoginForm() {
this.showLogin.set(true);
this.showRegister.set(false);
this.showRecoverPassword.set(false);
document.body.style.overflow = 'hidden';
}
showRegisterForm() {
this.showRegister.set(true);
this.showLogin.set(false);
this.showRecoverPassword.set(false);
document.body.style.overflow = 'hidden';
}
showRecoverPasswordForm() {
this.showRecoverPassword.set(true);
this.showLogin.set(false);
this.showRegister.set(false);
document.body.style.overflow = 'hidden';
}
hideAuthForms() {
this.showLogin.set(false);
this.showRegister.set(false);
this.showRecoverPassword.set(false);
document.body.style.overflow = 'auto';
}
prevSlide() {
this.currentSlide = this.currentSlide === 0 ? 1 : 0;
}
nextSlide() {
this.currentSlide = this.currentSlide === 1 ? 0 : 1;
}
goToSlide(index: number) {
this.currentSlide = index;
}
}