Skip to content

Open-source document signature platform. Not affiliated with DocuSign.

TypeScript

Keep identity controls for people with Part 11 signatures still open

Claude3426a69af39a
diff --git a/src/components/settings/people-panel.tsx b/src/components/settings/people-panel.tsx
index f34f485..9b52baf 100644
--- a/src/components/settings/people-panel.tsx
+++ b/src/components/settings/people-panel.tsx
@@ -35,6 +35,15 @@ function readPeopleList(payload: PeopleResponse): PeopleList | null {
}
export function PeoplePanel({ part11Mode = false }: { part11Mode?: boolean }) {
+ function showsPart11(person: Person) {
+ return (
+ part11Mode ||
+ person.hasOpenPart11Signing ||
+ person.identityVerifiedAt !== null ||
+ person.signingLockedAt !== null
+ );
+ }
+
const [list, setList] = useState<PeopleList | null>(null);
const [you, setYou] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
@@ -278,7 +287,7 @@ export function PeoplePanel({ part11Mode = false }: { part11Mode?: boolean }) {
{person.closing ? (
<span className="pill pill-warning">Closing</span>
) : null}
- {part11Mode || person.identityVerifiedAt !== null ? (
+ {showsPart11(person) ? (
person.identityVerifiedAt !== null ? (
<span
className="pill pill-success"
@@ -297,14 +306,12 @@ export function PeoplePanel({ part11Mode = false }: { part11Mode?: boolean }) {
) : null}
</div>
{/* Envelopes sent in Part 11 mode keep its rules after it is
- turned off, so an existing confirmation or lock can
- still be changed then. */}
- {part11Mode ||
- person.identityVerifiedAt !== null ||
- person.signingLockedAt !== null ? (
+ turned off, so the controls stay for anyone they still
+ concern. */}
+ {showsPart11(person) ? (
<div className="flex flex-wrap gap-2 pt-1">
{person.identityVerifiedAt === null ? (
- part11Mode ? (
+ part11Mode || person.hasOpenPart11Signing ? (
<button
aria-label={`Confirm ${person.name}'s identity`}
className="btn-quiet"
diff --git a/src/lib/people.ts b/src/lib/people.ts
index 006a640..f1f069e 100644
--- a/src/lib/people.ts
+++ b/src/lib/people.ts
@@ -29,6 +29,11 @@ export type Person = {
email: string;
emailVerified: boolean;
id: string;
+ /**
+ * Named to sign a Part 11 envelope that is still out, so the Part 11
+ * controls stay offered after the mode is turned off.
+ */
+ hasOpenPart11Signing: boolean;
/** When an administrator confirmed who this is, for Part 11 signing. */
identityVerifiedAt: number | null;
identityVerificationNote: string | null;
@@ -59,6 +64,7 @@ export class PeopleError extends Error {
type PersonRow = {
closing: boolean;
+ hasOpenPart11Signing: boolean;
createdAt: Date;
email: string;
emailVerified: boolean;
@@ -82,7 +88,16 @@ const PERSON_COLUMNS = `
u.signing_locked_at AS "signingLockedAt",
EXISTS (
SELECT 1 FROM account_closure_requests c WHERE c.user_id = u.id
- ) AS closing
+ ) AS closing,
+ EXISTS (
+ SELECT 1
+ FROM signers s
+ JOIN envelopes e ON e.id = s.envelope_id
+ WHERE s.user_id = u.id
+ AND e.part11
+ AND e.status = 'sent'
+ AND s.status IN ('pending', 'notified')
+ ) AS "hasOpenPart11Signing"
`;
function mapPerson(row: PersonRow): Person {
@@ -91,6 +106,7 @@ function mapPerson(row: PersonRow): Person {
createdAt: row.createdAt.toISOString(),
email: row.email,
emailVerified: row.emailVerified,
+ hasOpenPart11Signing: row.hasOpenPart11Signing,
id: row.id,
identityVerificationNote: row.identityVerificationNote ?? null,
identityVerifiedAt: row.identityVerifiedAt ?? null,