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

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

  ngOnInit() {
    this.curAllQues = {}
    console.log(this.curPageData)
  }
  getAnswer(question, options) {
    console.log('page8', 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: 8,
      questions
    }
    this.getAllAnswer.emit(ret)
  }
}
