From 34ade650c38e6c41916b2b220e37461c682aca24 Mon Sep 17 00:00:00 2001 From: Korrectional <156260369+korrectional@users.noreply.github.com> Date: Sat, 1 Feb 2025 15:09:12 -0500 Subject: [PATCH 1/3] I hate frontend --- index.html | 2 +- src/App.css | 183 ++++++++++++----- src/App.tsx | 11 +- src/components/SettingsButton.tsx | 39 ++-- src/components/SettingsDashboard.tsx | 291 +++++++++++++-------------- src/pages/Contact.tsx | 14 +- src/pages/Dashboard.tsx | 67 +++--- src/pages/Home.tsx | 49 ++--- src/pages/TutorPage.tsx | 31 ++- 9 files changed, 379 insertions(+), 308 deletions(-) diff --git a/index.html b/index.html index e4b78ea..7aca349 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ Vite + React + TS - +
diff --git a/src/App.css b/src/App.css index c1ad642..27661f0 100644 --- a/src/App.css +++ b/src/App.css @@ -1,76 +1,161 @@ @import "tailwindcss"; +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; + background-color: #f8f9fa; +} + +html, body { + height: 100%; + width: 100%; +} + #root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; + display: flex; + flex-direction: column; + min-height: 100vh; +} + +.flex { + display: flex; +} + +.flex-col { + flex-direction: column; +} + +.min-h-screen { + min-height: 100vh; +} + +.w-full { + width: 100%; +} + +.bg-gray-100 { + background-color: #f7fafc; +} + +.flex-1 { + flex: 1; +} + +.max-w-7xl { + max-width: 80rem; +} + +.mx-auto { + margin-left: auto; + margin-right: auto; +} + +.px-4 { + padding-left: 1rem; + padding-right: 1rem; +} + +.sm\:px-6 { + padding-left: 1.5rem; + padding-right: 1.5rem; } -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; +.lg\:px-8 { + padding-left: 2rem; + padding-right: 2rem; } -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); + +.py-8 { + padding-top: 2rem; + padding-bottom: 2rem; +} + +.bg-white { + background-color: #ffffff; +} + +.rounded-lg { + border-radius: 0.5rem; +} + +.shadow-md { + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); +} + +.text-gray-600 { + color: #718096; +} + +.text-gray-900 { + color: #1a202c; +} + +.text-3xl { + font-size: 1.875rem; + line-height: 2.25rem; +} + +.font-semibold { + font-weight: 600; +} + +.mb-4 { + margin-bottom: 1rem; +} + +.mb-6 { + margin-bottom: 1.5rem; +} + +.space-x-4 > :not([hidden]) ~ :not([hidden]) { + --tw-space-x-reverse: 0; + margin-right: calc(1rem * var(--tw-space-x-reverse)); + margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse))); } -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); + +.bg-blue-600 { + background-color: #3182ce; +} + +.text-white { + color: #ffffff; } -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } +.font-bold { + font-weight: 700; } -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } +.py-2 { + padding-top: 0.5rem; + padding-bottom: 0.5rem; } -.card { - padding: 2em; +.px-4 { + padding-left: 1rem; + padding-right: 1rem; } -.read-the-docs { - color: #888; +.rounded { + border-radius: 0.25rem; } -.chats { - text-align: left; - width: 15%; - height: 200%; - float: left; - background-color: #888; - position: fixed; +.hover\:bg-blue-700:hover { + background-color: #2b6cb0; } -.chat-messages { - text-align: left; - margin-left: 15%; +.transition { + transition: all 0.2s; } -.chats-form { - margin-left: 16%; - display: flex; - position: fixed; - text-align: center; +.bg-gray-300 { + background-color: #e2e8f0; } -.text-input { - width: 67vw; - margin-right: 1vw; +.text-gray-700 { + color: #4a5568; } -.chats-submit { - bottom: 5px; - width: 10vw; +.hover\:bg-gray-400:hover { + background-color: #cbd5e0; } \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 843eb51..2467d20 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,7 +10,7 @@ import Header from './components/Header'; import Footer from './components/Footer'; import './App.css'; import { store } from './services/auth'; -import { BrowserRouter, Routes, Route } from 'react-router-dom'; // Corrected import +import { BrowserRouter, Routes, Route } from 'react-router-dom'; import ProtectedRoutes from './utils/protectedRoutes'; import AuthProvider from 'react-auth-kit'; @@ -18,9 +18,9 @@ function App() { return ( -
-
{/* Add a header for navigation */} -
+
+
+
} /> } /> @@ -32,10 +32,11 @@ function App() { } /> } /> } /> +
-
{/* Add a footer for additional links or info */} +
diff --git a/src/components/SettingsButton.tsx b/src/components/SettingsButton.tsx index a421b04..8f93ae4 100644 --- a/src/components/SettingsButton.tsx +++ b/src/components/SettingsButton.tsx @@ -1,26 +1,29 @@ import { useState } from "react"; -import SettingsDashboard from "./SettingsDashboard" +import SettingsDashboard from "./SettingsDashboard"; -export default function SettingsButton(){ +export default function SettingsButton() { const [isPopupOpen, setIsPopupOpen] = useState(false); - return( + return (
- - {isPopupOpen && ( -
setIsPopupOpen(true)} + className="bg-blue-600 text-white font-bold py-2 px-4 rounded hover:bg-blue-700 transition" > - - -
)} + Settings + + {isPopupOpen && ( +
+
+ + +
+
+ )}
); - } \ No newline at end of file diff --git a/src/components/SettingsDashboard.tsx b/src/components/SettingsDashboard.tsx index a84aaf3..87a7b3c 100644 --- a/src/components/SettingsDashboard.tsx +++ b/src/components/SettingsDashboard.tsx @@ -1,24 +1,3 @@ -/* -const newUser = { - email, - password: pass, // Store hashed password - name: (fName + " " + lName), - phone: phone, - role: isTutor ? "tutor" : "student", - chats: [], - // the following is information which is later defined by the user - description: "", - languages: ["en"], - state: "", - GPA: 0.0, - // tutor specific (leave blank for students) - teaches: [], // all the classes this tutor teaches - rating: 0.0, - - createdAt: new Date(), - }; - */ - import { useEffect, useState } from "react"; import useAuthUser from "react-auth-kit/hooks/useAuthUser"; @@ -34,7 +13,6 @@ export default function SettingsDashboard() { teaches: [], }); - useEffect(() => { fetch("http://localhost:3000/api/user/user-data", { method: "POST", @@ -44,7 +22,7 @@ export default function SettingsDashboard() { body: JSON.stringify({ token: authUser.token }), }).then(async (res) => { const data = await res.json(); - setSettings(() => ({ + setSettings(() => ({ name: data.name, role: data.role, description: data.description, @@ -52,52 +30,50 @@ export default function SettingsDashboard() { state: data.state, GPA: data.GPA, teaches: data.teaches, - })) - }) - },[]) - + })); + }); + }, []); const handleChange = (e) => { const { name, value, options } = e.target; if (e.target.multiple) { const selectedValues = Array.from(options) - .filter((option) => option?.selected) - .map((option) => option?.value); - + .filter((option) => option?.selected) + .map((option) => option?.value); + setSettings((prevSettings) => ({ - ...prevSettings, - [name]: selectedValues, + ...prevSettings, + [name]: selectedValues, })); } else { setSettings((prevSettings) => ({ - ...prevSettings, - [name]: value, + ...prevSettings, + [name]: value, })); } - }; + }; const handleToggle = (e) => { const { value, checked } = e.target; - + setSettings((prevSettings) => ({ ...prevSettings, language: checked - ? [...(prevSettings.language || []), value] // Add if checked - : (prevSettings.language || []).filter((lang) => lang !== value), // Remove if unchecked + ? [...(prevSettings.language || []), value] // Add if checked + : (prevSettings.language || []).filter((lang) => lang !== value), // Remove if unchecked })); }; - + const handleTeachesToggle = (e) => { const { value, checked } = e.target; - + setSettings((prevSettings) => ({ ...prevSettings, teaches: checked - ? [...prevSettings.teaches, value] // Add if checked - : prevSettings.teaches.filter((teach) => teach !== value), // Remove if unchecked + ? [...prevSettings.teaches, value] // Add if checked + : prevSettings.teaches.filter((teach) => teach !== value), // Remove if unchecked })); }; - const saveSettings = () => { console.log("Updated Settings:", settings); @@ -109,124 +85,131 @@ export default function SettingsDashboard() { body: JSON.stringify({ token: authUser.token, ...settings }), }).then(async (res) => { console.log("data modified", await res.json()); - }) + }); }; - return ( -
-

Settings

- {settings.name === "LOADING" ? ( -

Loading Page

- ) : ( -
- - - -
- - -
- -