-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from nuuxcode/debug
Enhancements and Feature Additions for a Seamless BikeHub Experience
- Loading branch information
Showing
36 changed files
with
7,932 additions
and
29,768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,8 @@ export default function SignIn() { | |
const navigate = useNavigate(); | ||
const { logIn } = useAuth(); | ||
|
||
const handleLogin = async () => { | ||
const handleLogin = async (event: React.FormEvent) => { | ||
event.preventDefault(); // Prevent the form from refreshing the page | ||
console.log(process.env.REACT_APP_API_URL); | ||
const response = await fetch( | ||
`${process.env.REACT_APP_API_URL}auth/login`, | ||
|
@@ -26,7 +27,8 @@ export default function SignIn() { | |
const data = await response.json(); | ||
|
||
if (data?.user?.role === "admin") { | ||
logIn(); | ||
console.log("data.user", data.user) | ||
logIn(data.user); | ||
navigate("/admin"); | ||
} else if (data?.user?.role === "user") { | ||
setError("This page only for admins"); | ||
|
@@ -45,45 +47,47 @@ export default function SignIn() { | |
<p className="mb-9 ml-1 text-base text-gray-600"> | ||
Enter your email and password to sign in! | ||
</p> | ||
{/* Email */} | ||
<InputField | ||
variant="auth" | ||
extra="mb-3" | ||
label="Email*" | ||
placeholder="[email protected]" | ||
id="email" | ||
type="text" | ||
value={email} | ||
onChange={(e: any) => setEmail(e.target.value)} | ||
/> | ||
<form onSubmit={handleLogin}> | ||
{/* Email */} | ||
<InputField | ||
variant="auth" | ||
extra="mb-3" | ||
label="Email*" | ||
placeholder="[email protected]" | ||
id="email" | ||
type="text" | ||
value={email} | ||
onChange={(e: any) => setEmail(e.target.value)} | ||
/> | ||
|
||
{/* Password */} | ||
<InputField | ||
variant="auth" | ||
extra="mb-3" | ||
label="Password*" | ||
placeholder="Min. 8 characters" | ||
id="password" | ||
type="password" | ||
value={password} | ||
onChange={(e: any) => setPassword(e.target.value)} | ||
/> | ||
{/* Checkbox */} | ||
<div className="mb-4 flex items-center justify-between px-2"> | ||
<div className="flex items-center"> | ||
<Checkbox /> | ||
<p className="ml-2 text-sm font-medium text-navy-700 dark:text-white"> | ||
Keep me logged In | ||
</p> | ||
{/* Password */} | ||
<InputField | ||
variant="auth" | ||
extra="mb-3" | ||
label="Password*" | ||
placeholder="Min. 8 characters" | ||
id="password" | ||
type="password" | ||
value={password} | ||
onChange={(e: any) => setPassword(e.target.value)} | ||
/> | ||
{/* Checkbox */} | ||
<div className="mb-4 flex items-center justify-between px-2"> | ||
<div className="flex items-center"> | ||
<Checkbox /> | ||
<p className="ml-2 text-sm font-medium text-navy-700 dark:text-white"> | ||
Keep me logged In | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
{error && <div className="text-center text-red-500">{error}</div>} | ||
<button | ||
onClick={handleLogin} | ||
className="linear mt-2 w-full rounded-xl bg-teal-600 py-[12px] text-base font-medium text-white transition duration-200 hover:bg-teal-600 active:bg-teal-700 dark:bg-teal-400 dark:text-white dark:hover:bg-teal-300 dark:active:bg-teal-200" | ||
> | ||
Sign In | ||
</button> | ||
{error && <div className="text-center text-red-500">{error}</div>} | ||
<button | ||
onClick={handleLogin} | ||
className="linear mt-2 w-full rounded-xl bg-teal-600 py-[12px] text-base font-medium text-white transition duration-200 hover:bg-teal-600 active:bg-teal-700 dark:bg-teal-400 dark:text-white dark:hover:bg-teal-300 dark:active:bg-teal-200" | ||
> | ||
Sign In | ||
</button> | ||
</form> | ||
{/* <div className="mt-4"> | ||
<span className=" text-sm font-medium text-navy-700 dark:text-gray-600"> | ||
Not registered yet? | ||
|
Oops, something went wrong.