diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 73dfb70..b4ef972 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,6 @@ import "./styles/App.css"; import { Link, useNavigate } from 'react-router-dom'; -import MainSearch from './components/MainSearch'; +import { Outlet } from "react-router-dom"; import { SessionContext, destroySessionCookie, getSessionCookie } from "./contexts/session"; import { useState, useEffect, useContext } from "react"; @@ -24,14 +24,7 @@ export default function App() {
- PeerNotes Logo - +
diff --git a/frontend/src/components/MainSearch.tsx b/frontend/src/components/MainSearch.tsx index 1f7fe48..1a9617e 100644 --- a/frontend/src/components/MainSearch.tsx +++ b/frontend/src/components/MainSearch.tsx @@ -1,38 +1,77 @@ -import React from 'react'; +import React, { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import '../styles/MainScreenWrapper.css'; +interface Filters { + professor: string; + course: string; + topic: string; +} + const MainSearch: React.FC = () => { + const [filters, setFilters] = useState({ + professor: '', + course: '', + topic: '', + }); + + const navigate = useNavigate(); + + const handleChange = (event: React.ChangeEvent) => { + const { name, value } = event.target; + setFilters((prevFilters: Filters) => ({ + ...prevFilters, + [name]: value, + })); + }; + + const handleSubmit = (event: React.FormEvent) => { + event.preventDefault(); + const input = filters.toString() + const searchParams = new URLSearchParams(input) + navigate(`/results?${searchParams}`); + }; + return ( -
+ <> + PeerNotes Logo +
- - {/* temporary */} + {/* temporary options */}
- - {/* temporary */} + {/* temporary options */}
- - {/* temporary */} + {/* temporary options */}
-
+ + ); } diff --git a/frontend/src/components/Results.tsx b/frontend/src/components/Results.tsx new file mode 100644 index 0000000..22e19e2 --- /dev/null +++ b/frontend/src/components/Results.tsx @@ -0,0 +1,69 @@ +import React, { useState, useEffect } from 'react'; +import { useLocation, useNavigate } from 'react-router-dom'; +import styles from '../screens/Results.module.css'; // Make sure this path is correct + +interface File { + id: string; + name: string; // do we even use id and name? + professor: string; + course: string; + type?: string; // Assumed type is optional + // what other properties to add?semester? +} + +const Results: React.FC = () => { + const [files, setFiles] = useState([]); + const [isLoading, setLoading] = useState(false); + const location = useLocation(); + const navigate = useNavigate(); + + useEffect(() => { + const fetchFiles = async () => { + setLoading(true); + try { + // Need to double check this + const queryString = location.search; // Includes the '?' prefix + const response = await fetch(`/api/path-to-filefilterview${queryString}`); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const data = await response.json(); + setFiles(data); + } catch (e) { + console.error("Could not fetch files", e); + } finally { + setLoading(false); + } + }; + + fetchFiles(); + }, [location]); + + const handleSearchAgain = () => { + navigate('/'); + }; + + if (isLoading) return
Loading...
; + + return ( +
+
+ PeerNotes Logo + +
+
+ {isLoading ? ( +

Loading...

+ ) : files.length ? ( + + {/* Table structure here */} +
+ ) : ( +

No results found.

+ )} +
+
+ ); +}; + +export default Results; diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index 14705c2..88bae49 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -8,6 +8,8 @@ import { } from "react-router-dom"; import Login from './screens/Login.tsx'; import Signup from './screens/Signup.tsx'; +import Results from './components/Results.tsx'; +import MainSearch from './components/MainSearch.tsx'; const router = createBrowserRouter([ { @@ -15,8 +17,17 @@ const router = createBrowserRouter([ element: , children: [ // add more routes here + { + path: "search", + element: , + }, + { + path: "results", + element: , + }, ] }, + { path: "/login", element: , diff --git a/frontend/src/screens/Results.module.css b/frontend/src/screens/Results.module.css new file mode 100644 index 0000000..30223ec --- /dev/null +++ b/frontend/src/screens/Results.module.css @@ -0,0 +1,57 @@ +.wrapper { + display: flex; + flex-direction: column; + height: 100vh; + color: #FFFFFF; + } + + .header { + display: flex; + justify-content: space-between; + padding: 10px 20px; + position: fixed; + width: 100%; + top: 0; + left: 0; + background-color: #145DA0; + } + + .logo { + height: 80px; /* Adjust according to preference */ + margin-right: auto; + } + + + .resultsContainer { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding-top: 100px; /* Adjust based on header height to ensure content doesn't overlap */ + margin: auto; + width: 90%; + max-width: 600px; + } + + .resultsTable { + /* to be filled out */ + width: 100%; + } + + + .searchAgainButton { + height: 50px; + padding: 4px 8px; + background-color: #0C2D48; + color: white; + border: none; + border-radius: 4px; + font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif; + cursor: pointer; + margin-right: 35px; + margin-top: 15px; + } + + .searchAgainButton:hover { + background-color: #B1D4E0; /* lighter shade for hover effect */ + } \ No newline at end of file diff --git a/frontend/src/styles/App.css b/frontend/src/styles/App.css index ee9db94..2909c89 100644 --- a/frontend/src/styles/App.css +++ b/frontend/src/styles/App.css @@ -7,4 +7,18 @@ nav { border-radius: 5px; color: black; background-color: white; -} \ No newline at end of file +} +.App { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; /* If you're centering the content */ + height: 100vh; /* Full height */ + margin-top: -100px; /* Move up */ + } + + body { + background-color: #0C2D48; + font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif; + } + \ No newline at end of file diff --git a/frontend/src/styles/MainScreenWrapper.css b/frontend/src/styles/MainScreenWrapper.css index f1d68e6..4c2d85c 100644 --- a/frontend/src/styles/MainScreenWrapper.css +++ b/frontend/src/styles/MainScreenWrapper.css @@ -15,9 +15,16 @@ html, body { justify-content: center; padding: 20px; background: #B1D4E0; + gap: 15; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* shadow */ } + + .logo { + height: 100px; /* Adjust this value as needed */ + width: auto; /* Keep the logo's aspect ratio */ + margin-bottom: 15px; /* Gap between logo and search box */ + } .filter-item + .filter-item { margin-top: 20px; /* space between filter items */