import { Component, inject } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { UserService } from './services/user.service';
import {FormsModule} from '@angular/forms'
import { User } from './models/user';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet, FormsModule],
  templateUrl: './app.component.html',
  styleUrl: './app.component.css'
})
export class AppComponent {
  title = 'RTI';

  private userService = inject(UserService)

  username = ""
  password = ""

  login(){
    this.userService.login(this.username, this.password).subscribe(data=>{
      if(data){
        alert("Hello " + data.username)
      }
      else{
        alert("Bad data")
      }
    })
  }

  u: User = new User()

  register(){
    this.userService.register(this.u).subscribe(data=>{
      alert(data)
    })
  }
}
