@extends('admin.layouts.app')

@section('title', __('admin/ticket-departments.title'))

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

    <x-admin.card>
        <x-admin.data-table id="ticketDepartments" :records-url="route('api.admin.ticket-departments.records')">
            <th>{{ __('admin/ticket-departments.fields_name') }}</th>
            <th>{{ __('admin/ticket-departments.fields_description') }}</th>
            <th>{{ __('admin/ticket-departments.fields_client_only') }}</th>
            <th>{{ __('admin/ticket-departments.fields_hidden') }}</th>
            <th>{{ __('admin/ticket-departments.fields_status') }}</th>
            <th>{{ __('admin/ticket-departments.fields_created_at') }}</th>
            <th>{{ __('admin/ticket-departments.fields_actions') }}</th>
        </x-admin.data-table>
    </x-admin.card>
</div>
@endsection

@push('scripts')
<script>
    // Yetki kontrolü için permissions nesnesi
    window.permissions = {
        ticketDepartments: {
            update: {{ json_encode(Auth::user()->can('updateAny', App\Models\TicketDepartment::class)) }},
            delete: {{ json_encode(Auth::user()->can('deleteAny', App\Models\TicketDepartment::class)) }}
        }
    };

    // Route bilgilerini JavaScript'e aktar
    window.routes = {
        ticketDepartments: {
            edit: '{{ route("admin.ticket-departments.edit", ":id") }}',
            delete: '{{ route("api.admin.ticket-departments.destroy", ":id") }}'
        }
    };

    // Dil çevirilerini JavaScript'e aktar
    window.translations = {
        buttons: {
                    edit: '{{ __("admin/ticket-departments.buttons_edit") }}',
        delete: '{{ __("admin/ticket-departments.buttons_delete") }}'
        },
        status: {
                    active: '{{ __("admin/ticket-departments.status_active") }}',
        inactive: '{{ __("admin/ticket-departments.status_inactive") }}'
        },
        messages: {
                    delete_confirm: '{{ __("admin/ticket-departments.messages_delete_confirm") }}',
        delete_success: '{{ __("admin/ticket-departments.messages_delete_success") }}',
        delete_error: '{{ __("admin/ticket-departments.messages_delete_error") }}'
        }
    };
</script>
@vite('resources/js/admin/ticket-departments/index.js')
@endpush