"use client"; import { zodResolver } from "@hookform/resolvers/zod"; import { ArrowRight, Plus } from "lucide-react"; import { Fragment, useState } from "react"; import { Controller, useForm } from "react-hook-form"; import z from "zod"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { Button } from "@/components/ui/button"; import { Field, FieldDescription, FieldError, FieldTitle, } from "@/components/ui/field"; import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, } from "@/components/ui/input-group"; import { useMediaQuery } from "@/hooks/useMediaQuery"; import { cn } from "@/lib/utils"; type NewsletterData = { title?: string; description?: string; }; type NewsletterFormProps = NewsletterData; type FooterLink = { text: string; type?: string; link?: string; email?: string; }; type FooterLinksSection = { title: string; id: string; items: FooterLink[]; }; type SocialIcon = { title: string; light: string; dark: string; }; type SocialLink = { link: string; icon: SocialIcon; }; interface EcommerceFooter2Props { newsletter: NewsletterData; footerLinks: FooterLinksSection[]; socialLinks: SocialLink[]; description: string; className?: string; } interface FooterLinksSectionProps { sections: FooterLinksSection[]; } interface SocialMediaSectionProps { links: SocialLink[]; } const NEWSLETTER_DATA = { title: "عضویت در خبرنامه و ۱۰٪ تخفیف برای اولین خرید", description: "در خبرنامه ما عضو شوید و از پیشنهادهای ویژه، نکات فنی، معرفی محصولات جدید و دسترسی زودهنگام به جدیدترین لوازم الکترونیکی باخبر شوید.", }; const FOOTER_LINKS: FooterLinksSection[] = [ { title: "برند", id: "the-brand", items: [ { text: "درباره ما", link: "#", }, { text: "پایداری", link: "#", }, { text: "نظرات مشتریان", link: "#", }, { text: "یافتن فروشگاه", link: "#", }, { text: "معرفی به دوستان", link: "#", }, ], }, { title: "راهنما", id: "help", items: [ { text: "تماس با ما", link: "#", }, { text: "سؤالات متداول", link: "#", }, { text: "ارسال و پیگیری", link: "#", }, { text: "مرجوعی و تعویض", link: "#", }, ], }, { title: "اطلاعات", id: "information", items: [ { text: "شرایط و ضوابط", link: "#", }, { text: "حریم خصوصی", link: "#", }, { text: "سیاست ضمانت", link: "#", }, { text: "شرایط استفاده", link: "#", }, ], }, { title: "تماس", id: "contact", items: [ { type: "email", text: "support@techstore.com", email: "support@techstore.com", }, ], }, ]; const SOCIAL_ICONS = { facebook: { title: "Facebook", light: "/block-media/shadcnblocks/block/logos/facebook-icon.svg", dark: "/block-media/shadcnblocks/block/logos/facebook-icon.svg", }, x: { title: "X", light: "/block-media/shadcnblocks/block/logos/x.svg", dark: "/block-media/shadcnblocks/block/logos/x.svg", }, instagram: { title: "Instagram", light: "/block-media/shadcnblocks/block/logos/instagram-icon.svg", dark: "/block-media/shadcnblocks/block/logos/instagram-icon.svg", }, }; const SOCIAL_MEDIA_LINKS = [ { icon: SOCIAL_ICONS.facebook, link: "#", }, { icon: SOCIAL_ICONS.x, link: "#", }, { icon: SOCIAL_ICONS.instagram, link: "#", }, ]; const DESCRIPTION = "جدیدترین اخبار فناوری، تخفیف‌های ویژه، معرفی محصولات و نکات تخصصی را مستقیم در ایمیل خود دریافت کنید. همیشه یک قدم جلوتر از بقیه باشید."; const EcommerceFooter2 = ({ newsletter = NEWSLETTER_DATA, footerLinks = FOOTER_LINKS, socialLinks = SOCIAL_MEDIA_LINKS, description = DESCRIPTION, className, }: EcommerceFooter2Props) => { 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) => { const isDesktop = useMediaQuery("(min-width: 1024px)"); const [value, setValue] = useState(""); if (!sections) return; const allAccordionIds = sections.map(({ id }) => id); const handleOnValueChange = (value: string) => { setValue(value); }; if (isDesktop) { return ( ); } else { return ( ); } }; const AccordionItems = ({ sections }: { sections: FooterLinksSection[] }) => { return ( {sections.map(({ id, title, items }) => ( {title}
    {items.map(({ link, text, type, email }) => (
  • {type === "email" &&

    ایمیل ما:

    } {text}
  • ))}
))}
); }; const SocialMediaSection = ({ links }: SocialMediaSectionProps) => { return (
    {links.map(({ icon, link }) => (
  • ))}
); }; export { EcommerceFooter2 };