Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
516a337
initial commit, server connected to frontend and database
devinfiachra Jul 18, 2023
45c4127
added fluent ui component library
devinfiachra Jul 18, 2023
2991ca2
update config to connect client with the external live database
devinfiachra Jul 19, 2023
9d019ee
update hard coded server routes to point to external backend
devinfiachra Jul 19, 2023
4967a39
update config for vite frontend deployment on netlify
devinfiachra Jul 19, 2023
19ca406
update config for external deployment of vite app
devinfiachra Jul 19, 2023
589f3c9
update git ignore
devinfiachra Jul 19, 2023
aeebe55
new basic placeholder homepage elements for testing the API call
bienenbohnenbuhnen Jul 19, 2023
3d5cb78
basic-fluent-styled-homepage-elements
bienenbohnenbuhnen Jul 19, 2023
af5a7cb
Merge remote-tracking branch 'origin/add-basic-hompage-elements-to-ho…
devinfiachra Jul 19, 2023
699240d
Merge pull request #2 from devinfiachra/release-2023-1907-1
devinfiachra Jul 19, 2023
257d412
update directory structure for readability
devinfiachra Jul 20, 2023
8ffc7d8
Merge pull request #3 from devinfiachra/feature-update-login-routing
devinfiachra Jul 20, 2023
8332211
add button from fluent ui library to navbar
devinfiachra Jul 20, 2023
e252fb0
update styles signim page using ui-library
devinfiachra Jul 20, 2023
a2197cc
update styles login/registration page using ui-library
devinfiachra Jul 20, 2023
b416885
update login page ui
devinfiachra Jul 20, 2023
0e81955
update Signup function to generate token on login and route the user…
devinfiachra Jul 20, 2023
d094af3
Merge pull request #4 from devinfiachra/release-2023-20-07-1
devinfiachra Jul 20, 2023
da1fdd8
stuck on authorization
bienenbohnenbuhnen Jul 20, 2023
a10ac75
api response sent to console, rendering not complete
bienenbohnenbuhnen Jul 20, 2023
e2d507f
therapist scaffolding creation, auth path not yet clarified
bienenbohnenbuhnen Jul 21, 2023
09a3e85
fully functional therapist login and signup
bienenbohnenbuhnen Jul 21, 2023
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
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REACT_APP_SERVER_URL=http://localhost:5005
# VITE_LIVE_SERVER=https://bookworm-backend.adaptable.app
VITE_LIVE_SERVER=http://localhost:5005
DEV_SERVER=http://localhost:5005
4 changes: 3 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
REACT_APP_SERVER_URL=http://localhost:5005
REACT_APP_SERVER_URL=http://localhost:5005
# update live server string when working locally - change to localhost:5005
VITE_LIVE_SERVER=
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ dist
dist-ssr
*.local

.env

