From 96eb68e042de869183e5f9fd30e2a8770cc62367 Mon Sep 17 00:00:00 2001 From: Sukhman S Date: Sun, 2 Jul 2023 10:35:03 +0530 Subject: [PATCH] feat: use generic Modal with render props --- frontend/src/preferences/SelectDocsModal.tsx | 135 ++++++++----------- 1 file changed, 59 insertions(+), 76 deletions(-) diff --git a/frontend/src/preferences/SelectDocsModal.tsx b/frontend/src/preferences/SelectDocsModal.tsx index c4764878..c514ab86 100644 --- a/frontend/src/preferences/SelectDocsModal.tsx +++ b/frontend/src/preferences/SelectDocsModal.tsx @@ -1,6 +1,7 @@ import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { ActiveState } from '../models/misc'; +import Modal from '../Modal'; import { setSelectedDocs, setSourceDocs, @@ -50,85 +51,67 @@ export default function APIKeyModal({ 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.

+ { + 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. -

- )} -
-
-
+ + ); + }} + /> ); }