Files
documenso/apps/remix/app/utils/field-signing/name-field.ts
T
ephraimduncan 138d663c25 chore: merge main, resolve biome formatting conflicts
Merge origin/main into feat/external-2fa-codes. Resolve formatting
conflicts caused by biome rollout; preserve both feature streams:
PR's external 2FA token + signing-session 2FA proof additions plus
main's RateLimit/RecipientExpired/signingReminders/date-auto-insert.

In complete-document-with-token.ts, drop the duplicate early
field-fetching block introduced when main moved that logic later
with date auto-insert support; keep the EXTERNAL_TWO_FACTOR_AUTH
check using derivedRecipientActionAuth.
2026-05-12 11:46:11 +00:00

48 lines
1.1 KiB
TypeScript

import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
import type { TFieldName } from '@documenso/lib/types/field';
import type { TSignEnvelopeFieldValue } from '@documenso/trpc/server/envelope-router/sign-envelope-field.types';
import { FieldType } from '@prisma/client';
import { SignFieldNameDialog } from '~/components/dialogs/sign-field-name-dialog';
type HandleNameFieldClickOptions = {
field: TFieldName;
name: string | null;
};
export const handleNameFieldClick = async (
options: HandleNameFieldClickOptions,
): Promise<Extract<TSignEnvelopeFieldValue, { type: typeof FieldType.NAME }> | null> => {
const { field, name } = options;
if (field.type !== FieldType.NAME) {
throw new AppError(AppErrorCode.INVALID_REQUEST, {
message: 'Invalid field type',
});
}
if (field.inserted) {
return {
type: FieldType.NAME,
value: null,
};
}
let nameToInsert = name;
if (!nameToInsert) {
nameToInsert = await SignFieldNameDialog.call({
// Props here.
});
}
if (!nameToInsert) {
return null;
}
return {
type: FieldType.NAME,
value: nameToInsert,
};
};