diff --git a/src/Mutations/contactUs.mutation.tsx b/src/Mutations/contactUs.mutation.tsx
new file mode 100644
index 00000000..17825fad
--- /dev/null
+++ b/src/Mutations/contactUs.mutation.tsx
@@ -0,0 +1,12 @@
+import { gql } from '@apollo/client';
+
+export const SEND_MESSAGE_MUTATION = gql`
+ mutation sendMessage(
+ $name: String!
+ $email: String!
+ $phone: String
+ $message: String!
+ ) {
+ sendMessage(name: $name, email: $email, phone: $phone, message: $message)
+ }
+`;
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx
index 41fd7694..ceec5d7a 100644
--- a/src/components/Footer.tsx
+++ b/src/components/Footer.tsx
@@ -64,7 +64,9 @@ function Footer({ styles }: any) {
{t('Dev Pulse')}
- {t('About us')}
- - {t('Contact us')}
+ -
+ {t('Contact us')}
+
diff --git a/src/containers/Routes.tsx b/src/containers/Routes.tsx
index c7193430..3f9e79cc 100644
--- a/src/containers/Routes.tsx
+++ b/src/containers/Routes.tsx
@@ -25,6 +25,7 @@ const About = React.lazy(() => import('../pages/Comingsoon'));
const Community = React.lazy(() => import('../pages/Community'));
/* istanbul ignore next */
const Product = React.lazy(() => import('../pages/Comingsoon'));
+const ContactUs = React.lazy(() => import('../pages/ContactUs'));
/* istanbul ignore next */
const SignupOrgDocs = React.lazy(
() => import('../components/Docs/SignupOrgDocs'),
@@ -162,6 +163,14 @@ function MainRoutes() {
}
/>
+
}>
+
+
+ }
+ />
} />
} />
({
+ name: '',
+ email: '',
+ phone: '',
+ message: '',
+ });
+ const [sendMessage, { loading, error }] = useMutation(SEND_MESSAGE_MUTATION);
+
+ const [errors, setErrors] = useState<{ [key: string]: string }>({});
+
+ // Handle form input changes
+ const handleChange = (
+ e: React.ChangeEvent,
+ ) => {
+ const { name, value } = e.target;
+ setFormData({
+ ...formData,
+ [name]: value,
+ });
+
+ if (errors[name]) {
+ setErrors({
+ ...errors,
+ [name]: '',
+ });
+ }
+ };
+
+ // Validation function
+ const validateForm = () => {
+ const newErrors: { [key: string]: string } = {};
+
+ if (!formData.name) {
+ newErrors.name = 'Name is required';
+ }
+
+ // Email validation with regex
+ const emailPattern = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
+ if (!formData.email) {
+ newErrors.email = 'Email is required';
+ } else if (!emailPattern.test(formData.email)) {
+ newErrors.email = 'Invalid email address';
+ }
+
+ if (!formData.message) {
+ newErrors.message = 'Message is required';
+ }
+
+ setErrors(newErrors);
+ return Object.keys(newErrors).length === 0;
+ };
+
+ // Handle form submission
+ const handleSubmit = async (e: React.FormEvent) => {
+ e.preventDefault();
+
+ if (!validateForm()) {
+ return;
+ }
+
+ try {
+ const { data } = await sendMessage({
+ variables: {
+ name: formData.name,
+ email: formData.email,
+ phone: formData.phone,
+ message: formData.message,
+ },
+ });
+ toast.success('Your message has been sent successfully!');
+ setFormData({ name: '', email: '', phone: '', message: '' });
+ } catch (err) {
+ toast.error('Error submitting the form, Try again');
+ }
+ };
+
+ return (
+
+
+
+ Contact Us
+
+
+ We would love to hear from you. Please fill out the form below to get
+ in touch.
+
+
+
+
+
+ );
+}