mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 15:53:02 +10:00
feat: add a feature for redirecting users on signing
Signed-off-by: Adithya Krishna <adi@documenso.com>
This commit is contained in:
@ -149,7 +149,7 @@ export const EditDocumentForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onAddSubjectFormSubmit = async (data: TAddSubjectFormSchema) => {
|
const onAddSubjectFormSubmit = async (data: TAddSubjectFormSchema) => {
|
||||||
const { subject, message, timezone, dateFormat } = data.meta;
|
const { subject, message, timezone, dateFormat, redirectUrl } = data.meta;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendDocument({
|
await sendDocument({
|
||||||
@ -157,8 +157,9 @@ export const EditDocumentForm = ({
|
|||||||
meta: {
|
meta: {
|
||||||
subject,
|
subject,
|
||||||
message,
|
message,
|
||||||
timezone,
|
|
||||||
dateFormat,
|
dateFormat,
|
||||||
|
timezone,
|
||||||
|
redirectUrl,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ export type CreateDocumentMetaOptions = {
|
|||||||
timezone?: string;
|
timezone?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
dateFormat?: string;
|
dateFormat?: string;
|
||||||
|
redirectUrl?: string;
|
||||||
userId: number;
|
userId: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ export const upsertDocumentMeta = async ({
|
|||||||
documentId,
|
documentId,
|
||||||
userId,
|
userId,
|
||||||
password,
|
password,
|
||||||
|
redirectUrl,
|
||||||
}: CreateDocumentMetaOptions) => {
|
}: CreateDocumentMetaOptions) => {
|
||||||
await prisma.document.findFirstOrThrow({
|
await prisma.document.findFirstOrThrow({
|
||||||
where: {
|
where: {
|
||||||
@ -35,17 +37,19 @@ export const upsertDocumentMeta = async ({
|
|||||||
create: {
|
create: {
|
||||||
subject,
|
subject,
|
||||||
message,
|
message,
|
||||||
|
password,
|
||||||
dateFormat,
|
dateFormat,
|
||||||
timezone,
|
timezone,
|
||||||
password,
|
|
||||||
documentId,
|
documentId,
|
||||||
|
redirectUrl,
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
subject,
|
subject,
|
||||||
message,
|
message,
|
||||||
dateFormat,
|
|
||||||
password,
|
password,
|
||||||
|
dateFormat,
|
||||||
timezone,
|
timezone,
|
||||||
|
redirectUrl,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -166,6 +166,7 @@ model DocumentMeta {
|
|||||||
dateFormat String? @db.Text @default("yyyy-MM-dd hh:mm a")
|
dateFormat String? @db.Text @default("yyyy-MM-dd hh:mm a")
|
||||||
documentId Int @unique
|
documentId Int @unique
|
||||||
document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
||||||
|
redirectUrl String? @db.Text
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ReadStatus {
|
enum ReadStatus {
|
||||||
|
|||||||
@ -216,13 +216,14 @@ export const documentRouter = router({
|
|||||||
try {
|
try {
|
||||||
const { documentId, meta } = input;
|
const { documentId, meta } = input;
|
||||||
|
|
||||||
if (meta.message || meta.subject || meta.timezone || meta.dateFormat) {
|
if (meta.message || meta.subject || meta.timezone || meta.dateFormat || meta.redirectUrl) {
|
||||||
await upsertDocumentMeta({
|
await upsertDocumentMeta({
|
||||||
documentId,
|
documentId,
|
||||||
subject: meta.subject,
|
subject: meta.subject,
|
||||||
message: meta.message,
|
message: meta.message,
|
||||||
dateFormat: meta.dateFormat,
|
dateFormat: meta.dateFormat,
|
||||||
timezone: meta.timezone,
|
timezone: meta.timezone,
|
||||||
|
redirectUrl: meta.redirectUrl,
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,7 @@ export const ZSendDocumentMutationSchema = z.object({
|
|||||||
message: z.string(),
|
message: z.string(),
|
||||||
timezone: z.string(),
|
timezone: z.string(),
|
||||||
dateFormat: z.string(),
|
dateFormat: z.string(),
|
||||||
|
redirectUrl: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,6 @@ export const AddSubjectFormPartial = ({
|
|||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors, isSubmitting, touchedFields },
|
formState: { errors, isSubmitting, touchedFields },
|
||||||
getValues,
|
|
||||||
setValue,
|
setValue,
|
||||||
} = useForm<TAddSubjectFormSchema>({
|
} = useForm<TAddSubjectFormSchema>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@ -69,6 +68,7 @@ export const AddSubjectFormPartial = ({
|
|||||||
message: document.documentMeta?.message ?? '',
|
message: document.documentMeta?.message ?? '',
|
||||||
timezone: document.documentMeta?.timezone ?? DEFAULT_DOCUMENT_TIME_ZONE,
|
timezone: document.documentMeta?.timezone ?? DEFAULT_DOCUMENT_TIME_ZONE,
|
||||||
dateFormat: document.documentMeta?.dateFormat ?? DEFAULT_DOCUMENT_DATE_FORMAT,
|
dateFormat: document.documentMeta?.dateFormat ?? DEFAULT_DOCUMENT_DATE_FORMAT,
|
||||||
|
redirectUrl: document.documentMeta?.redirectUrl ?? '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -214,6 +214,28 @@ export const AddSubjectFormPartial = ({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<div className="flex flex-col gap-y-4">
|
||||||
|
<div>
|
||||||
|
<Label htmlFor="redirectUrl">
|
||||||
|
Title
|
||||||
|
<span className="text-destructive ml-1 inline-block font-medium">
|
||||||
|
*
|
||||||
|
</span>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
id="redirectUrl"
|
||||||
|
className="bg-background my-2"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
{...register('meta.redirectUrl')}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormErrorMessage className="mt-2" error={errors.meta} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</AccordionContent>
|
</AccordionContent>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|||||||
@ -9,6 +9,7 @@ export const ZAddSubjectFormSchema = z.object({
|
|||||||
message: z.string(),
|
message: z.string(),
|
||||||
timezone: z.string().optional().default(DEFAULT_DOCUMENT_TIME_ZONE),
|
timezone: z.string().optional().default(DEFAULT_DOCUMENT_TIME_ZONE),
|
||||||
dateFormat: z.string().optional().default(DEFAULT_DOCUMENT_DATE_FORMAT),
|
dateFormat: z.string().optional().default(DEFAULT_DOCUMENT_DATE_FORMAT),
|
||||||
|
redirectUrl: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user