contact endpoint added

This commit was merged in pull request #17.
This commit is contained in:
victorAnumudu
2026-05-25 18:26:15 +01:00
parent edbcb5f0c9
commit 345eeaf971
2 changed files with 47 additions and 9 deletions
+36 -5
View File
@@ -5,6 +5,8 @@ import {Form, Formik} from 'formik';
import * as Yup from "yup";
import { useTranslations } from "next-intl";
import { sendContactMsg } from "../components/services/services";
export default function Home() {
const t = useTranslations("ContactsPage")
@@ -24,13 +26,19 @@ export default function Home() {
const contactMutation = useMutation({
mutationFn: (fields) => {
return null //completePWDReset(fields)
return sendContactMsg(fields)
},
onSuccess: (res) => {
if (res?.data?.resultCode != '0') {
throw({message: res?.data?.resultDescription})
}
window.scrollTo(0, 0);
},
// onSettled: () => {
// setTimeout(() => {
// contactMutation.reset()
// }, 3000)
// }
// onError: (err) => {
// console.log('err', err)
// }
@@ -40,10 +48,6 @@ export default function Home() {
let reqData = {
...values
}
console.log(reqData)
setTimeout(() => {
contactMutation.reset()
}, 3000)
contactMutation.mutate(reqData)
}
@@ -85,6 +89,30 @@ export default function Home() {
return (
<Form name="contactform" className="row contact-form">
{/* Form Select */}
{contactMutation.isSuccess ?
<div className='w-100 text-center'>
<p className='p-lg' style={{lineHeight: '30px'}}>
Thank you for reaching out to us. We have received your message and will treat it with utmost urgency. Our team will respond to you as soon as possible.
</p>
<div className="d-flex justify-content-center mt-15" style={{marginTop: '80px'}}>
<Link href="/" className="btn btn--theme hover--theme submit">
Return Home
</Link>
</div>
</div>
:contactMutation.isError ?
<div className='w-100 text-center'>
<p className='p-lg' style={{lineHeight: '30px', color: 'red'}}>
Opps! An error occured, please try again.
</p>
<div className="d-flex justify-content-center mt-15" style={{marginTop: '80px'}}>
<button onClick={()=>contactMutation.reset()} type='button' className="btn btn--theme hover--theme submit">
Resend Message
</button>
</div>
</div>
:
<>
<div className="col-md-12 input-subject">
<p className="p-lg">{t("questionAbout")}{(props.errors.subject && props.touched.subject) &&
<span style={{display: 'inline'}} className='text-danger'>{props.errors.subject}</span>}</p>
@@ -134,9 +162,12 @@ export default function Home() {
{contactMutation.isPending ? t("sending") : contactMutation.isSuccess ? t("messageSent") : t("submitRequest")}
</button>
</div>
</>
}
<div className="contact-form-notice">
<p className="p-sm">{t("privacy")}</p>
</div>
{/* Contact Form Message */}
<div className="col-lg-12 contact-form-msg">
<span className="loading"/>