@extends("admin.layout.base")
@extends("admin.layout.header")

@section("title")
    Feedback - Vis
@endsection

@section("path")
    <a href="{{ route('feedbacks.index') }}" class="text-white">Vis Feedback</a> /
@endsection


@section("content")
    <style>
        .letterSpaceTable{
            letter-spacing: 1.2px;
        }
    </style>
    <table class="tbl letterSpaceTable" id="table_id">
        <thead>
            <th class="w-6em">Dato</th>
            <th>Feedback Besked</th>
            <th class="w-7em">Feedback type</th>
            @if(auth()->user()->can('feedback.delete'))
                <th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
            @endif
        </thead>
        <tbody>
            @foreach($feedback as $fb)
            <tr>
                <td>{{ date('d-m-Y', strtotime($fb->created_at)) }}</td>
                <td>{{ $fb->message }}</td>
                <td>{{ $fb->suggestion_form }}</td>
                @if(auth()->user()->can('feedback.delete'))
                    <td><form method="post" action="{{ route("feedbacks.destroy", [ "feedback" => $fb ]) }}" class="w-100 nostyle">
                            @csrf
                            @method("delete")

                            <button onclick="return confirm('Are you sure you want to delete?');" class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
                        </form>
                    </td>
                @endif
            </tr>
            @endforeach
        </tbody>
    </table>
@endsection
@section('scripts')
    <script>
        $(document).ready( function () {
            $('#table_id').DataTable({
                columnDefs: [
                    { orderable: false, targets: [-1] }
                ]
            });
        });
    </script>
@endsection