fix: allow template recipients to be filled (#1148)
## Description Update the template flow to allow for entering recipient placeholder emails and names ## Changes Made - General refactoring - Added advanced recipient settings for future usage
This commit is contained in:
@@ -141,6 +141,8 @@ export const EditTemplateForm = ({
|
|||||||
recipients={recipients}
|
recipients={recipients}
|
||||||
fields={fields}
|
fields={fields}
|
||||||
onSubmit={onAddTemplatePlaceholderFormSubmit}
|
onSubmit={onAddTemplatePlaceholderFormSubmit}
|
||||||
|
// Todo: Add when we setup template settings.
|
||||||
|
isTemplateOwnerEnterprise={false}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AddTemplateFieldsFormPartial
|
<AddTemplateFieldsFormPartial
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export const TemplatePageView = async ({ params, team }: TemplatePageViewProps)
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<EditTemplateForm
|
<EditTemplateForm
|
||||||
className="mt-8"
|
className="mt-6"
|
||||||
template={template}
|
template={template}
|
||||||
user={user}
|
user={user}
|
||||||
recipients={templateRecipients}
|
recipients={templateRecipients}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
@@ -5,7 +7,10 @@ import { InfoIcon, Plus } from 'lucide-react';
|
|||||||
import { useFieldArray, useForm } from 'react-hook-form';
|
import { useFieldArray, useForm } from 'react-hook-form';
|
||||||
import * as z from 'zod';
|
import * as z from 'zod';
|
||||||
|
|
||||||
import { TEMPLATE_RECIPIENT_PLACEHOLDER_REGEX } from '@documenso/lib/constants/template';
|
import {
|
||||||
|
TEMPLATE_RECIPIENT_EMAIL_PLACEHOLDER_REGEX,
|
||||||
|
TEMPLATE_RECIPIENT_NAME_PLACEHOLDER_REGEX,
|
||||||
|
} from '@documenso/lib/constants/template';
|
||||||
import { AppError } from '@documenso/lib/errors/app-error';
|
import { AppError } from '@documenso/lib/errors/app-error';
|
||||||
import type { Recipient } from '@documenso/prisma/client';
|
import type { Recipient } from '@documenso/prisma/client';
|
||||||
import { trpc } from '@documenso/trpc/react';
|
import { trpc } from '@documenso/trpc/react';
|
||||||
@@ -91,6 +96,8 @@ export function UseTemplateDialog({
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const team = useOptionalCurrentTeam();
|
const team = useOptionalCurrentTeam();
|
||||||
|
|
||||||
const form = useForm<TAddRecipientsForNewDocumentSchema>({
|
const form = useForm<TAddRecipientsForNewDocumentSchema>({
|
||||||
@@ -98,20 +105,18 @@ export function UseTemplateDialog({
|
|||||||
defaultValues: {
|
defaultValues: {
|
||||||
sendDocument: false,
|
sendDocument: false,
|
||||||
recipients: recipients.map((recipient) => {
|
recipients: recipients.map((recipient) => {
|
||||||
const isRecipientPlaceholder = recipient.email.match(TEMPLATE_RECIPIENT_PLACEHOLDER_REGEX);
|
const isRecipientEmailPlaceholder = recipient.email.match(
|
||||||
|
TEMPLATE_RECIPIENT_EMAIL_PLACEHOLDER_REGEX,
|
||||||
|
);
|
||||||
|
|
||||||
if (isRecipientPlaceholder) {
|
const isRecipientNamePlaceholder = recipient.name.match(
|
||||||
return {
|
TEMPLATE_RECIPIENT_NAME_PLACEHOLDER_REGEX,
|
||||||
id: recipient.id,
|
);
|
||||||
name: '',
|
|
||||||
email: '',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: recipient.id,
|
id: recipient.id,
|
||||||
name: recipient.name,
|
name: !isRecipientNamePlaceholder ? recipient.name : '',
|
||||||
email: recipient.email,
|
email: !isRecipientEmailPlaceholder ? recipient.email : '',
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@@ -158,8 +163,14 @@ export function UseTemplateDialog({
|
|||||||
name: 'recipients',
|
name: 'recipients',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) {
|
||||||
|
form.reset();
|
||||||
|
}
|
||||||
|
}, [open, form]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog open={open} onOpenChange={(value) => !form.formState.isSubmitting && setOpen(value)}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<Button className="cursor-pointer">
|
<Button className="cursor-pointer">
|
||||||
<Plus className="-ml-1 mr-2 h-4 w-4" />
|
<Plus className="-ml-1 mr-2 h-4 w-4" />
|
||||||
@@ -190,7 +201,7 @@ export function UseTemplateDialog({
|
|||||||
{index === 0 && <FormLabel required>Email</FormLabel>}
|
{index === 0 && <FormLabel required>Email</FormLabel>}
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} placeholder={recipients[index].email} />
|
<Input {...field} placeholder={recipients[index].email || 'Email'} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -205,7 +216,7 @@ export function UseTemplateDialog({
|
|||||||
{index === 0 && <FormLabel>Name</FormLabel>}
|
{index === 0 && <FormLabel>Name</FormLabel>}
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} placeholder={recipients[index].name} />
|
<Input {...field} placeholder={recipients[index].name || 'Name'} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
export const TEMPLATE_RECIPIENT_PLACEHOLDER_REGEX = /recipient\.\d+@documenso\.com/i;
|
export const TEMPLATE_RECIPIENT_EMAIL_PLACEHOLDER_REGEX = /recipient\.\d+@documenso\.com/i;
|
||||||
|
export const TEMPLATE_RECIPIENT_NAME_PLACEHOLDER_REGEX = /Recipient \d+/i;
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import type { SelectProps } from '@radix-ui/react-select';
|
||||||
|
import { InfoIcon } from 'lucide-react';
|
||||||
|
|
||||||
|
import { DOCUMENT_AUTH_TYPES } from '@documenso/lib/constants/document-auth';
|
||||||
|
import { RecipientActionAuth } from '@documenso/lib/types/document-auth';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@documenso/ui/primitives/select';
|
||||||
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@documenso/ui/primitives/tooltip';
|
||||||
|
|
||||||
|
export type RecipientActionAuthSelectProps = SelectProps;
|
||||||
|
|
||||||
|
export const RecipientActionAuthSelect = (props: RecipientActionAuthSelectProps) => {
|
||||||
|
return (
|
||||||
|
<Select {...props}>
|
||||||
|
<SelectTrigger className="bg-background text-muted-foreground">
|
||||||
|
<SelectValue placeholder="Inherit authentication method" />
|
||||||
|
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger className="-mr-1 ml-auto">
|
||||||
|
<InfoIcon className="mx-2 h-4 w-4" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
|
||||||
|
<TooltipContent className="text-foreground max-w-md p-4">
|
||||||
|
<h2>
|
||||||
|
<strong>Recipient action authentication</strong>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<p>The authentication required for recipients to sign fields</p>
|
||||||
|
|
||||||
|
<p className="mt-2">This will override any global settings.</p>
|
||||||
|
|
||||||
|
<ul className="ml-3.5 list-outside list-disc space-y-0.5 py-2">
|
||||||
|
<li>
|
||||||
|
<strong>Inherit authentication method</strong> - Use the global action signing
|
||||||
|
authentication method configured in the "General Settings" step
|
||||||
|
</li>
|
||||||
|
{/* <li>
|
||||||
|
<strong>Require account</strong> - The recipient must be
|
||||||
|
signed in
|
||||||
|
</li> */}
|
||||||
|
<li>
|
||||||
|
<strong>Require passkey</strong> - The recipient must have an account and passkey
|
||||||
|
configured via their settings
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>Require 2FA</strong> - The recipient must have an account and 2FA enabled
|
||||||
|
via their settings
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>None</strong> - No authentication required
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</SelectTrigger>
|
||||||
|
|
||||||
|
<SelectContent position="popper">
|
||||||
|
{/* Note: -1 is remapped in the Zod schema to the required value. */}
|
||||||
|
<SelectItem value="-1">Inherit authentication method</SelectItem>
|
||||||
|
|
||||||
|
{Object.values(RecipientActionAuth)
|
||||||
|
.filter((auth) => auth !== RecipientActionAuth.ACCOUNT)
|
||||||
|
.map((authType) => (
|
||||||
|
<SelectItem key={authType} value={authType}>
|
||||||
|
{DOCUMENT_AUTH_TYPES[authType].value}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
};
|
||||||
97
packages/ui/components/recipient/recipient-role-select.tsx
Normal file
97
packages/ui/components/recipient/recipient-role-select.tsx
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import type { SelectProps } from '@radix-ui/react-select';
|
||||||
|
import { InfoIcon } from 'lucide-react';
|
||||||
|
|
||||||
|
import { RecipientRole } from '@documenso/prisma/client';
|
||||||
|
import { ROLE_ICONS } from '@documenso/ui/primitives/recipient-role-icons';
|
||||||
|
import { Select, SelectContent, SelectItem, SelectTrigger } from '@documenso/ui/primitives/select';
|
||||||
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@documenso/ui/primitives/tooltip';
|
||||||
|
|
||||||
|
export type RecipientRoleSelectProps = SelectProps;
|
||||||
|
|
||||||
|
export const RecipientRoleSelect = (props: RecipientRoleSelectProps) => {
|
||||||
|
return (
|
||||||
|
<Select {...props}>
|
||||||
|
<SelectTrigger className="bg-background w-[60px]">
|
||||||
|
{/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */}
|
||||||
|
{ROLE_ICONS[props.value as RecipientRole]}
|
||||||
|
</SelectTrigger>
|
||||||
|
|
||||||
|
<SelectContent align="end">
|
||||||
|
<SelectItem value={RecipientRole.SIGNER}>
|
||||||
|
<div className="flex items-center">
|
||||||
|
<div className="flex w-[150px] items-center">
|
||||||
|
<span className="mr-2">{ROLE_ICONS[RecipientRole.SIGNER]}</span>
|
||||||
|
Needs to sign
|
||||||
|
</div>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<InfoIcon className="h-4 w-4" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
||||||
|
<p>The recipient is required to sign the document for it to be completed.</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
|
||||||
|
<SelectItem value={RecipientRole.APPROVER}>
|
||||||
|
<div className="flex items-center">
|
||||||
|
<div className="flex w-[150px] items-center">
|
||||||
|
<span className="mr-2">{ROLE_ICONS[RecipientRole.APPROVER]}</span>
|
||||||
|
Needs to approve
|
||||||
|
</div>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<InfoIcon className="h-4 w-4" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
||||||
|
<p>The recipient is required to approve the document for it to be completed.</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
|
||||||
|
<SelectItem value={RecipientRole.VIEWER}>
|
||||||
|
<div className="flex items-center">
|
||||||
|
<div className="flex w-[150px] items-center">
|
||||||
|
<span className="mr-2">{ROLE_ICONS[RecipientRole.VIEWER]}</span>
|
||||||
|
Needs to view
|
||||||
|
</div>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<InfoIcon className="h-4 w-4" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
||||||
|
<p>The recipient is required to view the document for it to be completed.</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
|
||||||
|
<SelectItem value={RecipientRole.CC}>
|
||||||
|
<div className="flex items-center">
|
||||||
|
<div className="flex w-[150px] items-center">
|
||||||
|
<span className="mr-2">{ROLE_ICONS[RecipientRole.CC]}</span>
|
||||||
|
Receives copy
|
||||||
|
</div>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<InfoIcon className="h-4 w-4" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
||||||
|
<p>
|
||||||
|
The recipient is not required to take any action and receives a copy of the
|
||||||
|
document after it is completed.
|
||||||
|
</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -4,20 +4,18 @@ import React, { useId, useMemo, useState } from 'react';
|
|||||||
|
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { InfoIcon, Plus, Trash } from 'lucide-react';
|
import { Plus, Trash } from 'lucide-react';
|
||||||
import { useSession } from 'next-auth/react';
|
import { useSession } from 'next-auth/react';
|
||||||
import { useFieldArray, useForm } from 'react-hook-form';
|
import { useFieldArray, useForm } from 'react-hook-form';
|
||||||
|
|
||||||
import { useLimits } from '@documenso/ee/server-only/limits/provider/client';
|
import { useLimits } from '@documenso/ee/server-only/limits/provider/client';
|
||||||
import { DOCUMENT_AUTH_TYPES } from '@documenso/lib/constants/document-auth';
|
import { ZRecipientAuthOptionsSchema } from '@documenso/lib/types/document-auth';
|
||||||
import {
|
|
||||||
RecipientActionAuth,
|
|
||||||
ZRecipientAuthOptionsSchema,
|
|
||||||
} from '@documenso/lib/types/document-auth';
|
|
||||||
import { nanoid } from '@documenso/lib/universal/id';
|
import { nanoid } from '@documenso/lib/universal/id';
|
||||||
import type { Field, Recipient } from '@documenso/prisma/client';
|
import type { Field, Recipient } from '@documenso/prisma/client';
|
||||||
import { RecipientRole, SendStatus } from '@documenso/prisma/client';
|
import { RecipientRole, SendStatus } from '@documenso/prisma/client';
|
||||||
import { AnimateGenericFadeInOut } from '@documenso/ui/components/animate/animate-generic-fade-in-out';
|
import { AnimateGenericFadeInOut } from '@documenso/ui/components/animate/animate-generic-fade-in-out';
|
||||||
|
import { RecipientActionAuthSelect } from '@documenso/ui/components/recipient/recipient-action-auth-select';
|
||||||
|
import { RecipientRoleSelect } from '@documenso/ui/components/recipient/recipient-role-select';
|
||||||
import { cn } from '@documenso/ui/lib/utils';
|
import { cn } from '@documenso/ui/lib/utils';
|
||||||
|
|
||||||
import { Button } from '../button';
|
import { Button } from '../button';
|
||||||
@@ -25,10 +23,7 @@ import { Checkbox } from '../checkbox';
|
|||||||
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '../form/form';
|
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '../form/form';
|
||||||
import { FormErrorMessage } from '../form/form-error-message';
|
import { FormErrorMessage } from '../form/form-error-message';
|
||||||
import { Input } from '../input';
|
import { Input } from '../input';
|
||||||
import { ROLE_ICONS } from '../recipient-role-icons';
|
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../select';
|
|
||||||
import { useStep } from '../stepper';
|
import { useStep } from '../stepper';
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip';
|
|
||||||
import { useToast } from '../use-toast';
|
import { useToast } from '../use-toast';
|
||||||
import type { TAddSignersFormSchema } from './add-signers.types';
|
import type { TAddSignersFormSchema } from './add-signers.types';
|
||||||
import { ZAddSignersFormSchema } from './add-signers.types';
|
import { ZAddSignersFormSchema } from './add-signers.types';
|
||||||
@@ -274,67 +269,11 @@ export const AddSignersFormPartial = ({
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="col-span-6">
|
<FormItem className="col-span-6">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Select
|
<RecipientActionAuthSelect
|
||||||
{...field}
|
{...field}
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
disabled={isSubmitting || hasBeenSentToRecipientId(signer.nativeId)}
|
disabled={isSubmitting || hasBeenSentToRecipientId(signer.nativeId)}
|
||||||
>
|
/>
|
||||||
<SelectTrigger className="bg-background text-muted-foreground">
|
|
||||||
<SelectValue placeholder="Inherit authentication method" />
|
|
||||||
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger className="-mr-1 ml-auto">
|
|
||||||
<InfoIcon className="mx-2 h-4 w-4" />
|
|
||||||
</TooltipTrigger>
|
|
||||||
|
|
||||||
<TooltipContent className="text-foreground max-w-md p-4">
|
|
||||||
<h2>
|
|
||||||
<strong>Recipient action authentication</strong>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<p>The authentication required for recipients to sign fields</p>
|
|
||||||
|
|
||||||
<p className="mt-2">This will override any global settings.</p>
|
|
||||||
|
|
||||||
<ul className="ml-3.5 list-outside list-disc space-y-0.5 py-2">
|
|
||||||
<li>
|
|
||||||
<strong>Inherit authentication method</strong> - Use the
|
|
||||||
global action signing authentication method configured in
|
|
||||||
the "General Settings" step
|
|
||||||
</li>
|
|
||||||
{/* <li>
|
|
||||||
<strong>Require account</strong> - The recipient must be
|
|
||||||
signed in
|
|
||||||
</li> */}
|
|
||||||
<li>
|
|
||||||
<strong>Require passkey</strong> - The recipient must have
|
|
||||||
an account and passkey configured via their settings
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<strong>Require 2FA</strong> - The recipient must have an
|
|
||||||
account and 2FA enabled via their settings
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<strong>None</strong> - No authentication required
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</SelectTrigger>
|
|
||||||
|
|
||||||
<SelectContent position="popper">
|
|
||||||
{/* Note: -1 is remapped in the Zod schema to the required value. */}
|
|
||||||
<SelectItem value="-1">Inherit authentication method</SelectItem>
|
|
||||||
|
|
||||||
{Object.values(RecipientActionAuth)
|
|
||||||
.filter((auth) => auth !== RecipientActionAuth.ACCOUNT)
|
|
||||||
.map((authType) => (
|
|
||||||
<SelectItem key={authType} value={authType}>
|
|
||||||
{DOCUMENT_AUTH_TYPES[authType].value}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
@@ -348,100 +287,11 @@ export const AddSignersFormPartial = ({
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="col-span-1 mt-auto">
|
<FormItem className="col-span-1 mt-auto">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Select
|
<RecipientRoleSelect
|
||||||
{...field}
|
{...field}
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
disabled={isSubmitting || hasBeenSentToRecipientId(signer.nativeId)}
|
disabled={isSubmitting || hasBeenSentToRecipientId(signer.nativeId)}
|
||||||
>
|
/>
|
||||||
<SelectTrigger className="bg-background w-[60px]">
|
|
||||||
{/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */}
|
|
||||||
{ROLE_ICONS[field.value as RecipientRole]}
|
|
||||||
</SelectTrigger>
|
|
||||||
|
|
||||||
<SelectContent align="end">
|
|
||||||
<SelectItem value={RecipientRole.SIGNER}>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="flex w-[150px] items-center">
|
|
||||||
<span className="mr-2">{ROLE_ICONS[RecipientRole.SIGNER]}</span>
|
|
||||||
Needs to sign
|
|
||||||
</div>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger>
|
|
||||||
<InfoIcon className="h-4 w-4" />
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
|
||||||
<p>
|
|
||||||
The recipient is required to sign the document for it to be
|
|
||||||
completed.
|
|
||||||
</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</SelectItem>
|
|
||||||
|
|
||||||
<SelectItem value={RecipientRole.APPROVER}>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="flex w-[150px] items-center">
|
|
||||||
<span className="mr-2">
|
|
||||||
{ROLE_ICONS[RecipientRole.APPROVER]}
|
|
||||||
</span>
|
|
||||||
Needs to approve
|
|
||||||
</div>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger>
|
|
||||||
<InfoIcon className="h-4 w-4" />
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
|
||||||
<p>
|
|
||||||
The recipient is required to approve the document for it to
|
|
||||||
be completed.
|
|
||||||
</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</SelectItem>
|
|
||||||
|
|
||||||
<SelectItem value={RecipientRole.VIEWER}>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="flex w-[150px] items-center">
|
|
||||||
<span className="mr-2">{ROLE_ICONS[RecipientRole.VIEWER]}</span>
|
|
||||||
Needs to view
|
|
||||||
</div>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger>
|
|
||||||
<InfoIcon className="h-4 w-4" />
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
|
||||||
<p>
|
|
||||||
The recipient is required to view the document for it to be
|
|
||||||
completed.
|
|
||||||
</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</SelectItem>
|
|
||||||
|
|
||||||
<SelectItem value={RecipientRole.CC}>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="flex w-[150px] items-center">
|
|
||||||
<span className="mr-2">{ROLE_ICONS[RecipientRole.CC]}</span>
|
|
||||||
Receives copy
|
|
||||||
</div>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger>
|
|
||||||
<InfoIcon className="h-4 w-4" />
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
|
||||||
<p>
|
|
||||||
The recipient is not required to take any action and
|
|
||||||
receives a copy of the document after it is completed.
|
|
||||||
</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
|
|||||||
@@ -1,20 +1,25 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useId, useState } from 'react';
|
import React, { useId, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { InfoIcon, Plus, Trash } from 'lucide-react';
|
import { Plus, Trash } from 'lucide-react';
|
||||||
import { useSession } from 'next-auth/react';
|
import { useSession } from 'next-auth/react';
|
||||||
import { Controller, useFieldArray, useForm } from 'react-hook-form';
|
import { useFieldArray, useForm } from 'react-hook-form';
|
||||||
|
|
||||||
|
import { ZRecipientAuthOptionsSchema } from '@documenso/lib/types/document-auth';
|
||||||
import { nanoid } from '@documenso/lib/universal/id';
|
import { nanoid } from '@documenso/lib/universal/id';
|
||||||
import { type Field, type Recipient, RecipientRole } from '@documenso/prisma/client';
|
import { type Field, type Recipient, RecipientRole } from '@documenso/prisma/client';
|
||||||
|
import { AnimateGenericFadeInOut } from '@documenso/ui/components/animate/animate-generic-fade-in-out';
|
||||||
|
import { RecipientActionAuthSelect } from '@documenso/ui/components/recipient/recipient-action-auth-select';
|
||||||
|
import { RecipientRoleSelect } from '@documenso/ui/components/recipient/recipient-role-select';
|
||||||
|
import { cn } from '@documenso/ui/lib/utils';
|
||||||
import { Button } from '@documenso/ui/primitives/button';
|
import { Button } from '@documenso/ui/primitives/button';
|
||||||
import { FormErrorMessage } from '@documenso/ui/primitives/form/form-error-message';
|
import { FormErrorMessage } from '@documenso/ui/primitives/form/form-error-message';
|
||||||
import { Input } from '@documenso/ui/primitives/input';
|
import { Input } from '@documenso/ui/primitives/input';
|
||||||
import { Label } from '@documenso/ui/primitives/label';
|
|
||||||
|
|
||||||
|
import { Checkbox } from '../checkbox';
|
||||||
import {
|
import {
|
||||||
DocumentFlowFormContainerActions,
|
DocumentFlowFormContainerActions,
|
||||||
DocumentFlowFormContainerContent,
|
DocumentFlowFormContainerContent,
|
||||||
@@ -22,10 +27,8 @@ import {
|
|||||||
DocumentFlowFormContainerStep,
|
DocumentFlowFormContainerStep,
|
||||||
} from '../document-flow/document-flow-root';
|
} from '../document-flow/document-flow-root';
|
||||||
import type { DocumentFlowStep } from '../document-flow/types';
|
import type { DocumentFlowStep } from '../document-flow/types';
|
||||||
import { ROLE_ICONS } from '../recipient-role-icons';
|
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '../form/form';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger } from '../select';
|
|
||||||
import { useStep } from '../stepper';
|
import { useStep } from '../stepper';
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip';
|
|
||||||
import type { TAddTemplatePlacholderRecipientsFormSchema } from './add-template-placeholder-recipients.types';
|
import type { TAddTemplatePlacholderRecipientsFormSchema } from './add-template-placeholder-recipients.types';
|
||||||
import { ZAddTemplatePlacholderRecipientsFormSchema } from './add-template-placeholder-recipients.types';
|
import { ZAddTemplatePlacholderRecipientsFormSchema } from './add-template-placeholder-recipients.types';
|
||||||
|
|
||||||
@@ -33,30 +36,29 @@ export type AddTemplatePlaceholderRecipientsFormProps = {
|
|||||||
documentFlow: DocumentFlowStep;
|
documentFlow: DocumentFlowStep;
|
||||||
recipients: Recipient[];
|
recipients: Recipient[];
|
||||||
fields: Field[];
|
fields: Field[];
|
||||||
|
isTemplateOwnerEnterprise: boolean;
|
||||||
onSubmit: (_data: TAddTemplatePlacholderRecipientsFormSchema) => void;
|
onSubmit: (_data: TAddTemplatePlacholderRecipientsFormSchema) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
||||||
documentFlow,
|
documentFlow,
|
||||||
|
isTemplateOwnerEnterprise,
|
||||||
recipients,
|
recipients,
|
||||||
fields: _fields,
|
fields: _fields,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
}: AddTemplatePlaceholderRecipientsFormProps) => {
|
}: AddTemplatePlaceholderRecipientsFormProps) => {
|
||||||
const initialId = useId();
|
const initialId = useId();
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
|
||||||
const user = session?.user;
|
const user = session?.user;
|
||||||
|
|
||||||
const [placeholderRecipientCount, setPlaceholderRecipientCount] = useState(() =>
|
const [placeholderRecipientCount, setPlaceholderRecipientCount] = useState(() =>
|
||||||
recipients.length > 1 ? recipients.length + 1 : 2,
|
recipients.length > 1 ? recipients.length + 1 : 2,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { currentStep, totalSteps, previousStep } = useStep();
|
const { currentStep, totalSteps, previousStep } = useStep();
|
||||||
|
|
||||||
const {
|
const form = useForm<TAddTemplatePlacholderRecipientsFormSchema>({
|
||||||
control,
|
|
||||||
handleSubmit,
|
|
||||||
getValues,
|
|
||||||
formState: { errors, isSubmitting },
|
|
||||||
} = useForm<TAddTemplatePlacholderRecipientsFormSchema>({
|
|
||||||
resolver: zodResolver(ZAddTemplatePlacholderRecipientsFormSchema),
|
resolver: zodResolver(ZAddTemplatePlacholderRecipientsFormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
signers:
|
signers:
|
||||||
@@ -67,6 +69,8 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
name: recipient.name,
|
name: recipient.name,
|
||||||
email: recipient.email,
|
email: recipient.email,
|
||||||
role: recipient.role,
|
role: recipient.role,
|
||||||
|
actionAuth:
|
||||||
|
ZRecipientAuthOptionsSchema.parse(recipient.authOptions)?.actionAuth ?? undefined,
|
||||||
}))
|
}))
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
@@ -74,12 +78,33 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
name: `Recipient 1`,
|
name: `Recipient 1`,
|
||||||
email: `recipient.1@documenso.com`,
|
email: `recipient.1@documenso.com`,
|
||||||
role: RecipientRole.SIGNER,
|
role: RecipientRole.SIGNER,
|
||||||
|
actionAuth: undefined,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const onFormSubmit = handleSubmit(onSubmit);
|
// Always show advanced settings if any recipient has auth options.
|
||||||
|
const alwaysShowAdvancedSettings = useMemo(() => {
|
||||||
|
const recipientHasAuthOptions = recipients.find((recipient) => {
|
||||||
|
const recipientAuthOptions = ZRecipientAuthOptionsSchema.parse(recipient.authOptions);
|
||||||
|
|
||||||
|
return recipientAuthOptions?.accessAuth || recipientAuthOptions?.actionAuth;
|
||||||
|
});
|
||||||
|
|
||||||
|
const formHasActionAuth = form.getValues('signers').find((signer) => signer.actionAuth);
|
||||||
|
|
||||||
|
return recipientHasAuthOptions !== undefined || formHasActionAuth !== undefined;
|
||||||
|
}, [recipients, form]);
|
||||||
|
|
||||||
|
const [showAdvancedSettings, setShowAdvancedSettings] = useState(alwaysShowAdvancedSettings);
|
||||||
|
|
||||||
|
const {
|
||||||
|
formState: { errors, isSubmitting },
|
||||||
|
control,
|
||||||
|
} = form;
|
||||||
|
|
||||||
|
const onFormSubmit = form.handleSubmit(onSubmit);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
append: appendSigner,
|
append: appendSigner,
|
||||||
@@ -102,8 +127,9 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
const onAddPlaceholderRecipient = () => {
|
const onAddPlaceholderRecipient = () => {
|
||||||
appendSigner({
|
appendSigner({
|
||||||
formId: nanoid(12),
|
formId: nanoid(12),
|
||||||
|
// Update TEMPLATE_RECIPIENT_NAME_PLACEHOLDER_REGEX if this is ever changed.
|
||||||
name: `Recipient ${placeholderRecipientCount}`,
|
name: `Recipient ${placeholderRecipientCount}`,
|
||||||
// Update TEMPLATE_RECIPIENT_PLACEHOLDER_REGEX if this is ever changed.
|
// Update TEMPLATE_RECIPIENT_EMAIL_PLACEHOLDER_REGEX if this is ever changed.
|
||||||
email: `recipient.${placeholderRecipientCount}@documenso.com`,
|
email: `recipient.${placeholderRecipientCount}@documenso.com`,
|
||||||
role: RecipientRole.SIGNER,
|
role: RecipientRole.SIGNER,
|
||||||
});
|
});
|
||||||
@@ -118,150 +144,118 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentFlowFormContainerContent>
|
<DocumentFlowFormContainerContent>
|
||||||
<div className="flex w-full flex-col gap-y-4">
|
<AnimateGenericFadeInOut motionKey={showAdvancedSettings ? 'Show' : 'Hide'}>
|
||||||
<AnimatePresence>
|
<Form {...form}>
|
||||||
|
<div className="flex w-full flex-col gap-y-2">
|
||||||
{signers.map((signer, index) => (
|
{signers.map((signer, index) => (
|
||||||
<motion.div
|
<motion.fieldset
|
||||||
key={signer.id}
|
key={signer.id}
|
||||||
data-native-id={signer.nativeId}
|
data-native-id={signer.nativeId}
|
||||||
className="flex flex-wrap items-end gap-x-4"
|
disabled={isSubmitting}
|
||||||
|
className={cn('grid grid-cols-8 gap-4 pb-4', {
|
||||||
|
'border-b pt-2': showAdvancedSettings,
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
<div className="flex-1">
|
<FormField
|
||||||
<Label htmlFor={`signer-${signer.id}-email`}>Email</Label>
|
control={form.control}
|
||||||
|
name={`signers.${index}.email`}
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem
|
||||||
|
className={cn('relative', {
|
||||||
|
'col-span-3': !showAdvancedSettings,
|
||||||
|
'col-span-4': showAdvancedSettings,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{!showAdvancedSettings && index === 0 && (
|
||||||
|
<FormLabel required>Email</FormLabel>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
id={`signer-${signer.id}-email`}
|
|
||||||
type="email"
|
type="email"
|
||||||
value={signer.email}
|
placeholder="Email"
|
||||||
disabled
|
{...field}
|
||||||
className="bg-background mt-2"
|
disabled={isSubmitting || signers[index].email === user?.email}
|
||||||
/>
|
/>
|
||||||
</div>
|
</FormControl>
|
||||||
|
|
||||||
<div className="flex-1">
|
<FormMessage />
|
||||||
<Label htmlFor={`signer-${signer.id}-name`}>Name</Label>
|
</FormItem>
|
||||||
|
)}
|
||||||
<Input
|
/>
|
||||||
id={`signer-${signer.id}-name`}
|
|
||||||
type="text"
|
<FormField
|
||||||
value={signer.name}
|
control={form.control}
|
||||||
disabled
|
name={`signers.${index}.name`}
|
||||||
className="bg-background mt-2"
|
render={({ field }) => (
|
||||||
/>
|
<FormItem
|
||||||
</div>
|
className={cn({
|
||||||
|
'col-span-3': !showAdvancedSettings,
|
||||||
<div className="w-[60px]">
|
'col-span-4': showAdvancedSettings,
|
||||||
<Controller
|
})}
|
||||||
control={control}
|
>
|
||||||
name={`signers.${index}.role`}
|
{!showAdvancedSettings && index === 0 && <FormLabel>Name</FormLabel>}
|
||||||
render={({ field: { value, onChange } }) => (
|
|
||||||
<Select value={value} onValueChange={(x) => onChange(x)}>
|
<FormControl>
|
||||||
<SelectTrigger className="bg-background">{ROLE_ICONS[value]}</SelectTrigger>
|
<Input
|
||||||
|
placeholder="Name"
|
||||||
<SelectContent className="" align="end">
|
{...field}
|
||||||
<SelectItem value={RecipientRole.SIGNER}>
|
disabled={isSubmitting || signers[index].email === user?.email}
|
||||||
<div className="flex items-center">
|
/>
|
||||||
<div className="flex w-[150px] items-center">
|
</FormControl>
|
||||||
<span className="mr-2">{ROLE_ICONS[RecipientRole.SIGNER]}</span>
|
|
||||||
Needs to sign
|
<FormMessage />
|
||||||
</div>
|
</FormItem>
|
||||||
<Tooltip>
|
)}
|
||||||
<TooltipTrigger>
|
/>
|
||||||
<InfoIcon className="h-4 w-4" />
|
|
||||||
</TooltipTrigger>
|
{showAdvancedSettings && isTemplateOwnerEnterprise && (
|
||||||
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
<FormField
|
||||||
<p>
|
control={form.control}
|
||||||
The recipient is required to sign the document for it to be
|
name={`signers.${index}.actionAuth`}
|
||||||
completed.
|
render={({ field }) => (
|
||||||
</p>
|
<FormItem className="col-span-6">
|
||||||
</TooltipContent>
|
<FormControl>
|
||||||
</Tooltip>
|
<RecipientActionAuthSelect
|
||||||
</div>
|
{...field}
|
||||||
</SelectItem>
|
onValueChange={field.onChange}
|
||||||
|
disabled={isSubmitting}
|
||||||
<SelectItem value={RecipientRole.APPROVER}>
|
/>
|
||||||
<div className="flex items-center">
|
</FormControl>
|
||||||
<div className="flex w-[150px] items-center">
|
|
||||||
<span className="mr-2">{ROLE_ICONS[RecipientRole.APPROVER]}</span>
|
<FormMessage />
|
||||||
Needs to approve
|
</FormItem>
|
||||||
</div>
|
)}
|
||||||
<Tooltip>
|
/>
|
||||||
<TooltipTrigger>
|
)}
|
||||||
<InfoIcon className="h-4 w-4" />
|
|
||||||
</TooltipTrigger>
|
<FormField
|
||||||
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
name={`signers.${index}.role`}
|
||||||
<p>
|
render={({ field }) => (
|
||||||
The recipient is required to approve the document for it to be
|
<FormItem className="col-span-1 mt-auto">
|
||||||
completed.
|
<FormControl>
|
||||||
</p>
|
<RecipientRoleSelect
|
||||||
</TooltipContent>
|
{...field}
|
||||||
</Tooltip>
|
onValueChange={field.onChange}
|
||||||
</div>
|
disabled={isSubmitting}
|
||||||
</SelectItem>
|
/>
|
||||||
|
</FormControl>
|
||||||
<SelectItem value={RecipientRole.VIEWER}>
|
|
||||||
<div className="flex items-center">
|
<FormMessage />
|
||||||
<div className="flex w-[150px] items-center">
|
</FormItem>
|
||||||
<span className="mr-2">{ROLE_ICONS[RecipientRole.VIEWER]}</span>
|
|
||||||
Needs to view
|
|
||||||
</div>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger>
|
|
||||||
<InfoIcon className="h-4 w-4" />
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
|
||||||
<p>
|
|
||||||
The recipient is required to view the document for it to be
|
|
||||||
completed.
|
|
||||||
</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</SelectItem>
|
|
||||||
|
|
||||||
<SelectItem value={RecipientRole.CC}>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="flex w-[150px] items-center">
|
|
||||||
<span className="mr-2">{ROLE_ICONS[RecipientRole.CC]}</span>
|
|
||||||
Receives copy
|
|
||||||
</div>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger>
|
|
||||||
<InfoIcon className="h-4 w-4" />
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
|
||||||
<p>
|
|
||||||
The recipient is not required to take any action and receives a
|
|
||||||
copy of the document after it is completed.
|
|
||||||
</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="inline-flex h-10 w-10 items-center justify-center text-slate-500 hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50"
|
className="col-span-1 mt-auto inline-flex h-10 w-10 items-center justify-center text-slate-500 hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50"
|
||||||
disabled={isSubmitting || signers.length === 1}
|
disabled={isSubmitting || signers.length === 1}
|
||||||
onClick={() => onRemoveSigner(index)}
|
onClick={() => onRemoveSigner(index)}
|
||||||
>
|
>
|
||||||
<Trash className="h-5 w-5" />
|
<Trash className="h-5 w-5" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</motion.fieldset>
|
||||||
|
|
||||||
<div className="w-full">
|
|
||||||
<FormErrorMessage className="mt-2" error={errors.signers?.[index]?.email} />
|
|
||||||
<FormErrorMessage className="mt-2" error={errors.signers?.[index]?.name} />
|
|
||||||
</div>
|
|
||||||
</motion.div>
|
|
||||||
))}
|
))}
|
||||||
</AnimatePresence>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<FormErrorMessage
|
<FormErrorMessage
|
||||||
@@ -270,7 +264,11 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
error={'signers__root' in errors && errors['signers__root']}
|
error={'signers__root' in errors && errors['signers__root']}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="mt-4 flex flex-row items-center space-x-4">
|
<div
|
||||||
|
className={cn('mt-2 flex flex-row items-center space-x-4', {
|
||||||
|
'mt-4': showAdvancedSettings,
|
||||||
|
})}
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
className="flex-1"
|
className="flex-1"
|
||||||
@@ -280,12 +278,14 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
<Plus className="-ml-1 mr-2 h-5 w-5" />
|
<Plus className="-ml-1 mr-2 h-5 w-5" />
|
||||||
Add Placeholder Recipient
|
Add Placeholder Recipient
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
className="dark:bg-muted dark:hover:bg-muted/80 bg-black/5 hover:bg-black/10"
|
className="dark:bg-muted dark:hover:bg-muted/80 bg-black/5 hover:bg-black/10"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
disabled={
|
disabled={
|
||||||
isSubmitting || getValues('signers').some((signer) => signer.email === user?.email)
|
isSubmitting ||
|
||||||
|
form.getValues('signers').some((signer) => signer.email === user?.email)
|
||||||
}
|
}
|
||||||
onClick={() => onAddPlaceholderSelfRecipient()}
|
onClick={() => onAddPlaceholderSelfRecipient()}
|
||||||
>
|
>
|
||||||
@@ -293,6 +293,27 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
Add Myself
|
Add Myself
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{!alwaysShowAdvancedSettings && isTemplateOwnerEnterprise && (
|
||||||
|
<div className="mt-4 flex flex-row items-center">
|
||||||
|
<Checkbox
|
||||||
|
id="showAdvancedRecipientSettings"
|
||||||
|
className="h-5 w-5"
|
||||||
|
checkClassName="dark:text-white text-primary"
|
||||||
|
checked={showAdvancedSettings}
|
||||||
|
onCheckedChange={(value) => setShowAdvancedSettings(Boolean(value))}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<label
|
||||||
|
className="text-muted-foreground ml-2 text-sm"
|
||||||
|
htmlFor="showAdvancedRecipientSettings"
|
||||||
|
>
|
||||||
|
Show advanced settings
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Form>
|
||||||
|
</AnimateGenericFadeInOut>
|
||||||
</DocumentFlowFormContainerContent>
|
</DocumentFlowFormContainerContent>
|
||||||
|
|
||||||
<DocumentFlowFormContainerFooter>
|
<DocumentFlowFormContainerFooter>
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import { ZRecipientActionAuthTypesSchema } from '@documenso/lib/types/document-auth';
|
||||||
|
|
||||||
|
import { ZMapNegativeOneToUndefinedSchema } from '../document-flow/add-settings.types';
|
||||||
import { RecipientRole } from '.prisma/client';
|
import { RecipientRole } from '.prisma/client';
|
||||||
|
|
||||||
export const ZAddTemplatePlacholderRecipientsFormSchema = z
|
export const ZAddTemplatePlacholderRecipientsFormSchema = z
|
||||||
@@ -11,6 +14,9 @@ export const ZAddTemplatePlacholderRecipientsFormSchema = z
|
|||||||
email: z.string().min(1).email(),
|
email: z.string().min(1).email(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
role: z.nativeEnum(RecipientRole),
|
role: z.nativeEnum(RecipientRole),
|
||||||
|
actionAuth: ZMapNegativeOneToUndefinedSchema.pipe(
|
||||||
|
ZRecipientActionAuthTypesSchema.optional(),
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user