@extends('admin.layouts.app')

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

    <x-admin.alert />

    <x-admin.card>
        <x-admin.data-table
            id="customReportsTable"
            :records-url="route('api.admin.reports.list.records')"
            :filterable="true">
            <th>{{ __('admin/reports.col_name') }}</th>
            <th>{{ __('admin/reports.col_owner') }}</th>
            <th>{{ __('admin/reports.col_public') }}</th>
            <th>{{ __('admin/reports.col_last_run') }}</th>
            <th>{{ __('admin/reports.col_updated') }}</th>
            <th>{{ __('admin/common.col_actions') }}</th>

            <x-slot:filters>
                <div class="row g-2">
                    <div class="col-md-3">
                        <select name="scope" class="form-select form-select-sm">
                            <option value="all">{{ __('admin/reports.scope_all') }}</option>
                            <option value="mine">{{ __('admin/reports.scope_mine') }}</option>
                            <option value="public">{{ __('admin/reports.scope_public') }}</option>
                        </select>
                    </div>
                </div>
            </x-slot:filters>
        </x-admin.data-table>
    </x-admin.card>
</div>
@endsection

@push('scripts')
<script>
window.pageConfig = {
    routes: {
        records: '{{ route("api.admin.reports.list.records") }}',
        show: '{{ route("admin.reports.custom.show", ":id") }}',
        edit: '{{ route("admin.reports.custom.edit", ":id") }}',
        delete: '{{ route("admin.reports.custom.destroy", ":id") }}',
        export: '{{ route("admin.reports.custom.export", ":id") }}',
    },
    permissions: {
        create: @json(auth('admin')->user()?->can('create custom reports') ?? false),
        manage: @json(auth('admin')->user()?->can('manage custom reports') ?? false),
        export: @json(auth('admin')->user()?->can('export custom reports') ?? false),
    },
    translations: {
        confirm_delete: '{{ __("admin/reports.confirm_delete") }}',
    },
};
</script>
@vite('resources/js/admin/reports/index.js')
@endpush
