"use client"; import { zodResolver } from "@hookform/resolvers/zod"; import type { LucideIcon } from "lucide-react"; import { Clock, MapPin, Phone } from "lucide-react"; import { Fragment } from "react"; import { Controller, useForm } from "react-hook-form"; import z from "zod"; import { Button } from "@/components/ui/button"; import { Field, FieldError } from "@/components/ui/field"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Separator } from "@/components/ui/separator"; import { cn } from "@/lib/utils"; type NewsletterData = { title?: string; description?: string; }; type NewsletterFormProps = NewsletterData; type FooterLink = { text: string; link: string; }; type FooterLinksSectionData = { title: string; items: FooterLink[]; }; interface FooterLinksSectionProps { sections: FooterLinksSectionData[]; } type SocialIcon = { title: string; src: string; className?: string; }; type SocialLink = { link: string; icon: SocialIcon; }; type ContactLink = { icon: LucideIcon; text: string; type: LinkTypes; link?: string; }; type ContactLinks = { contactDetails: ContactLink[]; socialMedia: SocialLink[]; }; interface ContactSectionProps { links: ContactLinks; } interface EcommerceFooter1Props { newsletter: NewsletterData; footerLinks: FooterLinksSectionData[]; contactLinks: ContactLinks; className?: string; } const LINK_TYPES = { NO_LINK: "NO_LINK", PHONE_LINK: "PHONE_LINK", EMAIL_LINK: "EMAIL_LINK", }; type LinkTypes = keyof typeof LINK_TYPES; const NEWSLETTER_DATA = { title: "خبرنامه", description: "در خبرنامه ما عضو شوید و از پیشنهادهای ویژه، نکات فنی و معرفی محصولات جدید باخبر شوید.", }; const FOOTER_LINKS: FooterLinksSectionData[] = [ { title: "اطلاعات", items: [ { text: "شرایط و ضوابط", link: "#", }, { text: "حریم خصوصی", link: "#", }, { text: "سیاست ضمانت", link: "#", }, { text: "شرایط استفاده", link: "#", }, ], }, { title: "مجموعهها", items: [ { text: "تازهها", link: "#", }, { text: "پرفروشترینها", link: "#", }, { text: "پیشنهادهای فصلی", link: "#", }, { text: "محصولات ضروری", link: "#", }, ], }, ]; const SOCIAL_ICONS = { facebook: { title: "Facebook", src: "/block-media/shadcnblocks/block/logos/facebook-icon.svg", }, x: { title: "X", src: "/block-media/shadcnblocks/block/logos/x.svg", className: "dark:invert", }, instagram: { title: "Instagram", src: "/block-media/shadcnblocks/block/logos/instagram-icon.svg", }, }; const CONTACT_LINKS: ContactLinks = { contactDetails: [ { icon: MapPin, text: "support@store.com", link: "support@store.com", type: LINK_TYPES.EMAIL_LINK as LinkTypes, }, { icon: Phone, text: "+12345678910", link: "+12345678910", type: LINK_TYPES.PHONE_LINK as LinkTypes, }, { icon: Clock, text: "شنبه تا پنجشنبه، ۹ صبح تا ۹ شب", type: LINK_TYPES.NO_LINK as LinkTypes, }, ], socialMedia: [ { icon: SOCIAL_ICONS.facebook, link: "#", }, { icon: SOCIAL_ICONS.x, link: "#", }, { icon: SOCIAL_ICONS.instagram, link: "#", }, ], }; const EcommerceFooter1 = ({ newsletter = NEWSLETTER_DATA, footerLinks = FOOTER_LINKS, contactLinks = CONTACT_LINKS, className, }: EcommerceFooter1Props) => { return ( © ۱۴۰۵ ری یو آی. تمامی حقوق محفوظ است. فارسی انگلیسی العربية ); }; const newsletterFormSchema = z.object({ email: z .string() .min(1, "ایمیل الزامی است") .email("آدرس ایمیل نامعتبر است"), }); type newsletterFormType = z.infer; const NewsletterSection = ({ title, description }: NewsletterFormProps) => { const form = useForm({ resolver: zodResolver(newsletterFormSchema), defaultValues: { email: "", }, }); const onSubmit = (data: newsletterFormType) => { console.log(data); }; return ( {title} {description} ( {fieldState.invalid && } )} /> عضویت ); }; const FooterLinksSection = ({ sections }: FooterLinksSectionProps) => { return ( {sections.map(({ title, items }) => ( {title} {items.map(({ text, link }) => ( {text} ))} ))} ); }; const ContactSection = ({ links }: ContactSectionProps) => { const { socialMedia, contactDetails } = links; return ( تماس با ما {contactDetails.map((item) => ( {item.type === LINK_TYPES.NO_LINK ? ( {item.text} ) : ( {item.text} )} ))} {socialMedia.map(({ icon, link }) => ( ))} ); }; export { EcommerceFooter1 };
© ۱۴۰۵ ری یو آی. تمامی حقوق محفوظ است.
{description}
{item.text}