Commit 6892cb29 by jaymehta

contact-us

1 parent 5e8dfe8d
...@@ -6,6 +6,8 @@ import { Formik, Form, Field, ErrorMessage } from "formik"; ...@@ -6,6 +6,8 @@ import { Formik, Form, Field, ErrorMessage } from "formik";
import * as Yup from "yup"; import * as Yup from "yup";
import PhoneInput from "react-phone-input-2"; import PhoneInput from "react-phone-input-2";
import "react-phone-input-2/lib/style.css"; import "react-phone-input-2/lib/style.css";
import axios from "axios";
import { toast } from "react-toastify";
const validationSchema = Yup.object().shape({ const validationSchema = Yup.object().shape({
fullName: Yup.string().required("Full name is required"), fullName: Yup.string().required("Full name is required"),
...@@ -44,10 +46,28 @@ const GetinTouch = () => { ...@@ -44,10 +46,28 @@ const GetinTouch = () => {
message: "" message: ""
}} }}
validationSchema={validationSchema} validationSchema={validationSchema}
onSubmit={(values, { setSubmitting }) => { onSubmit={async (values, { setSubmitting }) => {
// Handle form submission here // Handle form submission here
console.log(values); console.log(values);
setSubmitting(false); setSubmitting(false);
const finalData = {
name: values.fullName,
email: values.email,
number: values.phone,
zip: values.zipCode,
message: values.message
};
const config = {
header: {
"Content-Type": "application/json"
}
};
const response = await axios.post(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/contact-uses`, { data: finalData }, config);
if (response.status == 200) {
toast.success("Thank you, we will get back to you shortly.");
}
console.log(response);
}} }}
> >
{({ isSubmitting, values, handleChange, handleBlur, touched, errors }) => ( {({ isSubmitting, values, handleChange, handleBlur, touched, errors }) => (
...@@ -81,7 +101,7 @@ const GetinTouch = () => { ...@@ -81,7 +101,7 @@ const GetinTouch = () => {
<Field <Field
as={PhoneInput} as={PhoneInput}
inputClass="form-control" inputClass="form-control"
country={"in"} country={"us"}
name="phone" name="phone"
placeholder="Enter Your Contact Number" placeholder="Enter Your Contact Number"
onChange={phone => handleChange({ target: { name: "phone", value: phone } })} onChange={phone => handleChange({ target: { name: "phone", value: phone } })}
...@@ -115,8 +135,9 @@ const GetinTouch = () => { ...@@ -115,8 +135,9 @@ const GetinTouch = () => {
/> />
{touched.message && errors.message && <div className="text-danger">{errors.message}</div>} {touched.message && errors.message && <div className="text-danger">{errors.message}</div>}
</div> </div>
{/* {console.log(errors)} */}
<div className="col-md-12"> <div className="col-md-12">
<button className="btn btn-primary" type="submit" disabled={isSubmitting}> <button className="btn btn-primary" type="submit" disabled={Object.keys(errors).length > 0}>
Submit Submit
</button> </button>
</div> </div>
......
...@@ -335,7 +335,7 @@ export const getActivitiesForEndUser = () => async dispatch => { ...@@ -335,7 +335,7 @@ export const getActivitiesForEndUser = () => async dispatch => {
filters: { filters: {
approved: { $eq: "approved" } approved: { $eq: "approved" }
}, },
sort: [{ createdAt: 'desc' }], sort: [{ createdAt: 'asc' }],
pagination: { pagination: {
pageSize: 5 pageSize: 5
}, },
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!