-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from eperezme:dev
Update README, add form validation, and fix form submission messages
- Loading branch information
Showing
13 changed files
with
99 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
# React + Vite | ||
# My Portfolio | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
Welcome to my portfolio repository! This repository showcases my projects, skills, and achievements as a software developer. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
dist/assets/index-LiB_WsC6.css → dist/assets/index-jokBaQeX.css
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
import React, { useState, useEffect } from 'react'; | ||
import emailjs from '@emailjs/browser'; | ||
|
||
const Form = () => { | ||
const [name, setName] = useState(''); | ||
const [email, setEmail] = useState(''); | ||
const [subject, setSubject] = useState(''); | ||
const [message, setMessage] = useState(''); | ||
const [isFormValid, setIsFormValid] = useState(false); | ||
const [errorMessage, setErrorMessage] = useState(''); | ||
|
||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
|
||
if (!isFormValid) { | ||
const errorMessage = 'Please fill in all fields.'; // Set error message if any field is empty | ||
setErrorMessage(errorMessage); // Update the state | ||
alert(errorMessage); // Display error message in a popup alert | ||
return; | ||
} | ||
|
||
// Replace with your own emailjs service ID, template ID, and public key | ||
const serviceId = 'service_5shgyrp'; | ||
const templateId = 'template_06nu5j3'; | ||
|
@@ -23,51 +32,53 @@ const Form = () => { | |
}, publicKey) | ||
.then((response) => { | ||
console.log('Email sent successfully!', response.status, response.text); | ||
// Reset form fields | ||
// Reset form fields and error message | ||
setName(''); | ||
setEmail(''); | ||
setSubject(''); | ||
setMessage(''); | ||
alert('Email sent successfully!'); | ||
}) | ||
.catch((error) => { | ||
console.error('Error sending email:', error); | ||
}); | ||
}; | ||
|
||
return ( | ||
useEffect(() => { | ||
setIsFormValid(name.trim() !== '' && email.trim() !== '' && subject.trim() !== '' && message.trim() !== ''); | ||
}, [name, email, subject, message]); | ||
|
||
<form onSubmit={handleSubmit} className="col-md-11 col-lg-9"> | ||
<div className="form-group"> | ||
return ( | ||
<form onSubmit={handleSubmit} className='col-md-11 col-lg-9'> | ||
<div className="form-group js-build-in-item build-in-slideY-top" > | ||
<label className='form'> | ||
<h4>Name</h4> | ||
<input className='form-control' type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder="Your Name" /> | ||
</label> | ||
</div> | ||
|
||
<div className="form-group"> | ||
<div className="form-group js-build-in-item build-in-slideY-top"> | ||
<label> | ||
<h4>Email</h4> | ||
<h4 className=''>Email</h4> | ||
<input className='form-control' type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="[email protected]" /> | ||
</label> | ||
</div> | ||
|
||
<div className="form-group"> | ||
<div className="form-group js-build-in-item build-in-slideY-top"> | ||
<label> | ||
<h4>Subject</h4> | ||
<input className='form-control' value={subject} onChange={(e) => setSubject(e.target.value)} placeholder="Brief Description of Inquiry/Offer" /> | ||
</label> | ||
</div> | ||
|
||
<div className="form-group"> | ||
<div className="form-group js-build-in-item build-in-slideY-top"> | ||
<label> | ||
<h4>Message</h4> | ||
<textarea className='form-control' value={message} onChange={(e) => setMessage(e.target.value)} placeholder="Enter your message" /> | ||
</label> | ||
</div> | ||
|
||
|
||
<div className="d-flex flex-column flex-md-row mt-3 pb-2"> | ||
<div className="d-flex flex-column flex-md-row mt-3 pb-2 js-build-in-item build-in-fade"> | ||
<button type="submit" className="btn-mktg">Submit | ||
<svg xmlns="http://www.w3.org/2000/svg" className="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none"><path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path><path className="octicon-chevrow-stem" stroke="currentColor" d="M1.75 8H11" strokeWidth="1.5" strokeLinecap="round"></path></svg> | ||
</button> | ||
|