feat: remove the existing empty signer if its the only one

This commit is contained in:
Adithya Krishna
2024-04-29 17:10:56 +05:30
committed by GitHub
parent 345e42537a
commit e82e402540

View File

@ -138,16 +138,6 @@ export const AddSignersFormPartial = ({
); );
}; };
const onAddSelfSigner = () => {
appendSigner({
formId: nanoid(12),
name: user?.name ?? '',
email: user?.email ?? '',
role: RecipientRole.SIGNER,
actionAuth: undefined,
});
};
const onAddSigner = () => { const onAddSigner = () => {
appendSigner({ appendSigner({
formId: nanoid(12), formId: nanoid(12),
@ -174,6 +164,17 @@ export const AddSignersFormPartial = ({
removeSigner(index); removeSigner(index);
}; };
const onAddSelfSigner = () => {
if(signers.length !== 0) onRemoveSigner(0);
appendSigner({
formId: nanoid(12),
name: user?.name ?? '',
email: user?.email ?? '',
role: RecipientRole.SIGNER,
actionAuth: undefined,
});
};
const onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => { const onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter' && event.target instanceof HTMLInputElement) { if (event.key === 'Enter' && event.target instanceof HTMLInputElement) {
onAddSigner(); onAddSigner();
@ -302,10 +303,10 @@ export const AddSignersFormPartial = ({
global action signing authentication method configured in global action signing authentication method configured in
the "General Settings" step the "General Settings" step
</li> </li>
{/* <li> <li>
<strong>Require account</strong> - The recipient must be <strong>Require account</strong> - The recipient must be
signed in signed in
</li> */} </li>
<li> <li>
<strong>Require passkey</strong> - The recipient must have <strong>Require passkey</strong> - The recipient must have
an account and passkey configured via their settings an account and passkey configured via their settings
@ -326,13 +327,11 @@ export const AddSignersFormPartial = ({
{/* Note: -1 is remapped in the Zod schema to the required value. */} {/* Note: -1 is remapped in the Zod schema to the required value. */}
<SelectItem value="-1">Inherit authentication method</SelectItem> <SelectItem value="-1">Inherit authentication method</SelectItem>
{Object.values(RecipientActionAuth) {Object.values(RecipientActionAuth).map((authType) => (
.filter((auth) => auth !== RecipientActionAuth.ACCOUNT) <SelectItem key={authType} value={authType}>
.map((authType) => ( {DOCUMENT_AUTH_TYPES[authType].value}
<SelectItem key={authType} value={authType}> </SelectItem>
{DOCUMENT_AUTH_TYPES[authType].value} ))}
</SelectItem>
))}
</SelectContent> </SelectContent>
</Select> </Select>
</FormControl> </FormControl>