diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/edit/[id]/publish/page.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/edit/[id]/publish/page.tsx index 4e147fe6..0ccff274 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/edit/[id]/publish/page.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/edit/[id]/publish/page.tsx @@ -197,27 +197,37 @@ export default function PublishPage() { setStatus('saving'); mutate( { - status: 'ACTIVE', - isPublic: true, - isActive: true, + status: isPublished ? 'REGISTERED' : 'ACTIVE', + isPublic: isPublished ? false : true, + isActive: isPublished ? false : true, }, { onSuccess: () => { - toast('Model published successfully', { - id: PUBLISH_SUCCESS_TOAST_ID, - }); + toast( + isPublished + ? 'Model unpublished successfully' + : 'Model published successfully', + { + id: PUBLISH_SUCCESS_TOAST_ID, + } + ); setStatus('saved'); refetch(); router.push( - `/dashboard/${params.entityType}/${params.entitySlug}/aimodels?tab=active` + `/dashboard/${params.entityType}/${params.entitySlug}/aimodels?tab=${isPublished ? 'draft' : 'published'}` ); }, onError: (error: any) => { const errorMessage = typeof error?.message === 'string' && error.message.trim() ? error.message.trim() - : 'Unable to publish model right now. Please try again.'; - toast(`Error: ${errorMessage}`, { id: PUBLISH_ERROR_TOAST_ID }); + : isPublished + ? 'Unable to unpublish model right now. Please try again.' + : 'Unable to publish model right now. Please try again.'; + toast( + isPublished ? `Error: ${errorMessage}` : `Error: ${errorMessage}`, + { id: PUBLISH_ERROR_TOAST_ID } + ); setStatus('unsaved'); }, } @@ -531,7 +541,7 @@ export default function PublishPage() { disabled={isPublishDisabled} loading={updateLoading} > - Publish + {isPublished ? 'Unpublish' : 'Publish'} )} diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/page.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/page.tsx index ab081821..0a3eeb23 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/page.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/page.tsx @@ -70,20 +70,20 @@ export default function AIModelsPage({ let navigationOptions = [ { - label: 'Registered', - url: `registered`, - selected: navigationTab === 'registered', + label: 'Draft', + url: `draft`, + selected: navigationTab === 'draft', }, { - label: 'Active', - url: `active`, - selected: navigationTab === 'active', - }, - { - label: 'Approved', - url: `approved`, - selected: navigationTab === 'approved', + label: 'Published', + url: `published`, + selected: navigationTab === 'published', }, + // { + // label: 'Approved', + // url: `approved`, + // selected: navigationTab === 'approved', + // }, ]; const AllAIModels: { data: any; isLoading: boolean; refetch: any } = useQuery( @@ -97,11 +97,11 @@ export default function AIModelsPage({ { filters: { status: - navigationTab === 'active' + navigationTab === 'published' ? 'ACTIVE' - : navigationTab === 'approved' - ? 'APPROVED' - : 'REGISTERED', + : navigationTab === 'draft' + ? 'REGISTERED' + : 'APPROVED', }, order: { updatedAt: 'DESC' }, } @@ -110,7 +110,7 @@ export default function AIModelsPage({ useEffect(() => { if (navigationTab === null || navigationTab === undefined) - setNavigationTab('registered'); + setNavigationTab('draft'); AllAIModels.refetch(); }, [AllAIModels, navigationTab, setNavigationTab]); @@ -130,11 +130,15 @@ export default function AIModelsPage({ ), { onSuccess: () => { - toast(`Deleted AI Model successfully`,{id: AIMODELS_ACTION_TOAST_ID}); + toast(`Deleted AI Model successfully`, { + id: AIMODELS_ACTION_TOAST_ID, + }); AllAIModels.refetch(); }, onError: (err: any) => { - toast('Error: ' + err.message.split(':')[0],{id: AIMODELS_ACTION_TOAST_ID}); + toast('Error: ' + err.message.split(':')[0], { + id: AIMODELS_ACTION_TOAST_ID, + }); }, } ); @@ -163,13 +167,17 @@ export default function AIModelsPage({ { onSuccess: (data: any) => { const newModelId = data.createAiModel.data.id; - toast(`Created AI Model successfully`,{id: AIMODELS_ACTION_TOAST_ID}); + toast(`Created AI Model successfully`, { + id: AIMODELS_ACTION_TOAST_ID, + }); router.push( `/dashboard/${entityType}/${entitySlug}/aimodels/edit/${newModelId}/details` ); }, onError: (err: any) => { - toast('Error: ' + err.message.split(':')[0],{id: AIMODELS_ACTION_TOAST_ID}); + toast('Error: ' + err.message.split(':')[0], { + id: AIMODELS_ACTION_TOAST_ID, + }); }, } ); @@ -186,7 +194,7 @@ export default function AIModelsPage({ {row.original.displayName} @@ -260,7 +268,7 @@ export default function AIModelsPage({ {AllAIModels.data?.aiModels.length > 0 ? (