Skip to content
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
41 changes: 29 additions & 12 deletions client/src/pages/signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,36 @@ const SignupPage: FC = () => {
return true;
};

const handleSignup = async (e: React.FormEvent) => {
e.preventDefault();
if (validatePasswords(password, confirmPassword)) {
try {
// Replace with actual user data from form
await signup({ email, username: 'NewUser' });
router.push('/login'); // Redirect to userDetails or dashboard
} catch (error) {
// Handle errors (e.g., show message to the user)
setError('Failed to sign up. Please try again.');
}
const handleSignup = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();

// Simple validation check
if (!email || !password) {
setError('Email and password are required.');
return;
}
};

try {
const response = await fetch('/api/signup', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ email, password })
});

const data = await response.json();

if (response.ok) {
router.push('/login');
} else {
throw new Error(data.message || 'Failed to sign up.');
}
} catch (error: any) {
setError(error.message);
}
};


return (
<div className="mt-[5rem] flex flex-col items-center justify-center py-2 bg-gradient-to-r from-background-start-rgb to-background-end-rgb">
Expand Down
8 changes: 3 additions & 5 deletions server/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,12 @@ def login():
def signup():
try:
data = request.get_json()
username = data['username']
email = data['email']
password = data['password']
professional_id = data['professional_id']
qualifications = data['qualifications']
work_schedule = data['work_schedule']


# Register new healthcare professional
user = HealthcareProfessional.signup(username, password, professional_id, qualifications, work_schedule)
user = HealthcareProfessional.signup(email, password)

# If signup is successful, proceed to create user.
if user:
Expand Down