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
csimonis d2225decc1
Some checks failed
CI / Get Changed Files (pull_request) Successful in 7s
CI / Docker frontend validation (pull_request) Successful in 1m2s
CI / Checkstyle Main (pull_request) Successful in 1m8s
CI / eslint (pull_request) Failing after 1m29s
CI / Docker backend validation (pull_request) Successful in 1m32s
CI / prettier (pull_request) Failing after 31s
CI / oxlint (pull_request) Successful in 44s
CI / test-build (pull_request) Successful in 38s
feat(auth): add email verification feature and handler
2025-05-15 10:49:24 +02:00

92 lines
2.2 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';
@Component({
selector: 'app-landing-page',
standalone: true,
imports: [NgFor, RouterLink, LoginComponent, RegisterComponent],
templateUrl: './landing.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LandingComponent implements OnInit, OnDestroy {
currentSlide = 0;
private autoplayInterval: ReturnType<typeof setInterval> | undefined;
authService: AuthService = inject(AuthService);
route: ActivatedRoute = inject(ActivatedRoute);
showLogin = signal(false);
showRegister = signal(false);
ngOnInit() {
this.startAutoplay();
document.body.style.overflow = 'auto';
if (this.route.snapshot.queryParamMap.get('login') === 'true') {
this.showLoginForm();
}
}
ngOnDestroy() {
this.stopAutoplay();
document.body.style.overflow = 'auto';
}
showLoginForm() {
this.showLogin.set(true);
this.showRegister.set(false);
document.body.style.overflow = 'hidden';
}
showRegisterForm() {
this.showRegister.set(true);
this.showLogin.set(false);
document.body.style.overflow = 'hidden';
}
hideAuthForms() {
this.showLogin.set(false);
this.showRegister.set(false);
document.body.style.overflow = 'auto';
}
prevSlide() {
this.currentSlide = this.currentSlide === 0 ? 1 : 0;
this.resetAutoplay();
}
nextSlide() {
this.currentSlide = this.currentSlide === 1 ? 0 : 1;
this.resetAutoplay();
}
goToSlide(index: number) {
this.currentSlide = index;
this.resetAutoplay();
}
private startAutoplay() {
this.autoplayInterval = setInterval(() => {
this.nextSlide();
}, 5000);
}
private stopAutoplay() {
if (this.autoplayInterval) {
clearInterval(this.autoplayInterval);
}
}
private resetAutoplay() {
this.stopAutoplay();
this.startAutoplay();
}
}