|
| 1 | +// ------------------------------------------------------------------------- |
| 2 | +// Root element called by App.js. Handles main views |
| 3 | +// ------------------------------------------------------------------------- |
| 4 | + |
1 | 5 | // System imports |
2 | | -import React, { useState } from "react"; |
| 6 | +import React, { useState, useEffect } from "react"; |
3 | 7 | import { useNavigate, useParams } from "react-router-dom"; |
4 | | -import { useEffect } from "react"; |
5 | | -import Form from "react-bootstrap/Form"; |
6 | 8 |
|
7 | 9 | // Local imports |
8 | 10 | import CbUpload from "../components/CbUpload"; |
9 | 11 | import CbHeader from "../components/CbHeader"; |
10 | 12 | import CbShareNav from "../components/CbShareNav"; |
11 | 13 | import CbFiles from "../components/CbFiles"; |
| 14 | +import CbShareSearch from "../components/CbShareSearch"; |
12 | 15 |
|
13 | 16 | // Root Component |
14 | | -export function CbRoot( { isHome } ) { |
| 17 | +export function CbRoot({ isHome }) { |
15 | 18 |
|
16 | 19 | // Useful hooks |
17 | | - const [shareId, setShareId] = useState(useParams().shareId); |
18 | 20 | const navigate = useNavigate(); |
19 | 21 | // Hooks if in share |
20 | 22 | const [viewMode, setViewMode] = useState("list"); |
21 | 23 | const [fileInfo, setFileInfo] = useState([]); |
22 | | - |
23 | | - // Evaluate entered shareId |
24 | | - function handleChange(e) { |
25 | | - setShareId(e.target.value); |
26 | | - } |
27 | | - |
28 | | - // Redirect on submit |
29 | | - function handleRedirect() { |
30 | | - navigate(`/share/${encodeURIComponent(shareId)}`); |
31 | | - } |
| 24 | + const [searchTerms, setSearchTerms] = useState(null); |
32 | 25 |
|
33 | 26 | function loadFiles() { |
34 | 27 | const shareId_forLoad = window.location.pathname.split('/')[2]; // Use useRef instead? |
@@ -63,15 +56,11 @@ export function CbRoot( { isHome } ) { |
63 | 56 | <CbHeader /> |
64 | 57 | <CbUpload loadFiles={loadFiles} /> |
65 | 58 | {isHome ? |
66 | | - <Form className="mt-3" onChange={handleChange} onSubmit={handleRedirect}> |
67 | | - <Form.Group> |
68 | | - <Form.Control type="text" placeholder="Enter Share ID to Retrieve an Existing Share" /> |
69 | | - </Form.Group> |
70 | | - </Form> |
| 59 | + <CbShareSearch /> |
71 | 60 | : |
72 | 61 | <div> |
73 | | - <CbShareNav changeViewMode={setViewMode} viewMode={viewMode} /> |
74 | | - <CbFiles fileInfo={fileInfo} viewMode={viewMode} loadFiles={loadFiles} /> |
| 62 | + <CbShareNav changeViewMode={setViewMode} viewMode={viewMode} setSearchTerms={setSearchTerms}/> |
| 63 | + <CbFiles fileInfo={fileInfo} viewMode={viewMode} loadFiles={loadFiles} searchTerms={searchTerms} /> |
75 | 64 | </div> |
76 | 65 | } |
77 | 66 | </div> |
|
0 commit comments