@extends('layouts.app')

@section('content')
<div class="container app-content pt-3">
    <h1 class="h3 mb-4">Template Exports</h1>
    <div class="py-3">
        <a href="{{ route('admin.template.create') }}" class="btn btn-success"><i class="mr-2 fa fa-plus"></i>Add Template</a>
    </div>
    <div class="card">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead class="thead-light">
                    <tr>
                        <th>Name</th>
                        <th>Type</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($templates as $template)
                        <tr>
                            <td>{{ $template->name }}</td>
                            <td>{{ $template->type }}</td>
                            <td>
                                <a href="{{ route('admin.template.edit', $template) }}" class="btn btn-warning btn-sm" type="button">Edit</a>
                                <a href="{{ route('admin.template.destroy', $template) }}" class="btn btn-danger btn-sm"
                                    onclick="event.preventDefault();document.getElementById('delete-{{ $template->id }}').submit();">Delete</a>

                                <form id="delete-{{ $template->id }}" action="{{ route('admin.template.destroy', $template) }}" method="POST" style="display: none;">
                                    @csrf
                                    @method('DELETE')
                                </form>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>

        @if ($templates->hasPages())
            <div class="card-footer">
                {{ $templates->links() }}
            </div>
        @endif
    </div>
</div>
@endsection
