Skip to content

Commit

Permalink
feat: enhance contact form to handle missing name and email inputs wi…
Browse files Browse the repository at this point in the history
…th default values
  • Loading branch information
AhmedNassar7 committed Dec 4, 2024
1 parent cf03cf1 commit ae781a8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/components/Contact/Contact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ const Contact = () => {
import.meta.env.VITE_EMAILJS_SERVICE_ID,
import.meta.env.VITE_EMAILJS_TEMPLATE_ID,
{
from_name: formData.name,
from_email: formData.email,
from_name: formData.name || 'Anonymous',
from_email: formData.email || 'No Email Provided',
country: formData.country?.label || 'N/A',
message: formData.message,
to_email: import.meta.env.VITE_EMAILJS_TO_EMAIL,
Expand All @@ -158,8 +158,8 @@ const Contact = () => {
// Save form data to Firebase
try {
await addMessage({
name: formData.name,
email: formData.email,
name: formData.name || 'Anonymous',
email: formData.email || 'No Email Provided',
country: formData.country?.label || 'N/A',
message: formData.message,
});
Expand Down Expand Up @@ -200,7 +200,6 @@ const Contact = () => {
onChange={(e) =>
setFormData({ ...formData, name: e.target.value })
}
required
className="custom-input"
/>
</Form.Group>
Expand All @@ -213,7 +212,6 @@ const Contact = () => {
onChange={(e) =>
setFormData({ ...formData, email: e.target.value })
}
required
className="custom-input"
/>
</Form.Group>
Expand Down

0 comments on commit ae781a8

Please sign in to comment.