@model CustomerProductReviewsModel
@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@inject IWorkContext workContext
@{
    Layout = "_TwoColumns";

    var supportRtl = workContext.WorkingLanguage.Rtl;

    //title
    pagebuilder.AddTitleParts(Loc["Title.Account"]);
}
@section left
{
    @await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Reviews })
}
<div class="page account-page product-reviews-page pl-lg-3 pt-lg-0 pt-3">
    <h1 class="h2 generalTitle">@Loc["Account.Reviews"]</h1>
    @if (Model.Reviews.Any())
    {
        <div class="product-review-list">
            @foreach (var review in Model.Reviews)
            {
                int ratingStars = review.Rating;
                <div class="card product-review-item mb-3">
                    <header class="card-header">
                        <div class="review-info d-inline-flex w-100">
                            <b-icon icon="calendar2-check" variant="info" class="mx-2"></b-icon>
                            <small class="date d-flex text-muted">
                                @if (supportRtl)
                                {
                                    <span class="ml-1">@Loc["Reviews.Date"]:</span>
                                    <span>@Convert.ToDateTime(review.CreatedOn).ToString("tt HH:mm yyyy/MM/dd")</span>
                                }
                                else
                                {
                                    <span class="mr-1">@Loc["Reviews.Date"]:</span>
                                    <span>@review.CreatedOn.ToString("g")</span>
                                }
                            </small>
                        </div>
                    </header>
                    <div class="card-body">
                        <div class="review-title mb-3">
                            <div class="user d-inline-flex align-items-center w-100">
                                <a href="@Url.RouteUrl("Product", new { SeName = review.ProductSeName })"><h6 class="mb-0">@review.ProductName</h6></a>
                            </div>
                            <b-form-rating id='rating-inline2' class='p-0' variant='warning' no-border size='sm' show-value precision='2' readonly inline value='@(ratingStars)'></b-form-rating>
                        </div>
                        <div class="review-content">
                            <div class="review-text">
                                @review.ReviewText
                            </div>
                        </div>
                    </div>
                    <footer class="card-footer">
                        @if (!string.IsNullOrEmpty(review.ReplyText))
                        {
                            <div class="reply-content">
                                <blockquote class="administration-response">
                                    <h5 class="administration-response-header">@Loc["Reviews.AdministrationResponse"]</h5>
                                    <i>@review.ReplyText</i>
                                    <p class="h6 mb-0 mt-2">@review.Signature</p>
                                </blockquote>
                            </div>
                        }
                    </footer>
                </div>
            }
        </div>
    }
    else
    {
        <div class="no-data alert alert-info my-3">
            @Loc["Account.Reviews.NoExists"]
        </div>
    }
</div>

