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 { subject, message, timezone, dateFormat } = data.meta;
|
||||
const { subject, message, timezone, dateFormat, redirectUrl } = data.meta;
|
||||
|
||||
try {
|
||||
await sendDocument({
|
||||
@ -157,8 +157,9 @@ export const EditDocumentForm = ({
|
||||
meta: {
|
||||
subject,
|
||||
message,
|
||||
timezone,
|
||||
dateFormat,
|
||||
timezone,
|
||||
redirectUrl,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ export type CreateDocumentMetaOptions = {
|
||||
timezone?: string;
|
||||
password?: string;
|
||||
dateFormat?: string;
|
||||
redirectUrl?: string;
|
||||
userId: number;
|
||||
};
|
||||
|
||||
@ -20,6 +21,7 @@ export const upsertDocumentMeta = async ({
|
||||
documentId,
|
||||
userId,
|
||||
password,
|
||||
redirectUrl,
|
||||
}: CreateDocumentMetaOptions) => {
|
||||
await prisma.document.findFirstOrThrow({
|
||||
where: {
|
||||
@ -35,17 +37,19 @@ export const upsertDocumentMeta = async ({
|
||||
create: {
|
||||
subject,
|
||||
message,
|
||||
password,
|
||||
dateFormat,
|
||||
timezone,
|
||||
password,
|
||||
documentId,
|
||||
redirectUrl,
|
||||
},
|
||||
update: {
|
||||
subject,
|
||||
message,
|
||||
dateFormat,
|
||||
password,
|
||||
dateFormat,
|
||||
timezone,
|
||||
redirectUrl,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@ -166,6 +166,7 @@ model DocumentMeta {
|
||||
dateFormat String? @db.Text @default("yyyy-MM-dd hh:mm a")
|
||||
documentId Int @unique
|
||||
document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
||||
redirectUrl String? @db.Text
|
||||
}
|
||||
|
||||
enum ReadStatus {
|
||||
|
||||
@ -216,13 +216,14 @@ export const documentRouter = router({
|
||||
try {
|
||||
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({
|
||||
documentId,
|
||||
subject: meta.subject,
|
||||
message: meta.message,
|
||||
dateFormat: meta.dateFormat,
|
||||
timezone: meta.timezone,
|
||||
redirectUrl: meta.redirectUrl,
|
||||
userId: ctx.user.id,
|
||||
});
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ export const ZSendDocumentMutationSchema = z.object({
|
||||
message: z.string(),
|
||||
timezone: z.string(),
|
||||
dateFormat: z.string(),
|
||||
redirectUrl: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@ -60,7 +60,6 @@ export const AddSubjectFormPartial = ({
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors, isSubmitting, touchedFields },
|
||||
getValues,
|
||||
setValue,
|
||||
} = useForm<TAddSubjectFormSchema>({
|
||||
defaultValues: {
|
||||
@ -69,6 +68,7 @@ export const AddSubjectFormPartial = ({
|
||||
message: document.documentMeta?.message ?? '',
|
||||
timezone: document.documentMeta?.timezone ?? DEFAULT_DOCUMENT_TIME_ZONE,
|
||||
dateFormat: document.documentMeta?.dateFormat ?? DEFAULT_DOCUMENT_DATE_FORMAT,
|
||||
redirectUrl: document.documentMeta?.redirectUrl ?? '',
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -214,6 +214,28 @@ export const AddSubjectFormPartial = ({
|
||||
)}
|
||||
/>
|
||||
</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>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
|
||||
@ -9,6 +9,7 @@ export const ZAddSubjectFormSchema = z.object({
|
||||
message: z.string(),
|
||||
timezone: z.string().optional().default(DEFAULT_DOCUMENT_TIME_ZONE),
|
||||
dateFormat: z.string().optional().default(DEFAULT_DOCUMENT_DATE_FORMAT),
|
||||
redirectUrl: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user