mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
chore: implement feedback
This commit is contained in:
@ -8,8 +8,8 @@ import { useFieldArray, useForm } from 'react-hook-form';
|
||||
import { nanoid } from '@documenso/lib/universal/id';
|
||||
import { AttachmentType } from '@documenso/prisma/generated/types';
|
||||
import { trpc } from '@documenso/trpc/react';
|
||||
import type { TSetDocumentAttachmentsSchema } from '@documenso/trpc/server/attachment-router/schema';
|
||||
import { ZSetDocumentAttachmentsSchema } from '@documenso/trpc/server/attachment-router/schema';
|
||||
import type { TSetDocumentAttachmentsSchema } from '@documenso/trpc/server/document-router/set-document-attachments.types';
|
||||
import { ZSetDocumentAttachmentsSchema } from '@documenso/trpc/server/document-router/set-document-attachments.types';
|
||||
import { Button } from '@documenso/ui/primitives/button';
|
||||
import {
|
||||
Dialog,
|
||||
@ -39,12 +39,11 @@ export const AttachmentForm = ({ documentId }: AttachmentFormProps) => {
|
||||
const { toast } = useToast();
|
||||
|
||||
const { data: attachmentsData, refetch: refetchAttachments } =
|
||||
trpc.attachment.getDocumentAttachments.useQuery({
|
||||
trpc.document.attachments.find.useQuery({
|
||||
documentId,
|
||||
});
|
||||
|
||||
const { mutateAsync: setDocumentAttachments } =
|
||||
trpc.attachment.setDocumentAttachments.useMutation();
|
||||
const { mutateAsync: setDocumentAttachments } = trpc.document.attachments.set.useMutation();
|
||||
|
||||
const defaultAttachments = [
|
||||
{
|
||||
|
||||
@ -8,8 +8,8 @@ import { useFieldArray, useForm } from 'react-hook-form';
|
||||
import { nanoid } from '@documenso/lib/universal/id';
|
||||
import { AttachmentType } from '@documenso/prisma/generated/types';
|
||||
import { trpc } from '@documenso/trpc/react';
|
||||
import type { TSetTemplateAttachmentsSchema } from '@documenso/trpc/server/attachment-router/schema';
|
||||
import { ZSetTemplateAttachmentsSchema } from '@documenso/trpc/server/attachment-router/schema';
|
||||
import type { TSetTemplateAttachmentsSchema } from '@documenso/trpc/server/template-router/set-template-attachments.types';
|
||||
import { ZSetTemplateAttachmentsSchema } from '@documenso/trpc/server/template-router/set-template-attachments.types';
|
||||
import { Button } from '@documenso/ui/primitives/button';
|
||||
import {
|
||||
Dialog,
|
||||
@ -39,12 +39,11 @@ export const AttachmentForm = ({ templateId }: AttachmentFormProps) => {
|
||||
const { t } = useLingui();
|
||||
|
||||
const { data: attachmentsData, refetch: refetchAttachments } =
|
||||
trpc.attachment.getTemplateAttachments.useQuery({
|
||||
trpc.template.attachments.find.useQuery({
|
||||
templateId,
|
||||
});
|
||||
|
||||
const { mutateAsync: setTemplateAttachments } =
|
||||
trpc.attachment.setTemplateAttachments.useMutation();
|
||||
const { mutateAsync: setTemplateAttachments } = trpc.template.attachments.set.useMutation();
|
||||
|
||||
const defaultAttachments = [
|
||||
{
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { buildTeamWhereQuery } from '../../utils/teams';
|
||||
|
||||
export type FindDocumentAttachmentsOptions = {
|
||||
documentId?: number;
|
||||
userId: number;
|
||||
teamId: number;
|
||||
};
|
||||
|
||||
export const findDocumentAttachments = async ({
|
||||
documentId,
|
||||
userId,
|
||||
teamId,
|
||||
}: FindDocumentAttachmentsOptions) => {
|
||||
const attachments = await prisma.attachment.findMany({
|
||||
where: {
|
||||
document: {
|
||||
id: documentId,
|
||||
team: buildTeamWhereQuery({ teamId, userId }),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return attachments;
|
||||
};
|
||||
@ -1,26 +0,0 @@
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { buildTeamWhereQuery } from '../../utils/teams';
|
||||
|
||||
export type FindTemplateAttachmentsOptions = {
|
||||
templateId: number;
|
||||
userId: number;
|
||||
teamId: number;
|
||||
};
|
||||
|
||||
export const findTemplateAttachments = async ({
|
||||
templateId,
|
||||
userId,
|
||||
teamId,
|
||||
}: FindTemplateAttachmentsOptions) => {
|
||||
const attachments = await prisma.attachment.findMany({
|
||||
where: {
|
||||
template: {
|
||||
id: templateId,
|
||||
team: buildTeamWhereQuery({ teamId, userId }),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return attachments;
|
||||
};
|
||||
@ -1,92 +0,0 @@
|
||||
import { findDocumentAttachments } from '@documenso/lib/server-only/attachment/find-document-attachments';
|
||||
import { findTemplateAttachments } from '@documenso/lib/server-only/attachment/find-template-attachments';
|
||||
import { setDocumentAttachments } from '@documenso/lib/server-only/attachment/set-document-attachments';
|
||||
import { setTemplateAttachments } from '@documenso/lib/server-only/attachment/set-template-attachments';
|
||||
|
||||
import { authenticatedProcedure, router } from '../trpc';
|
||||
import {
|
||||
ZGetDocumentAttachmentsResponseSchema,
|
||||
ZGetDocumentAttachmentsSchema,
|
||||
ZGetTemplateAttachmentsResponseSchema,
|
||||
ZGetTemplateAttachmentsSchema,
|
||||
ZSetDocumentAttachmentsResponseSchema,
|
||||
ZSetDocumentAttachmentsSchema,
|
||||
ZSetTemplateAttachmentsResponseSchema,
|
||||
ZSetTemplateAttachmentsSchema,
|
||||
} from './schema';
|
||||
|
||||
export const attachmentRouter = router({
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
getDocumentAttachments: authenticatedProcedure
|
||||
.input(ZGetDocumentAttachmentsSchema)
|
||||
.output(ZGetDocumentAttachmentsResponseSchema)
|
||||
.query(async ({ input, ctx }) => {
|
||||
const { documentId } = input;
|
||||
const { user } = ctx;
|
||||
|
||||
const attachments = await findDocumentAttachments({
|
||||
documentId,
|
||||
userId: user.id,
|
||||
teamId: ctx.teamId,
|
||||
});
|
||||
|
||||
return attachments;
|
||||
}),
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
setDocumentAttachments: authenticatedProcedure
|
||||
.input(ZSetDocumentAttachmentsSchema)
|
||||
.output(ZSetDocumentAttachmentsResponseSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const { documentId, attachments } = input;
|
||||
|
||||
const updatedAttachments = await setDocumentAttachments({
|
||||
documentId,
|
||||
attachments,
|
||||
user: ctx.user,
|
||||
teamId: ctx.teamId,
|
||||
requestMetadata: ctx.metadata.requestMetadata,
|
||||
});
|
||||
|
||||
return updatedAttachments;
|
||||
}),
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
getTemplateAttachments: authenticatedProcedure
|
||||
.input(ZGetTemplateAttachmentsSchema)
|
||||
.output(ZGetTemplateAttachmentsResponseSchema)
|
||||
.query(async ({ input, ctx }) => {
|
||||
const { templateId } = input;
|
||||
|
||||
const attachments = await findTemplateAttachments({
|
||||
templateId,
|
||||
userId: ctx.user.id,
|
||||
teamId: ctx.teamId,
|
||||
});
|
||||
|
||||
return attachments;
|
||||
}),
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
setTemplateAttachments: authenticatedProcedure
|
||||
.input(ZSetTemplateAttachmentsSchema)
|
||||
.output(ZSetTemplateAttachmentsResponseSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const { templateId, attachments } = input;
|
||||
|
||||
const updatedAttachments = await setTemplateAttachments({
|
||||
templateId,
|
||||
userId: ctx.user.id,
|
||||
teamId: ctx.teamId,
|
||||
attachments,
|
||||
});
|
||||
|
||||
return updatedAttachments;
|
||||
}),
|
||||
});
|
||||
@ -1,75 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { AttachmentType } from '@documenso/prisma/generated/types';
|
||||
|
||||
export const ZGetDocumentAttachmentsSchema = z.object({
|
||||
documentId: z.number(),
|
||||
});
|
||||
|
||||
export const ZGetDocumentAttachmentsResponseSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
url: z.string(),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
);
|
||||
|
||||
export const ZGetTemplateAttachmentsSchema = z.object({
|
||||
templateId: z.number(),
|
||||
});
|
||||
|
||||
export const ZGetTemplateAttachmentsResponseSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
url: z.string(),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
);
|
||||
|
||||
export const ZSetDocumentAttachmentsSchema = z.object({
|
||||
documentId: z.number(),
|
||||
attachments: z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string().min(1, 'Label is required'),
|
||||
url: z.string().url('Invalid URL'),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export type TSetDocumentAttachmentsSchema = z.infer<typeof ZSetDocumentAttachmentsSchema>;
|
||||
|
||||
export const ZSetDocumentAttachmentsResponseSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
url: z.string(),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
);
|
||||
|
||||
export const ZSetTemplateAttachmentsSchema = z.object({
|
||||
templateId: z.number(),
|
||||
attachments: z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string().min(1, 'Label is required'),
|
||||
url: z.string().url('Invalid URL'),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export type TSetTemplateAttachmentsSchema = z.infer<typeof ZSetTemplateAttachmentsSchema>;
|
||||
|
||||
export const ZSetTemplateAttachmentsResponseSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
url: z.string(),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
);
|
||||
@ -0,0 +1,47 @@
|
||||
import { buildTeamWhereQuery } from '@documenso/lib/utils/teams';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { authenticatedProcedure } from '../trpc';
|
||||
import {
|
||||
ZGetDocumentAttachmentsResponseSchema,
|
||||
ZGetDocumentAttachmentsSchema,
|
||||
} from './find-document-attachments.types';
|
||||
|
||||
export const findDocumentAttachmentsRoute = authenticatedProcedure
|
||||
.input(ZGetDocumentAttachmentsSchema)
|
||||
.output(ZGetDocumentAttachmentsResponseSchema)
|
||||
.query(async ({ input, ctx }) => {
|
||||
const { documentId } = input;
|
||||
const { user } = ctx;
|
||||
|
||||
const attachments = await findDocumentAttachments({
|
||||
documentId,
|
||||
userId: user.id,
|
||||
teamId: ctx.teamId,
|
||||
});
|
||||
|
||||
return attachments;
|
||||
});
|
||||
|
||||
export type FindDocumentAttachmentsOptions = {
|
||||
documentId?: number;
|
||||
userId: number;
|
||||
teamId: number;
|
||||
};
|
||||
|
||||
export const findDocumentAttachments = async ({
|
||||
documentId,
|
||||
userId,
|
||||
teamId,
|
||||
}: FindDocumentAttachmentsOptions) => {
|
||||
const attachments = await prisma.attachment.findMany({
|
||||
where: {
|
||||
document: {
|
||||
id: documentId,
|
||||
team: buildTeamWhereQuery({ teamId, userId }),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return attachments;
|
||||
};
|
||||
@ -0,0 +1,16 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { AttachmentType } from '@documenso/prisma/generated/types';
|
||||
|
||||
export const ZGetDocumentAttachmentsSchema = z.object({
|
||||
documentId: z.number(),
|
||||
});
|
||||
|
||||
export const ZGetDocumentAttachmentsResponseSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
url: z.string(),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
);
|
||||
@ -27,6 +27,7 @@ import { getPresignPostUrl } from '@documenso/lib/universal/upload/server-action
|
||||
import { isDocumentCompleted } from '@documenso/lib/utils/document';
|
||||
|
||||
import { authenticatedProcedure, procedure, router } from '../trpc';
|
||||
import { findDocumentAttachmentsRoute } from './find-document-attachments';
|
||||
import { findInboxRoute } from './find-inbox';
|
||||
import { getInboxCountRoute } from './get-inbox-count';
|
||||
import {
|
||||
@ -55,6 +56,7 @@ import {
|
||||
ZSetSigningOrderForDocumentMutationSchema,
|
||||
ZSuccessResponseSchema,
|
||||
} from './schema';
|
||||
import { setDocumentAttachmentsRoute } from './set-document-attachments';
|
||||
import { updateDocumentRoute } from './update-document';
|
||||
|
||||
export const documentRouter = router({
|
||||
@ -63,6 +65,10 @@ export const documentRouter = router({
|
||||
getCount: getInboxCountRoute,
|
||||
},
|
||||
updateDocument: updateDocumentRoute,
|
||||
attachments: {
|
||||
find: findDocumentAttachmentsRoute,
|
||||
set: setDocumentAttachmentsRoute,
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@ -1,13 +1,35 @@
|
||||
import type { Attachment, User } from '@prisma/client';
|
||||
|
||||
import { AppError } from '@documenso/lib/errors/app-error';
|
||||
import { AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import { DOCUMENT_AUDIT_LOG_TYPE } from '@documenso/lib/types/document-audit-logs';
|
||||
import type { RequestMetadata } from '@documenso/lib/universal/extract-request-metadata';
|
||||
import { createDocumentAuditLogData } from '@documenso/lib/utils/document-audit-logs';
|
||||
import { buildTeamWhereQuery } from '@documenso/lib/utils/teams';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { AppError } from '../../errors/app-error';
|
||||
import { AppErrorCode } from '../../errors/app-error';
|
||||
import { DOCUMENT_AUDIT_LOG_TYPE } from '../../types/document-audit-logs';
|
||||
import { createDocumentAuditLogData } from '../../utils/document-audit-logs';
|
||||
import { buildTeamWhereQuery } from '../../utils/teams';
|
||||
import { authenticatedProcedure } from '../trpc';
|
||||
import {
|
||||
ZSetDocumentAttachmentsResponseSchema,
|
||||
ZSetDocumentAttachmentsSchema,
|
||||
} from './set-document-attachments.types';
|
||||
|
||||
export const setDocumentAttachmentsRoute = authenticatedProcedure
|
||||
.input(ZSetDocumentAttachmentsSchema)
|
||||
.output(ZSetDocumentAttachmentsResponseSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const { documentId, attachments } = input;
|
||||
|
||||
const updatedAttachments = await setDocumentAttachments({
|
||||
documentId,
|
||||
attachments,
|
||||
user: ctx.user,
|
||||
teamId: ctx.teamId,
|
||||
requestMetadata: ctx.metadata.requestMetadata,
|
||||
});
|
||||
|
||||
return updatedAttachments;
|
||||
});
|
||||
|
||||
export type CreateAttachmentsOptions = {
|
||||
documentId: number;
|
||||
@ -0,0 +1,26 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { AttachmentType } from '@documenso/prisma/generated/types';
|
||||
|
||||
export const ZSetDocumentAttachmentsSchema = z.object({
|
||||
documentId: z.number(),
|
||||
attachments: z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string().min(1, 'Label is required'),
|
||||
url: z.string().url('Invalid URL'),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export type TSetDocumentAttachmentsSchema = z.infer<typeof ZSetDocumentAttachmentsSchema>;
|
||||
|
||||
export const ZSetDocumentAttachmentsResponseSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
url: z.string(),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
);
|
||||
@ -1,6 +1,5 @@
|
||||
import { adminRouter } from './admin-router/router';
|
||||
import { apiTokenRouter } from './api-token-router/router';
|
||||
import { attachmentRouter } from './attachment-router/router';
|
||||
import { authRouter } from './auth-router/router';
|
||||
import { documentRouter } from './document-router/router';
|
||||
import { embeddingPresignRouter } from './embedding-router/_router';
|
||||
@ -32,7 +31,6 @@ export const appRouter = router({
|
||||
template: templateRouter,
|
||||
webhook: webhookRouter,
|
||||
embeddingPresign: embeddingPresignRouter,
|
||||
attachment: attachmentRouter,
|
||||
});
|
||||
|
||||
export type AppRouter = typeof appRouter;
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
import { buildTeamWhereQuery } from '@documenso/lib/utils/teams';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { authenticatedProcedure } from '../trpc';
|
||||
import {
|
||||
ZGetTemplateAttachmentsResponseSchema,
|
||||
ZGetTemplateAttachmentsSchema,
|
||||
} from './find-template-attachments.types';
|
||||
|
||||
export const findTemplateAttachmentsRoute = authenticatedProcedure
|
||||
.input(ZGetTemplateAttachmentsSchema)
|
||||
.output(ZGetTemplateAttachmentsResponseSchema)
|
||||
.query(async ({ input, ctx }) => {
|
||||
const { templateId } = input;
|
||||
|
||||
const attachments = await findTemplateAttachments({
|
||||
templateId,
|
||||
userId: ctx.user.id,
|
||||
teamId: ctx.teamId,
|
||||
});
|
||||
|
||||
return attachments;
|
||||
});
|
||||
|
||||
export type FindTemplateAttachmentsOptions = {
|
||||
templateId: number;
|
||||
userId: number;
|
||||
teamId: number;
|
||||
};
|
||||
|
||||
export const findTemplateAttachments = async ({
|
||||
templateId,
|
||||
userId,
|
||||
teamId,
|
||||
}: FindTemplateAttachmentsOptions) => {
|
||||
const attachments = await prisma.attachment.findMany({
|
||||
where: {
|
||||
template: {
|
||||
id: templateId,
|
||||
team: buildTeamWhereQuery({ teamId, userId }),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return attachments;
|
||||
};
|
||||
@ -0,0 +1,16 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { AttachmentType } from '@documenso/prisma/generated/types';
|
||||
|
||||
export const ZGetTemplateAttachmentsSchema = z.object({
|
||||
templateId: z.number(),
|
||||
});
|
||||
|
||||
export const ZGetTemplateAttachmentsResponseSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
url: z.string(),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
);
|
||||
@ -29,6 +29,7 @@ import { getPresignPostUrl } from '@documenso/lib/universal/upload/server-action
|
||||
|
||||
import { ZGenericSuccessResponse, ZSuccessResponseSchema } from '../document-router/schema';
|
||||
import { authenticatedProcedure, maybeAuthenticatedProcedure, router } from '../trpc';
|
||||
import { findTemplateAttachmentsRoute } from './find-template-attachments';
|
||||
import {
|
||||
ZBulkSendTemplateMutationSchema,
|
||||
ZCreateDocumentFromDirectTemplateRequestSchema,
|
||||
@ -52,8 +53,14 @@ import {
|
||||
ZUpdateTemplateRequestSchema,
|
||||
ZUpdateTemplateResponseSchema,
|
||||
} from './schema';
|
||||
import { setTemplateAttachmentsRoute } from './set-template-attachments';
|
||||
|
||||
export const templateRouter = router({
|
||||
attachments: {
|
||||
find: findTemplateAttachmentsRoute,
|
||||
set: setTemplateAttachmentsRoute,
|
||||
},
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
|
||||
@ -1,10 +1,31 @@
|
||||
import type { Attachment } from '@prisma/client';
|
||||
|
||||
import { AppError } from '@documenso/lib/errors/app-error';
|
||||
import { AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import { buildTeamWhereQuery } from '@documenso/lib/utils/teams';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { AppError } from '../../errors/app-error';
|
||||
import { AppErrorCode } from '../../errors/app-error';
|
||||
import { buildTeamWhereQuery } from '../../utils/teams';
|
||||
import { authenticatedProcedure } from '../trpc';
|
||||
import {
|
||||
ZSetTemplateAttachmentsResponseSchema,
|
||||
ZSetTemplateAttachmentsSchema,
|
||||
} from './set-template-attachments.types';
|
||||
|
||||
export const setTemplateAttachmentsRoute = authenticatedProcedure
|
||||
.input(ZSetTemplateAttachmentsSchema)
|
||||
.output(ZSetTemplateAttachmentsResponseSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const { templateId, attachments } = input;
|
||||
|
||||
const updatedAttachments = await setTemplateAttachments({
|
||||
templateId,
|
||||
userId: ctx.user.id,
|
||||
teamId: ctx.teamId,
|
||||
attachments,
|
||||
});
|
||||
|
||||
return updatedAttachments;
|
||||
});
|
||||
|
||||
export type CreateAttachmentsOptions = {
|
||||
templateId: number;
|
||||
@ -0,0 +1,26 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { AttachmentType } from '@documenso/prisma/generated/types';
|
||||
|
||||
export const ZSetTemplateAttachmentsSchema = z.object({
|
||||
templateId: z.number(),
|
||||
attachments: z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string().min(1, 'Label is required'),
|
||||
url: z.string().url('Invalid URL'),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export type TSetTemplateAttachmentsSchema = z.infer<typeof ZSetTemplateAttachmentsSchema>;
|
||||
|
||||
export const ZSetTemplateAttachmentsResponseSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
url: z.string(),
|
||||
type: z.nativeEnum(AttachmentType),
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user