From 96868491f7eb49c7564cf0f0f4b34f29dc3ceb28 Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Wed, 13 Dec 2023 17:52:01 -0800 Subject: [PATCH] loading states complete/no documents found component --- .../DocumentsList/SearchView/index.tsx | 4 + .../DocumentsList/index.tsx | 91 +++++++++++++++++-- 2 files changed, 85 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/WorkspaceDashboard/DocumentsList/SearchView/index.tsx b/frontend/src/pages/WorkspaceDashboard/DocumentsList/SearchView/index.tsx index daff032..91f5145 100644 --- a/frontend/src/pages/WorkspaceDashboard/DocumentsList/SearchView/index.tsx +++ b/frontend/src/pages/WorkspaceDashboard/DocumentsList/SearchView/index.tsx @@ -17,6 +17,7 @@ export default function SearchView({ searchMode, setSearchMode, handleSearchResults, + setLoading, }: { organization: object; workspace: object; @@ -26,6 +27,7 @@ export default function SearchView({ searchMode: boolean; setSearchMode: (searchMode: boolean) => void; handleSearchResults: (results: any) => void; + setLoading: (loading: boolean) => void; }) { const formEl = useRef(null); const [searching, setSearching] = useState(false); @@ -44,6 +46,7 @@ export default function SearchView({ const handleSearch = async (e: SyntheticEvent) => { e.preventDefault(); setSearchMode(true); + setLoading(true); const formData = new FormData(e.target as any); const query = formData.get('query') as string; @@ -57,6 +60,7 @@ export default function SearchView({ setDocuments(matches); setSearching(false); + setLoading(false); handleSearchResults(matches); }; diff --git a/frontend/src/pages/WorkspaceDashboard/DocumentsList/index.tsx b/frontend/src/pages/WorkspaceDashboard/DocumentsList/index.tsx index a93d5b4..42fca09 100644 --- a/frontend/src/pages/WorkspaceDashboard/DocumentsList/index.tsx +++ b/frontend/src/pages/WorkspaceDashboard/DocumentsList/index.tsx @@ -22,6 +22,7 @@ import { Trash, X, } from '@phosphor-icons/react'; +import PreLoader from '../../../components/Preloader'; export default function DocumentsList({ knownConnector, @@ -94,18 +95,77 @@ export default function DocumentsList({ if (loading) { return ( -
-
-
-

- Documents {totalDocuments! > 0 ? `(${totalDocuments})` : ''} -

+ <> +
+
+
+
+ + Documents + + + {' '} + + + ({workspace?.documentCount}) + +
+ setSearchMode(false)} + deleteDocument={deleteDocument} + setSearchMode={setSearchMode} + handleSearchResults={handleSearchResults} + /> +
+
+ +
+ + + + + + + + + +
+ Name + + Date + + Vectors + + {' '} +
+ +
+
+ +
+
-
-
-
-
+ ); } @@ -137,6 +197,7 @@ export default function DocumentsList({ deleteDocument={deleteDocument} setSearchMode={setSearchMode} handleSearchResults={handleSearchResults} + setLoading={setLoading} />
@@ -203,6 +264,16 @@ export default function DocumentsList({ )} + {searchMode && searchResults?.length === 0 && ( +
+
+
+ No documents found +
+
+
+ )} + {documents?.length === 0 && (