Skip to content

Commit

Permalink
single dish update
Browse files Browse the repository at this point in the history
  • Loading branch information
wlgs committed Dec 19, 2021
1 parent 683852d commit 449b3f8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lab5/restauracja/src/app/singledish/singledish.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,12 @@ span.np{
.strong{
font-weight: bold;
font-size:1.2em;
}

.center{
display:flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size:1.6em;
}
6 changes: 6 additions & 0 deletions lab5/restauracja/src/app/singledish/singledish.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ <h2 class="shdesc">kuchnia {{ dish[0].type}}, {{ dish[0].category }}</h2>
<h2>Dostępny u nas tylko za <span class="price">${{dish[0].price}}</span></h2>
</div>
<h2>Recenzje</h2>
<div class="center">
<app-dish-rating (ratingChanged)="ratingEventHandler(dish[0], $event)" [dishLikes]="dish[0].likes"
[dishDislikes]="dish[0].dislikes"></app-dish-rating>
</div>
<div class="review" *ngFor="let review of reviews">
<span class="strong">Użytkownik: </span><span>{{review.nick}}</span>
<p></p>
<span class="strong">Data: </span><span>{{review.date}}</span>
<p></p>
<span class="strong">Treść: </span><span>{{review.review}}</span>
</div>


<app-dishrate (newReviewEvent)="addReview($event)"></app-dishrate>
</ng-container>
9 changes: 9 additions & 0 deletions lab5/restauracja/src/app/singledish/singledish.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ export class SingledishComponent implements OnInit {
this.reviews.push(newReview);
}

ratingEventHandler(dish: Dish, ev: any) {
if (ev == 1) {
dish.likes += 1
}
else {
dish.dislikes += 1
}
}

}
interface review {
nick: string;
Expand Down

0 comments on commit 449b3f8

Please sign in to comment.