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

#5 Add Metadata #17

Closed
wants to merge 5 commits into from
Closed
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
14 changes: 14 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"date-fns": "^2.28.0",
"dateformat": "^5.0.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-router-dom": "^6.3.0",
Expand Down
Binary file removed frontend/public/favicon.ico
Binary file not shown.
8 changes: 4 additions & 4 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="%PUBLIC_URL%/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="A simple yet productive task manager"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />

<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand All @@ -25,7 +25,7 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />
<title>React App</title>
<title>TaskWizard</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file added frontend/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/public/logo192.png
Binary file not shown.
Binary file removed frontend/public/logo512.png
Binary file not shown.
5 changes: 4 additions & 1 deletion frontend/src/components/TaskDetails.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTasksContext } from "../hooks/usetasksContext";
import { useAuthContext } from "../hooks/useAuthContext";

import dateFormat from "dateformat";
const TaskDetails = ({ task }) => {
const { dispatch } = useTasksContext();
const { user } = useAuthContext();
Expand Down Expand Up @@ -35,6 +35,9 @@ const TaskDetails = ({ task }) => {
<strong>Progress: </strong>
{task.progress}
</p>
<p>
{dateFormat(task.createdAt,"longDate")}
</p>
<span className="material-symbols-outlined" onClick={handleClick}>
delete
</span>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/hooks/useLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useAuthContext } from "./useAuthContext";

export const useLogin = () => {
const [isLoading, setIsLoading] = useState(null);
const [error, setError] = useState(null);
const { dispatch } = useAuthContext();

const login = async (email, password) => {
Expand All @@ -16,6 +17,7 @@ export const useLogin = () => {
const json = await response.json();

if (!response.ok) {
setError(json.error);
setIsLoading(false);
}
if (response.ok) {
Expand All @@ -24,10 +26,12 @@ export const useLogin = () => {
// update the auth context
dispatch({ type: "LOGIN", payload: json });

// saving it to localStorage of browser to save user session
localStorage.setItem("user", JSON.stringify(json));
// update loading state
setIsLoading(false);
}
};

return { login, isLoading };
return { login, isLoading, error };
};
5 changes: 3 additions & 2 deletions frontend/src/hooks/useSignup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useAuthContext } from "./useAuthContext";
export const useSignup = () => {
const [isLoading, setIsLoading] = useState(null);
const { dispatch } = useAuthContext();

const [error, setError] = useState(null);
const signup = async (email, password) => {
setIsLoading(true);

Expand All @@ -16,6 +16,7 @@ export const useSignup = () => {
const json = await response.json();

if (!response.ok) {
setError(json.error);
setIsLoading(false);
}
if (response.ok) {
Expand All @@ -29,5 +30,5 @@ export const useSignup = () => {
}
};

return { signup, isLoading };
return { signup, isLoading, error };
};
5 changes: 5 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,9 @@ form.signup, form.login {
padding: 20px;
background: #fff;
border-radius: 4px;
}

.error-element{
color: red;
font-weight: 500;
}
4 changes: 2 additions & 2 deletions frontend/src/pages/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useLogin } from "../hooks/useLogin";
const Login = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const { login, isLoading } = useLogin();
const { login, isLoading, error } = useLogin();

const handleSubmit = async (e) => {
e.preventDefault();
Expand All @@ -28,7 +28,7 @@ const Login = () => {
/>

<button disabled={isLoading}>Log in</button>
{/* Display error message if there was an issue with the login */}
{error && <div className="error-element">{error}</div>}
</form>
);
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSignup } from "../hooks/useSignup";
const Signup = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const { signup, isLoading } = useSignup();
const { signup, isLoading, error } = useSignup();

const handleSubmit = async (e) => {
e.preventDefault();
Expand All @@ -30,7 +30,7 @@ const Signup = () => {
/>

<button disabled={isLoading}>Sign up</button>
{/* Display error message if there was an issue with the Sign up */}
{error && <div className="error-element">{error}</div>}
</form>
);
};
Expand Down