Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge development #8

Merged
merged 9 commits into from
Oct 21, 2024
Merged
2 changes: 1 addition & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ geocoder_provider=mapquest
geocoder_api_key= # Get your API key from https://developer.mapquest.com/

# File upload configuration
file_upload_path=./public/uploads
file_upload_path=../ui/public/images
max_file_upload=1000000

# JWT configuration
Expand Down
26 changes: 26 additions & 0 deletions ui/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import pluginReact from 'eslint-plugin-react';

export default [
{ files: ['**/*.{js,mjs,cjs,jsx}'] },
{
languageOptions: {
globals: {
...globals.builtin,
...globals.browser,
...globals.node,
...globals.es2022,
...globals.es2023,
...globals.esnext,
},
},
settings: {
react: {
version: 'detect',
},
},
},
pluginJs.configs.recommended,
pluginReact.configs.flat.recommended,
];
352 changes: 173 additions & 179 deletions ui/package-lock.json

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"bootstrap": "^5.3.3",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-bootstrap": "^2.10.4",
"react-dom": "^18.3.1",
Expand All @@ -18,7 +19,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --passWithNoTests",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"lint": "npx eslint ."
},
"eslintConfig": {
"extends": [
Expand All @@ -37,5 +39,13 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@eslint/js": "^9.13.0",
"eslint": "^8.57.1",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^5.0.0",
"globals": "^15.11.0"
}
}
Binary file added ui/public/images/no-photo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 9 additions & 39 deletions ui/src/App.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useEffect, useState } from 'react';
import React from 'react';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { ToastContainer } from 'react-toastify';

