diff options
-rw-r--r-- | src/App.js | 4 | ||||
-rw-r--r-- | src/components/Home.js | 3 | ||||
-rw-r--r-- | src/components/Navbar.js | 22 | ||||
-rw-r--r-- | src/layouts/GridLayout.js | 7 | ||||
-rw-r--r-- | src/pages/404.js | 26 | ||||
-rw-r--r-- | src/pages/About.js | 26 | ||||
-rw-r--r-- | src/pages/Careers.js | 26 | ||||
-rw-r--r-- | src/pages/Contact.js | 26 | ||||
-rw-r--r-- | src/pages/Dashboard.js | 4 | ||||
-rw-r--r-- | src/pages/HelpCenter.js | 26 | ||||
-rw-r--r-- | src/pages/PrivacyPolicy.js | 26 | ||||
-rw-r--r-- | src/pages/Profile.js | 23 | ||||
-rw-r--r-- | src/pages/TermsOfService.js | 26 | ||||
-rw-r--r-- | src/providers/AuthContext.js | 26 |
14 files changed, 232 insertions, 39 deletions
@@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React from 'react'; import { BrowserRouter as Router, Routes, Route, useLocation } from 'react-router-dom'; import Navbar from './components/Navbar'; import Footer from './components/Footer'; @@ -15,6 +15,7 @@ import TermsOfService from "./pages/TermsOfService"; import PrivacyPolicy from "./pages/PrivacyPolicy"; import Dashboard from "./pages/Dashboard"; import {AuthProvider} from "./providers/AuthContext"; +import Profile from "./pages/Profile"; function App() { const location = useLocation(); @@ -34,6 +35,7 @@ function App() { <Route path="/privacy-policy" element={<PrivacyPolicy />} /> <Route path="/login" element={<Login />} /> <Route path="/dashboard" element={<Dashboard />} /> + <Route path="/profile" element={<Profile />} /> <Route path="/forgot-password" element={<ForgotPassword />} /> <Route path="/sign-up" element={<SignUp />} /> </Routes> diff --git a/src/components/Home.js b/src/components/Home.js index dd368ed..8892880 100644 --- a/src/components/Home.js +++ b/src/components/Home.js @@ -6,6 +6,7 @@ import Cta from "../components/Cta"; import Faq from "../components/Faq"; import {AuthContext} from "../providers/AuthContext"; import React, {useContext} from "react"; +import GridLayout from "../layouts/GridLayout"; const Home = () => { const {user} = useContext(AuthContext); @@ -29,8 +30,10 @@ const Home = () => { <Cta/> </> ) : ( + <GridLayout> <> </> + </GridLayout> )} </> ); diff --git a/src/components/Navbar.js b/src/components/Navbar.js index 3fdf94d..a836e22 100644 --- a/src/components/Navbar.js +++ b/src/components/Navbar.js @@ -10,7 +10,7 @@ import {BellIcon} from "@heroicons/react/24/outline"; const Navbar = () => { - const { user } = useContext(AuthContext); + const { user, logout } = useContext(AuthContext); const loggedOutNavigation = [ "Find Opportunities", @@ -142,11 +142,23 @@ const Navbar = () => { </div> </div> <ul className="py-2 text-sm text-gray-700 dark:text-gray-200"> - {loggedInNavigation.map((menu, index) => ( + {loggedInNavigation.map((item, index) => ( <li className="mr-3 nav__item" key={index}> - <Link key={index} to={`/${menu.toLowerCase().replace(/\s+/g, '-')}`} className="inline-block px-4 py-2 text-md font-normal text-gray-800 no-underline rounded-md dark:text-gray-200 hover:text-indigo-500 focus:text-indigo-500 focus:bg-indigo-100 focus:outline-none dark:focus:bg-gray-800"> - {menu} - </Link> + {item === 'Sign Out' ? ( + <button + onClick={logout} + className="inline-block px-4 py-2 text-md font-normal text-gray-800 no-underline rounded-md dark:text-gray-200 hover:text-indigo-500 focus:text-indigo-500 focus:bg-indigo-100 focus:outline-none dark:focus:bg-gray-800" + > + {item} + </button> + ) : ( + <Link + to={`/${item.toLowerCase().replace(/\s+/g, '-')}`} + className="inline-block px-4 py-2 text-md font-normal text-gray-800 no-underline rounded-md dark:text-gray-200 hover:text-indigo-500 focus:text-indigo-500 focus:bg-indigo-100 focus:outline-none dark:focus:bg-gray-800" + > + {item} + </Link> + )} </li> ))} </ul> diff --git a/src/layouts/GridLayout.js b/src/layouts/GridLayout.js index a96b351..506a934 100644 --- a/src/layouts/GridLayout.js +++ b/src/layouts/GridLayout.js @@ -58,13 +58,12 @@ const GridLayout = ({ children }) => { </div> {/*Middle column */} - <div className="overflow-auto bg-blue-300 h-screen">01 - <div>01 asdfasdf</div> + <div className="overflow-auto bg-blue-300 h-screen"> + {children} </div> {/*Right column */} - <div className="bg-green-300">01</div> - {children} + <div></div> </div> ); } diff --git a/src/pages/404.js b/src/pages/404.js index 9026548..17be31e 100644 --- a/src/pages/404.js +++ b/src/pages/404.js @@ -1,3 +1,23 @@ -export default function FoHunnid() { - return <h1>this page should be a fallback - something went wrong rip</h1> -}
\ No newline at end of file +import React, { useContext } from 'react'; +import { AuthContext } from '../providers/AuthContext'; +import GridLayout from '../layouts/GridLayout'; + +const FoHunnid = () => { + const { user } = useContext(AuthContext); + + return ( + <> + {!user ? ( + <h1>fo-hunnid</h1> + ) : ( + <GridLayout> + <> + fo-hunnid + </> + </GridLayout> + )} + </> + ); +}; + +export default FoHunnid;
\ No newline at end of file diff --git a/src/pages/About.js b/src/pages/About.js index ac11556..e64e9cd 100644 --- a/src/pages/About.js +++ b/src/pages/About.js @@ -1,3 +1,23 @@ -export default function About() { - return <h1>hands that help</h1> -}
\ No newline at end of file +import React, { useContext } from 'react'; +import { AuthContext } from '../providers/AuthContext'; +import GridLayout from '../layouts/GridLayout'; + +const About = () => { + const { user } = useContext(AuthContext); + + return ( + <> + {!user ? ( + <h1>hands that help</h1> + ) : ( + <GridLayout> + <> + hands that help + </> + </GridLayout> + )} + </> + ); +}; + +export default About;
\ No newline at end of file diff --git a/src/pages/Careers.js b/src/pages/Careers.js index 2b88706..889695c 100644 --- a/src/pages/Careers.js +++ b/src/pages/Careers.js @@ -1,3 +1,23 @@ -export default function Careers() { - return <h1>we cant even get jobs, how we gonna employee you??</h1> -}
\ No newline at end of file +import React, { useContext } from 'react'; +import { AuthContext } from '../providers/AuthContext'; +import GridLayout from '../layouts/GridLayout'; + +const Careers = () => { + const { user } = useContext(AuthContext); + + return ( + <> + {!user ? ( + <h1>we cant even get jobs, how we gonna employee you??</h1> + ) : ( + <GridLayout> + <> + we cant even get jobs, how we gonna employee you?? + </> + </GridLayout> + )} + </> + ); +}; + +export default Careers;
\ No newline at end of file diff --git a/src/pages/Contact.js b/src/pages/Contact.js index e174b9a..dfcc05a 100644 --- a/src/pages/Contact.js +++ b/src/pages/Contact.js @@ -1,3 +1,23 @@ -export default function ContactUs() { - return <h1>dont contact us pls</h1> -}
\ No newline at end of file +import React, { useContext } from 'react'; +import { AuthContext } from '../providers/AuthContext'; +import GridLayout from '../layouts/GridLayout'; + +const ContactUs = () => { + const { user } = useContext(AuthContext); + + return ( + <> + {!user ? ( + <h1>don't contact us pls</h1> + ) : ( + <GridLayout> + <> + don't contact us pls + </> + </GridLayout> + )} + </> + ); +}; + +export default ContactUs;
\ No newline at end of file diff --git a/src/pages/Dashboard.js b/src/pages/Dashboard.js index c7f136d..5bdfdcf 100644 --- a/src/pages/Dashboard.js +++ b/src/pages/Dashboard.js @@ -1,9 +1,9 @@ -import Sidebar from "../components/Sidebar"; +import GridLayout from "../layouts/GridLayout"; const Dashboard = () => { return ( <> - <Sidebar /> + <GridLayout /> </> ); } diff --git a/src/pages/HelpCenter.js b/src/pages/HelpCenter.js index 22206fd..bafde98 100644 --- a/src/pages/HelpCenter.js +++ b/src/pages/HelpCenter.js @@ -1,3 +1,23 @@ -export default function HelpCenter() { - return <h1>halp</h1> -}
\ No newline at end of file +import React, { useContext } from 'react'; +import { AuthContext } from '../providers/AuthContext'; +import GridLayout from '../layouts/GridLayout'; + +const HelpCenter = () => { + const { user } = useContext(AuthContext); + + return ( + <> + {!user ? ( + <h1>halp</h1> + ) : ( + <GridLayout> + <> + halp + </> + </GridLayout> + )} + </> + ); +}; + +export default HelpCenter;
\ No newline at end of file diff --git a/src/pages/PrivacyPolicy.js b/src/pages/PrivacyPolicy.js index 27333d1..e8ad594 100644 --- a/src/pages/PrivacyPolicy.js +++ b/src/pages/PrivacyPolicy.js @@ -1,3 +1,23 @@ -export default function PrivacyPolicy() { - return <h1>so private</h1> -}
\ No newline at end of file +import React, { useContext } from 'react'; +import { AuthContext } from '../providers/AuthContext'; +import GridLayout from '../layouts/GridLayout'; + +const PrivacyPolicy = () => { + const { user } = useContext(AuthContext); + + return ( + <> + {!user ? ( + <h1>so private</h1> + ) : ( + <GridLayout> + <> + so private + </> + </GridLayout> + )} + </> + ); +}; + +export default PrivacyPolicy;
\ No newline at end of file diff --git a/src/pages/Profile.js b/src/pages/Profile.js new file mode 100644 index 0000000..3776245 --- /dev/null +++ b/src/pages/Profile.js @@ -0,0 +1,23 @@ +import React, { useContext } from 'react'; +import { AuthContext } from '../providers/AuthContext'; +import GridLayout from '../layouts/GridLayout'; + +const Profile = () => { + const { user } = useContext(AuthContext); + + return ( + <> + {!user ? ( + <h1>private</h1> + ) : ( + <GridLayout> + <> + private + </> + </GridLayout> + )} + </> + ); +}; + +export default Profile;
\ No newline at end of file diff --git a/src/pages/TermsOfService.js b/src/pages/TermsOfService.js index 71df372..0f0688f 100644 --- a/src/pages/TermsOfService.js +++ b/src/pages/TermsOfService.js @@ -1,3 +1,23 @@ -export default function TermsOfService() { - return <h1>be good volunteer pls</h1> -}
\ No newline at end of file +import React, { useContext } from 'react'; +import { AuthContext } from '../providers/AuthContext'; +import GridLayout from '../layouts/GridLayout'; + +const TermsOfService = () => { + const { user } = useContext(AuthContext); + + return ( + <> + {!user ? ( + <h1>don't be a douche pls</h1> + ) : ( + <GridLayout> + <> + don't be a douche pls + </> + </GridLayout> + )} + </> + ); +}; + +export default TermsOfService;
\ No newline at end of file diff --git a/src/providers/AuthContext.js b/src/providers/AuthContext.js index a32fb01..03ab298 100644 --- a/src/providers/AuthContext.js +++ b/src/providers/AuthContext.js @@ -1,4 +1,4 @@ -import React, { createContext, useEffect, useState } from 'react'; +import React, {createContext, useEffect, useState} from 'react'; export const AuthContext = createContext(); @@ -33,11 +33,25 @@ export const AuthProvider = ({ children }) => { localStorage.setItem('refreshToken', token); }; - const logout = () => { - setUser(null); - setRefreshToken(null); - localStorage.removeItem('user'); - localStorage.removeItem('refreshToken'); + const logout = async () => { + try { + const response = await fetch(process.env.REACT_APP_LOGOUT_ROUTE, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }); + if (response.ok) { + setUser(null); + setRefreshToken(null); + localStorage.removeItem('user'); + localStorage.removeItem('refreshToken'); + } else { + console.error('Logout failed:', response.statusText); + } + } catch (error) { + console.error('Error logging out:', error); + } }; const authContextValue = { |