chore: implement feedback part 1

new form component added for document attachments with Zod validation and TRPC integration.
This commit is contained in:
Catalin Pit
2025-07-04 16:29:57 +03:00
parent 0b03bd3fce
commit 52b474d12b
5 changed files with 241 additions and 136 deletions
@@ -0,0 +1,39 @@
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 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),
}),
);
+2
View File
@@ -1,5 +1,6 @@
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 { billingRouter } from './billing/router';
import { documentRouter } from './document-router/router';
@@ -31,6 +32,7 @@ export const appRouter = router({
template: templateRouter,
webhook: webhookRouter,
embeddingPresign: embeddingPresignRouter,
attachment: attachmentRouter,
});
export type AppRouter = typeof appRouter;