-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from Matsadura/front-end
Front end
- Loading branch information
Showing
27 changed files
with
984 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="https://cdn-icons-png.flaticon.com/128/14090/14090460.png" /> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Gothic+A1:wght@400;500;700&display=swap" rel="stylesheet"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Clinema</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/favicon.ico" /> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Gothic+A1:wght@400;500;700&display=swap" rel="stylesheet"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Clinema</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
|
||
</html> |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createContext, useState } from "react"; | ||
import React from "react"; | ||
|
||
export const DataContext = createContext(); | ||
|
||
export const ContextProvider = ({ children }) => { | ||
const [isAuthenticated, setAuth] = useState(false); | ||
const [user, setUser] = useState(null); | ||
|
||
return ( | ||
<DataContext.Provider value={{ setAuth, setUser, isAuthenticated, user }}> | ||
{children} | ||
</DataContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,71 @@ | ||
import {useState} from "react"; | ||
import { useContext, useState } from "react"; | ||
import { CiBookmark } from "react-icons/ci"; | ||
import { FaUserCircle } from "react-icons/fa"; | ||
import clinema from "../images/Clinema.png"; // Adjust this depending on the location of Navbar.jsx | ||
|
||
|
||
import { DataContext } from "./Context"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
const Navbar = () => { | ||
const [activeLink, setActiveLink] = useState("Home"); | ||
const [activeLink, setActiveLink] = useState("Home"); | ||
const { user } = useContext(DataContext); | ||
const navigate = useNavigate(); | ||
|
||
const handleClick = (link) => { | ||
setActiveLink(link); | ||
} | ||
const handleClick = (link) => { | ||
setActiveLink(link); | ||
}; | ||
|
||
return ( | ||
<nav className="bg-secondary-dark p-4 flex justify-between items-center shadow-white shadow-b-xl"> | ||
{/* Left side - Logo */} | ||
<div className="text-white text-lg font-bold"> | ||
<img | ||
src={clinema} | ||
alt="Clinema" | ||
className="w-32 h-auto" | ||
/> | ||
</div> | ||
<div className="flex space-x-4 items-center"> | ||
<a href="#" | ||
onClick={() => handleClick("Home")} | ||
className={`text-gray-300 hover:text-white ${activeLink === "Home" ? "text-white" : ""}`} | ||
> | ||
Home | ||
</a> | ||
<a | ||
href="/about" | ||
onClick={() => handleClick("About us")} | ||
className={`text-gray-300 hover:text-white ${activeLink === "About us" ? "text-white" : ""}`} | ||
> | ||
About us | ||
</a> | ||
return ( | ||
<nav className="bg-secondary-dark p-4 flex justify-between items-center shadow-white shadow-b-xl"> | ||
{/* Left side - Logo */} | ||
<div className="text-white text-lg font-bold"> | ||
<img src={clinema} alt="Clinema" className="w-32 h-auto" /> | ||
</div> | ||
<div className="flex space-x-4 items-center"> | ||
<a | ||
href="#" | ||
onClick={() => handleClick("Home")} | ||
className={`text-gray-300 hover:text-white ${ | ||
activeLink === "Home" ? "text-white" : "" | ||
}`} | ||
> | ||
Home | ||
</a> | ||
<a | ||
href="/about" | ||
onClick={() => handleClick("About us")} | ||
className={`text-gray-300 hover:text-white ${ | ||
activeLink === "About us" ? "text-white" : "" | ||
}`} | ||
> | ||
About us | ||
</a> | ||
</div> | ||
{/*Right side - Home*/} | ||
<div className="flex space-x-4 items-center text-white"> | ||
{/*<div className="relative p-2 hover:bg-secondary-light rounded-full">*/} | ||
{/* <CiHome className="text-2xl text-green-400"/>*/} | ||
{/*</div>*/} | ||
{user ? ( | ||
<> | ||
<div className="p-2 hover:bg-secondary-light rounded-full"> | ||
<CiBookmark className="text-2xl" /> | ||
</div> | ||
{/*Right side - Home*/} | ||
<div className="flex space-x-4 items-center text-white"> | ||
{/*<div className="relative p-2 hover:bg-secondary-light rounded-full">*/} | ||
{/* <CiHome className="text-2xl text-green-400"/>*/} | ||
{/*</div>*/} | ||
<div className="p-2 hover:bg-secondary-light rounded-full"> | ||
<CiBookmark className="text-2xl"/> | ||
</div> | ||
<div className="p-2 hover:bg-secondary-light rounded-full"> | ||
<FaUserCircle className="text-2xl"/> | ||
</div> | ||
<div className="p-2 hover:bg-secondary-light rounded-full"> | ||
<FaUserCircle className="text-2xl" /> | ||
</div> | ||
</nav> | ||
); | ||
</> | ||
) : ( | ||
<button | ||
onClick={() => navigate("/auth")} | ||
className="p-2 hover:bg-secondary-light rounded-full | ||
font-bold w-20 bg-indigo-700 text-black" | ||
> | ||
login | ||
</button> | ||
)} | ||
</div> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default Navbar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { DataContext } from "./Context"; | ||
import { useContext } from "react"; | ||
import { Navigate } from "react-router-dom"; | ||
import { request } from "../tools/requestModule"; | ||
|
||
export const PrivateRoute = ({ open = false, element: Element }) => { | ||
const [isLoading, setIsLoading] = useState(true); | ||
const { setAuth, setUser, isAuthenticated } = useContext(DataContext); | ||
const token = localStorage.getItem("_token"); | ||
const headers = { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}; | ||
|
||
useEffect(() => { | ||
request("/auth_validate", headers) | ||
.then((res) => { | ||
if (res.status === 200) { | ||
setUser(res.data); | ||
setAuth(true); | ||
} else { | ||
setAuth(false); | ||
setUser(null); | ||
} | ||
}) | ||
.finally(() => { | ||
setIsLoading(false); | ||
}); | ||
}, []); | ||
|
||
if (isLoading) return null; | ||
|
||
if (open) { | ||
return <Element />; | ||
} | ||
|
||
return isAuthenticated ? <Element /> : <Navigate to="/auth" />; | ||
}; |
Oops, something went wrong.