import Link from 'next/link';
import { type FC, type InputHTMLAttributes, type ReactNode } from 'react';
import { ClockIcon } from '@/components/icons';
/**
* The page frame every auth screen shares: the brand, an optional line under
* it, the card, and the way back home.
*/
export const AuthShell: FC<{ subtitle?: string; children: ReactNode }> = ({
subtitle,
children,
}) => (
Botsmann
{subtitle &&
{subtitle}
}
{children}
Back to Home
);
/**
* The form's error line. While a rate limit is counting down it turns amber
* and shows the countdown instead of the message.
*/
export const AuthAlert: FC<{ error: string; rateLimitSeconds: number }> = ({
error,
rateLimitSeconds,
}) => {
if (!error) return null;
const limited = rateLimitSeconds > 0;
return (
{limited ? (
Too many attempts. Try again in {rateLimitSeconds}s
) : (
error
)}
);
};
type AuthFieldProps = InputHTMLAttributes & {
id: string;
label: ReactNode;
/** Something to sit at the label's right edge (e.g. a "Forgot password?" link). */
labelExtra?: ReactNode;
};
/** A labelled input in the auth forms' one style. */
export const AuthField: FC = ({ id, label, labelExtra, ...input }) => (
{labelExtra ? (
{labelExtra}
) : (
)}
);
/** The form's primary button: busy label while submitting, countdown while limited. */
export const AuthSubmitButton: FC<{
loading: boolean;
loadingLabel: string;
rateLimitSeconds: number;
children: ReactNode;
}> = ({ loading, loadingLabel, rateLimitSeconds, children }) => (
);