@extends('admin.layouts.app')

@section('content')
<div class="container-fluid px-4">
    <x-admin.page-header :title="$pool->name" :subtitle="$pool->cidr" icon="fas fa-network-wired"
        :buttons="[
            ['label' => __('admin/common.edit'), 'route' => route('admin.ip-pools.edit', $pool),
             'icon' => 'fas fa-edit', 'color' => 'primary', 'permission' => 'update ip pools'],
            ['label' => __('admin/common.back'), 'route' => route('admin.ip-pools.index'),
             'icon' => 'fas fa-arrow-left', 'color' => 'outline-secondary'],
        ]" />

    <x-admin.alert />

    <x-admin.card :padding="false">
        <x-admin.tab-nav :tabs="[
            ['id' => 'overview', 'label' => __('admin/ip_pools.tab_overview'), 'icon' => 'fas fa-chart-pie'],
            ['id' => 'addresses', 'label' => __('admin/ip_pools.tab_addresses'), 'icon' => 'fas fa-list'],
            ['id' => 'imports', 'label' => __('admin/ip_pools.tab_imports'), 'icon' => 'fas fa-file-import'],
            ['id' => 'settings', 'label' => __('admin/ip_pools.tab_settings'), 'icon' => 'fas fa-cog'],
        ]" id="ipPoolTabs" />

        <div class="tab-content p-4" id="ipPoolTabsContent">
            <div class="tab-pane fade show active" id="overview" role="tabpanel">
                @include('admin.ip_pools._tab_overview')
            </div>
            <div class="tab-pane fade" id="addresses" role="tabpanel">
                @include('admin.ip_pools._tab_addresses')
            </div>
            <div class="tab-pane fade" id="imports" role="tabpanel">
                @include('admin.ip_pools._tab_imports')
            </div>
            <div class="tab-pane fade" id="settings" role="tabpanel">
                @include('admin.ip_pools._tab_settings')
            </div>
        </div>
    </x-admin.card>
</div>
@endsection

@push('scripts')
<script>
window.pageConfig = {
    pool: { id: {{ $pool->id }}, cidr: '{{ $pool->cidr }}' },
    routes: {
        addresses_records: '{{ route("api.admin.ip-pools.addresses.records", $pool) }}',
        import_cidr: '{{ route("admin.ip-pools.import-cidr", $pool) }}',
        addresses_store: '{{ route("admin.ip-pools.addresses.store", $pool) }}',
        reserve: '{{ url("admin/ip-addresses/:id/reserve") }}',
        unreserve: '{{ url("admin/ip-addresses/:id/unreserve") }}',
        release: '{{ url("admin/ip-addresses/:id/release") }}',
        force_release: '{{ url("admin/ip-addresses/:id/force-release") }}',
        rdns: '{{ url("admin/ip-addresses/:id/rdns") }}',
    },
    permissions: {
        manage: @json(auth('admin')->user()?->can('manage ip allocations') ?? false),
    },
    translations: {
        confirm_force_release: '{{ __("admin/ip_pools.confirm_force_release") }}',
    },
};
</script>
@vite('resources/js/admin/ip-pools/show.js')
@endpush
