contact endpoint added #17
@@ -26,11 +26,11 @@ const blogBasePath = () => {
|
||||
}
|
||||
|
||||
const siteServerPath = () => {
|
||||
// NEXT_PUBLIC_APP_MAIN_API="https://devapi.mermsemr.com"
|
||||
return 'https://devapi.mermsemr.com';
|
||||
return process.env.NEXT_PUBLIC_APP_MAIN_API;
|
||||
}
|
||||
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 = {}
|
||||
if (!media) {
|
||||
newPostData = {...postData}
|
||||
@@ -75,3 +75,10 @@ export const serMermsWebContact = (reqData) => {
|
||||
}
|
||||
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 { 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"/>
|
||||
|
||||
Reference in New Issue
Block a user