@extends('admin.layouts.app')

@section('title', 'Client Discounts')

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

    <x-admin.alert />

    <x-admin.card :padding="false">
        <x-admin.data-table id="clientDiscountsTable" :records-url="route('api.admin.client-discounts.records')">
            <th>ID</th>
            <th>{{ __('admin/common.fields_name') }}</th>
            <th>{{ __('admin/common.fields_client') }}</th>
            <th>{{ __('admin/common.fields_type') }}</th>
            <th>{{ __('admin/common.fields_applies_to') }}</th>
            <th>{{ __('admin/common.fields_status') }}</th>
            <th>{{ __('admin/common.fields_expires_at') }}</th>
            <th>{{ __('admin/common.fields_created_at') }}</th>
            <th>{{ __('admin/common.fields_actions') }}</th>
        </x-admin.data-table>
    </x-admin.card>
</div>
@endsection

@push('scripts')
<script>
    window.routes = {
        delete: '{{ route("api.admin.client-discounts.destroy", ":id") }}',
        toggleStatus: '{{ route("api.admin.client-discounts.toggle-status", ":id") }}'
    };

    window.permissions = {
        client_discounts: {
            view: {{ json_encode(auth()->user()->can('view client discounts')) }},
            update: {{ json_encode(auth()->user()->can('update client discounts')) }},
            delete: {{ json_encode(auth()->user()->can('delete client discounts')) }}
        }
    };

    window.translations = {
        search_placeholder: '{{ __("admin/common.search_placeholder") }}',
        buttons_edit: '{{ __("admin/common.buttons_edit") }}',
        buttons_delete: '{{ __("admin/common.buttons_delete") }}',
        buttons_show: '{{ __("admin/common.buttons_show") }}',
        delete_confirm: '{{ __("admin/common.messages_delete_confirm") }}',
        delete_success: '{{ __("admin/common.messages_client_discount_deleted") }}',
        delete_error: '{{ __("admin/common.messages_discount_delete_error") }}',
        status_active: '{{ __("admin/common.status_active") }}',
        status_inactive: '{{ __("admin/common.status_inactive") }}'
    };
</script>
@vite('resources/js/admin/client-discounts/index.js')
@endpush
