From 01320798423db4b3f9583b15fb8ad9c759211aed Mon Sep 17 00:00:00 2001 From: ajaythapliyal Date: Fri, 24 Feb 2023 07:59:19 +0530 Subject: [PATCH] fixes 1. from Nicks list --- frontend/src/preferences/APIKeyModal.tsx | 2 +- frontend/src/preferences/SelectDocsModal.tsx | 264 +++++++++---------- 2 files changed, 133 insertions(+), 133 deletions(-) diff --git a/frontend/src/preferences/APIKeyModal.tsx b/frontend/src/preferences/APIKeyModal.tsx index b440500a..6dc49de2 100644 --- a/frontend/src/preferences/APIKeyModal.tsx +++ b/frontend/src/preferences/APIKeyModal.tsx @@ -41,7 +41,7 @@ export default function APIKeyModal({ >

OpenAI API Key

-

+

Before you can start using DocsGPT we need you to provide an API key for llm. Currently, we support only OpenAI but soon many more. You can find it here. diff --git a/frontend/src/preferences/SelectDocsModal.tsx b/frontend/src/preferences/SelectDocsModal.tsx index 691f90c1..36919632 100644 --- a/frontend/src/preferences/SelectDocsModal.tsx +++ b/frontend/src/preferences/SelectDocsModal.tsx @@ -1,132 +1,132 @@ -import { useEffect, useState } from 'react'; -import { useDispatch, useSelector } from 'react-redux'; -import { ActiveState } from '../models/misc'; -import { - setSelectedDocs, - setSourceDocs, - selectSourceDocs, -} from './preferenceSlice'; -import { getDocs, Doc } from './selectDocsApi'; - -export default function APIKeyModal({ - modalState, - setModalState, - isCancellable = true, -}: { - modalState: ActiveState; - setModalState: (val: ActiveState) => void; - isCancellable?: boolean; -}) { - const dispatch = useDispatch(); - const docs = useSelector(selectSourceDocs); - const [localSelectedDocs, setLocalSelectedDocs] = useState(null); - const [isDocsListOpen, setIsDocsListOpen] = useState(false); - const [isError, setIsError] = useState(false); - - function handleSubmit() { - if (!localSelectedDocs) { - setIsError(true); - } else { - dispatch(setSelectedDocs(localSelectedDocs)); - setModalState('INACTIVE'); - setLocalSelectedDocs(null); - setIsError(false); - } - } - - function handleCancel() { - setLocalSelectedDocs(null); - setIsError(false); - setModalState('INACTIVE'); - } - - useEffect(() => { - async function requestDocs() { - const data = await getDocs(); - dispatch(setSourceDocs(data)); - } - - requestDocs(); - }, []); - - return ( -

-
-

Select Source Documentation

-

- Please select the library of documentation that you would like to use - with our app. -

-
-
setIsDocsListOpen(!isDocsListOpen)} - > - {!localSelectedDocs ? ( -

Select

- ) : ( -

- {localSelectedDocs.name} {localSelectedDocs.version} -

- )} -
- {isDocsListOpen && ( -
- {docs ? ( - docs.map((doc, index) => { - if (doc.model) { - return ( -
{ - setLocalSelectedDocs(doc); - setIsDocsListOpen(false); - }} - className="h-10 w-full cursor-pointer border-x-2 border-b-2 hover:bg-gray-100" - > -

- {doc.name} {doc.version} -

-
- ); - } - }) - ) : ( -
-

No default documentation.

-
- )} -
- )} -
-
- {isCancellable && ( - - )} - - {isError && ( -

- Please select source documentation. -

- )} -
-
-
- ); -} +import { useEffect, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { ActiveState } from '../models/misc'; +import { + setSelectedDocs, + setSourceDocs, + selectSourceDocs, +} from './preferenceSlice'; +import { getDocs, Doc } from './selectDocsApi'; + +export default function APIKeyModal({ + modalState, + setModalState, + isCancellable = true, +}: { + modalState: ActiveState; + setModalState: (val: ActiveState) => void; + isCancellable?: boolean; +}) { + const dispatch = useDispatch(); + const docs = useSelector(selectSourceDocs); + const [localSelectedDocs, setLocalSelectedDocs] = useState(null); + const [isDocsListOpen, setIsDocsListOpen] = useState(false); + const [isError, setIsError] = useState(false); + + function handleSubmit() { + if (!localSelectedDocs) { + setIsError(true); + } else { + dispatch(setSelectedDocs(localSelectedDocs)); + setModalState('INACTIVE'); + setLocalSelectedDocs(null); + setIsError(false); + } + } + + function handleCancel() { + setLocalSelectedDocs(null); + setIsError(false); + setModalState('INACTIVE'); + } + + useEffect(() => { + async function requestDocs() { + const data = await getDocs(); + dispatch(setSourceDocs(data)); + } + + requestDocs(); + }, []); + + return ( +
+
+

Select Source Documentation

+

+ Please select the library of documentation that you would like to use + with our app. +

+
+
setIsDocsListOpen(!isDocsListOpen)} + > + {!localSelectedDocs ? ( +

Select

+ ) : ( +

+ {localSelectedDocs.name} {localSelectedDocs.version} +

+ )} +
+ {isDocsListOpen && ( +
+ {docs ? ( + docs.map((doc, index) => { + if (doc.model) { + return ( +
{ + setLocalSelectedDocs(doc); + setIsDocsListOpen(false); + }} + className="h-10 w-full cursor-pointer border-x-2 border-b-2 hover:bg-gray-100" + > +

+ {doc.name} {doc.version} +

+
+ ); + } + }) + ) : ( +
+

No default documentation.

+
+ )} +
+ )} +
+
+ {isCancellable && ( + + )} + + {isError && ( +

+ Please select source documentation. +

+ )} +
+
+
+ ); +}