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

Fixes:#495 - Jashwanth/navlogin #522

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 12 additions & 8 deletions client/src/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const Navbar = ({ isAuthenticated, user, handleLogout }) => {
const handleToggleMode = () => {
setDark(dark === 'light' ? 'dark' : 'light');
};
const handleLogoutlocal = () => {
localStorage.removeItem('basicDetails');
window.location.reload();
};

// Scroll event listener
const controlNavbar = useCallback(() => {
Expand Down Expand Up @@ -212,7 +216,7 @@ const Navbar = ({ isAuthenticated, user, handleLogout }) => {
</NavLink>
)}

{isAuthenticated ? (
{localStorage.getItem('basicDetails') ? (
<button
className="bg-white px-5 py-1 rounded-lg text-black font-bold hover:brightness-75"
onClick={handleLogout}
Expand Down Expand Up @@ -274,19 +278,19 @@ const Navbar = ({ isAuthenticated, user, handleLogout }) => {
</NavLink>

<NavLink to="/labtest" className="flex items-baseline gap-2">
<MdOutlineLocalHospital className="mr-0.5 relative top-[5px] " />{' '}
<MdOutlineLocalHospital className="mr-0.5 relative top-[4px] text-xl" />{' '}
<p className="font-bold text-lg hover:brightness-50">Lab Test</p>
</NavLink>

{/* Add the new Hospitals Around Link for Desktop */}
<NavLink to="/hospitals-around" className="flex items-baseline gap-2">
<FaHospitalAlt className="mr-0.5 relative top-[3px] " />
<FaHospitalAlt className="mr-0.5 relative top-[3px] text-xl" />
<p className="font-bold text-lg hover:brightness-50">
Hospitals Around
</p>
</NavLink>

{isAuthenticated ? (
{localStorage.getItem('basicDetails') ? (
<>
<NavLink to="/profile" className="flex items-baseline gap-2">
<FaUser />
Expand All @@ -311,7 +315,7 @@ const Navbar = ({ isAuthenticated, user, handleLogout }) => {
</>
) : (
<NavLink to="/registerOPD" className="flex items-baseline gap-2">
<MdOutlineLocalHospital className="mr-0.5 relative top-[5px] " />
<MdOutlineLocalHospital className="mr-0.5 relative top-[4px] text-xl" />
<p className="font-bold text-lg hover:brightness-50">
Instant OPD
</p>
Expand All @@ -320,14 +324,14 @@ const Navbar = ({ isAuthenticated, user, handleLogout }) => {
</div>

<div className="flex gap-3">
{localStorage?.getItem('token') ? (
{localStorage.getItem('basicDetails') ? (
<button
className={`${
dark === 'dark'
? 'bg-gray-900 text-gray-100'
: 'bg-white text-black'
} flex gap-2 items-center px-5 py-1 rounded-lg font-bold hover:brightness-75`}
onClick={handleLogout}
} flex gap-2 items-center px-5 py-1 rounded-lg font-bold hover:brightness-75 ml-32`}
onClick={handleLogoutlocal}
>
Log Out
</button>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ReviewDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ function ReviewDetails() {

if (response.ok) {
notify('Registration successful', 'success');
navigate('/login');
} else {
notify(data.message || 'An error occurred. Please try again.', 'warn');
}
Expand All @@ -98,6 +97,7 @@ function ReviewDetails() {
} finally {
setIsLoading(false);
}
navigate('/');
};

return (
Expand Down
140 changes: 80 additions & 60 deletions client/src/components/StepOne.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ function StepOne() {

return newErrors;
};

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

Expand All @@ -91,34 +90,41 @@ function StepOne() {
}));
return;
}
nextStep();

// Store basicDetails in localStorage
localStorage.setItem('basicDetails', JSON.stringify(basicDetails));

nextStep(); // Move to the next step
};

return (
<>
<form
className={`auth-form ${dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`auth-form ${
dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
>
<div className="form-section">
<label
className={`auth-form ${dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`auth-form ${
dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
>
User Type:
</label>
<select
name="type"
value={basicDetails.type}
onChange={handleChange}
className={`${dark === 'dark'
? 'bg-gray-800 text-yellow-400 border-yellow-400'
: 'bg-white text-gray-700 border-gray-300'
}`}
className={`${
dark === 'dark'
? 'bg-gray-800 text-yellow-400 border-yellow-400'
: 'bg-white text-gray-700 border-gray-300'
}`}
>
<option value="user">User</option>
<option value="hospital">Hospital</option>
Expand All @@ -128,10 +134,11 @@ function StepOne() {
<div className="form-section">
<label
htmlFor="name"
className={`auth-form ${dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`auth-form ${
dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
style={{ display: 'inline' }}
>
Name: <span style={{ color: 'red' }}>*</span>
Expand All @@ -144,10 +151,11 @@ function StepOne() {
onChange={handleChange}
placeholder="John Doe"
required
className={`${dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`${
dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
/>
{errors.frontend.name && (
<span className="error">{errors.frontend.name}</span>
Expand All @@ -157,10 +165,11 @@ function StepOne() {
<div className="form-section">
<label
htmlFor="phone"
className={`auth-form ${dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`auth-form ${
dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
style={{ display: 'inline' }}
>
Phone: <span style={{ color: 'red' }}>*</span>
Expand All @@ -173,10 +182,11 @@ function StepOne() {
value={basicDetails.phone}
onChange={handleChange}
required
className={`${dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`${
dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
/>
{errors.frontend.phone && (
<span className="error">{errors.frontend.phone}</span>
Expand All @@ -186,10 +196,11 @@ function StepOne() {
<div className="form-section">
<label
htmlFor="email"
className={`auth-form ${dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`auth-form ${
dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
style={{ display: 'inline' }}
>
Email: <span style={{ color: 'red' }}>*</span>
Expand All @@ -202,10 +213,11 @@ function StepOne() {
value={basicDetails.email}
onChange={handleChange}
required
className={`${dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`${
dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
/>
{errors.frontend.email && (
<span className="error">{errors.frontend.email}</span>
Expand All @@ -214,10 +226,11 @@ function StepOne() {

<div className="form-section">
<label
className={`auth-form ${dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`auth-form ${
dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
style={{ display: 'inline' }}
>
Password: <span style={{ color: 'red' }}>*</span>
Expand All @@ -230,10 +243,11 @@ function StepOne() {
value={basicDetails.password}
onChange={handleChange}
required
className={`${dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`${
dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
/>
<button
type="button"
Expand All @@ -250,10 +264,11 @@ function StepOne() {

<div className="form-section">
<label
className={`auth-form ${dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`auth-form ${
dark === 'dark'
? 'bg-gray-900 text-yellow-400'
: 'bg-white text-gray-700'
}`}
style={{ display: 'inline' }}
>
Confirm Password: <span style={{ color: 'red' }}>*</span>
Expand All @@ -266,10 +281,11 @@ function StepOne() {
value={basicDetails.confirmPassword}
onChange={handleChange}
required
className={`${dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
className={`${
dark === 'dark'
? 'bg-gray-800 text-yellow-400'
: 'bg-white text-gray-700'
}`}
/>
<button
type="button"
Expand All @@ -287,10 +303,11 @@ function StepOne() {
<div className="register-button">
<button
type="submit"
className={`auth-button ${dark === 'dark'
? 'bg-yellow-400 text-gray-900 hover:bg-yellow-500'
: 'bg-blue-600 text-white hover:bg-blue-700'
}`}
className={`auth-button ${
dark === 'dark'
? 'bg-yellow-400 text-gray-900 hover:bg-yellow-500'
: 'bg-blue-600 text-white hover:bg-blue-700'
}`}
onClick={handleContinue}
>
Continue
Expand All @@ -299,8 +316,11 @@ function StepOne() {

<Link
to="/login"
className={`toggle-auth-button text-center ${dark === 'dark' ? 'text-white' : 'text-black'
}`}

className={`toggle-auth-button text-center ${
dark === 'dark' ? 'text-yellow-400' : 'text-gray-700'
}`}

>
Already have an account? Login
</Link>
Expand Down