"use client";

import { cn } from "@/lib/utils";

type Props = {
  className?: string;
};

export function LogoutButton({ className }: Props) {
  return (
    <button
      type="button"
      className={cn(
        "text-sm text-muted-foreground underline-offset-4 hover:text-foreground",
        className,
      )}
      onClick={async () => {
        await fetch("/api/auth/logout", { method: "POST" });
        window.location.href = "/";
      }}
    >
      Log out
    </button>
  );
}
