"use client";

import { useRouter } from "next/navigation";
import { LogOut } from "lucide-react";
import { api } from "@/lib/api";

export function LogoutButton() {
  const router = useRouter();
  return (
    <button type="button" onClick={async () => { try { await api.logout(); } finally { router.push("/login"); } }} className="flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-sm font-semibold text-muted-foreground hover:bg-muted hover:text-cocoa">
      <LogOut size={18} /> Log out
    </button>
  );
}
