Initial import of 1407 block sources under blocks/
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,421 @@
|
||||
"use client";
|
||||
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { LoaderIcon, Mail, MapPin, MessagesSquare, Phone } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Field,
|
||||
FieldError,
|
||||
FieldGroup,
|
||||
FieldLabel,
|
||||
} from "@/components/ui/field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface ContactInfo {
|
||||
icon: React.ReactNode;
|
||||
title: string;
|
||||
description: string;
|
||||
value: string;
|
||||
href: string;
|
||||
badge?: string;
|
||||
}
|
||||
|
||||
const contactInfo: ContactInfo[] = [
|
||||
{
|
||||
icon: <Mail className="size-6" />,
|
||||
title: "ایمیل",
|
||||
description: "پاسخگویی در روزهای کاری، حداکثر تا ۲۴ ساعت",
|
||||
value: "hello@company.com",
|
||||
href: "mailto:hello@company.com",
|
||||
badge: "پیشنهادی",
|
||||
},
|
||||
{
|
||||
icon: <MessagesSquare className="size-6" />,
|
||||
title: "چت زنده",
|
||||
description: "کارشناسان پشتیبانی آماده پاسخگویی هستند.",
|
||||
value: "شروع گفتگو",
|
||||
href: "#",
|
||||
badge: "آنلاین",
|
||||
},
|
||||
{
|
||||
icon: <Phone className="size-6" />,
|
||||
title: "تلفن",
|
||||
description: "دوشنبه تا جمعه، ۹ صبح تا ۶ عصر",
|
||||
value: "۲۱-۱۲۳۴۵۶۷۸",
|
||||
href: "tel:+982112345678",
|
||||
},
|
||||
{
|
||||
icon: <MapPin className="size-6" />,
|
||||
title: "دفتر",
|
||||
description: "برای برگزاری جلسه حضوری، پیش از مراجعه هماهنگ کنید.",
|
||||
value: "تهران، خیابان ولیعصر",
|
||||
href: "#",
|
||||
},
|
||||
];
|
||||
|
||||
const contactFormSchema = z.object({
|
||||
firstName: z.string().min(1, "نام الزامی است"),
|
||||
lastName: z.string().min(1, "نام خانوادگی الزامی است"),
|
||||
email: z
|
||||
.string()
|
||||
.min(1, "ایمیل الزامی است")
|
||||
.email("آدرس ایمیل نامعتبر است"),
|
||||
company: z.string().optional(),
|
||||
message: z.string().min(1, "پیام الزامی است"),
|
||||
// @ts-ignore
|
||||
agreeToTerms: z.literal(true, {
|
||||
errorMap: () => ({ message: "برای ادامه، لازم است شرایط استفاده را بپذیرید." }),
|
||||
}),
|
||||
});
|
||||
|
||||
type ContactFormData = z.infer<typeof contactFormSchema>;
|
||||
|
||||
interface Contact6Props {
|
||||
className?: string;
|
||||
onSubmit?: (data: ContactFormData) => Promise<void>;
|
||||
}
|
||||
|
||||
const Contact6 = ({ className, onSubmit }: Contact6Props) => {
|
||||
const [isSubmitted, setIsSubmitted] = useState(false);
|
||||
const [showSuccess, setShowSuccess] = useState(false);
|
||||
|
||||
const form = useForm<ContactFormData>({
|
||||
resolver: zodResolver(contactFormSchema),
|
||||
mode: "onSubmit",
|
||||
reValidateMode: "onSubmit",
|
||||
defaultValues: {
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
company: "",
|
||||
message: "",
|
||||
agreeToTerms: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const handleFormSubmit = async (data: ContactFormData) => {
|
||||
try {
|
||||
if (onSubmit) {
|
||||
await onSubmit(data);
|
||||
} else {
|
||||
console.log("Form submitted:", data);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
setIsSubmitted(true);
|
||||
setShowSuccess(true);
|
||||
form.reset();
|
||||
setTimeout(() => setShowSuccess(false), 4500);
|
||||
setTimeout(() => setIsSubmitted(false), 5000);
|
||||
} catch {
|
||||
form.setError("root", {
|
||||
message: "مشکلی پیش آمد. لطفاً دوباره تلاش کنید.",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<section dir="rtl" lang="fa" className={cn("bg-background py-24", className)}>
|
||||
<div className="container px-4 md:px-6">
|
||||
<div className="mx-auto max-w-4xl">
|
||||
<div className="mb-16 text-center">
|
||||
<h1 className="mb-4 text-3xl font-bold tracking-tight sm:text-xl md:text-2xll">
|
||||
تماس با ما
|
||||
</h1>
|
||||
<p className="mx-auto max-w-2xl text-lg text-muted-foreground">
|
||||
اگر قصد شروع پروژه جدید یا توسعه کسبوکار خود را دارید، کارشناسان ما آمادهاند تا بهترین راهکار را متناسب با نیاز شما ارائه دهند.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-12 lg:grid-cols-2">
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-4">
|
||||
{contactInfo.map((info, index) => (
|
||||
<Card key={index} className="border-0 bg-muted shadow-none">
|
||||
<CardContent>
|
||||
<div className="flex items-start gap-4">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted">
|
||||
{info.icon}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="mb-1 flex items-center gap-2">
|
||||
<h3 className="font-semibold">{info.title}</h3>
|
||||
</div>
|
||||
<p className="mb-2 text-sm text-muted-foreground">
|
||||
{info.description}
|
||||
</p>
|
||||
<a
|
||||
href={info.href}
|
||||
className="text-sm font-medium transition-colors hover:underline"
|
||||
dir={
|
||||
info.title === "ایمیل" || info.title === "تلفن"
|
||||
? "ltr"
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{info.value}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card className="border-0 shadow-none">
|
||||
<CardHeader>
|
||||
<CardTitle>پیام خود را برای ما ارسال کنید</CardTitle>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
فرم زیر را تکمیل کنید تا در کوتاهترین زمان ممکن با شما تماس بگیریم.
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{isSubmitted && (
|
||||
<div
|
||||
className={cn(
|
||||
"mb-6 rounded-lg border border-green-500/20 bg-green-500/10 p-4 text-center transition-opacity duration-500",
|
||||
showSuccess ? "opacity-100" : "opacity-0",
|
||||
)}
|
||||
>
|
||||
<p className="text-sm font-medium text-green-600 dark:text-green-400">
|
||||
پیام شما با موفقیت ارسال شد!
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={form.handleSubmit(handleFormSubmit)}>
|
||||
<FieldGroup>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="firstName"
|
||||
render={({ field, fieldState }) => (
|
||||
<Field data-invalid={fieldState.invalid}>
|
||||
<FieldLabel htmlFor={field.name}>
|
||||
نام{" "}
|
||||
<span className="text-destructive">*</span>
|
||||
</FieldLabel>
|
||||
<Input
|
||||
{...field}
|
||||
id={field.name}
|
||||
aria-invalid={fieldState.invalid}
|
||||
placeholder="علی"
|
||||
/>
|
||||
{fieldState.invalid && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="lastName"
|
||||
render={({ field, fieldState }) => (
|
||||
<Field data-invalid={fieldState.invalid}>
|
||||
<FieldLabel htmlFor={field.name}>
|
||||
نام خانوادگی{" "}
|
||||
<span className="text-destructive">*</span>
|
||||
</FieldLabel>
|
||||
<Input
|
||||
{...field}
|
||||
id={field.name}
|
||||
aria-invalid={fieldState.invalid}
|
||||
placeholder="محمدی"
|
||||
/>
|
||||
{fieldState.invalid && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="email"
|
||||
render={({ field, fieldState }) => (
|
||||
<Field data-invalid={fieldState.invalid}>
|
||||
<FieldLabel htmlFor={field.name}>
|
||||
ایمیل{" "}
|
||||
<span className="text-destructive">*</span>
|
||||
</FieldLabel>
|
||||
<Input
|
||||
{...field}
|
||||
id={field.name}
|
||||
type="email"
|
||||
aria-invalid={fieldState.invalid}
|
||||
placeholder="example@company.com"
|
||||
dir="rtl"
|
||||
className="text-start"
|
||||
/>
|
||||
{fieldState.invalid && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="company"
|
||||
render={({ field }) => (
|
||||
<Field>
|
||||
<FieldLabel htmlFor={field.name}>شرکت</FieldLabel>
|
||||
<Input
|
||||
{...field}
|
||||
id={field.name}
|
||||
placeholder="نام شرکت یا سازمان"
|
||||
/>
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="message"
|
||||
render={({ field, fieldState }) => (
|
||||
<Field data-invalid={fieldState.invalid}>
|
||||
<FieldLabel htmlFor={field.name}>
|
||||
پیام <span className="text-destructive">*</span>
|
||||
</FieldLabel>
|
||||
<Textarea
|
||||
{...field}
|
||||
id={field.name}
|
||||
aria-invalid={fieldState.invalid}
|
||||
placeholder="نیازها، اهداف یا جزئیات پروژه خود را برای ما شرح دهید."
|
||||
rows={4}
|
||||
className="resize-none"
|
||||
/>
|
||||
{fieldState.invalid && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="agreeToTerms"
|
||||
render={({ field, fieldState }) => (
|
||||
<Field data-invalid={fieldState.invalid}>
|
||||
<div className="flex items-start gap-3">
|
||||
<Checkbox
|
||||
id={field.name}
|
||||
// @ts-ignore
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
aria-invalid={fieldState.invalid}
|
||||
/>
|
||||
<label
|
||||
htmlFor={field.name}
|
||||
className="text-sm leading-relaxed text-muted-foreground"
|
||||
>
|
||||
موافقم با{" "}
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-foreground hover:underline"
|
||||
>
|
||||
شرایط استفاده
|
||||
</a>{" "}
|
||||
و{" "}
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-foreground hover:underline"
|
||||
>
|
||||
حریم خصوصی
|
||||
</a>
|
||||
</label>
|
||||
</div>
|
||||
{fieldState.invalid && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
{form.formState.errors.root && (
|
||||
<p className="text-sm text-destructive">
|
||||
{form.formState.errors.root.message}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full gap-2"
|
||||
disabled={form.formState.isSubmitting}
|
||||
>
|
||||
{form.formState.isSubmitting ? (
|
||||
<>
|
||||
<LoaderIcon className="size-4 animate-spin" />
|
||||
در حال ارسال...
|
||||
</>
|
||||
) : (
|
||||
"ارسال پیام"
|
||||
)}
|
||||
</Button>
|
||||
</FieldGroup>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="mt-12">
|
||||
<Separator className="mb-8" />
|
||||
<Card className="border-0 bg-muted shadow-none">
|
||||
<CardContent className="p-6">
|
||||
<div className="grid gap-8 md:grid-cols-2">
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-lg font-semibold">ساعات کاری</h3>
|
||||
<div className="space-y-2 text-sm text-muted-foreground">
|
||||
<div className="flex justify-between gap-4">
|
||||
<span>دوشنبه تا جمعه</span>
|
||||
<span dir="rtl">۹:۰۰ - ۱۸:۰۰</span>
|
||||
</div>
|
||||
<div className="flex justify-between gap-4">
|
||||
<span>شنبه</span>
|
||||
<span dir="rtl">۱۰:۰۰ - ۱۶:۰۰</span>
|
||||
</div>
|
||||
<div className="flex justify-between gap-4">
|
||||
<span>یکشنبه</span>
|
||||
<span>تعطیل</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-lg font-semibold">اطلاعات تماس</h3>
|
||||
<div className="space-y-2 text-sm text-muted-foreground">
|
||||
<div className="flex justify-between gap-4">
|
||||
<span>ایمیل</span>
|
||||
<span dir="rtl">اطلاعات@نمونه.ایران</span>
|
||||
</div>
|
||||
<div className="flex justify-between gap-4">
|
||||
<span>تلفن</span>
|
||||
<span dir="rtl">۲۱-۱۲۳۴۵۶۷۸</span>
|
||||
</div>
|
||||
<div className="flex justify-between gap-4">
|
||||
<span>آدرس</span>
|
||||
<span>تهران، خیابان ولیعصر</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
export { Contact6 };
|
||||
Reference in New Issue
Block a user