Commit 6892cb29 by jaymehta

contact-us

1 parent 5e8dfe8d
......@@ -6,6 +6,8 @@ import { Formik, Form, Field, ErrorMessage } from "formik";
import * as Yup from "yup";
import PhoneInput from "react-phone-input-2";
import "react-phone-input-2/lib/style.css";
import axios from "axios";
import { toast } from "react-toastify";
const validationSchema = Yup.object().shape({
fullName: Yup.string().required("Full name is required"),
......@@ -44,10 +46,28 @@ const GetinTouch = () => {
message: ""
}}
validationSchema={validationSchema}
onSubmit={(values, { setSubmitting }) => {
onSubmit={async (values, { setSubmitting }) => {
// Handle form submission here
console.log(values);
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 }) => (
......@@ -81,7 +101,7 @@ const GetinTouch = () => {
<Field
as={PhoneInput}
inputClass="form-control"
country={"in"}
country={"us"}
name="phone"
placeholder="Enter Your Contact Number"
onChange={phone => handleChange({ target: { name: "phone", value: phone } })}
......@@ -115,8 +135,9 @@ const GetinTouch = () => {
/>
{touched.message && errors.message && <div className="text-danger">{errors.message}</div>}
</div>
{/* {console.log(errors)} */}
<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
</button>
</div>
......
......@@ -335,7 +335,7 @@ export const getActivitiesForEndUser = () => async dispatch => {
filters: {
approved: { $eq: "approved" }
},
sort: [{ createdAt: 'desc' }],
sort: [{ createdAt: 'asc' }],
pagination: {
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!