Skip to content

Commit 25e1baa

Browse files
authored
Implement Basic Version of Favourites Page (SE310-1#57)
* Created Favourites button in navbar Also set up the Favourites page folder, following the convention established by the previous group. The index and css files are yet to be implemented. * Placeholder implementation of favourites page * Created route for favourites page * /fix - route to favourites page Fixed the route, was previously incorrectly set so that only unauthenticated users could access the favourites page, and authenticated users were redirected to login. Fixed to now be vice versa * Fixed typo in App.jsx
1 parent 72a7b9e commit 25e1baa

File tree

7 files changed

+67
-33
lines changed

7 files changed

+67
-33
lines changed

.vs/ProjectSettings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"CurrentProjectSetting": null
3+
}

.vs/VSWorkspaceState.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ExpandedNodes": [
3+
""
4+
],
5+
"PreviewInSolutionExplorer": false
6+
}

.vs/slnx.sqlite

88 KB
Binary file not shown.

client/src/App.jsx

+37-32
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,49 @@
1-
import {BrowserRouter, Navigate, Route, Routes,} from 'react-router-dom'
2-
import {useAuthContext} from './hooks/useAuthContext'
1+
import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom";
2+
import { useAuthContext } from "./hooks/useAuthContext";
33
import Navbar from "./Components/Navbar/index.jsx";
44
import Login from "./Pages/Login/index.jsx";
55
import Signup from "./Pages/Signup/index.jsx";
66
import Home from "./Pages/Home/index.jsx";
7-
import './App.css'
8-
import MovieDetailsPage from './Pages/Details';
7+
import "./App.css";
8+
import MovieDetailsPage from "./Pages/Details";
99
import Search from "./Pages/Search/Search.jsx";
10+
import Favourites from "./Pages/Favourites";
1011

1112
function App() {
12-
const {user} = useAuthContext()
13+
const { user } = useAuthContext();
1314

14-
return (
15-
<div className="App">
16-
<BrowserRouter>
17-
<Navbar/>
18-
<div className="pages">
19-
<Routes>
20-
<Route
21-
path="/"
22-
element={user ? <Home/> : <Navigate to="/login"/>}
23-
/>
24-
<Route
25-
path="/search"
26-
element={user ? <Search/> : <Navigate to="/login"/>}
27-
/>
28-
<Route path="/detail/:id" element={<MovieDetailsPage/>} />
29-
<Route
30-
path="/login"
31-
element={!user ? <Login/> : <Navigate to="/"/>}
32-
/>
33-
<Route
34-
path="/signup"
35-
element={!user ? <Signup/> : <Navigate to="/"/>}
36-
/>
37-
</Routes>
38-
</div>
39-
</BrowserRouter>
15+
return (
16+
<div className="App">
17+
<BrowserRouter>
18+
<Navbar />
19+
<div className="pages">
20+
<Routes>
21+
<Route
22+
path="/"
23+
element={user ? <Home /> : <Navigate to="/login" />}
24+
/>
25+
<Route
26+
path="/search"
27+
element={user ? <Search /> : <Navigate to="/login" />}
28+
/>
29+
<Route path="/detail/:id" element={<MovieDetailsPage />} />
30+
<Route
31+
path="/login"
32+
element={!user ? <Login /> : <Navigate to="/" />}
33+
/>
34+
<Route
35+
path="/signup"
36+
element={!user ? <Signup /> : <Navigate to="/" />}
37+
/>
38+
<Route
39+
path="/favourites"
40+
element={user ? <Favourites /> : <Navigate to="/signup" />}
41+
/>
42+
</Routes>
4043
</div>
41-
)
44+
</BrowserRouter>
45+
</div>
46+
);
4247
}
4348

4449
export default App;

client/src/Components/Navbar/index.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const Navbar = () => {
2121
{user ? (
2222
<div>
2323
<span>Welcome {user.username}</span>
24+
<button className="button-13">
25+
<Link to="/favourites">Favourites</Link>
26+
</button>
2427
<button className="button-13">
2528
<Link to="/search" className="search-button">
2629
<i className="fas fa-search"></i> Search
@@ -29,7 +32,6 @@ const Navbar = () => {
2932
<button className="button-13" onClick={handleClick}>
3033
<i className="fas fa-sign-out-alt"></i> Logout
3134
</button>
32-
3335
</div>
3436
) : (
3537
<div>

client/src/Pages/Favourites/index.jsx

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
3+
const Favourites = () => {
4+
// The actual list component content goes here
5+
return (
6+
<div>
7+
<h1>Favourites</h1>
8+
<ul>
9+
<li>Item 1</li>
10+
<li>Item 2</li>
11+
<li>Item 3</li>
12+
{/* Add more list items as needed */}
13+
</ul>
14+
</div>
15+
);
16+
}
17+
18+
export default Favourites;

client/src/Pages/Favourites/style.css

Whitespace-only changes.

0 commit comments

Comments
 (0)