import { Header, Footer } from './components';
import { HomePage, AboutPage, NotFoundPage } from './pages';
import { LoginPage, RegisterPage, ManageAccountPage } from './pages/user';
import { LoginPage, RegisterPage, ManageAccountPage, ResetPasswordPage, UpdatePasswordPage } from './pages/user';
import {
AddBootcampPage,
AddCoursePage,
Expand All @@ -18,18 +18,7 @@ import {
ManageReviewsPage,
} from './pages/bootcamps';

import ProtectedRoute from './routes/ProtectedRoute';

function App() {
const [isAuthenticated, setIsAuthenticated] = useState(false);

useEffect(() => {
const token = localStorage.getItem('token');
if (token) {
setIsAuthenticated(true);
}
}, []);

return (
<BrowserRouter>
<Header />
Expand All @@ -38,40 +27,21 @@ function App() {
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="/about" element={<AboutPage />} />
<Route path="/login" element={<LoginPage setIsAuthenticated={setIsAuthenticated} />} />
<Route path="/register" element={<RegisterPage />} />
<Route
path="/account/manage"
element={
<ProtectedRoute isAuthenticated={isAuthenticated}>
<ManageAccountPage />
</ProtectedRoute>
}
/>
<Route path="/user/login" element={<LoginPage />} />
<Route path="/user/register" element={<RegisterPage />} />
<Route path="/user/password/reset" element={<ResetPasswordPage />} />
<Route path="/user/password/update" element={<UpdatePasswordPage />} />
<Route path="/user/manage" element={<ManageAccountPage />} />
<Route path="/bootcamps" element={<BootcampsPage />} />
<Route path="/bootcamps/:bootcampId" element={<BootcampDetailsPage />} />
<Route path="/bootcamps/add" element={<AddBootcampPage />} />
<Route path="/bootcamps/manage" element={<ManageBootcampsPage />} />
<Route
path="/bootcamps/:bootcampId/manage"
element={
<ProtectedRoute isAuthenticated={isAuthenticated}>
<ManageBootcampPage />
</ProtectedRoute>
}
/>
<Route path="/bootcamps/:bootcampId/manage" element={<ManageBootcampPage />} />
<Route path="/bootcamps/:bootcampId/courses/add" element={<AddCoursePage />} />
<Route path="/bootcamps/:bootcampId/courses/manage" element={<ManageCoursesPage />} />
<Route path="/bootcamps/:bootcampId/reviews" element={<BootcampReviewsPage />} />
<Route path="/bootcamps/:bootcampId/reviews/manage" element={<ManageReviewsPage />} />{' '}
<Route
path="/bootcamps/:bootcampId/reviews/add"
element={
<ProtectedRoute isAuthenticated={isAuthenticated}>
<AddReviewPage />
</ProtectedRoute>
}
/>
<Route path="/bootcamps/:bootcampId/reviews/add" element={<AddReviewPage />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
</main>
Expand Down
13 changes: 12 additions & 1 deletion ui/src/components/Bootcamp.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import { Image } from 'react-bootstrap';

const Bootcamp = ({ id, photo, name, averageRating, location, careers }) => {
return (
<div className="card mb-3">
<div className="row no-gutters">
<div className="col-md-4">
<Image src={photo} className="card-img" alt={name} />
<Image src={`/images/${photo}`} className="card-img full-size-image" alt={name} />
</div>
<div className="col-md-8">
<div className="card-body">
Expand All @@ -27,4 +29,13 @@ const Bootcamp = ({ id, photo, name, averageRating, location, careers }) => {
);
};

Bootcamp.propTypes = {
id: PropTypes.string.isRequired,
photo: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
averageRating: PropTypes.number,
location: PropTypes.object.isRequired,
careers: PropTypes.array.isRequired,
};

export default Bootcamp;
10 changes: 9 additions & 1 deletion ui/src/components/BootcampReviewRating.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import { GrEdit, GrClose } from 'react-icons/gr';

const BootcampReviewRating = ({ bootcampId, bootCampName, bootCampRating }) => {
Expand All @@ -11,12 +13,18 @@ const BootcampReviewRating = ({ bootcampId, bootCampName, bootCampRating }) => {
<GrEdit />
</Link>

<button class="btn btn-danger mb-1">
<button className="btn btn-danger mb-1">
<GrClose />
</button>
</td>
</tr>
);
};

BootcampReviewRating.propTypes = {
bootcampId: PropTypes.string.isRequired,
bootCampName: PropTypes.string.isRequired,
bootCampRating: PropTypes.number.isRequired,
};

export default BootcampReviewRating;
1 change: 1 addition & 0 deletions ui/src/components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
const Footer = () => {
return <footer>{/* Add footer details here */}</footer>;
};
Expand Down
11 changes: 9 additions & 2 deletions ui/src/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import { Nav, Navbar, Container, Dropdown } from 'react-bootstrap';
import { FaSignInAlt, FaUserPlus, FaSearch, FaUser, FaSignOutAlt, FaCogs, FaStar } from 'react-icons/fa';

Expand Down Expand Up @@ -46,10 +48,10 @@ function Header({ isAuthenticated, setIsAuthenticated }) {
</Dropdown>
) : (
<>
<Nav.Link as={Link} to="/login">
<Nav.Link as={Link} to="/user/login">
<FaSignInAlt /> Login
</Nav.Link>
<Nav.Link as={Link} to="/register">
<Nav.Link as={Link} to="/user/register">
<FaUserPlus /> Register
</Nav.Link>
</>
Expand All @@ -66,4 +68,9 @@ function Header({ isAuthenticated, setIsAuthenticated }) {
);
}

Header.propTypes = {
isAuthenticated: PropTypes.bool,
setIsAuthenticated: PropTypes.func,
};

export default Header;
1 change: 1 addition & 0 deletions ui/src/components/Pagination.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
const Pagination = () => {
return (
<nav aria-label="Page navigation example">
Expand Down
6 changes: 6 additions & 0 deletions ui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ img {
align-items: center;
height: 100vh; /* Full viewport height */
}

.full-size-image {
width: 100%;
height: 100%;
object-fit: cover;
}
1 change: 1 addition & 0 deletions ui/src/pages/AboutPage.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
const AboutPage = () => {
return <div>AboutPage</div>;
};
Expand Down
1 change: 1 addition & 0 deletions ui/src/pages/HomePage.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { Row, Col, Form, Button } from 'react-bootstrap';

const HomePage = () => {
Expand Down
1 change: 1 addition & 0 deletions ui/src/pages/NotFoundPage.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
const NotFoundPage = () => {
return <div>Not Found Page</div>;
};
Expand Down
8 changes: 7 additions & 1 deletion ui/src/pages/bootcamps/AddBootcampPage.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';

Expand All @@ -21,6 +21,9 @@ const AddBootcampPage = () => {
});

const [error, setError] = useState(null);

// TODO: Fix eslint error during page implementation
// eslint-disable-next-line
const { name, address, phone, email, website, description, careers, housing, jobAssistance, jobGuarantee, acceptGi } =
formData;

Expand All @@ -44,6 +47,9 @@ const AddBootcampPage = () => {
}
};

// TODO: Add error handling
if (error) return <h1>Error: {error}</h1>;

return (
<section className="container mt-5">
<div className="container">
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/bootcamps/AddCoursePage.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';
import { Link, useParams, useNavigate } from 'react-router-dom';
import { AiOutlineLeft } from 'react-icons/ai';
import courseService from '../../services/courseService';
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/bootcamps/BootcampDetailsPage.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import React, { useState, useEffect } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { Button, Card, ListGroup } from 'react-bootstrap';
import { FaCheck, FaComments, FaTimes } from 'react-icons/fa';
Expand Down
6 changes: 3 additions & 3 deletions ui/src/pages/bootcamps/BootcampReviewsPage.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import React, { useState, useEffect } from 'react';
import { Link, useParams } from 'react-router-dom';
import Card from 'react-bootstrap/Card';
import { FaPencil } from 'react-icons/fa6';
Expand Down Expand Up @@ -30,8 +30,8 @@ const BootcampReviewsPage = () => {
</Link>
<h1 className="mb-4">{bootcamp} Reviews</h1>
{/* <!-- Reviews --> */}
{reviews.map((data, key) => (
<Card className="card mb-3">
{reviews.map((data) => (
<Card className="card mb-3" key={data.key}>
<h5 className="card-header bg-dark text-white">{data.title}</h5>
<div className="card-body">
<h5 className="card-title">
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/bootcamps/BootcampsPage.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import React, { useState, useEffect } from 'react';
import { Oval } from 'react-loader-spinner';
import { Bootcamp } from '../../components';
import bootcampService from '../../services/bootcampService';
Expand Down
Loading