-
Notifications
You must be signed in to change notification settings - Fork 201
Added the icon and title to the site #56
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c475414
added the icon and the title
parassareen4 4d5dc2c
added the logo in the navbar
parassareen4 f190f60
login functionality and CORS:
parassareen4 06f9437
added login button in navbar
parassareen4 cd05948
added .env logic instead of hardcoding for backend url
parassareen4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| VITE_BACKEND_URL=http://localhost:5000 | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import React, { useState, ChangeEvent, FormEvent } from "react"; | ||
| import axios from "axios"; | ||
| import { useNavigate } from "react-router-dom"; // Import the hook for navigation | ||
|
yashksaini-coder marked this conversation as resolved.
|
||
|
|
||
| const backendUrl = import.meta.env.VITE_BACKEND_URL; | ||
| interface LoginFormData { | ||
| email: string; | ||
| password: string; | ||
| } | ||
|
|
||
| const Login: React.FC = () => { | ||
| const [formData, setFormData] = useState<LoginFormData>({ email: "", password: "" }); | ||
| const [message, setMessage] = useState<string>(""); | ||
|
|
||
| const navigate = useNavigate(); // Initialize the navigate hook | ||
|
|
||
| const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
| const { name, value } = e.target; | ||
| setFormData({ ...formData, [name]: value }); | ||
| }; | ||
|
|
||
| const handleSubmit = async (e: FormEvent) => { | ||
| e.preventDefault(); | ||
| try { | ||
| const response = await axios.post(`${backendUrl}/api/auth/login`, | ||
| formData, | ||
|
|
||
| ); | ||
| setMessage(response.data.message); // Show success message from backend | ||
|
|
||
| // Navigate to /home if login is successful | ||
| if (response.data.message === 'Login successful') { | ||
| navigate("/home"); | ||
| } | ||
| } catch (error: any) { | ||
| setMessage(error.response?.data?.message || "Something went wrong"); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="max-w-md mt-12 mx-auto bg-white p-8 rounded-lg shadow-md"> | ||
| <h2 className="text-2xl font-semibold text-center mb-6">Login</h2> | ||
| <form onSubmit={handleSubmit} className="space-y-4"> | ||
| <div> | ||
| <input | ||
| type="email" | ||
| name="email" | ||
| placeholder="Email" | ||
| value={formData.email} | ||
| onChange={handleChange} | ||
| required | ||
| className="w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" | ||
| /> | ||
| </div> | ||
| <div> | ||
| <input | ||
| type="password" | ||
| name="password" | ||
| placeholder="Password" | ||
| value={formData.password} | ||
| onChange={handleChange} | ||
| required | ||
| className="w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" | ||
| /> | ||
| </div> | ||
| <button | ||
| type="submit" | ||
| className="w-full bg-blue-500 text-white py-3 rounded-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500" | ||
| > | ||
| Login | ||
| </button> | ||
| </form> | ||
| {message && <p className="text-center text-red-500 mt-4">{message}</p>} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Login; | ||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import React, { useState, ChangeEvent, FormEvent } from "react"; | ||
| import axios from "axios"; | ||
| import { useNavigate } from "react-router-dom"; | ||
|
|
||
| const backendUrl = import.meta.env.VITE_BACKEND_URL; | ||
| interface SignUpFormData { | ||
| username: string; | ||
|
yashksaini-coder marked this conversation as resolved.
|
||
| email: string; | ||
| password: string; | ||
| } | ||
|
|
||
| const SignUp: React.FC = () => { | ||
| const [formData, setFormData] = useState<SignUpFormData>({ username: "", email: "", password: "" }); | ||
| const [message, setMessage] = useState<string>(""); | ||
|
|
||
| const navigate = useNavigate(); | ||
|
|
||
| const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
| const { name, value } = e.target; | ||
| setFormData({ ...formData, [name]: value }); | ||
| }; | ||
|
|
||
| const handleSubmit = async (e: FormEvent) => { | ||
| e.preventDefault(); | ||
| try { | ||
| const response = await axios.post( | ||
| `${backendUrl}/api/auth/signup`, | ||
| formData // Include cookies for session | ||
| ); | ||
| setMessage(response.data.message); // Show success message from backend | ||
|
|
||
| // Navigate to login page after successful signup | ||
| if (response.data.message === 'User created successfully') { | ||
| navigate("/login"); | ||
| } | ||
| } catch (error: any) { | ||
| setMessage(error.response?.data?.message || "Something went wrong"); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="mt-12 max-w-md mx-auto bg-white p-8 rounded-lg shadow-md"> | ||
| <h2 className="text-2xl font-semibold text-center mb-6">Sign Up</h2> | ||
| <form onSubmit={handleSubmit} className="space-y-4"> | ||
| <div> | ||
| <input | ||
| type="text" | ||
| name="username" | ||
| placeholder="Username" | ||
| value={formData.username} | ||
| onChange={handleChange} | ||
| required | ||
| className="w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" | ||
| /> | ||
| </div> | ||
| <div> | ||
| <input | ||
| type="email" | ||
| name="email" | ||
| placeholder="Email" | ||
| value={formData.email} | ||
| onChange={handleChange} | ||
| required | ||
| className="w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" | ||
| /> | ||
| </div> | ||
| <div> | ||
| <input | ||
| type="password" | ||
| name="password" | ||
| placeholder="Password" | ||
| value={formData.password} | ||
| onChange={handleChange} | ||
| required | ||
| className="w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" | ||
| /> | ||
| </div> | ||
| <button | ||
| type="submit" | ||
| className="w-full bg-blue-500 text-white py-3 rounded-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500" | ||
| > | ||
| Sign Up | ||
| </button> | ||
| </form> | ||
| {message && <p className="text-center text-red-500 mt-4">{message}</p>} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SignUp; | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1 +1,11 @@ | ||
| /// <reference types="vite/client" /> | ||
|
|
||
| interface ImportMetaEnv { | ||
| readonly VITE_BACKEND_URL: string; | ||
| // Add other variables if needed | ||
| } | ||
|
|
||
| interface ImportMeta { | ||
| readonly env: ImportMetaEnv; | ||
| } | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.