@php
    $status = $record->user->status->value;
    $label = $label ?? 'record';
    $editMessage = $editMessage ?? "Are you sure you want to edit this {$label}?";
    $approveMessage = $approveMessage ?? "Are you sure you want to approve this {$label}?";
    $rejectMessage = $rejectMessage ?? "Are you sure you want to reject this {$label}?";
    $deleteMessage = $deleteMessage ?? "Are you sure you want to delete this {$label}?";
@endphp
<div class="dropdown ms-auto text-end">
    <a href="javascript:void(0);" class="btn-link" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Actions">
        <svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg">
            <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                <rect x="0" y="0" width="24" height="24"></rect>
                <circle fill="currentColor" cx="5" cy="12" r="2"></circle>
                <circle fill="currentColor" cx="12" cy="12" r="2"></circle>
                <circle fill="currentColor" cx="19" cy="12" r="2"></circle>
            </g>
        </svg>
    </a>
    <div class="dropdown-menu dropdown-menu-end">
        <a class="dropdown-item" href="{{ route($resource.'.show', $record) }}">View</a>
        <a class="dropdown-item" href="{{ route($resource.'.edit', $record) }}" onclick="return confirm({{ json_encode($editMessage) }})">Edit</a>
        @if ($status !== 'approved')
            <form action="{{ route($resource.'.approve', $record) }}" method="POST" class="m-0" onsubmit="return confirm({{ json_encode($approveMessage) }})">
                @csrf
                @method('PATCH')
                <button type="submit" class="dropdown-item">Approve</button>
            </form>
        @endif
        @if ($status !== 'rejected')
            <form action="{{ route($resource.'.reject', $record) }}" method="POST" class="m-0" onsubmit="return confirm({{ json_encode($rejectMessage) }})">
                @csrf
                @method('PATCH')
                <button type="submit" class="dropdown-item">Reject</button>
            </form>
        @endif
        <form action="{{ route($resource.'.destroy', $record) }}" method="POST" class="m-0" onsubmit="return confirm({{ json_encode($deleteMessage) }})">
            @csrf
            @method('DELETE')
            <button type="submit" class="dropdown-item text-danger">Delete</button>
        </form>
    </div>
</div>
