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

Added Frontend Routes and renamed all "Register" items to "SignUp" #16

Merged
merged 6 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 58 additions & 31 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,77 @@
import './App.css';
import EmailSending from './components/EmailTemplates/EmailSending';
import { ChakraProvider } from '@chakra-ui/react';
import { Route, Routes, BrowserRouter as Router } from 'react-router-dom';
import { CookiesProvider } from 'react-cookie';
import Login from './components/Authentication/Login';
import Logout from './components/Authentication/Logout';
import Register from './components/Authentication/register';
import Dashboard from './pages/Dashboard/Dashboard';
import PublishedSchedule from './pages/PublishedSchedule/PublishedSchedule';
import SignUp from './components/Authentication/SignUp';
import Notifications from './pages/Notifications/Notifications';
import ForgotPassword from './components/Authentication/ForgotPassword';
import EmailAction from './components/Authentication/EmailAction';
import AUTH_ROLES from './utils/auth_config';
import ProtectedRoute from './utils/ProtectedRoute';
import Catalog from './pages/Catalog/Catalog';
import PublishedSchedule from './pages/PublishedSchedule/PublishedSchedule';
import Playground from './pages/Playground/Playground';

const { ADMIN_ROLE, USER_ROLE } = AUTH_ROLES.AUTH_ROLES;

const App = () => {
return (
<ChakraProvider>
<EmailSending />
<CookiesProvider>
<Router>
<Routes>
<Route exact path="/" element={<Login />} />
<Route exact path="/logout" element={<Logout />} />
<Route exact path="/forgotpassword" element={<ForgotPassword />} />
<Route exact path="/register" element={<Register />} />
<Route exact path="/emailAction" element={<EmailAction redirectPath="/" />} />
<Route exact path="/publishedSchedule" element={<PublishedSchedule />} />
<Route
exact
path="/dashboard"
element={
<ProtectedRoute
Component={Dashboard}
redirectPath="/"
roles={[ADMIN_ROLE, USER_ROLE]}
/>
}
/>
<Route exact path="/catalog" element={<Catalog />} />
</Routes>
</Router>
</CookiesProvider>
</ChakraProvider>
<ChakraProvider>
<CookiesProvider>
<Router>
<Routes>
<Route
exact path="/"
element={
<ProtectedRoute
Component={PublishedSchedule}
redirectPath='/login'
roles={[ADMIN_ROLE, USER_ROLE]}
/>
}
/>
<Route exact path="/login" element={<Login />} />
<Route exact path="/logout" element={<Logout />} />
<Route exact path="/forgotpassword" element={<ForgotPassword />} />
<Route exact path="/signUp" element={<SignUp />} />
<Route exact path="/emailAction" element={<EmailAction redirectPath="/" />} />
<Route
exact
path="/notifications"
element={
<ProtectedRoute
Component={Notifications}
redirectPath="/login"
roles={[ADMIN_ROLE, USER_ROLE]}
/>
}
/>
<Route
exact path="/catalog"
element={
<ProtectedRoute
Component={Catalog}
redirectPath="/login"
roles={[ADMIN_ROLE, USER_ROLE]}
/>
}
/>
<Route exact path="/publishedSchedule"
element={
<ProtectedRoute
Component={PublishedSchedule}
redirectPath="/login"
roles={[ADMIN_ROLE, USER_ROLE]}
/>
}
/>
<Route exact path="/playground" element={<Playground />}/>
</Routes>
</Router>
</CookiesProvider>
</ChakraProvider>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/Authentication/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Login = ({ cookies }) => {
const handleStdLogin = async e => {
try {
e.preventDefault();
await logInWithEmailAndPassword(email, password, '/dashboard', navigate, cookies);
await logInWithEmailAndPassword(email, password, '/publishedSchedule', navigate, cookies);
} catch (err) {
setErrorMessage(err.message);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Authentication/Logout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Logout = ({ cookies }) => {

const handleLogout = async () => {
try {
await logout('/', navigate, cookies);
await logout('/login', navigate, cookies);
} catch (err) {
setErrorMessage(err.message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { registerWithEmailAndPassword } from '../../utils/auth_utils';

const Register = () => {
const SignUp = () => {
const [email, setEmail] = useState();
const [password, setPassword] = useState();
const [checkPassword, setCheckPassword] = useState();
Expand Down Expand Up @@ -39,7 +39,7 @@ const Register = () => {

return (
<div>
<h2>Register</h2>
<h2>Sign Up</h2>
<form onSubmit={handleSubmit}>
<input type="text" onChange={({ target }) => setEmail(target.value)} placeholder="Email" />
<br />
Expand All @@ -57,7 +57,7 @@ const Register = () => {
type="password"
/>
<br />
<button type="submit">Register</button>
<button type="submit">Sign Up</button>
{/* <div className="login-buttons">
<button type="button" onClick={handleGoogleSignIn}>
<span>Sign Up With Google</span>
Expand All @@ -69,4 +69,4 @@ const Register = () => {
);
};

export default Register;
export default SignUp;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const Dashboard = () => {
const Notifications = () => {
return (
<div>
<h1>Dashboard</h1>
</div>
);
};

export default Dashboard;
export default Notifications;
9 changes: 9 additions & 0 deletions src/pages/Playground/Playground.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Playground = () => {
return (
<div>
<h1>Playground</h1>
</div>
);
};

export default Playground;
Loading