Back

Version 0

1/8/2025
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import React, { useState } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";

function App() {
const [isLogin, setIsLogin] = useState(true);
const [formData, setFormData] = useState({
firstName: '',
lastName: '',
email: '',
gender: '',
password: '',
confirmPassword: ''
});

const handleInputChange = (e) => {
const { name, value } = e.target;
setFormData(prev => ({ ...prev, [name]: value }));
};

const validateForm = () => {
if (formData.password !== formData.confirmPassword) {
alert("Passwords do not match!");
return false;
}
return true;
};

const handleSubmit = async (e) => {
e.preventDefault();
if (!validateForm()) return;

try {
const endpoint = isLogin ? '/login' : '/signup';
const response = await fetch(endpoint, {