Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/components/screens/signature/PublicSignPage.tsx
T

76 lines
3.5 KiB
TypeScript

// AK-P16d Interim-UI (AD-28) — public signer page for /sign/:token, restyled
// from hand-written markup to ~/ui components (analog to the login/verify
// public routes, which also use ~/ui; the embed-safe PublicFormRenderer rule
// does not apply here because this page never runs inside a host iframe).
// The form posts the route action's existing contract: otp, signatureSvg,
// intentAccepted. Final Subframe optics land as a tracked design-nachzug.
import { useState } from "react";
import { Form } from "react-router";
import { useTranslation } from "react-i18next";
import { Alert } from "~/ui/components/Alert";
import { Button } from "~/ui/components/Button";
import { Checkbox } from "~/ui/components/Checkbox";
import { TextArea } from "~/ui/components/TextArea";
import { TextInput } from "~/ui/components/TextInput";
export type PublicSignPageProps = {
documentTitle: string;
signerName: string;
signerEmail: string;
isComplete: boolean;
errorKey: string | null;
submitting: boolean;
};
export function PublicSignPage(props: PublicSignPageProps) {
const { t } = useTranslation();
// The ~/ui Checkbox is a controlled Radix button; the hidden input carries
// the value into the plain form POST the route action expects.
const [intentAccepted, setIntentAccepted] = useState(false);
return (
<main className="mx-auto flex min-h-screen w-full max-w-xl flex-col justify-center gap-6 p-6" data-ui-id="ui.signature.public.page">
<header className="flex flex-col gap-1">
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{props.signerEmail}</span>
<h1 className="text-heading-2 font-heading-2 text-text-neutral-primary">{props.documentTitle}</h1>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("signature.public.intentIntro", { name: props.signerName })}
</span>
</header>
{props.isComplete ? (
<Alert
variant="success"
notDismissible
title={t("signature.public.completeTitle")}
description={t("signature.public.completeBody")}
data-ui-id="ui.signature.public.complete"
/>
) : (
<Form method="post" className="flex w-full flex-col gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-primary p-4">
{props.errorKey ? <Alert variant="error" notDismissible title={t(props.errorKey)} /> : null}
<TextInput className="w-full" label={t("signature.public.otp")} showLabel>
<TextInput.Input name="otp" inputMode="numeric" maxLength={6} autoComplete="one-time-code" data-ui-id="ui.signature.public.otp" />
</TextInput>
<TextArea className="w-full max-w-none" label={t("signature.public.signature")} showLabel>
<TextArea.Input name="signatureSvg" data-ui-id="ui.signature.public.signature" />
</TextArea>
<input type="hidden" name="intentAccepted" value={intentAccepted ? "on" : ""} readOnly />
<Checkbox
label={t("signature.public.intentCheckbox")}
checked={intentAccepted}
onCheckedChange={setIntentAccepted}
data-ui-id="ui.signature.public.intent"
/>
<div className="flex w-full items-center justify-end">
<Button type="submit" loading={props.submitting} data-ui-id="ui.signature.public.submit">
{t("signature.public.submit")}
</Button>
</div>
</Form>
)}
</main>
);
}