@extends('admin.layouts.app')

@section('title', __('admin/transactions.title'))

@section('content')
<div class="container-fluid px-4">
    <x-admin.page-header
        :title="__('admin/transactions.title')"
        icon="fas fa-exchange-alt"
        :buttons="[
            ['label' => __('admin/transactions.buttons_create'), 'route' => route('admin.transactions.create'), 'icon' => 'fas fa-plus', 'color' => 'primary'],
            ['label' => __('admin/transactions.add_balance_title'), 'route' => route('admin.transactions.add-balance'), 'icon' => 'fas fa-wallet', 'color' => 'success'],
            ['label' => __('admin/transactions.failed_title'), 'route' => route('admin.transactions.failed'), 'icon' => 'fas fa-exclamation-triangle', 'color' => 'outline-danger'],
        ]"
    />

    <x-admin.card :padding="false">
        <x-admin.data-table
            id="transactions"
            :records-url="route('api.admin.transactions.records')"
        >
            <th>{{ __('admin/transactions.fields_id') }}</th>
            <th>{{ __('admin/transactions.fields_client') }}</th>
            <th>{{ __('admin/transactions.fields_invoice_number') }}</th>
            <th>{{ __('admin/transactions.fields_type') }}</th>
            <th>{{ __('admin/transactions.fields_amount') }}</th>
            <th>{{ __('admin/transactions.fields_payment_method') }}</th>
            <th>{{ __('admin/transactions.fields_status') }}</th>
            <th>{{ __('admin/transactions.fields_payment_gateway') }}</th>
            <th>{{ __('admin/transactions.fields_created_at') }}</th>
            <th>{{ __('admin/transactions.fields_actions') }}</th>
        </x-admin.data-table>
    </x-admin.card>
</div>
@endsection

@push('scripts')
<script>
    window.permissions = {
        transactions: {
            view: {{ auth()->user()->can('view transactions') ? 'true' : 'false' }},
            update: {{ auth()->user()->can('update transactions') ? 'true' : 'false' }},
            delete: {{ auth()->user()->can('delete transactions') ? 'true' : 'false' }},
        }
    };

    window.routes = {
        transactions: {
            show: '{{ route("admin.transactions.show", ":id") }}',
            edit: '{{ route("admin.transactions.edit", ":id") }}'
        }
    };

    window.translations = {
        transactions: {
            types_payment: '{{ __("admin/transactions.types_payment") }}',
            types_refund: '{{ __("admin/transactions.types_refund") }}',
            types_credit: '{{ __("admin/transactions.types_credit") }}',
            types_debit: '{{ __("admin/transactions.types_debit") }}',
            statuses_pending: '{{ __("admin/transactions.statuses_pending") }}',
            statuses_completed: '{{ __("admin/transactions.statuses_completed") }}',
            statuses_failed: '{{ __("admin/transactions.statuses_failed") }}'
        },
        common: {
            buttons_view: '{{ __("admin/common.buttons_view") }}',
            buttons_edit: '{{ __("admin/transactions.buttons_edit") }}'
        }
    };
    window.translations.filters_all_types = '{{ __("admin/transactions.filters_all_types") }}';
    window.translations.filters_all_statuses = '{{ __("admin/transactions.filters_all_statuses") }}';
    window.translations.search_placeholder = '{{ __("admin/common.search_placeholder") }}';
</script>
@vite('resources/js/admin/transactions/index.js')
@endpush
