import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { User } from 'src/app/models/user';
import { StorageService } from 'src/app/services/storage.service';
import { UserService } from 'src/app/services/user.service';

@Component({
  selector: 'app-user-login',
  templateUrl: './user-login.page.html',
  styleUrls: ['./user-login.page.scss'],
  standalone: false,
})
export class UserLoginPage implements OnInit {
  public users: Array<User> = [];

  constructor(
    private userService: UserService,
    private storageService: StorageService,
    private router: Router
  ) { }

  ngOnInit() {
    this.userService.getUserList().subscribe(users => {
      this.users = users
    });
  }

  selectUser(id: number) {
    this.storageService.set('user-id', id);
    this.router.navigate(['/tabs/allowance', id]);
  }
}
