"use client";

import { Button } from "@mosaic/ui";

const API_URL = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:3001";

export function LoginButton(): React.JSX.Element {
  const handleLogin = (): void => {
    // Redirect to the backend OIDC authentication endpoint
    // BetterAuth will handle the OIDC flow and redirect back to the callback
    window.location.assign(`${API_URL}/auth/signin/authentik`);
  };

  return (
    <Button variant="primary" onClick={handleLogin} className="w-full">
      Sign In with Authentik
    </Button>
  );
}
