@extends('admin.layouts.app')

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

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

    <x-admin.card>
        <x-admin.data-table id="ticketStatusesTable" :records-url="route('api.admin.ticket-statuses.records')">
            <th>{{ __('admin/ticket-statuses.fields_name') }}</th>
            <th>{{ __('admin/ticket-statuses.fields_color') }}</th>
            <th>{{ __('admin/ticket-statuses.fields_scope') }}</th>
            <th>{{ __('admin/ticket-statuses.fields_is_closed') }}</th>
            <th>{{ __('admin/ticket-statuses.fields_is_default') }}</th>
            <th>{{ __('admin/ticket-statuses.fields_is_system') }}</th>
            <th>{{ __('admin/ticket-statuses.fields_sort_order') }}</th>
            <th>{{ __('admin/ticket-statuses.fields_status') }}</th>
            <th>{{ __('admin/ticket-statuses.fields_actions') }}</th>
        </x-admin.data-table>
    </x-admin.card>
</div>
@endsection

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

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

    // Çevirileri JavaScript'e aktar
    window.translations = {
        ticketStatuses: {
            edit: '{{ __("admin/ticket-statuses.buttons_edit") }}',
            delete: '{{ __("admin/ticket-statuses.buttons_delete") }}',
            confirmDelete: '{{ __("admin/ticket-statuses.messages_confirm_delete") }}',
            systemCannotDelete: '{{ __("admin/ticket-statuses.messages_system_cannot_delete") }}',
            defaultCannotDelete: '{{ __("admin/ticket-statuses.messages_default_cannot_delete") }}'
        },
        scopes: {
            pending: '{{ __("admin/ticket-statuses.scope_options_pending") }}',
            open: '{{ __("admin/ticket-statuses.scope_options_open") }}',
            closed: '{{ __("admin/ticket-statuses.scope_options_closed") }}'
        },
        common: {
            yes: '{{ __("admin/common.yes") }}',
            no: '{{ __("admin/common.no") }}',
            active: '{{ __("admin/common.active") }}',
            inactive: '{{ __("admin/common.inactive") }}'
        }
    };
</script>
@vite('resources/js/admin/ticket-statuses/index.js')
@endpush