+
);
diff --git a/src/app/api/product_categories/contact/contactMessages.json b/src/app/api/contact/contactMessages.json
similarity index 100%
rename from src/app/api/product_categories/contact/contactMessages.json
rename to src/app/api/contact/contactMessages.json
diff --git a/src/app/api/product_categories/contact/route.ts b/src/app/api/contact/route.ts
similarity index 91%
rename from src/app/api/product_categories/contact/route.ts
rename to src/app/api/contact/route.ts
index 1f42807..d30de19 100644
--- a/src/app/api/product_categories/contact/route.ts
+++ b/src/app/api/contact/route.ts
@@ -7,6 +7,7 @@ const filePath = path.resolve(process.cwd(), 'contactMessages.json');
export async function POST(request: NextRequest) {
try {
const body = await request.json();
+ console.log(body)
const { first_name, last_name, phone, email, message } = body;
if (!first_name || !last_name || !phone || !email || !message) {
@@ -25,7 +26,9 @@ export async function POST(request: NextRequest) {
}
const newMessage = {
- name,
+ first_name,
+ last_name,
+ phone,
email,
message,
createdAt: new Date().toISOString(),
@@ -41,6 +44,8 @@ export async function POST(request: NextRequest) {
message: 'Your message has been received.',
});
} catch (error) {
+ console.log(error)
+ console.log(error)
return NextResponse.json(
{ error, message: 'مشکلی پیش آمده.' },
{ status: 400 },
diff --git a/src/app/api/project_categories/data.ts b/src/app/api/project_categories/data.ts
new file mode 100644
index 0000000..bc7c753
--- /dev/null
+++ b/src/app/api/project_categories/data.ts
@@ -0,0 +1,118 @@
+export const productCategories = [
+ {
+ id: '1',
+ title: 'Ghazaghi',
+ fa_title: 'قزاقی',
+ icon: 'categoryGhazaghi',
+ typesCount: 22,
+ priceTypeTitle: 'Economy',
+ fa_priceTypeTitle: 'اقتصادی',
+ bestForTitle: 'Best For Interior Part',
+ fa_bestForTitle: 'Best For Interior Part',
+ fa_description: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`,
+ description: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`,
+ },
+ {
+ id: '2',
+ title: 'Ghermez',
+ fa_title: 'قرمز',
+ icon: 'categoryGhermez',
+ typesCount: 12,
+ priceTypeTitle: 'Luxury',
+ fa_priceTypeTitle: 'لاکچری',
+ bestForTitle: 'Best For Exterior Part',
+ fa_bestForTitle: 'Best For Exterior Part',
+ fa_description: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`,
+ description: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`,
+ },
+ {
+ id: '3',
+ title: 'oryZard',
+ fa_title: 'زرد',
+ icon: 'categoryZard',
+ typesCount: 11,
+ priceTypeTitle: 'Economy',
+ fa_priceTypeTitle: 'اقتصادی',
+ bestForTitle: 'Best For Facing',
+ fa_bestForTitle: 'Best For Facing',
+ fa_description: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`,
+ description: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`,
+ },
+ {
+ id: '40',
+ title: 'Semirom',
+ fa_title: 'سمیرم',
+ icon: 'categorySemirom',
+ typesCount: 40,
+ priceTypeTitle: 'Economy',
+ fa_priceTypeTitle: 'اقتصادی',
+ bestForTitle: 'Best For Building',
+ fa_bestForTitle: 'Best For Building',
+ fa_description: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`,
+ description: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`,
+ },
+] as APIProductCategoryEntity[];
+
+interface APIProductCategoryEntity {
+ id: string;
+ title: string;
+ fa_title?: string;
+ icon: string;
+ typesCount: number;
+ priceTypeTitle: string;
+ fa_priceTypeTitle?: string;
+ bestForTitle: string;
+ fa_bestForTitle?: string;
+ fa_description?: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`;
+ description?: `Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+Facing Bricks: Characteristics and Features
+Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
+
+Facing Bricks: Characteristics and Features`;
+}
diff --git a/src/app/api/project_categories/route.ts b/src/app/api/project_categories/route.ts
new file mode 100644
index 0000000..4cb1e56
--- /dev/null
+++ b/src/app/api/project_categories/route.ts
@@ -0,0 +1,51 @@
+import { NextResponse } from 'next/server';
+import { cookies } from 'next/headers';
+import { productCategories } from './data';
+
+export async function GET(request: Request) {
+ let data = productCategories;
+
+ const cookieStore = await cookies();
+ const lang = (await cookieStore).get('lang')?.value || 'fa';
+
+ if (lang === 'fa') {
+ data = productCategories.map(
+ ({
+ id,
+ title,
+ fa_title,
+ icon,
+ typesCount,
+ priceTypeTitle,
+ fa_priceTypeTitle,
+ bestForTitle,
+ fa_bestForTitle,
+ description,
+ fa_description,
+ }) => {
+ if (lang === 'fa') {
+ return {
+ id,
+ icon,
+ typesCount,
+ title: fa_title || title,
+ priceTypeTitle: fa_priceTypeTitle || priceTypeTitle,
+ bestForTitle: fa_bestForTitle || bestForTitle,
+ description: fa_description || description,
+ };
+ }
+ return {
+ id,
+ icon,
+ typesCount,
+ title,
+ priceTypeTitle,
+ bestForTitle,
+ description,
+ };
+ },
+ );
+ }
+
+ return NextResponse.json({ data: productCategories });
+}
diff --git a/src/components/pages/contact/ContactMeForm.tsx b/src/components/pages/contact/ContactMeForm.tsx
index 28232de..000d5b4 100644
--- a/src/components/pages/contact/ContactMeForm.tsx
+++ b/src/components/pages/contact/ContactMeForm.tsx
@@ -1,32 +1,148 @@
'use client';
+import { useState } from 'react';
import Button from '@/components/uikit/button';
import FormField from '@/components/uikit/inputs';
import { useTranslations } from 'next-intl';
+import api from '@/lib/axios';
+import { setContact } from '@/services/contact';
const ContactForm = () => {
const t = useTranslations();
+ const [formData, setFormData] = useState({
+ first_name: '',
+ last_name: '',
+ email: '',
+ phone: '',
+ message: '',
+ });
+
+ const [errors, setErrors] = useState
>({});
+ const [loading, setLoading] = useState(false);
+
+ const validate = () => {
+ const newErrors: Record = {};
+
+ if (!formData.first_name.trim())
+ newErrors.first_name = t('com_contact_first_name_required');
+ if (!formData.last_name.trim())
+ newErrors.last_name = t('com_contact_last_name_required');
+
+ if (!formData.email) {
+ newErrors.email = t('com_contact_email_required');
+ } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) {
+ newErrors.email = t('com_contact_email_error');
+ }
+
+ if (!formData.phone) {
+ newErrors.phone = t('com_contact_phone_required');
+ } else if (!/^09\d{9}$/.test(formData.phone)) {
+ newErrors.phone = t('com_contact_phone_error');
+ }
+
+ if (!formData.message.trim()) {
+ newErrors.message = t('com_contact_textarea_required');
+ } else if (formData.message.trim().length < 10) {
+ newErrors.message = t('com_contact_textarea_error');
+ }
+
+ setErrors(newErrors);
+ return Object.keys(newErrors).length === 0;
+ };
+
+ const handleChange = (field: string, value: string) => {
+ setFormData({ ...formData, [field]: value });
+ setErrors({ ...errors, [field]: '' });
+ };
+
+ const handleSubmit = (e: React.FormEvent) => {
+ console.log(e);
+ e.preventDefault();
+ setLoading(true);
+ setContact(formData).finally(() => {
+ setLoading(false);
+ });
+ };
+
return (
-
-
+
);
};
diff --git a/src/components/pages/contact/TouchUs.tsx b/src/components/pages/contact/TouchUs.tsx
index 2a4cdc7..635ed7a 100644
--- a/src/components/pages/contact/TouchUs.tsx
+++ b/src/components/pages/contact/TouchUs.tsx
@@ -1,5 +1,6 @@
'use client';
+import SectionTitle from '@/components/layout/sectionTitle';
import { Icon } from '@/components/uikit/icons';
import { useTranslations } from 'next-intl';
@@ -8,23 +9,18 @@ const TouchUs = () => {
return (