- - {{ comment.author }} - {{ comment.dateCreated | date: 'medium' }} + + Laisser un commentaire + + + + + + + + + + + + + + + + + + + + + + + Votre commentaire : + + + + + + + + + {{ poll.comments.length }} Commentaires + + + + + {{ comment.pseudo }} , le + + il y a + {{ calculateDaysAgoOfComment(comment.owner.created_at) }} jours, le {{ comment.owner.created_at }} + + + + + {{ comment.text }} + + + - - {{ comment.content }} - - + diff --git a/src/app/shared/components/comments/comments.component.ts b/src/app/shared/components/comments/comments.component.ts index a05feb7d..7de1c384 100644 --- a/src/app/shared/components/comments/comments.component.ts +++ b/src/app/shared/components/comments/comments.component.ts @@ -1,8 +1,6 @@ -import { Component } from '@angular/core'; -import { Observable } from 'rxjs'; - -import { Poll } from '../../../core/models/poll.model'; +import { Component, Input } from '@angular/core'; import { PollService } from '../../../core/services/poll.service'; +import * as moment from 'moment'; @Component({ selector: 'app-comments', @@ -10,7 +8,26 @@ import { PollService } from '../../../core/services/poll.service'; styleUrls: ['./comments.component.scss'], }) export class CommentsComponent { - public _poll: Observable = this.pollService.poll; + @Input() public poll: any; + + public config: any = { + myName: '', + myEmail: '', + myComment: '', + }; constructor(private pollService: PollService) {} + calculateDaysAgoOfComment(dateAsString) { + let numberOfDays = 0; + + if (dateAsString && dateAsString) { + numberOfDays = moment(new Date()).diff(moment(new Date(dateAsString)), 'days'); + } + + return numberOfDays; + } + + addComment() { + alert('TODO'); + } } diff --git a/src/proxy.conf.json b/src/proxy.conf.json index 5b9f3ff5..244c8195 100644 --- a/src/proxy.conf.json +++ b/src/proxy.conf.json @@ -1,6 +1,6 @@ { "/api/*": { - "target": "http://localhost:3001", + "target": "http://localhost:8000/api", "secure": false, "logLevel": "debug" }
+ + + {{ comment.pseudo }} , le + + il y a + {{ calculateDaysAgoOfComment(comment.owner.created_at) }} jours, le {{ comment.owner.created_at }} + + + + + {{ comment.text }} + + +
Laisser un commentaire
+ + +{{ poll.comments.length }} Commentaires
+ +