import { FormGroup, FormBuilder } from '@angular/forms';
import { Component, EventEmitter, Output, OnInit } from '@angular/core';
@Component({
    selector: 'bank-transfer',
    templateUrl: './bank-transfer.component.html',
    styleUrls: ['bank-transfer.component.scss']
})
export class BankTransferComponent implements OnInit{
    public bankTransferForm: FormGroup;
    @Output() public formSaved = new EventEmitter();
    private uid;
    private orderNumber;
    public details = "Some details";
    constructor(private fb: FormBuilder){
    }

    ngOnInit() {
        //TODO
        this.uid = "something";
        let currDate = new Date();
        this.orderNumber = "" + this.uid + currDate.getTime();
        this.bankTransferForm = this.fb.group({
            paymentMethod: 'BANK_TRANSFER',
            deliveryRequired: true,
            orderNumber: this.orderNumber,
            details: this.details
        });
    }

    nextStep(){
        this.formSaved.next(this.bankTransferForm.value);
    }

    generateOrderNumber() {
        return this.orderNumber;
    }
}