import React from 'react'; import { GoogleLogin, GoogleOAuthProvider } from '@react-oauth/google'; import { Link, useNavigate } from 'react-router-dom'; const CLIENT_ID = "532143017111-4eqtlp0oejqaovj6rf5l1ergvhrp4vao.apps.googleusercontent.com"; const RegistrationFormContent: React.FC = () => { const navigate = useNavigate(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); const nameElement = document.getElementById('name') as HTMLInputElement | null; const emailElement = document.getElementById('email') as HTMLInputElement | null; const passwordElement = document.getElementById('password') as HTMLInputElement | null; const confirmPasswordElement = document.getElementById('confirm-password') as HTMLInputElement | null; if (!nameElement || !emailElement || !passwordElement || !confirmPasswordElement) { console.error('One or more input fields are missing'); return; } const name = nameElement.value; const email = emailElement.value; const password = passwordElement.value; const confirmPassword = confirmPasswordElement.value; if (password !== confirmPassword) { console.error('Passwords do not match'); alert('Passwords do not match'); return; } try { const response = await fetch('http://localhost:5000/api/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, email, password }), }); const data = await response.json(); if (response.ok) { console.log('User registered successfully:', data.message); const loggedInUser = { name, email, picture: 'https://via.placeholder.com/150', }; localStorage.setItem('user', JSON.stringify(loggedInUser)); navigate('/dashboard'); } else { console.error('Error:', data.error); alert(data.error); } } catch (error) { console.error('Error registering user:', error); alert('Error registering user'); } }; const handleGoogleLoginSuccess = async (response: any) => { try { const res = await fetch('http://localhost:5000/api/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token: response.credential }), }); const data = await res.json(); const loggedInUser = { name: data.user.name, email: data.user.email, picture: data.user.picture || 'https://via.placeholder.com/150', }; localStorage.setItem('user', JSON.stringify(loggedInUser)); navigate('/dashboard'); } catch (error) { console.error('Error tiken verification:', error); } }; const handleGoogleLoginError = () => { console.error('Error auth: Google login failed'); }; return (

Create Your Account

Join us to explore personalized health solutions.

OR

Already have an account?{' '} Sign In

); }; const RegistrationForm: React.FC = () => { return ( ); }; export default RegistrationForm;