@extends('shop::layouts.master')

@section('page_title')
    {{ __('shop::app.customer.account.review.index.page-title') }}
@endsection

@push('css')
    <link rel="stylesheet" href="{{bagisto_asset('styles/style.css')}}">
    <link rel="stylesheet" href="{{bagisto_asset('styles/categories-tv.css')}}">
    <link rel="stylesheet" href="{{bagisto_asset('styles/comments.css')}}">
@endpush

@php
    //@dd($reviews);
@endphp
@section('content-wrapper')
        <svg display="none">
            <symbol id="star" viewBox="0 0 16 16">
                <path
                    id="icon__"
                    data-name="icon ()"
                    d="M15.958,6.542a.858.858,0,0,0-.731-.609l-4.619-.438L8.782,1.035a.837.837,0,0,0-1.565,0L5.392,5.495.773,5.932a.86.86,0,0,0-.731.609.914.914,0,0,0,.248.943L3.781,10.68,2.751,15.411a.907.907,0,0,0,.331.916.819.819,0,0,0,.935.043L8,13.885l3.982,2.485a.821.821,0,0,0,.935-.043.907.907,0,0,0,.331-.916L12.218,10.68,15.71,7.485a.914.914,0,0,0,.248-.943Zm-7.881,7.3"
                    transform="translate(0 -0.496)"
                />
            </symbol>
        </svg>
        <section class="breadcrumb">
            <div class="container breadcrumb-container">
                <ul class="breadcrumb">
                    <li><a href="/">Главная</a></li>
                    <li>
                        <a href="#">Данные профиля</a>
                    </li>
                    <li>
                        <a href="#" class="current">История комментариев</a>
                    </li>
                </ul>
            </div>
        </section>

        <section class="comment-section">
            <div class="container">
                <div class="comment-section-top">
                    <h3 class="item-section-title-text">
                        История комментариев
                    </h3>
                    <div class="horizontal"></div>
                </div>
                <div class="comments">

                @if (count($reviews) > 1)
                <form  action="{{ route('customer.review.deleteall') }}" method="post">
                            @method('delete')
                            @csrf
                            <input type="submit" style="
                            padding: 1.2rem 2.35rem;
                            cursor: pointer;
                            border: none;
                            color: #fff;
                            background-color: #c3000e;
                            border-radius: 0.5rem;
                            " value="{{ __('shop::app.customer.account.review.delete-all.title') }}">
                </form>
                @endif


                @if (! $reviews->isEmpty())
                    @foreach ($reviews as $review)
                    <div class="comment">
                        <div>
                            <div class="comment-top" style="padding-bottom:20px;">
                                <div class="comment-desc">
                                    <div class="comment-desc-img">
                                    <?php $image = productimage()->getProductBaseImage($review->product); ?>
                                    <a href="{{ route('shop.productOrCategory.index', $review->product->url_key) }}"><img
                                            src="{{ $image['small_image_url'] }}"
                                            alt=""
                                        /></a>
                                        
                                    </div>
                                    <span class="comment-product">
                                        {{$review->product->name}}
                                    </span>
                                </div>

                                <div class="comment-action">
                                    <!-- <button>Удалить</button> -->
                                    <form id="deleteReviewForm" action="{{ route('customer.review.delete', $review->id) }}" method="post">
                                        @method('delete')
                                        @csrf
                                        <input type="submit" style="
                                            padding: 1.2rem 2.35rem;
                                            cursor: pointer;
                                            border: none;
                                            color: #fff;
                                            background-color: #c3000e;
                                            border-radius: 0.5rem;
                                        " value="delete">
                                    </form>
                                </div>
                                
                            </div>
                            <div class="horizontal" style="padding-top:30px;border:none;border-top:0.01rem solid rgba(0, 0, 0, 30%)"></div>
                            <div class="comment-middle">
                                <div class="rating">
                                    <div class="rating-stars">
                                    @for($i=0 ; $i < $review->rating ; $i++)
                                        <div class="rating-star">
                                            <svg class="star red">
                                                <use xlink:href="#star"></use>
                                            </svg>
                                        </div>
                                    @endfor
                                        
                                    </div>
                                    <span class="rating-num">{{ $review->rating }}.0</span>
                                </div>
                                <div class="date">
                                    <span class="date-title"
                                        >Дата публикации:</span
                                    >
                                    <span class="date-date">03.05.2022</span>
                                </div>
                                <div class="comment-content">
                                    <span class="comment-title"
                                        >Комментарий:</span
                                    >
                                    <p class="comment-comment">
                                        {{ $review->comment }}
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    @endforeach

                    
                @else
                    <p>
                        {{ __('customer::app.reviews.empty') }}
                    <p>
                @endif

                    


                </div>
            </div>
        </section>
        
@endsection

@push("scripts")
    <script src="{{bagisto_asset('scripts/comments.js')}}"></script>
    
@endpush
