diff --git a/components/services/services.js b/components/services/services.js index 207633b..ed2f767 100644 --- a/components/services/services.js +++ b/components/services/services.js @@ -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) +} diff --git a/pages/contacts.js b/pages/contacts.js index 4cb26e8..a7af4a4 100644 --- a/pages/contacts.js +++ b/pages/contacts.js @@ -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 Select */} + {contactMutation.isSuccess ? +
+

+ 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. +

+
+ + Return Home + +
+
+ :contactMutation.isError ? +
+

+ Opps! An error occured, please try again. +

+
+ +
+
+ : + <>

{t("questionAbout")}{(props.errors.subject && props.touched.subject) && {props.errors.subject}}

@@ -134,9 +162,12 @@ export default function Home() { {contactMutation.isPending ? t("sending") : contactMutation.isSuccess ? t("messageSent") : t("submitRequest")}
+ + }

{t("privacy")}

+ {/* Contact Form Message */}