diff --git a/src/app/assistants/[id]/SideNavigation.tsx b/src/app/assistants/[id]/SideNavigation.tsx
index d4c3c1c..c13f686 100644
--- a/src/app/assistants/[id]/SideNavigation.tsx
+++ b/src/app/assistants/[id]/SideNavigation.tsx
@@ -8,6 +8,7 @@ import {
HiCog,
HiChartBar,
HiPuzzle,
+ HiShoppingBag,
} from 'react-icons/hi';
import { Assistant } from '@/app/types/assistant';
import Image from 'next/image';
diff --git a/src/app/assistants/[id]/client.ts b/src/app/assistants/[id]/client.ts
index b504074..6ba60ca 100644
--- a/src/app/assistants/[id]/client.ts
+++ b/src/app/assistants/[id]/client.ts
@@ -279,6 +279,21 @@ export async function getMessageMetrics(request: MetricsRequest) {
return [response.status, await response.json()];
}
+export async function updateVisibilityStatus(id: string | undefined) {
+ if (!id) {
+ return [400, { error: 'Assistant ID is required' }];
+ }
+
+ let response = await fetch('/api/assistants/' + id + '/visibility', {
+ method: 'PUT',
+ headers: {
+ accept: 'application.json',
+ },
+ });
+
+ return [response.status, await response.json()];
+}
+
export async function uploadFile(assistantId: string, file: File) {
const formData = new FormData();
formData.append('file', file);
diff --git a/src/app/assistants/[id]/settings/page.tsx b/src/app/assistants/[id]/settings/page.tsx
index 252ffed..83d078d 100644
--- a/src/app/assistants/[id]/settings/page.tsx
+++ b/src/app/assistants/[id]/settings/page.tsx
@@ -1,9 +1,12 @@
'use client';
-import { Button, Modal, Table } from 'flowbite-react';
-import React, { useContext, useState } from 'react';
+import { Button, Modal, Table, ToggleSwitch } from 'flowbite-react';
+import React, { useCallback, useContext, useState } from 'react';
import { HiOutlineExclamationCircle } from 'react-icons/hi';
-import { deleteAssistant } from '@/app/assistants/[id]/client';
+import {
+ deleteAssistant,
+ updateVisibilityStatus,
+} from '@/app/assistants/[id]/client';
import { toast } from 'react-hot-toast';
import { useRouter } from 'next/navigation';
import EditAssistant from '@/app/assistants/[id]/settings/EditAssistant';
@@ -12,9 +15,37 @@ import AssistantContext from '@/app/assistants/[id]/AssistantContext';
export default function Settings() {
const [openModal, setOpenModal] = useState(false);
const { assistant } = useContext(AssistantContext);
+ console.log(assistant.published);
+ const [publish, setPublish] = useState(
+ assistant.published ? assistant.published : false
+ );
const { push } = useRouter();
+ const toggleVisibility = async () => {
+ let visibility = !publish;
+ if (assistant && assistant.id) {
+ let [status, response] = await updateVisibilityStatus(assistant.id);
+ if (status === 200) {
+ let message =
+ 'Assistant ' + assistant.name + ' now available in store.';
+
+ if (!visibility) {
+ message = 'Assistant ' + assistant.name + ' removed from store.';
+ }
+ setPublish(visibility);
+
+ toast.success(message, {
+ duration: 4000,
+ });
+ } else {
+ toast.error('Assistant ' + assistant.name + ' could not be deleted.', {
+ duration: 4000,
+ });
+ }
+ }
+ };
+
const handleAssistantDelete = async () => {
if (assistant && assistant.id) {
let [status, response] = await deleteAssistant(assistant.id);
@@ -42,20 +73,45 @@ export default function Settings() {
Adjust the original configuration of your assistant here
-
+
+
+
+
General Settings
+
+
-
Danger Zone
+ Store
+
+
+
+
+
+
+ Available for Everyone
+
+
+ When enabled this assistant will be available on the store.
+
+
+
+
+
+
+
+
+
+
Danger Zone
-
+
Delete this assistant
@@ -63,14 +119,15 @@ export default function Settings() {
Please be certain.
-
+
+
+
diff --git a/src/app/types/assistant.ts b/src/app/types/assistant.ts
index 5dc98be..dcc2431 100644
--- a/src/app/types/assistant.ts
+++ b/src/app/types/assistant.ts
@@ -30,4 +30,5 @@ export interface Assistant {
avatar?: string | null;
profile?: string | null;
theme?: AssistantTheme | null;
+ published?: boolean;
}