import { Component } from '@angular/core';

@Component({
  selector: 'app-account',
  standalone: false,
  templateUrl: './account.component.html',
  styleUrl: './account.component.css'
})

export class AccountComponent {
  info: Info = new Info();
  infos: Array<Info> = [];
  newInfo: boolean = false;
  
  constructor() {}
  ngOnInit(): void {}

  addInfo() {
    if (this.info.gender && this.info.nameFirst && this.info.nameLast && this.info.email && this.info.address) {
      this.info.date = new Date();
      this.info.nameFirst = this.info.nameFirst.charAt(0).toUpperCase() + this.info.nameFirst.slice(1).toLowerCase()
      this.infos.push({
        gender: this.info.gender,
        nameFirst: this.info.nameFirst,
        nameLast: this.info.nameLast.toUpperCase(),
        email: this.info.email.toLowerCase() + '@edu.igensia.com',
        address: this.info.address,
        date: this.info.date
      })
      this.info.nameFirst = '';
      this.info.nameLast = '';
      this.info.email = '';
      this.info.address = '';
      this.info.gender = '';
    }
  }

  updateGender() {
    // console.log("Le genre sélectionné est :", this.info.gender);
  }

}

export class Info {
  gender: string = '';
  nameFirst: string = '';
  nameLast: string = '';
  email: string = '';
  address: string= '';
  date: Date | null = null;
}
