-
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 #60 from JumboCode/con-page-email-conn
completed contact page translation and admin email connection
- Loading branch information
Showing
5 changed files
with
103 additions
and
37 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,8 +4,10 @@ import { postContact } from '@/api/contact-wrapper'; | |
import Form from "@/components/Form/Form" | ||
import FormInput from '@/components/Form/FormInput'; | ||
import FormSubmit from '@/components/Form/FormSubmit'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
export default function Contact() { | ||
const { t } = useTranslation(); | ||
|
||
const [formData, setFormData] = useState({ | ||
name: '', | ||
|
@@ -20,29 +22,34 @@ export default function Contact() { | |
|
||
const handleSubmit = async (e) => { | ||
e.preventDefault(); | ||
const contactData = { | ||
name: e.target.name.value, | ||
email: e.target.email.value, | ||
subject: e.target.subject.value, | ||
message: e.target.message.value | ||
}; | ||
try { | ||
const response = await postContact(formData) | ||
const response = await postContact(contactData); | ||
|
||
if (!response.ok) { | ||
throw new Error(`Response status: ${response.status}`); | ||
if (response.ok) { | ||
alert("Message submitted successfully!"); | ||
} else { | ||
const errorResponse = await response.json(); | ||
alert(`Failed to send message: ${errorResponse.message}`); | ||
} | ||
const json = await response.json() | ||
console.log(json) | ||
alert("Inquiry submitted successfully!") | ||
|
||
} catch (err) { | ||
console.error(error.message) | ||
alert("There was an error submitting the inquiry.") | ||
console.error('Error in handleSubmit:', err); | ||
alert("There was an error submitting the inquiry."); | ||
} | ||
}; | ||
|
||
|
||
return ( | ||
<div className="w-full h-full bg-white flex flex-col sm:flex-row justify-center items-center"> | ||
<div className="sm:w-1/3 w-full p-8"> | ||
<h2 className="text-3xl font-semibold mb-6">CONTACT US</h2> | ||
<h2 className="text-3xl font-semibold mb-6">{t("contact_heading")}</h2> | ||
<p className="mb-2 text-lg"> | ||
Email: | ||
{t("email_field")}: | ||
<a href="mailto:[email protected]" className="text-black"> | ||
[email protected] | ||
</a> | ||
|
@@ -58,9 +65,9 @@ export default function Contact() { | |
<div className="sm:w-2/3 w-full bg-blue-200 p-10 flex justify-center"> | ||
{/* form box */} | ||
<Form width="w-3/5"> | ||
<h2 className="text-2xl font-semibold mb-2">Get in Touch</h2> | ||
<h2 className="text-2xl font-semibold mb-2">{t("form_heading")}</h2> | ||
<p className="mb-4 text-gray-600 opacity-70"> | ||
Let us know if you have questions or concerns. | ||
{t("form_description")} | ||
</p> | ||
<form | ||
onSubmit={handleSubmit} | ||
|
@@ -69,36 +76,36 @@ export default function Contact() { | |
<FormInput | ||
type="text" | ||
name="name" | ||
placeholder="Name" | ||
placeholder={t("name_field")} | ||
value={formData.name} | ||
onChange={handleChange} | ||
isRequired={true} | ||
/> | ||
<FormInput | ||
type="email" | ||
name="email" | ||
placeholder="Email" | ||
placeholder={t("email_field")} | ||
value={formData.email} | ||
onChange={handleChange} | ||
isRequired={true} | ||
/> | ||
<FormInput | ||
type="text" | ||
name="subject" | ||
placeholder="Subject" | ||
placeholder={t("subject_field")} | ||
value={formData.subject} | ||
onChange={handleChange} | ||
isRequired={true} | ||
/> | ||
<FormInput | ||
type="textarea" | ||
name="message" | ||
placeholder="Message" | ||
placeholder={t("message_field")} | ||
value={formData.message} | ||
onChange={handleChange} | ||
required | ||
/> | ||
<FormSubmit label={"Submit"} /> | ||
<FormSubmit label={t("submit_button")} /> | ||
</form> | ||
</Form> | ||
</div> | ||
|