contact endpoint added
This commit was merged in pull request #17.
This commit is contained in:
@@ -26,11 +26,11 @@ const blogBasePath = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const siteServerPath = () => {
|
const siteServerPath = () => {
|
||||||
// NEXT_PUBLIC_APP_MAIN_API="https://devapi.mermsemr.com"
|
return process.env.NEXT_PUBLIC_APP_MAIN_API;
|
||||||
return 'https://devapi.mermsemr.com';
|
|
||||||
}
|
}
|
||||||
const postAuxEnd = (path, postData, media = false) => {
|
|
||||||
const basePath = media ? 'https://blogdata.chiefsoft.net' : 'https://blogdata.chiefsoft.net'
|
const postAuxEnd = (basePath, path, postData) => {
|
||||||
|
// const basePath = media ? process.env.NEXT_PUBLIC_APP_MAIN_API : process.env.NEXT_PUBLIC_APP_MAIN_API;
|
||||||
let newPostData = {}
|
let newPostData = {}
|
||||||
if (!media) {
|
if (!media) {
|
||||||
newPostData = {...postData}
|
newPostData = {...postData}
|
||||||
@@ -75,3 +75,10 @@ export const serMermsWebContact = (reqData) => {
|
|||||||
}
|
}
|
||||||
return getAuxEnd(siteServerPath(), '/mermsblogdata/mermsemr', postData)
|
return getAuxEnd(siteServerPath(), '/mermsblogdata/mermsemr', postData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const sendContactMsg = (reqData) => {
|
||||||
|
let postData = {
|
||||||
|
...reqData
|
||||||
|
}
|
||||||
|
return postAuxEnd(siteServerPath(), '/website/contact', postData)
|
||||||
|
}
|
||||||
|
|||||||
+36
-5
@@ -5,6 +5,8 @@ import {Form, Formik} from 'formik';
|
|||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
|
import { sendContactMsg } from "../components/services/services";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const t = useTranslations("ContactsPage")
|
const t = useTranslations("ContactsPage")
|
||||||
|
|
||||||
@@ -24,13 +26,19 @@ export default function Home() {
|
|||||||
|
|
||||||
const contactMutation = useMutation({
|
const contactMutation = useMutation({
|
||||||
mutationFn: (fields) => {
|
mutationFn: (fields) => {
|
||||||
return null //completePWDReset(fields)
|
return sendContactMsg(fields)
|
||||||
},
|
},
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
if (res?.data?.resultCode != '0') {
|
if (res?.data?.resultCode != '0') {
|
||||||
throw({message: res?.data?.resultDescription})
|
throw({message: res?.data?.resultDescription})
|
||||||
}
|
}
|
||||||
|
window.scrollTo(0, 0);
|
||||||
},
|
},
|
||||||
|
// onSettled: () => {
|
||||||
|
// setTimeout(() => {
|
||||||
|
// contactMutation.reset()
|
||||||
|
// }, 3000)
|
||||||
|
// }
|
||||||
// onError: (err) => {
|
// onError: (err) => {
|
||||||
// console.log('err', err)
|
// console.log('err', err)
|
||||||
// }
|
// }
|
||||||
@@ -40,10 +48,6 @@ export default function Home() {
|
|||||||
let reqData = {
|
let reqData = {
|
||||||
...values
|
...values
|
||||||
}
|
}
|
||||||
console.log(reqData)
|
|
||||||
setTimeout(() => {
|
|
||||||
contactMutation.reset()
|
|
||||||
}, 3000)
|
|
||||||
contactMutation.mutate(reqData)
|
contactMutation.mutate(reqData)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +89,30 @@ export default function Home() {
|
|||||||
return (
|
return (
|
||||||
<Form name="contactform" className="row contact-form">
|
<Form name="contactform" className="row contact-form">
|
||||||
{/* Form Select */}
|
{/* 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">
|
<div className="col-md-12 input-subject">
|
||||||
<p className="p-lg">{t("questionAbout")}{(props.errors.subject && props.touched.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>
|
<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")}
|
{contactMutation.isPending ? t("sending") : contactMutation.isSuccess ? t("messageSent") : t("submitRequest")}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
}
|
||||||
<div className="contact-form-notice">
|
<div className="contact-form-notice">
|
||||||
<p className="p-sm">{t("privacy")}</p>
|
<p className="p-sm">{t("privacy")}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Contact Form Message */}
|
{/* Contact Form Message */}
|
||||||
<div className="col-lg-12 contact-form-msg">
|
<div className="col-lg-12 contact-form-msg">
|
||||||
<span className="loading"/>
|
<span className="loading"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user