Issue
I just to display No Reviews message for the user who don't have any reviews. Currently when the Review button is pressed, it shows the reviews for the user who have the reviews, but if any user who don't have any review, Review Button pressing show nothing.
Here is the code
<div class="checkbox-item mt-2" (click)="getReviews(item.offer_by.id)">
<button type="button" class="btn btn-outline-secondary" >Reviews</button>
</div>
<div class="çontainer" *ngFor="let items of reviews" >
<div class="row" *ngIf="items.tasker_id == item.offer_by.id">
<h6>{{items.name}}</h6>
<div class="emVaRl">
<div class="lnfldP">
<svg width="16" height="16" class="elJCm" viewBox="0 0 24 24" *ngFor='let in of
counter(items.review_rating) ;let i = index'>
<path d="M16.2 8.16l4.74.73a1.23 1.23 0 01.67 2.11l-3.46 3.28a1.23 1.23 0 00-.37 1.1l.77 4.68a1.24 1.24 0 01-1.82 1.29L12.5 19.1a1.28 1.28 0 00-1.16 0l-4.27 2.17A1.25 1.25 0 015.27 20l.85-4.68a1.19 1.19 0 00-.34-1.09l-3.41-3.4a1.23 1.23 0 01.71-2.1l4.75-.64a1.26 1.26 0 00.95-.67l2.16-4.24a1.25 1.25 0 012.24 0l2.09 4.28a1.22 1.22 0 00.93.7z">
</path>
</svg>
</div>
</div>
<p>({{items.review}})</p>
<hr>
</div>
</div>
.ts code
review(data: any): boolean {
data['job_id'] = this.jobOffer.id;
data['tasker_id'] = this.jobOffer.assign_to_id;
this.ds.addReview(data).subscribe((resp: any) => {
if (resp.status == true) {
this.makeReview = false;
window.location.reload();
this.ts.success(resp.msg);
return true;
} else {
this.ts.error(resp.msg);
return false;
}
});
return true;
}
getReviews(data: any) {
this.ds.getReviews(data).subscribe((resp: any) => {
if (resp.status == true) {
this.reviews = [];
this.rating = '';
this.total_rating = '';
this.reviews = resp.data;
this.rating = resp.rating;
this.total_rating = resp.total_rating;
return true;
}
}, );
}
Solution
Do like this and show your .ts code also
<div *ngIf="reviews">
<div *ngIf="reviews.length > 0">
<div class="çontainer" *ngFor="let items of reviews">
<div class="row" *ngIf="items.tasker_id == item.offer_by.id">
<h6>{{items.name}}</h6>
<div class="emVaRl">
<div class="lnfldP">
<svg width="16" height="16" class="elJCm" viewBox="0 0 24 24"
*ngFor='let in of counter(items.review_rating) ;let i =index'>
<path
d="M16.2 8.16l4.74.73a1.23 1.23 0 01.67 2.11l-3.46 3.28a1.23 1.23 0 00-.37 1.1l.77 4.68a1.24 1.24 0 01-1.82 1.29L12.5 19.1a1.28 1.28 0 00-1.16 0l-4.27 2.17A1.25 1.25 0 015.27 20l.85-4.68a1.19 1.19 0 00-.34-1.09l-3.41-3.4a1.23 1.23 0 01.71-2.1l4.75-.64a1.26 1.26 0 00.95-.67l2.16-4.24a1.25 1.25 0 012.24 0l2.09 4.28a1.22 1.22 0 00.93.7z">
</path>
</svg>
</div>
</div>
<p>({{items.review}})</p>
<hr>
</div>
</div>
</div>
<div *ngIf="reviews.length == 0">
<h3 style="text-align: center;">No Reviews</h3>
</div>
edit your .ts code like this
getReviews(data: any) {
this.ds.getReviews(data).subscribe((resp: any) => {
if (resp.status == true) {
this.reviews = [];
this.rating = '';
this.total_rating = '';
this.reviews = resp.data;
this.rating = resp.rating;
this.total_rating = resp.total_rating;
return true;
} else {
this.ts.warning('No Reviews')
this.ts.error(resp.msg);
return false;
}
}, (error : any) => {
this.ts.warning('No Reviews')
});
}
Answered By - Team Thunder
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.