This commit is contained in:
David Nguyen
2025-02-12 16:41:35 +11:00
parent 548d92c2fc
commit 15922d447b
70 changed files with 889 additions and 551 deletions

View File

@ -7,7 +7,7 @@ import { FilePlus, Loader } from 'lucide-react';
import { useNavigate } from 'react-router';
import { useSession } from '@documenso/lib/client-only/providers/session';
import { AppError } from '@documenso/lib/errors/app-error';
import { putPdfFile } from '@documenso/lib/universal/upload/put-file';
import { trpc } from '@documenso/trpc/react';
import { Button } from '@documenso/ui/primitives/button';
import {
@ -48,27 +48,7 @@ export const TemplateCreateDialog = ({ templateRootPath }: TemplateCreateDialogP
setIsUploadingFile(true);
try {
// Todo
// const { type, data } = await putPdfFile(file);
const formData = new FormData();
formData.append('file', file);
const response = await fetch('/api/file', {
method: 'POST',
body: formData,
})
.then(async (res) => await res.json())
.catch((e) => {
console.error('Upload failed:', e);
throw new AppError('UPLOAD_FAILED');
});
// Why do we run this twice?
// const { id: templateDocumentDataId } = await createDocumentData({
// type: response.type,
// data: response.data,
// });
const response = await putPdfFile(file);
const { id } = await createTemplate({
title: file.name,