first project version mrDecor

This commit is contained in:
alirez.br
2026-05-11 15:30:57 +03:30
commit 8724072983
302 changed files with 25401 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
'use server'
const TELEGRAM_BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN
const TELEGRAM_CHAT_ID = process.env.TELEGRAM_CHAT_ID
const TELEGRAM_URL = process.env.TELEGRAM_URL ?? 'https://api.telegram.org'
export type ContactFormData = {
name: string
phone: string
email?: string
subject?: string
message?: string
}
function buildTelegramMessage(data: ContactFormData): string {
const lines = [
'📞 *تماس با ما*',
'',
`👤 *نام:* ${data.name}`,
`📱 *تلفن:* ${data.phone}`,
]
if (data.email?.trim()) {
lines.push(`📧 *ایمیل:* ${data.email.trim()}`)
}
if (data.subject?.trim()) {
lines.push(`📌 *موضوع:* ${data.subject.trim()}`)
}
if (data.message?.trim()) {
lines.push('', '*پیام:*', data.message.trim())
}
return lines.join('\n')
}
export async function submitContact(
data: ContactFormData
): Promise<{ success: boolean; error?: string }> {
const name = data.name?.trim()
const phone = data.phone?.trim().replace(/\s/g, '')
if (!name || name.length < 2) {
return { success: false, error: 'نام و نام خانوادگی را وارد کنید.' }
}
if (!phone || phone.length < 10) {
return { success: false, error: 'شماره تماس معتبر وارد کنید.' }
}
if (!TELEGRAM_BOT_TOKEN || !TELEGRAM_CHAT_ID) {
console.error('TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_ID is not set')
return {
success: false,
error: 'پیکربندی ارسال پیام انجام نشده است. لطفاً با پشتیبانی تماس بگیرید.',
}
}
const text = buildTelegramMessage({
name,
phone,
email: data.email,
subject: data.subject,
message: data.message,
})
const url = `${TELEGRAM_URL}/bot${TELEGRAM_BOT_TOKEN}/sendMessage`
const body = {
chat_id: TELEGRAM_CHAT_ID,
text,
parse_mode: 'Markdown',
}
try {
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
})
const result = await res.json()
if (!res.ok || !result.ok) {
console.error('Telegram API error:', result)
return {
success: false,
error: 'ارسال پیام با خطا مواجه شد. لطفاً دوباره تلاش کنید.',
}
}
return { success: true }
} catch (e) {
console.error('Failed to send to Telegram', e)
return {
success: false,
error: 'ارسال پیام با خطا مواجه شد. لطفاً دوباره تلاش کنید.',
}
}
}
+88
View File
@@ -0,0 +1,88 @@
import React from 'react'
import type { Metadata } from 'next'
import { ContactInfoGrid } from '@/components/sections/other/contact-info-grid'
import { ContactForm } from '@/components/sections/other/contact-form'
import { getContentSync } from '@/lib/content'
export async function generateMetadata(): Promise<Metadata> {
try {
const content = getContentSync()
const meta = content.meta?.pages?.contact
if (meta?.title) {
return { title: meta.title, description: meta.description ?? undefined }
}
} catch {
// fallback if content fails
}
return { title: 'تماس با ما', description: 'برای ارتباط با مستر دکور با ما تماس بگیرید.' }
}
export default function ContactPage() {
const content = getContentSync()
const contact = content.pages?.contact
// const siteName = content.meta?.siteName ?? 'مستر دکور'
const heading = contact?.heading ?? 'تماس با ما'
const description =
contact?.description ?? 'برای دریافت مشاوره، استعلام قیمت و انتخاب بهترین دکور ویترین طلافروشی با ما در ارتباط باشید.'
const contactItems = [
{
label: 'ایمیل',
description: 'برای دریافت پیش فاکتور، کاتالوگ یا پاسخ تخصصی، درخواست خود را ایمیل کنید.',
value: 'info@mrdecorr.com',
href: 'mailto:info@mrdecorr.com',
icon: 'mail' as const,
},
{
label: 'دفتر',
description: 'برای هماهنگی جلسه حضوری و بررسی دقیق نیاز فروشگاه، به دفتر ما مراجعه کنید.',
value: 'مشاهده موقعیت روی نقشه',
href: 'https://maps.google.com',
icon: 'map' as const,
},
{
label: 'تلفن',
description: 'برای مشاوره سریع و ثبت سفارش، از شنبه تا پنجشنبه پاسخگوی شما هستیم.',
value: '۰۹۱۲ ۹۴ ۹۷ ۳۱۵',
href: 'tel:09129497315',
icon: 'phone' as const,
},
{
label: 'پشتیبانی واتساپ',
description: 'برای ارسال عکس ویترین و دریافت پیشنهاد اولیه، در واتساپ پیام دهید.',
value: 'شروع گفتگو',
href: 'https://wa.me/989129497315',
icon: 'chat' as const,
},
]
return (
<main className="min-h-screen">
<ContactInfoGrid title={heading} description={description} items={contactItems} />
<section
id="contact-form"
className="flex min-h-[50vh] flex-col items-center justify-center px-4 py-24 md:px-6 md:py-32 lg:py-40"
aria-labelledby="contact-form-heading"
>
<div className="mx-auto w-full max-w-7xl">
<div className="flex flex-col items-center space-y-10 text-center">
<div className="space-y-4">
<h2
id="contact-form-heading"
className="text-heading-2 font-semibold text-foreground"
>
تکمیل فرم
</h2>
<p className="text-body mx-auto max-w-2xl text-muted-foreground">
اطلاعات فروشگاه و نیاز خود را ثبت کنید تا کارشناسان مستر دکور در کوتاه ترین زمان با شما تماس بگیرند.
</p>
</div>
<div className="w-full max-w-2xl">
<ContactForm />
</div>
</div>
</div>
</section>
</main>
)
}