From 5daaf84e0565f6d771a236e5c92258b0d11bd83a Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Tue, 5 Mar 2024 14:26:08 +0530 Subject: [PATCH] fix: combined two dropdowns into a single component --- frontend/src/Navigation.tsx | 4 +- frontend/src/Setting.tsx | 186 +++++---------------- frontend/src/components/Dropdown.tsx | 122 +++++--------- frontend/src/components/SourceDropdown.tsx | 102 +++++++++++ 4 files changed, 194 insertions(+), 220 deletions(-) create mode 100644 frontend/src/components/SourceDropdown.tsx diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index 5fa07bff..4a65c6f8 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -40,7 +40,7 @@ import { Doc, getConversations } from './preferences/preferenceApi'; import SelectDocsModal from './preferences/SelectDocsModal'; import ConversationTile from './conversation/ConversationTile'; import { useDarkTheme } from './hooks'; -import Dropdown from './components/Dropdown'; +import SourceDropdown from './components/SourceDropdown'; interface NavigationProps { navOpen: boolean; @@ -277,7 +277,7 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
- { method: 'GET', }) .then((response) => { - if(response.ok && documents){ - const updatedDocuments = [...documents.slice(0, index), ...documents.slice(index + 1)]; + if (response.ok && documents) { + const updatedDocuments = [ + ...documents.slice(0, index), + ...documents.slice(index + 1), + ]; dispatch(setSourceDocs(updatedDocuments)); } }) @@ -96,8 +100,10 @@ const Setting: React.FC = () => { }; return ( -
-

Settings

+
+

+ Settings +

@@ -188,7 +195,9 @@ const General: React.FC = () => { const themes = ['Light', 'Dark']; const languages = ['English']; const [isDarkTheme, toggleTheme] = useDarkTheme(); - const [selectedTheme, setSelectedTheme] = useState(isDarkTheme ? 'Dark' : 'Light'); + const [selectedTheme, setSelectedTheme] = useState( + isDarkTheme ? 'Dark' : 'Light', + ); const [selectedLanguage, setSelectedLanguage] = useState(languages[0]); return (
@@ -197,14 +206,16 @@ const General: React.FC = () => { { - setSelectedTheme(option); - option !==selectedTheme && toggleTheme(); - }} + onSelect={(option: string) => { + setSelectedTheme(option); + option !== selectedTheme && toggleTheme(); + }} />
-

Select Language

+

+ Select Language +

= ({

Active Prompt

- = ({
-

Prompt name

{' '} +

Prompt name

{' '}

start by editing name

@@ -372,7 +383,7 @@ const Prompts: React.FC = ({

Prompt content