'use client'

import { logout } from '@/app/actions'
import { Button } from '@/components/ui/button'
import { LogOut } from 'lucide-react'
import { showSwal } from '@/lib/swal'

export function LogoutButton() {
    const handleLogout = async () => {
        const result = await showSwal.confirm(
            'Keluar?',
            'Apakah Anda yakin ingin mengakhiri sesi ini?'
        )

        if (result.isConfirmed) {
            logout()
        }
    }

    return (
        <Button
            variant="outline"
            onClick={handleLogout}
            className="gap-2 border-black bg-white text-black hover:bg-gray-100 hover:text-black transition-colors"
        >
            <LogOut className="h-4 w-4" />
            Logout
        </Button>
    )
}
