31 lines
931 B
TypeScript
31 lines
931 B
TypeScript
import { Component, Input, OnInit } from '@angular/core';
|
|
import { Answer } from 'src/app/core/enums/answer.enum';
|
|
|
|
import { Choice } from '../../../core/models/choice.model';
|
|
import { Poll } from '../../../core/models/poll.model';
|
|
import { User } from '../../../core/models/user.model';
|
|
import { PollService } from '../../../core/services/poll.service';
|
|
|
|
@Component({
|
|
selector: 'app-add-answer',
|
|
templateUrl: './add-answer.component.html',
|
|
styleUrls: ['./add-answer.component.scss'],
|
|
})
|
|
export class AddAnswerComponent implements OnInit {
|
|
@Input() user: User;
|
|
@Input() poll: Poll;
|
|
@Input() choice: Choice;
|
|
public answerEnum = Answer;
|
|
public response: Answer;
|
|
|
|
constructor(private pollService: PollService) {}
|
|
|
|
ngOnInit(): void {}
|
|
|
|
public vote(response: string): void {
|
|
this.response = response as Answer;
|
|
console.log(this.response);
|
|
this.pollService.saveParticipation(this.choice, this.user, this.response);
|
|
}
|
|
}
|