<div class="order-history-block-container-wrapper">
    @if ($records instanceof \Illuminate\Pagination\LengthAwarePaginator && count($records))
        @foreach ($records as $key => $record)
            <div class="order-history-block-list">
                @if ($enableMassActions)
                    <span class="order-history-head-text">
                        @php
                            $record_id = $record->{$index};
                        @endphp

                        <span class="checkbox">
                            <input type="checkbox" v-model="dataIds" @change="select($event)" value="{{ $record_id }}">

                            <label class="checkbox-view" for="checkbox"></label>
                        </span>
                    </span>
                @endif

                @foreach ($columns as $column)
                    @php
                        $columnIndex = explode('.', $column['index']);

                        $columnIndex = end($columnIndex);

                        $supportedClosureKey = ['wrapper', 'closure'];

                        $isClosure = ! empty(array_intersect($supportedClosureKey, array_keys($column)));
                    @endphp

                    @if ($isClosure)
                        {{--
                            Depereciation Notice:
                            The following key i.e. `wrapper` will remove in the later version. Use only `closure`
                            key to manipulate the column. This will only hit the raw html.
                        --}}
                        @if (isset($column['wrapper']) && gettype($column['wrapper']) === 'object' && $column['wrapper'] instanceof \Closure)
                            @if (isset($column['closure']) && $column['closure'] == true)
                                <span class="order-history-head-text number" data-value="{{ $column['label'] }}">{!! $column['wrapper']($record) !!}</span>
                            @else
                                <span class="order-history-head-text number" data-value="{{ $column['label'] }}">{{ $column['wrapper']($record) }}</span>
                            @endif
                        @elseif (isset($column['closure']) && gettype($column['closure']) === 'object' && $column['closure'] instanceof \Closure)
                            <span class="order-history-head-text number" data-value="{{ $column['label'] }}">{!! $column['closure']($record) !!}</span>
                        @endif
                    @else
                        @if ($column['type'] == 'price')
                            @if (isset($column['currencyCode']))
                                <span class="order-history-head-text number" data-value="{{ $column['label'] }}">{{ core()->formatPrice($record->{$columnIndex}, $column['currencyCode']) }}</span>
                            @else
                                <span class="order-history-head-text number" data-value="{{ $column['label'] }}">{{ core()->formatBasePrice($record->{$columnIndex}) }}</span>
                            @endif
                        @else
                            <span class="order-history-head-text number" data-value="{{ $column['label'] }}">{{ $record->{$columnIndex} }}</span>
                        @endif
                    @endif
                @endforeach

                @if ($enableActions)
                    <div class="more" data-value="{{ __('ui::app.datagrid.actions') }}">
                        @foreach ($actions as $action)
                            @php
                                $toDisplay = (isset($action['condition']) && gettype($action['condition']) == 'object') ? $action['condition']($record) : true;
                            @endphp

                            @if ($toDisplay)
                                <a
                                    id="{{ $record->{$action['index'] ?? $index} }}"

                                    @if ($action['method'] == 'GET')
                                        href="{{ route($action['route'], $record->{$action['index'] ?? $index}) }}"
                                    @endif

                                    @if ($action['method'] != 'GET')
                                        @if (isset($action['function']))
                                            onclick="{{ $action['function'] }}"
                                        @else
                                            v-on:click="doAction($event)"
                                        @endif
                                    @endif

                                    data-method="{{ $action['method'] }}"
                                    data-action="{{ route($action['route'], $record->{$index}) }}"
                                    data-token="{{ csrf_token() }}"

                                    @if (isset($action['target']))
                                        target="{{ $action['target'] }}"
                                    @endif

                                    @if (isset($action['title']))
                                        title="{{ $action['title'] }}"
                                    @endif
                                >Подробнее</a>
                                <div class="more-img">
                                    <img src="{{ bagisto_asset('icons/right_arrow_1.svg') }}" alt="arrow">
                                </div>
                            @endif
                        @endforeach
                    </div>
                @endif
            </div>
            <div class="horizontal"></div>
        @endforeach
    @else
        <div class="item-section empty">
            <div class="empty_icon">
                <img src="{{bagisto_asset('icons/history.svg')}}" alt="empty orders">
            </div>
            <h2 class="empty_text">{{ $norecords }}</h2>
        </div>

    @endif
</div>
