Skip to content

Commit 803db2b

Browse files
authored
Merge pull request #40 from Code-the-Dream-School/notified-unauthorise-user-to-auth
Notified unauthorize user to auth
2 parents ae8f2b3 + fc06c2c commit 803db2b

File tree

4 files changed

+59
-28
lines changed

4 files changed

+59
-28
lines changed

src/components/LoginAuth.jsx

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ const CardWithForm = ({ isAuthentificated }) => {
2424

2525
const storedAuth = JSON.parse(localStorage.getItem("auth"));
2626
const navigate = useNavigate();
27-
/*const [isSignedIn, setIsSignedIn] = useState(() => {
28-
return JSON.parse(localStorage.getItem("auth")) || false;
29-
});*/
30-
3127
const handleLogout = () => {
3228
localStorage.removeItem("auth"); // Clear auth data the logout api will be call here
3329
navigate("/"); // Redirect to Home

src/components/ui/toaster.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
export const toaster = createToaster({
3434
placement: "bottom-end",
3535
pauseOnPageIdle: true,
36+
overlap: true,
3637
});
3738

3839
export const Toaster = () => {

src/views/HomePage.jsx

+58-23
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,71 @@ import { Field } from "../components/ui/field";
44
import { Button } from "../components/ui/button";
55
import "../styles/Homepage.css";
66
import { useNavigate } from "react-router-dom";
7-
7+
import { Toaster, toaster } from "../components/ui/toaster";
88
const HomePage = () => {
9+
const storedAuth = JSON.parse(localStorage.getItem("auth"));
910
const navigate = useNavigate();
1011

12+
const handleAuthentificationCheck = () => {
13+
console.log("token: ", storedAuth);
14+
if (!storedAuth) {
15+
toaster.create({
16+
title: "Sign In Required!",
17+
description: "You must be signed in to proceed with this request.",
18+
type: "warning",
19+
duration: 4000,
20+
action: {
21+
label: "x",
22+
},
23+
});
24+
return;
25+
} else {
26+
navigate("/share-project");
27+
}
28+
};
29+
1130
return (
1231
<div className="sections-container">
13-
<div className = 'section1'>
14-
15-
<div className="content-area">
16-
<div className="content-area-responsive">
17-
<div className="title-responsive">
18-
<div className="build-title">
32+
<div className="section1">
33+
<div className="content-area">
34+
<div className="content-area-responsive">
35+
<div className="title-responsive">
36+
<div className="build-title">
1937
<img className="cycle" src="./images/cycle.png"></img>
20-
<h1>Build.<br /> Share.<br /> Review.<br /> Repeat.</h1>
21-
</div>
22-
<p className="top-text">Showcase your work and connect with peers who can help you reach the next level.</p>
23-
</div>
24-
<div className="button-area">
25-
<button
26-
className = "share-button"
27-
onClick={() => navigate('/share-project')}>
28-
SHARE A PROJECT</button>
29-
<button className = "explore-button"
30-
onClick={() => navigate('/explore-project')}>
31-
EXPLORE PROJECTS</button>
32-
</div>
33-
</div>
38+
<h1>
39+
Build.
40+
<br /> Share.
41+
<br /> Review.
42+
<br /> Repeat.
43+
</h1>
44+
</div>
45+
<p className="top-text">
46+
Showcase your work and connect with peers who can help you reach
47+
the next level.
48+
</p>
49+
</div>
50+
<div className="button-area">
51+
<button
52+
className="share-button"
53+
onClick={() => handleAuthentificationCheck()}
54+
>
55+
SHARE A PROJECT
56+
</button>
57+
<button
58+
className="explore-button"
59+
onClick={() => navigate("/explore-project")}
60+
>
61+
EXPLORE PROJECTS
62+
</button>
3463
</div>
35-
<img className="section-image" src="./images/sectionimg-1.png"></img>
64+
</div>
3665
</div>
37-
<p className="top-text-2">Showcase your work and connect with peers who can help you reach the next level.</p>
66+
<img className="section-image" src="./images/sectionimg-1.png"></img>
67+
</div>
68+
<p className="top-text-2">
69+
Showcase your work and connect with peers who can help you reach the
70+
next level.
71+
</p>
3872
<div className="home-data-rectangle">
3973
<p>PROJECTS SHARED: 1,024+</p>
4074
<p>REVIEWS GIVEN: 5,678+ </p>
@@ -80,6 +114,7 @@ const HomePage = () => {
80114
<Button className="register-button" size="md">
81115
Register NOW!
82116
</Button>
117+
<Toaster />
83118
</div>
84119
</div>
85120
<img className="ctd-logo" src="./images/ctd-logo.png"></img>

src/views/ShareAProject.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const ShareAProject = () => {
2424

2525
const handleSubmit = async (e) => {
2626
e.preventDefault();
27-
2827
try {
2928
const response = await fetch("http://localhost:8001/addproject", {
3029
method: "POST",

0 commit comments

Comments
 (0)