@model CustomerProductReviewsModel

@using Nop.Core.Domain.Catalog

@inject Nop.Services.Html.IHtmlFormatter htmlFormatter

@{
    Layout = "_ColumnsTwo";

    //title
    NopHtml.AddTitleParts(T("PageTitle.CustomerProductReviews").Text);
    //page class
    NopHtml.AppendPageCssClassParts("html-account-page");
    NopHtml.AppendPageCssClassParts("html-my-product-reviews-list-page");
}
@section left
{
    @await Component.InvokeAsync(typeof(CustomerNavigationViewComponent), new { selectedTabId = CustomerNavigationEnum.ProductReviews })
}
<div class="page account-page my-product-reviews-list-page">
    <div class="page-title">
        <h1>@T("Account.MyAccount") - @T("Account.CustomerProductReviews")</h1>
    </div>
    <div class="page-body">
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CustomerProductReviewsTop, additionalData = Model })
        @if (Model.ProductReviews.Count > 0)
        {
            foreach (var review in Model.ProductReviews)
            {
                var ratingPercent = review.Rating * 20;
                <div class="product-review-item">
                    <div class="review-item-head">
                        <div class="review-title">
                            <strong>@review.Title</strong>@(!string.IsNullOrEmpty(review.ApprovalStatus) ? $" - {review.ApprovalStatus}" : null)
                        </div>
                        <div class="product-review-box">
                            <div class="rating">
                                <div style="width: @(ratingPercent)%">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="review-content">
                        <div class="review-text">
                            @Html.Raw(htmlFormatter.FormatText(review.ReviewText, false, true, false, false, false, false))
                        </div>
                        @foreach (var reviewType in review.AdditionalProductReviewList.Where(x => x.Rating > 0))
                        {
                            var ratingExtPercent = reviewType.Rating * 20;
                            <div class="review-type-rating-ext">
                                <div class="review-title">
                                    <i>@reviewType.Name</i>
                                </div>
                                <div class="product-review-box">
                                    <div class="rating">
                                        <div style="width: @(ratingExtPercent)%">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <br /><br />
                        }
                        <div class="review-info">
                            <span class="user">
                                <label>@T("Account.CustomerProductReviews.ProductReviewFor"):</label>
                                <a href="@(Url.RouteUrl<Product>(new { SeName = review.ProductSeName }))">@review.ProductName</a>

                            </span>
                            <span class="separator">|</span>
                            <span class="date">
                                <label>@T("Reviews.Date"):</label>
                                <span>@review.WrittenOnStr</span>
                            </span>
                        </div>
                        @if (!string.IsNullOrEmpty(review.ReplyText))
                        {
                            <div class="reply">
                                <div class="reply-header">
                                    @T("Reviews.Reply")
                                </div>
                                <div class="reply-text">
                                    @Html.Raw(htmlFormatter.FormatText(review.ReplyText, false, true, false, false, false, false))
                                </div>
                            </div>
                        }
                    </div>
                </div>
            }
            var pager = await Html.PagerAsync(Model.PagerModel);
            if (!string.IsNullOrEmpty(await pager.RenderHtmlContentAsync()))
            {
                <div class="pager">
                    @pager
                </div>
            }
        }
        else
        {
            <div class="no-data">
                @T("Account.CustomerProductReviews.NoRecords")
            </div>
        }
    </div>
    @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CustomerProductReviewsBottom, additionalData = Model })
</div>