import { ActiveState } from '../models/misc'; import Exit from '../assets/exit.svg'; import Input from '../components/Input'; import React from 'react'; function AddPrompt({ setModalState, handleAddPrompt, newPromptName, setNewPromptName, newPromptContent, setNewPromptContent, disableSave, }: { setModalState: (state: ActiveState) => void; handleAddPrompt?: () => void; newPromptName: string; setNewPromptName: (name: string) => void; newPromptContent: string; setNewPromptContent: (content: string) => void; disableSave: boolean; }) { return (

Add Prompt

Add your custom prompt and save it to DocsGPT

setNewPromptName(e.target.value)} />
Prompt Name
Prompt Text
); } function EditPrompt({ setModalState, handleEditPrompt, editPromptName, setEditPromptName, editPromptContent, setEditPromptContent, currentPromptEdit, disableSave, }: { setModalState: (state: ActiveState) => void; handleEditPrompt?: (id: string, type: string) => void; editPromptName: string; setEditPromptName: (name: string) => void; editPromptContent: string; setEditPromptContent: (content: string) => void; currentPromptEdit: { name: string; id: string; type: string }; disableSave: boolean; }) { return (

Edit Prompt

Edit your custom prompt and save it to DocsGPT

setEditPromptName(e.target.value)} >
Prompt Name
Prompt Text
); } export default function PromptsModal({ existingPrompts, modalState, setModalState, type, newPromptName, setNewPromptName, newPromptContent, setNewPromptContent, editPromptName, setEditPromptName, editPromptContent, setEditPromptContent, currentPromptEdit, handleAddPrompt, handleEditPrompt, }: { existingPrompts: { name: string; id: string; type: string }[]; modalState: ActiveState; setModalState: (state: ActiveState) => void; type: 'ADD' | 'EDIT'; newPromptName: string; setNewPromptName: (name: string) => void; newPromptContent: string; setNewPromptContent: (content: string) => void; editPromptName: string; setEditPromptName: (name: string) => void; editPromptContent: string; setEditPromptContent: (content: string) => void; currentPromptEdit: { name: string; id: string; type: string }; handleAddPrompt?: () => void; handleEditPrompt?: (id: string, type: string) => void; }) { const [disableSave, setDisableSave] = React.useState(true); const handlePrompNameChange = (edit: boolean, newName: string) => { const nameExists = existingPrompts.find( (prompt) => newName === prompt.name, ); if (newName && !nameExists) { setDisableSave(false); } else { setDisableSave(true); } if (edit) { setEditPromptName(newName); } else { setNewPromptName(newName); } }; let view; if (type === 'ADD') { view = ( ); } else if (type === 'EDIT') { view = ( ); } else { view = <>; } return (
{view}
); }