import React, { useState } from "react"; export default function JobsForm() { const [formValue, setFormValue] = useState({ email: "" }); const [formError, setFormError] = useState({}); const [submit, setSubmit] = useState(false); const [loading, setLoading] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); setLoading(true); setFormError(validateForm(formValue)); if (Object.keys(validateForm(formValue)).length > 0) { setLoading(false); return null; } else { setSubmit(true); setFormValue({ email: "" }); setLoading(false); } }; const handleValidation = (e) => { const { name, value } = e.target; setFormValue({ ...formValue, [name]: value }); }; const validateForm = (value) => { const errors = {}; const emailValidation = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/; if (!value.email) { errors.email = "Empty email field"; } else if (!emailValidation.test(value.email)) { errors.email = "Invalid email format"; } return errors; }; return (

Ready to advance your career?

Send us your email and we will contact you.

{loading ? (
Loading...
) : submit && Object.keys(formError).length === 0 ? (

We received your request! Please check you email.

) : (
{formError.email}
)}
); }