# Editor directories and files
.vscode/*
!.vscode/extensions.json
Expand Down
2,215 changes: 2,182 additions & 33 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@fluentui/react-components": "^9.26.1",
"axios": "^1.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
120 changes: 96 additions & 24 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
FluentProvider,
teamsLightTheme,
Button,
Input,
} from "@fluentui/react-components";
import "./App.css";
import { Routes, Route } from "react-router-dom";
import Navbar from "./components/Navbar";
Expand All @@ -10,34 +16,100 @@ import SignupPage from "./pages/SignupPage";
import LoginPage from "./pages/LoginPage";
import IsPrivate from "./components/IsPrivate";
import IsAnon from "./components/IsAnon";
import IsTherapist from "./components/IsTherapist";
import TherapistLoginPage from "./pages/TherapistLogin";
import TherapistSignupPage from "./pages/TherapistSignUp";
import TherapistDashboard from "./pages/TherapistDashboard";

function App() {
return (
<div className="App">
<Navbar />

<Routes>
<Route path="/" element={<HomePage />} />

<Route
path="/projects"
element={ <IsPrivate> <ProjectListPage /> </IsPrivate> }
/>

<Route
path="/projects/:projectId"
element={ <IsPrivate> <ProjectDetailsPage /> </IsPrivate> }
/>

<Route
path="/projects/edit/:projectId"
element={ <IsPrivate> <EditProjectPage /> </IsPrivate> }
/>

<Route path="/signup" element={<IsAnon> <SignupPage /> </IsAnon>} />
<Route path="/login" element={<IsAnon> <LoginPage /> </IsAnon>} />

</Routes>
<FluentProvider theme={teamsLightTheme}>
<Navbar />

<Button appearance="primary">FLUENT UI FOR STEPHEN</Button>

<Routes>
<Route path="/" element={<HomePage />} />

<Route
path="/projects"
element={
<IsPrivate>
{" "}
<ProjectListPage />{" "}
</IsPrivate>
}
/>

<Route
path="/projects/:projectId"
element={
<IsPrivate>
{" "}
<ProjectDetailsPage />{" "}
</IsPrivate>
}
/>

<Route
path="/projects/edit/:projectId"
element={
<IsPrivate>
{" "}
<EditProjectPage />{" "}
</IsPrivate>
}
/>

<Route
path="/signup"
element={
<IsAnon>
{" "}
<SignupPage />{" "}
</IsAnon>
}
/>
<Route
path="/login"
element={
<IsAnon>
{" "}
<LoginPage />{" "}
</IsAnon>
}
/>

<Route
path="/therapist/signup"
element={
<IsAnon>
{" "}
<TherapistSignupPage />{" "}
</IsAnon>
}
/>
<Route
path="/therapist/login"
element={
<IsAnon>
{" "}
<TherapistLoginPage />{" "}
</IsAnon>
}
/>
<Route
path="/therapist/dashboard"
element={
<IsTherapist>
{" "}
<TherapistDashboard />{" "}
</IsTherapist>
}
/>
</Routes>
</FluentProvider>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import { useState } from "react";
import axios from "axios";

const API_URL = "http://localhost:5005";
const API_URL = import.meta.env.VITE_LIVE_SERVER;

function AddProject(props) {
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");


const handleSubmit = (e) => {
e.preventDefault();
const requestBody = { title, description };

// Get the token from the localStorage
const storedToken = localStorage.getItem('authToken');
const storedToken = localStorage.getItem("authToken");

// Send the token through the request "Authorization" Headers
axios
.post(
`${API_URL}/api/projects`,
requestBody,
{ headers: { Authorization: `Bearer ${storedToken}` } }
)
.post(`${API_URL}/api/projects`, requestBody, {
headers: { Authorization: `Bearer ${storedToken}` },
})
.then((response) => {
// Reset the state
setTitle("");
Expand All @@ -31,7 +28,6 @@ function AddProject(props) {
.catch((error) => console.log(error));
};


return (
<div className="AddProject">
<h3>Add Project</h3>
Expand Down Expand Up @@ -59,4 +55,4 @@ function AddProject(props) {
);
}

export default AddProject;
export default AddProject;
25 changes: 10 additions & 15 deletions src/components/AddTask.jsx → src/components/AddTask/index.jsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,44 @@
import { useState } from "react";
import axios from "axios";

const API_URL = "http://localhost:5005";

const API_URL = import.meta.env.VITE_LIVE_SERVER;

function AddTask(props) {
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");


const handleSubmit = (e) => {
e.preventDefault();
e.preventDefault();

// We need the project id when creating the new task
const { projectId } = props;
// Create an object representing the body of the POST request
const requestBody = { title, description, projectId };

// Get the token from the localStorage
const storedToken = localStorage.getItem('authToken');
const storedToken = localStorage.getItem("authToken");

// Send the token through the request "Authorization" Headers
// Send the token through the request "Authorization" Headers
axios
.post(
`${API_URL}/api/tasks`,
requestBody,
{ headers: { Authorization: `Bearer ${storedToken}` } }
)
.post(`${API_URL}/api/tasks`, requestBody, {
headers: { Authorization: `Bearer ${storedToken}` },
})
.then((response) => {
// Reset the state to clear the inputs
setTitle("");
setDescription("");

// Invoke the callback function coming through the props
// from the ProjectDetailsPage, to refresh the project details
props.refreshProject();
})
.catch((error) => console.log(error));
};


return (
<div className="AddTask">
<h3>Add New Task</h3>

<form onSubmit={handleSubmit}>
<label>Title:</label>
<input
Expand All @@ -67,4 +62,4 @@ function AddTask(props) {
);
}

export default AddTask;
export default AddTask;
6 changes: 3 additions & 3 deletions src/components/IsAnon.jsx → src/components/IsAnon/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from "react";
import { AuthContext } from "../context/auth.context";
import { AuthContext } from "../../context/auth.context";
import { Navigate } from "react-router-dom";

function IsAnon({ children }) {
Expand All @@ -9,12 +9,12 @@ function IsAnon({ children }) {
if (isLoading) return <p>Loading ...</p>;

if (isLoggedIn) {
// If the user is logged in, navigate to home page ❌
// If the user is logged in, navigate to home page ❌
return <Navigate to="/" />;
} else {
// If the user is not logged in, allow to see the page ✅
return children;
}
}

export default IsAnon;
export default IsAnon;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from "react";
import { AuthContext } from "../context/auth.context";
import { AuthContext } from "../../context/auth.context";
import { Navigate } from "react-router-dom";

function IsPrivate({ children }) {
Expand All @@ -9,12 +9,12 @@ function IsPrivate({ children }) {
if (isLoading) return <p>Loading ...</p>;

if (!isLoggedIn) {
// If the user is not logged in ❌
// If the user is not logged in ❌
return <Navigate to="/login" />;
} else {
// If the user is logged in, allow to see the page ✅
// If the user is logged in, allow to see the page ✅
return children;
}
}

export default IsPrivate;
export default IsPrivate;
17 changes: 17 additions & 0 deletions src/components/IsTherapist/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useContext } from "react";
import { TherapistAuthContext } from "../../context/therapistAuth.context";
import { Navigate } from "react-router-dom";

function IsTherapist({ children }) {
const { isLoggedIn, isLoading } = useContext(TherapistAuthContext);

if (isLoading) return <p>Loading ...</p>;

if (!isLoggedIn) {
return <Navigate to="/therapist/login" />;
} else {
return children;
}
}

export default IsTherapist;
20 changes: 14 additions & 6 deletions src/components/Navbar.jsx → src/components/Navbar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button } from "@fluentui/react-components";
import { Link } from "react-router-dom";
import { useContext } from "react";
import { AuthContext } from "../context/auth.context";
import { AuthContext } from "../../context/auth.context";

function Navbar() {
// Subscribe to the AuthContext to gain access to
Expand All @@ -10,16 +11,16 @@ function Navbar() {
return (
<nav>
<Link to="/">
<button>Home</button>
<Button>Home</Button>
</Link>

{isLoggedIn && (
<>
<Link to="/projects">
<button>Projects</button>
<Button>Projects</Button>
</Link>

<button onClick={logOutUser}>Logout</button>
<Button onClick={logOutUser}>Logout</Button>
<span>{user && user.name}</span>
</>
)}
Expand All @@ -28,11 +29,18 @@ function Navbar() {
<>
<Link to="/signup">
{" "}
<button>Sign Up</button>{" "}
<Button>Sign Up</Button>{" "}
</Link>
<Link to="/login">
{" "}
<button>Login</button>{" "}
<Button>Login</Button>{" "}
</Link>
<Link to="/therapist/signup">
<Button>Sign Up Therapist</Button>
</Link>
<Link to="therapist/login">
{" "}
<Button>TherapistLogin</Button>{" "}
</Link>
</>
)}
Expand Down
File renamed without changes.
File renamed without changes.
Loading