import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import {
CheckCircle2,
Phone,
Star,
ChevronDown,
ChevronUp,
MapPin,
Mail,
Fuel,
CloudRain,
Volume2,
Lock,
ShieldCheck,
Wrench,
Clock,
Award,
Users,
Search,
Car,
Settings,
Battery,
Thermometer,
Droplet,
Instagram,
Facebook,
Twitter,
Youtube,
Linkedin,
ArrowLeftRight
} from 'lucide-react';
import { Button, Container, SectionTitle, cn } from './Shared';
import { useData } from '../contexts/DataContext';
import { FooterColumn } from '../types';
// ---- HELPERS ----
const IconResolver = ({ name, size = 24, className }: { name: string, size?: number, className?: string }) => {
const icons: any = {
ShieldCheck, Wrench, Clock, Award, Users, Search, Car, Settings, Battery, Thermometer, Droplet
};
const Icon = icons[name] || Settings;
return ;
};
// ---- SUB-COMPONENTS ----
const FeatureItem: React.FC<{ icon: string, title: string, description: string }> = ({ icon, title, description }) => (
);
const ServiceCard: React.FC<{ service: any, whatsappLink: string }> = ({ service, whatsappLink }) => (
{service.title}
{service.description}
Agendar →
);
const PackageCard: React.FC<{ pkg: any, whatsappLink: string }> = ({ pkg, whatsappLink }) => (
{pkg.recommended && (
Mais Popular
)}
{pkg.name}
R$
{pkg.price}
/ serviço
{pkg.features.map((feat: string, i: number) => (
{feat}
))}
window.open(whatsappLink, '_blank')}>
Escolher Plano
);
const AccordionItem: React.FC<{ faq: any }> = ({ faq }) => {
const [isOpen, setIsOpen] = React.useState(false);
return (
setIsOpen(!isOpen)}
>
{faq.question}
{isOpen ? : }
);
};
// Componente Antes e Depois Slider
const BeforeAfterSlider: React.FC<{ before: string, after: string, title: string }> = ({ before, after, title }) => {
const [sliderPosition, setSliderPosition] = useState(50);
const [isDragging, setIsDragging] = useState(false);
const handleMove = (event: React.MouseEvent | React.TouchEvent) => {
if (!isDragging) return;
const rect = event.currentTarget.getBoundingClientRect();
const x = 'touches' in event ? event.touches[0].clientX : (event as React.MouseEvent).clientX;
const position = ((x - rect.left) / rect.width) * 100;
setSliderPosition(Math.min(100, Math.max(0, position)));
};
return (
{title}
setIsDragging(true)}
onMouseUp={() => setIsDragging(false)}
onMouseLeave={() => setIsDragging(false)}
onMouseMove={handleMove}
onTouchStart={() => setIsDragging(true)}
onTouchEnd={() => setIsDragging(false)}
onTouchMove={handleMove}
>
{/* Trick to keep image fixed */}
{/* Fix for width calculation in simple implementation: better to just let it fit container */}
{/* Layer to prevent drag issues */}
{/* Handle */}
{/* Labels */}
ANTES
DEPOIS
{/* Alternative slider logic for better compatibility if custom drag fails often */}
setSliderPosition(Number(e.target.value))}
className="absolute inset-0 w-full h-full opacity-0 cursor-ew-resize z-20"
/>
);
};
// ---- SECTIONS ----
export const SpecialOffersSection = () => {
const { data, getWhatsAppLink } = useData();
const t = data.texts.specialOffers;
return (
{data.specialOffers.map((offer) => (
{offer.specs.fuel}
{offer.specs.grip}
{offer.specs.noise}
{offer.title}
{[...Array(5)].map((_, i) => (
))}
({offer.reviews})
{offer.price}
No PIX ou {offer.installment}
window.open(getWhatsAppLink(`Olá! Tenho interesse no pneu: ${offer.title}`), '_blank')}>Comprar Agora
))}
);
};
export const AboutSection = () => {
const { data } = useData();
const t = data.texts.about;
return (
{data.promises.map((item, idx) => )}
{t.badgeYear}
{t.badgeText}
);
};
export const ServicesSection = () => {
const { data, getWhatsAppLink } = useData();
const t = data.texts.services;
return (
{data.services.map((s) => )}
);
};
export const BigCTA = () => {
const { data, getWhatsAppLink } = useData();
const t = data.texts.bigCta;
const handleCall = () => {
window.open(getWhatsAppLink("Olá! Preciso de ajuda imediata/emergência."), '_blank');
};
return (
{t.title}
{data.settings.contactPhoneDisplay}
{t.buttonText}
{t.subtitle}
);
};
export const PackagesSection = () => {
const { data, getWhatsAppLink } = useData();
const t = data.texts.packages;
return (
{data.packages.map((p, i) =>
)}
);
};
export const GallerySection = () => {
const { data } = useData();
const t = data.texts.gallery;
return (
{data.gallery.map((img, idx) => (
))}
);
};
// --- NOVA SEÇÃO DE ANTES E DEPOIS ---
export const BeforeAfterSection = () => {
const { data } = useData();
const t = data.texts.beforeAfter;
return (
{data.beforeAfter.map((item) => (
))}
);
};
export const StatsSection = () => {
const { data } = useData();
return (
{data.stats.map((s, i) => (
))}
);
};
export const WhyChooseSection = () => {
const { data } = useData();
const t = data.texts.whyChoose;
return (
{data.whyChoose.map((item, i) => (
))}
);
};
export const TestimonialsSection = () => {
const { data } = useData();
const t = data.texts.testimonials;
return (
{data.testimonials.map((t, i) => (
{[...Array(5)].map((_, i) => )}
"{t.text}"
))}
);
};
export const TeamSection = () => {
const { data } = useData();
const t = data.texts.team;
return (
{data.team.map((member, i) => (
{member.name}
{member.role}
))}
);
};
export const FaqSection = () => {
const { data } = useData();
const t = data.texts.faq;
return (
{data.faqs.map((faq, i) =>
)}
);
};
export const BlogSection = () => {
const { data } = useData();
const t = data.texts.blog;
return (
{data.blog.map((post, i) => (
{post.date}
{post.title}
{post.excerpt}
Ler mais
))}
);
};
export const ContactSection = () => {
const { data } = useData();
const t = data.texts.contact;
return (
);
};
export const ClientsSection = () => {
const { data } = useData();
return (
Empresas que confiam na CAR
{data.clients.map((client, i) => (
client.url ? (
) : (
{client.name}
)
))}
);
};
// Renderiza o conteúdo de uma coluna baseado no tipo
const FooterColumnRenderer: React.FC<{ column: FooterColumn }> = ({ column }) => {
const { data } = useData();
if (column.type === 'services_dynamic') {
return (
{column.title}
{data.services.slice(0, 4).map((s) => (
{s.title}
))}
);
}
if (column.type === 'hours') {
return (
{column.title}
Seg - Sex: 08h - 18h
Sábado: 08h - 14h
Emergência 24h: {data.settings.contactPhoneDisplay}
);
}
if (column.type === 'custom' && column.links) {
return (
{column.title}
{column.links.map((link, idx) => (
{link.href.startsWith('/') ? (
{link.label}
) : (
{link.label}
)}
))}
);
}
return null;
}
export const Footer = () => {
const { data } = useData();
return (
{/* Logo & Descrição sempre primeiro */}
{data.settings.logoUrl ? (
) : (
{data.settings.siteName}.
)}
{data.footer.description}
{/* Social Icons Render */}
{data.settings.social?.instagram && (
)}
{data.settings.social?.facebook && (
)}
{data.settings.social?.twitter && (
)}
{data.settings.social?.youtube && (
)}
{data.settings.social?.linkedin && (
)}
{/* Renderiza Colunas Dinâmicas */}
{data.footer.columns.map((col) => (
))}
© 2024 {data.settings.siteName}. Todos os direitos reservados.
{data.footer.bottomLinks.map((link, idx) => (
{link.label}
))}
Área Administrativa
);
};