@extends('admin.layouts.app')

@section('title', __('admin/client-balances.title'))

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

        <x-admin.card :padding="false">
            <x-admin.data-table id="clientBalancesTable" :records-url="route('api.admin.client-balances.records')">
                <th>{{ __('admin/client-balances.columns_client_name') }}</th>
                <th>{{ __('admin/client-balances.columns_client_email') }}</th>
                <th>{{ __('admin/client-balances.columns_currency_code') }}</th>
                <th>{{ __('admin/client-balances.columns_balance') }}</th>
                <th>{{ __('admin/client-balances.columns_balance_status') }}</th>
                <th>{{ __('admin/client-balances.columns_created_at') }}</th>
                <th>{{ __('admin/client-balances.columns_actions') }}</th>
            </x-admin.data-table>
        </x-admin.card>
    </div>
@endsection

@push('scripts')
    <script>
        window.routes = window.routes || {};
        window.routes.clientBalances_show = '{{ route("admin.client-balances.show", ":id") }}';
        window.routes.clientBalances_create = '{{ route("admin.client-balances.create") }}';
        window.routes.clientBalances_clientSearch = '{{ route("api.admin.clients.search") }}';

        window.pageConfig = window.pageConfig || {};
        window.pageConfig.currencies = @json($currencies->map(fn($c) => ['id' => $c->id, 'code' => $c->code, 'name' => $c->name]));

        window.permissions = window.permissions || {};
        window.permissions.clientBalances = {
            view: {{ json_encode(auth()->user()->can('view client balances')) }},
            create: {{ json_encode(auth()->user()->can('create client balances')) }},
        };

        window.translations = window.translations || {};
        window.translations.clientBalances_buttons_show = '{{ __("admin/client-balances.buttons_show") }}';
        window.translations.clientBalances_statuses_positive = '{{ __("admin/client-balances.statuses_positive") }}';
        window.translations.clientBalances_statuses_negative = '{{ __("admin/client-balances.statuses_negative") }}';
        window.translations.clientBalances_statuses_zero = '{{ __("admin/client-balances.statuses_zero") }}';
        window.translations.clientBalances_filters_all_clients = '{{ __("admin/client-balances.filters_all_clients") }}';
        window.translations.clientBalances_filters_all_currencies = '{{ __("admin/client-balances.filters_all_currencies") }}';
        window.translations.clientBalances_filters_all_statuses = '{{ __("admin/client-balances.filters_all_statuses") }}';
        window.translations.clientBalances_filters_positive = '{{ __("admin/client-balances.filters_positive") }}';
        window.translations.clientBalances_filters_negative = '{{ __("admin/client-balances.filters_negative") }}';
        window.translations.clientBalances_filters_zero = '{{ __("admin/client-balances.filters_zero") }}';
        window.translations.search_placeholder = '{{ __("admin/common.search_placeholder") }}';
    </script>
    @vite('resources/js/admin/client-balances/index.js')
@endpush
