import {
  Component,
  OnInit,
  Input,
  Output,
  EventEmitter,
  ViewChild,
  Optional
} from '@angular/core';
import { ucapAnimations } from '../animations';

@Component({
  selector: 'ucap-pick-time',
  templateUrl: './pick-time.component.html',
  styleUrls: ['./pick-time.component.scss'],
  animations: ucapAnimations
})
export class PickTimeComponent implements OnInit {
  @Input()
  hour: number;

  @Input()
  hourStep = 1;

  @Input()
  minute: number;

  @Input()
  minuteStep = 1;

  @Output()
  readonly hourSelected: EventEmitter<number> = new EventEmitter<number>();

  @Output()
  readonly minuteSelected: EventEmitter<number> = new EventEmitter<number>();

  constructor() {}

  ngOnInit() {}

  onChangedHour(hour: number) {
    this.hourSelected.emit(hour);
  }
  onChangedMinute(minute: number) {
    if (!!minute && minute === 60) {
      minute = minute - this.minuteStep;
    }
    this.minuteSelected.emit(minute);
  }
}
