mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
Compare commits
8 Commits
v1.12.2-rc
...
feat/add-m
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d569292ce | |||
| b1474de2da | |||
| 6b8ff4567d | |||
| 1a81b46859 | |||
| ef1d4ed0fa | |||
| 318a77c936 | |||
| 2bc0407d06 | |||
| 80de7d3ea9 |
@ -5,6 +5,7 @@ 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 { InfoIcon, Plus, Trash } from 'lucide-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';
|
||||||
@ -60,6 +61,8 @@ export const AddSignersFormPartial = ({
|
|||||||
}: AddSignersFormProps) => {
|
}: AddSignersFormProps) => {
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { remaining } = useLimits();
|
const { remaining } = useLimits();
|
||||||
|
const { data: session } = useSession();
|
||||||
|
const user = session?.user;
|
||||||
|
|
||||||
const initialId = useId();
|
const initialId = useId();
|
||||||
|
|
||||||
@ -135,6 +138,18 @@ export const AddSignersFormPartial = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onAddSelfSigner = () => {
|
||||||
|
const newSelfSignerId = nanoid(12);
|
||||||
|
|
||||||
|
appendSigner({
|
||||||
|
formId: newSelfSignerId,
|
||||||
|
name: user?.name ?? '',
|
||||||
|
email: user?.email ?? '',
|
||||||
|
role: RecipientRole.SIGNER,
|
||||||
|
actionAuth: undefined,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const onAddSigner = () => {
|
const onAddSigner = () => {
|
||||||
appendSigner({
|
appendSigner({
|
||||||
formId: nanoid(12),
|
formId: nanoid(12),
|
||||||
@ -209,8 +224,12 @@ export const AddSignersFormPartial = ({
|
|||||||
<Input
|
<Input
|
||||||
type="email"
|
type="email"
|
||||||
placeholder="Email"
|
placeholder="Email"
|
||||||
disabled={isSubmitting || hasBeenSentToRecipientId(signer.nativeId)}
|
|
||||||
{...field}
|
{...field}
|
||||||
|
disabled={
|
||||||
|
isSubmitting ||
|
||||||
|
hasBeenSentToRecipientId(signer.nativeId) ||
|
||||||
|
signers[index].email === user?.email
|
||||||
|
}
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
@ -237,8 +256,12 @@ export const AddSignersFormPartial = ({
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
placeholder="Name"
|
placeholder="Name"
|
||||||
disabled={isSubmitting || hasBeenSentToRecipientId(signer.nativeId)}
|
|
||||||
{...field}
|
{...field}
|
||||||
|
disabled={
|
||||||
|
isSubmitting ||
|
||||||
|
hasBeenSentToRecipientId(signer.nativeId) ||
|
||||||
|
signers[index].email === user?.email
|
||||||
|
}
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
@ -403,32 +426,46 @@ export const AddSignersFormPartial = ({
|
|||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
|
className="flex-1"
|
||||||
disabled={isSubmitting || signers.length >= remaining.recipients}
|
disabled={isSubmitting || signers.length >= remaining.recipients}
|
||||||
onClick={() => onAddSigner()}
|
onClick={() => onAddSigner()}
|
||||||
>
|
>
|
||||||
<Plus className="-ml-1 mr-2 h-5 w-5" />
|
<Plus className="-ml-1 mr-2 h-5 w-5" />
|
||||||
Add Signer
|
Add Signer
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
{!alwaysShowAdvancedSettings && isDocumentEnterprise && (
|
type="button"
|
||||||
<div className="flex flex-row items-center">
|
variant="secondary"
|
||||||
<Checkbox
|
className="dark:bg-muted dark:hover:bg-muted/80 bg-black/5 hover:bg-black/10"
|
||||||
id="showAdvancedRecipientSettings"
|
disabled={
|
||||||
className="h-5 w-5"
|
isSubmitting ||
|
||||||
checkClassName="dark:text-white text-primary"
|
form.getValues('signers').some((signer) => signer.email === user?.email)
|
||||||
checked={showAdvancedSettings}
|
}
|
||||||
onCheckedChange={(value) => setShowAdvancedSettings(Boolean(value))}
|
onClick={() => onAddSelfSigner()}
|
||||||
/>
|
>
|
||||||
|
<Plus className="-ml-1 mr-2 h-5 w-5" />
|
||||||
<label
|
Add myself
|
||||||
className="text-muted-foreground ml-2 text-sm"
|
</Button>
|
||||||
htmlFor="showAdvancedRecipientSettings"
|
|
||||||
>
|
|
||||||
Show advanced settings
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{!alwaysShowAdvancedSettings && isDocumentEnterprise && (
|
||||||
|
<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>
|
</Form>
|
||||||
</AnimateGenericFadeInOut>
|
</AnimateGenericFadeInOut>
|
||||||
</DocumentFlowFormContainerContent>
|
</DocumentFlowFormContainerContent>
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import React, { useId, useState } from 'react';
|
|||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import { Plus, Trash } from 'lucide-react';
|
import { Plus, Trash } from 'lucide-react';
|
||||||
|
import { useSession } from 'next-auth/react';
|
||||||
import { Controller, useFieldArray, useForm } from 'react-hook-form';
|
import { Controller, useFieldArray, useForm } from 'react-hook-form';
|
||||||
|
|
||||||
import { nanoid } from '@documenso/lib/universal/id';
|
import { nanoid } from '@documenso/lib/universal/id';
|
||||||
@ -41,6 +42,8 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
onSubmit,
|
onSubmit,
|
||||||
}: AddTemplatePlaceholderRecipientsFormProps) => {
|
}: AddTemplatePlaceholderRecipientsFormProps) => {
|
||||||
const initialId = useId();
|
const initialId = useId();
|
||||||
|
const { data: session } = useSession();
|
||||||
|
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,
|
||||||
);
|
);
|
||||||
@ -50,6 +53,7 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
|
getValues,
|
||||||
formState: { errors, isSubmitting },
|
formState: { errors, isSubmitting },
|
||||||
} = useForm<TAddTemplatePlacholderRecipientsFormSchema>({
|
} = useForm<TAddTemplatePlacholderRecipientsFormSchema>({
|
||||||
resolver: zodResolver(ZAddTemplatePlacholderRecipientsFormSchema),
|
resolver: zodResolver(ZAddTemplatePlacholderRecipientsFormSchema),
|
||||||
@ -85,6 +89,17 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
name: 'signers',
|
name: 'signers',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onAddPlaceholderSelfRecipient = () => {
|
||||||
|
const newSelfSignerId = nanoid(12);
|
||||||
|
|
||||||
|
appendSigner({
|
||||||
|
formId: newSelfSignerId,
|
||||||
|
name: user?.name ?? '',
|
||||||
|
email: user?.email ?? '',
|
||||||
|
role: RecipientRole.SIGNER,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const onAddPlaceholderRecipient = () => {
|
const onAddPlaceholderRecipient = () => {
|
||||||
appendSigner({
|
appendSigner({
|
||||||
formId: nanoid(12),
|
formId: nanoid(12),
|
||||||
@ -203,11 +218,27 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
error={'signers__root' in errors && errors['signers__root']}
|
error={'signers__root' in errors && errors['signers__root']}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="mt-4">
|
<div className="mt-4 flex flex-row items-center space-x-4">
|
||||||
<Button type="button" disabled={isSubmitting} onClick={() => onAddPlaceholderRecipient()}>
|
<Button
|
||||||
|
type="button"
|
||||||
|
className="flex-1"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
onClick={() => onAddPlaceholderRecipient()}
|
||||||
|
>
|
||||||
<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
|
||||||
|
type="button"
|
||||||
|
className="dark:bg-muted dark:hover:bg-muted/80 bg-black/5 hover:bg-black/10"
|
||||||
|
disabled={
|
||||||
|
isSubmitting || getValues('signers').some((signer) => signer.email === user?.email)
|
||||||
|
}
|
||||||
|
onClick={() => onAddPlaceholderSelfRecipient()}
|
||||||
|
>
|
||||||
|
<Plus className="-ml-1 mr-2 h-5 w-5" />
|
||||||
|
Add Myself
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</DocumentFlowFormContainerContent>
|
</DocumentFlowFormContainerContent>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user