Skip to content

Commit

Permalink
Add GPT Visual support in testing suite (#142)
Browse files Browse the repository at this point in the history
* Add GPT Visual support in testing suite

* Fix typing
  • Loading branch information
Ashesh3 authored Oct 18, 2023
1 parent b22851b commit d0394b6
Show file tree
Hide file tree
Showing 13 changed files with 399 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export default function Page({ params }: { params: { project_id: string, documen

const router = useRouter();

const documentQuery = useQuery(["document", document_id], () => API.documents.get(project_id, document_id));
const documentQuery = useQuery(["document", document_id], () => API.projects.documents.get(project_id, document_id));

const doc: Document | undefined = documentQuery.data;

const editDocumentMutation = useMutation((formData) => API.documents.edit(project_id, document_id, formData as any), {
const editDocumentMutation = useMutation((formData) => API.projects.documents.edit(project_id, document_id, formData as any), {
onSuccess: () => {
documentQuery.refetch();
}
Expand All @@ -29,7 +29,7 @@ export default function Page({ params }: { params: { project_id: string, documen
const onSubmit = async (document: Partial<Document>) => {
const formData = new FormData();
formData.append("title", document.title as string);
formData.append("file", document.file as File);
formData.append("file", document.raw_file as File);
formData.append("description", document.description as string);
await editDocumentMutation.mutateAsync(formData as any);
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/admin/projects/[project_id]/documents/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ export default function Page({ params }: { params: { project_id: string } }) {

const router = useRouter();

const createDocumentMutation = useMutation((formData) => API.documents.create(project_id, formData as any), {
const createDocumentMutation = useMutation((formData) => API.projects.documents.create(project_id, formData as any), {
onSuccess: () => {
router.push(`/admin/projects/${project_id}`);
}
});

const onSubmit = async (doc: Partial<Document>) => {
const formData = new FormData();
doc.title && formData.append("title", doc.title as string);
doc.file && formData.append("file", doc.file as File);
doc.description && formData.append("description", doc.description as string);
doc.text_content && formData.append("text_content", doc.text_content as string);
doc.title && formData.append("title", doc.title);
doc.raw_file && formData.append("file", doc.raw_file as File);
doc.description && formData.append("description", doc.description);
doc.text_content && formData.append("text_content", doc.text_content);
doc.document_type && formData.append("document_type", `${doc.document_type}`);
await createDocumentMutation.mutateAsync(formData as any);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/admin/projects/[project_id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Page({ params }: { params: { project_id: string } }) {
);
const project: Project | undefined = projectsQuery.data || undefined;
const documentsQuery = useQuery(["project", project_id, "documents"], () =>
API.documents.list(project_id)
API.projects.documents.list(project_id)
);
const documents: Document[] | undefined = documentsQuery.data?.results;
const [showDeleteModal, setShowDeleteModel] = useState(false);
Expand Down
Loading

1 comment on commit d0394b6

@vercel
Copy link

@vercel vercel bot commented on d0394b6 Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.