import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AppwriteService } from '../../services/appwrite.service';
import { FormsModule } from '@angular/forms';
import { Router } from '@angular/router';

@Component({
  selector: 'app-register',
  imports: [CommonModule, FormsModule],
  templateUrl: './register.component.html',
  styleUrl: './register.component.css'
})
export class RegisterComponent {

  email = 'ich@example.com';
  userName = 'TestUser';
  password = '123456789';


  constructor(
    private router: Router,
    private appwriteService: AppwriteService
  ) { }

  async registerUser(): Promise<void>{
    try {
      const responseUserSignIn = await this.appwriteService.register(this.email, this.password, this.userName);
      this.router.navigate(['/login']);
    } catch (error) {
      console.log('Registrierung fehlgeschlagen :' + error);
    }
  }

  goTologin() {
    this.router.navigate(['/login']);
  }
}
