-
-

-
+
+
+
-
- {list.map((item, index) => (
-
+ {tabs.map((tab, index) => (
+
+ {tab}
+
))}
-
-
-

-
+
+
- {returnActiveTabs()}
+ {renderActiveTab()}
+
+ {isAddDocumentModalOpen && (
+
+ )}
+
+ {/* {activeTab === 'Widgets' && (
+
+ )} */}
+
+ );
+
+ function scrollTabs(direction: number) {
+ const container = document.querySelector('.flex-nowrap');
+ if (container) {
+ container.scrollLeft += direction * 100; // Adjust the scroll amount as needed
+ }
+ }
+
+ function renderActiveTab() {
+ switch (activeTab) {
+ case 'General':
+ return
;
+ case 'Prompts':
+ return (
+
+ );
+ case 'Documents':
+ return (
+
+ );
+ case 'Widgets':
+ return (
+
+ );
+ default:
+ return null;
+ }
+ }
+
+ function addPrompt(name: string) {
+ if (name) {
+ setPrompts([...prompts, name]);
+ setNewPromptName('');
+ toggleAddPromptModal();
+ }
+ }
+
+ function toggleAddPromptModal() {
+ setAddPromptModalOpen(!isAddPromptModalOpen);
+ }
+};
+
+const General: React.FC = () => {
+ const themes = ['Light', 'Dark'];
+ const languages = ['English', 'French', 'Hindi'];
+ const [selectedTheme, setSelectedTheme] = useState(themes[0]);
+ const [selectedLanguage, setSelectedLanguage] = useState(languages[0]);
+
+ return (
+
);
};
-const General = () => {
- const [theme, setTheme] = useState('Light');
- const [isThemeListOpen, setIsThemeListOpen] = useState(false);
- const themes = ['Light', 'Dark (WIP)'];
- const [language, setLanguage] = useState('English');
- const languages = ['English'];
- const [isLanguageListOpen, setIsLanguageListOpen] = useState(false);
+export default Setting;
+
+const Prompts: React.FC
= ({
+ prompts,
+ selectedPrompt,
+ onSelectPrompt,
+ onAddPrompt,
+ onDeletePrompt,
+}) => {
+ const [isAddPromptModalOpen, setAddPromptModalOpen] = useState(false);
+ const [newPromptName, setNewPromptName] = useState('');
+
+ const openAddPromptModal = () => {
+ setAddPromptModalOpen(true);
+ };
+
+ const closeAddPromptModal = () => {
+ setAddPromptModalOpen(false);
+ };
+
+ const handleDeletePrompt = () => {
+ if (selectedPrompt) {
+ onDeletePrompt(selectedPrompt); // Remove the selected prompt
+ }
+ };
+
return (
- <>
-
-
Select Theme
-
-
setIsThemeListOpen(!isThemeListOpen)}
- >
- {theme && (
-
{theme}
- )}
-

-
- {isThemeListOpen && (
-
- {themes.map((item, index) => (
-
{
- setTheme(item);
- setIsThemeListOpen(false);
- }}
- className="flex h-10 w-full cursor-pointer items-center justify-between border-x-2 border-b-2 hover:bg-gray-100"
- >
-
- {item}
-
-
- ))}
-
- )}
-
+
+
-
-
Select Language
-
-
setIsLanguageListOpen(!isLanguageListOpen)}
- >
- {language && (
-
- {language}
-
- )}
-

-
- {isLanguageListOpen && (
-
- {languages.map((item, index) => (
-
{
- setLanguage(item);
- setIsLanguageListOpen(false);
- }}
- className="flex h-10 w-full cursor-pointer items-center justify-between border-x-2 border-b-2 hover:bg-gray-100"
- >
-
- {item}
-
-
- ))}
-
- )}
-
+
+
- >
+ {isAddPromptModalOpen && (
+
{
+ onAddPrompt(newPromptName);
+ closeAddPromptModal();
+ }}
+ onClose={closeAddPromptModal}
+ />
+ )}
+
+
+
+
);
};
-const Prompts = () => {
- return
This is prompts WIP
;
+
+function Dropdown({
+ options,
+ selectedValue,
+ onSelect,
+}: {
+ options: string[];
+ selectedValue: string;
+ onSelect: (value: string) => void;
+}) {
+ const [isOpen, setIsOpen] = useState(false);
+
+ return (
+
+
+ {isOpen && (
+
+ {options.map((option, index) => (
+
{
+ onSelect(option);
+ setIsOpen(false);
+ }}
+ className="flex cursor-pointer items-center justify-between border-b-2 py-3 hover:bg-gray-100"
+ >
+
+ {option}
+
+
+ ))}
+
+ )}
+
+ );
+}
+
+type AddPromptModalProps = {
+ newPromptName: string;
+ onNewPromptNameChange: (name: string) => void;
+ onAddPrompt: () => void;
+ onClose: () => void;
};
-const Documents = () => {
- return
This is Documents WIP
;
+
+const AddPromptModal: React.FC
= ({
+ newPromptName,
+ onNewPromptNameChange,
+ onAddPrompt,
+ onClose,
+}) => {
+ return (
+
+
+
Add New Prompt
+
onNewPromptNameChange(e.target.value)}
+ className="mb-4 w-full rounded-lg border-2 p-2"
+ />
+
+
+
+
+ );
};
-const Widgets = () => {
- return This is widgets WIP
;
+
+type DocumentsProps = {
+ documents: Document[];
+ isAddDocumentModalOpen: boolean;
+ newDocument: Document;
+ handleDeleteDocument: (index: number) => void;
+ toggleAddDocumentModal: () => void;
+};
+
+const Documents: React.FC = ({
+ documents,
+ isAddDocumentModalOpen,
+ newDocument,
+ handleDeleteDocument,
+ toggleAddDocumentModal,
+}) => {
+ return (
+
+
+ {/*
Documents
*/}
+
+
+
+
+
+ | Document Name |
+ Vector Date |
+ Vector Location |
+ Actions |
+
+
+
+ {documents.map((document, index) => (
+
+ | {document.name} |
+ {document.vectorDate} |
+
+ {document.vectorLocation}
+ |
+
+
+ |
+
+ ))}
+
+
+
+
+
+
+ {/* {isAddDocumentModalOpen && (
+
+ )} */}
+
+ );
+};
+
+type Document = {
+ name: string;
+ vectorDate: string;
+ vectorLocation: string;
+};
+
+// Modal for adding a new document
+type AddDocumentModalProps = {
+ newDocument: Document;
+ onNewDocumentChange: (document: Document) => void;
+ onAddDocument: () => void;
+ onClose: () => void;
+};
+
+const AddDocumentModal: React.FC = ({
+ newDocument,
+ onNewDocumentChange,
+ onAddDocument,
+ onClose,
+}) => {
+ return (
+
+ );
+};
+
+const Widgets: React.FC<{
+ widgetScreenshot: File | null;
+ onWidgetScreenshotChange: (screenshot: File | null) => void;
+}> = ({ widgetScreenshot, onWidgetScreenshotChange }) => {
+ const widgetSources = ['Source 1', 'Source 2', 'Source 3'];
+ const widgetMethods = ['Method 1', 'Method 2', 'Method 3'];
+ const widgetTypes = ['Type 1', 'Type 2', 'Type 3'];
+
+ const [selectedWidgetSource, setSelectedWidgetSource] = useState(
+ widgetSources[0],
+ );
+ const [selectedWidgetMethod, setSelectedWidgetMethod] = useState(
+ widgetMethods[0],
+ );
+ const [selectedWidgetType, setSelectedWidgetType] = useState(widgetTypes[0]);
+
+ // const [widgetScreenshot, setWidgetScreenshot] = useState(null);
+ const [widgetCode, setWidgetCode] = useState(''); // Your widget code state
+
+ const handleScreenshotChange = (
+ event: React.ChangeEvent,
+ ) => {
+ const files = event.target.files;
+
+ if (files && files.length > 0) {
+ const selectedScreenshot = files[0];
+ onWidgetScreenshotChange(selectedScreenshot); // Update the screenshot in the parent component
+ }
+ };
+
+ const handleCopyToClipboard = () => {
+ // Create a new textarea element to select the text
+ const textArea = document.createElement('textarea');
+ textArea.value = widgetCode;
+ document.body.appendChild(textArea);
+
+ // Select and copy the text
+ textArea.select();
+ document.execCommand('copy');
+
+ // Clean up the textarea element
+ document.body.removeChild(textArea);
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ {widgetScreenshot && (
+
+
})
+
+ )}
+
+ );
};
-export default Setting;