From 8c1f7c7501c64042a7ee0e24cdb674f91837355a Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Tue, 22 Apr 2025 15:29:05 +0330 Subject: [PATCH] meta fix bug --- src/app/contact/ContactForm.tsx | 150 ++++++++++++++++++++++++++++++++ src/app/contact/page.tsx | 149 +------------------------------ 2 files changed, 154 insertions(+), 145 deletions(-) create mode 100644 src/app/contact/ContactForm.tsx diff --git a/src/app/contact/ContactForm.tsx b/src/app/contact/ContactForm.tsx new file mode 100644 index 0000000..f2176bd --- /dev/null +++ b/src/app/contact/ContactForm.tsx @@ -0,0 +1,150 @@ +'use client' +import Button from '@/components/Button' +import Input from '@/components/Input' +import Textarea from '@/components/Textarea' +import { CallCalling, Location, SmsTracking } from 'iconsax-react' +import React from 'react' +import { CreateContactType } from './types/ContactTypes' +import { useFormik } from 'formik' +import * as Yup from 'yup' +import { useCreateContact } from './hooks/useContactData' +import { toast } from 'react-toastify' +import { ErrorType } from '@/helpers/types' + +const ContactForm = () => { + + const createContact = useCreateContact() + + const formik = useFormik({ + initialValues: { + fullName: '', + email: '', + phone: '', + businessName: '', + content: '', + }, + validationSchema: Yup.object({ + fullName: Yup.string().required('نام وارد کنید'), + email: Yup.string().email('ایمیل معتبر وارد کنید').required('ایمیل وارد کنید'), + phone: Yup.string().required('شماره تماس وارد کنید'), + businessName: Yup.string().required('نام شرکت وارد کنید'), + content: Yup.string().required('پیام وارد کنید'), + }), + onSubmit: (values) => { + createContact.mutate(values, { + onSuccess: () => { + toast.success('پیام شما با موفقیت ثبت شد') + formik.resetForm() + }, + onError: (error: ErrorType) => { + toast.error(error.response?.data?.error.message[0]) + } + }) + }, + }) + return ( +
+

+ تماس با ما +

+ +
+
+
+ شماره تماس +
+
+ +
+ ۰۲۱-۹۱۶۹۳۵۳۳ +
+
+ +
+ ایمیل +
+
+ +
+ info@danakcorp.com +
+
+ +
+ آدرس +
+
+ +
+ تهران - یوسف آباد - فتحی شقاقی - پلاک ۵ - واحد ۱۳ +
+
+
+ +
+
+ فرم تماس +
+ +
+ + +
+
+ + +
+ +
+