import { Component, OnInit } from '@angular/core';
import { NbDialogRef } from '@nebular/theme';
import { DropDownOption } from '../../../entity/dropDownOption';
import { HappinessCost } from '../../../entity/happiness-cost.model';
import { AuthService } from '../../../services/auth.service';
import { LoginUserService } from '../../../services/login-user.service';

@Component({
  selector: 'ngx-add-new-cost-dlg',
  templateUrl: './add-new-cost-dlg.component.html',
  styleUrls: ['./add-new-cost-dlg.component.scss']
})
export class AddNewCostDlgComponent implements OnInit {
  taskrOptions: DropDownOption[] = [];
  task: HappinessCost;
  constructor(
    private loginUserService: LoginUserService,
    private dlgRef: NbDialogRef<AddNewCostDlgComponent>
  ) { }

  ngOnInit(): void {
    this.task = new HappinessCost();
    this.task.tasker = this.loginUserService.userAccess.firstName;
  }
  close() {
    this.dlgRef.close();
  }
  submit() {
    if (this.task.tasker && this.task.content && this.task.amount > 0) {
      this.dlgRef.close(this.task);
    }
  }
}
