import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'

@Component({
  selector: 'app-page7',
  templateUrl: './page7.component.html',
  styleUrls: ['./page7.component.css']
})
export class Page7Component implements OnInit {
  @Input() curPageData: Array<any>
  @Input() hasMate: boolean
  @Output() getAllAnswer = new EventEmitter<any>()
  curAllQues: Object
  constructor() {}

  ngOnInit() {
    this.curAllQues = {}
    console.log(this.curPageData)
    console.log(this.hasMate)
  }
  getAnswer(question, options) {
    console.log('page7', question, options)
    const questionId = question['questionId']
    this.curAllQues[questionId] = options
    const questions = Object.keys(this.curAllQues).map(questionId => {
      return { questionId, options: this.curAllQues[questionId] }
    })
    const ret = {
      pageId: 7,
      questions
    }
    this.getAllAnswer.emit(ret)
  }
}
