@extends('admin.layouts.app')

@section('content')
<div class="container-fluid px-4">
    <x-admin.page-header
        :title="__('admin/downloads.title')"
        icon="fas fa-download"
        :buttons="[
            ['label' => __('admin/downloads.title'), 'route' => route('admin.downloads.create'), 'icon' => 'fas fa-plus', 'color' => 'primary', 'permission' => 'create downloads'],
        ]"
    />

    <x-admin.card>
        <x-admin.data-table id="downloadsTable" :records-url="route('api.admin.downloads.records')">
            <th>ID</th>
            <th>{{ __('admin/downloads.form_title') }}</th>
            <th>{{ __('admin/downloads.form_category') }}</th>
            <th>{{ __('admin/downloads.form_file_size') }}</th>
            <th>{{ __('admin/downloads.column_downloads') }}</th>
            <th>{{ __('admin/downloads.form_status') }}</th>
            <th class="text-end pe-4">{{ __('admin/common.actions') }}</th>
        </x-admin.data-table>
    </x-admin.card>
</div>
@endsection

@push('scripts')
<script>
    window.pageConfig = {
        permissions: {
            update: {{ json_encode(Auth::user()->can('update downloads')) }},
            delete: {{ json_encode(Auth::user()->can('delete downloads')) }}
        }
    };

    window.downloadsConfig = {
        routes: {
            edit: '{{ route("admin.downloads.edit", ":id") }}',
            destroy: '{{ route("api.admin.downloads.destroy", ":id") }}',
            customerLink: '{{ route("store.auth.downloads.file", ":id") }}'
        },
        translations: {
            category_general: '{{ __("admin/downloads.category_general") }}',
            category_software: '{{ __("admin/downloads.category_software") }}',
            category_documentation: '{{ __("admin/downloads.category_documentation") }}',
            category_tools: '{{ __("admin/downloads.category_tools") }}',
            status_active: '{{ __("admin/downloads.status_active") }}',
            status_inactive: '{{ __("admin/downloads.status_inactive") }}',
            confirm_delete: '{{ __("admin/downloads.confirm_delete") }}',
            copy_link: '{{ __("admin/downloads.copy_link") }}',
            link_copied: '{{ __("admin/downloads.link_copied") }}',
            link_copy_failed: '{{ __("admin/downloads.link_copy_failed") }}'
        }
    };
</script>
@vite('resources/js/admin/downloads/index.js')
@endpush
