import { redeemAction } from "./actions";

/**
 * The emailed link lands here, but the token is only consumed on an explicit POST.
 * This stops mail-scanner link previews from burning the single-use token.
 */
export default async function VerifyPage({ searchParams }: { searchParams: Promise<{ token?: string }> }) {
  const { token } = await searchParams;
  return (
    <div className="narrow">
      <div className="card">
        <h1>Finish signing in</h1>
        {token ? (
          <form action={redeemAction} className="stack">
            <input type="hidden" name="token" value={token} />
            <button type="submit">Continue to my photos</button>
          </form>
        ) : (
          <p className="notice bad">This link is missing its token. Please request a new sign-in link.</p>
        )}
      </div>
    </div>
  );
}
