"use client";

import { useTransition } from "react";
import { signOutAction } from "@/lib/appwrite/auth-actions";

export function SignOutForm() {
  const [isPending, startTransition] = useTransition();

  function handleSignOut() {
    startTransition(async () => {
      await signOutAction();
    });
  }

  return (
    <button
      type="button"
      onClick={handleSignOut}
      disabled={isPending}
      className="text-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50"
    >
      {isPending ? "Çıkış yapılıyor..." : "Çıkış yap"}
    </button>
  );
}
