diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/components/content.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/components/content.tsx index ce3e5103..20078379 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/components/content.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/components/content.tsx @@ -1,64 +1,11 @@ 'use client'; -import { useParams, useRouter } from 'next/navigation'; -import { graphql } from '@/gql'; -import { useMutation } from '@tanstack/react-query'; -import { Button, Icon, Text, toast } from 'opub-ui'; +import { Button, Icon, Text } from 'opub-ui'; import { twMerge } from 'tailwind-merge'; -import { GraphQL } from '@/lib/api'; import { Icons } from '@/components/icons'; -const createDatasetMutationDoc: any = graphql(` - mutation Generate_Dataset_Name { - addDataset { - success - errors { - fieldErrors { - messages - } - } - data { - id - title - created - } - } - } -`); -export const Content = () => { - const router = useRouter(); - const params = useParams<{ entityType?: string; entitySlug?: string }>(); - const entityType = params?.entityType; - const entitySlug = params?.entitySlug; - - const isValidParams = - typeof entityType === 'string' && typeof entitySlug === 'string'; - - const ownerArgs: Record | null = isValidParams - ? { [entityType]: entitySlug } - : null; - - const CreateDatasetMutation: { mutate: any; isLoading: boolean; error: any } = - useMutation(() => GraphQL(createDatasetMutationDoc, ownerArgs || {}, []), { - onSuccess: (data: any) => { - if (data.addDataset.success) { - toast('Dataset created successfully!'); - if (isValidParams && entityType && entitySlug) { - router.push( - `/dashboard/${entityType}/${entitySlug}/dataset/${data?.addDataset?.data?.id}/edit/metadata` - ); - } - } else { - toast('Error: ' + data.addDataset.errors.fieldErrors[0].messages[0]); - } - }, - }); - - if (!isValidParams) { - return null; - } - +export const Content = ({ onAddNew }: { onAddNew: () => void }) => { return (
@@ -71,9 +18,7 @@ export const Content = () => { You have not added any datasets yet. - +
); diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/page-layout.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/page-layout.tsx index feb8203f..133e7ae8 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/page-layout.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/page-layout.tsx @@ -85,7 +85,7 @@ export const Page = () => { isLoading={isLoading} /> - + mutate()} /> ); }; diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/page.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/page.tsx index 42d13e26..ee455d12 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/page.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/page.tsx @@ -299,7 +299,7 @@ export default function DatasetPage() { ) : AllDatasetsQuery.isLoading ? ( ) : ( - + setIsTypeModalOpen(true)} /> )} {/* */}