import React, { forwardRef } from "react"; import { BaseComponentProps } from "../../types"; export interface PrivacySection { id: string; title: string; content: string | React.ReactNode; subsections?: PrivacySection[]; } export interface PrivacyPolicyProps extends BaseComponentProps { companyName?: string; contactEmail?: string; lastUpdated?: string; sections?: PrivacySection[]; showTableOfContents?: boolean; enablePrint?: boolean; } const defaultSections: PrivacySection[] = [ { id: "information-collection", title: "Information We Collect", content: "We collect information you provide directly to us, such as when you create an account, make a purchase, or contact us for support.", subsections: [ { id: "personal-information", title: "Personal Information", content: "This may include your name, email address, postal address, phone number, and other similar contact data.", }, { id: "usage-data", title: "Usage Data", content: "We automatically collect certain information about your interaction with our services, such as your IP address, browser type, and pages visited.", }, ], }, { id: "information-use", title: "How We Use Your Information", content: "We use the information we collect to provide, maintain, and improve our services, process transactions, and communicate with you.", }, { id: "information-sharing", title: "Information Sharing and Disclosure", content: "We do not sell, trade, or otherwise transfer your personal information to third parties without your consent, except as described in this policy.", }, { id: "data-security", title: "Data Security", content: "We implement appropriate technical and organizational measures to protect your personal information against unauthorized access, alteration, disclosure, or destruction.", }, { id: "your-rights", title: "Your Rights", content: "You have the right to access, update, or delete your personal information. You may also opt-out of certain communications from us.", }, { id: "contact-us", title: "Contact Us", content: "If you have any questions about this Privacy Policy, please contact us at the email address provided below.", }, ]; export const PrivacyPolicy = forwardRef( ( { className = "", companyName = "Your Company", contactEmail = "privacy@yourcompany.com", lastUpdated = new Date().toISOString().split("T")[0], sections = defaultSections, showTableOfContents = true, enablePrint = true, ...props }, ref ) => { const handlePrint = () => { window.print(); }; const renderSection = (section: PrivacySection, level = 1) => { const headingLevel = Math.min(level + 1, 6); return (
{headingLevel === 2 && (

{section.title}

)} {headingLevel === 3 && (

{section.title}

)} {headingLevel === 4 && (

{section.title}

)} {headingLevel === 5 && (
{section.title}
)} {headingLevel === 6 && (
{section.title}
)}
{typeof section.content === "string" ? (

{section.content}

) : ( section.content )}
{section.subsections && section.subsections.length > 0 && (
{section.subsections.map((subsection) => renderSection(subsection, level + 1) )}
)}
); }; const renderTableOfContents = () => { if (!showTableOfContents) return null; const renderTocItem = (section: PrivacySection, level = 0) => (
  • 0 ? "ml-4" : ""}> {section.title} {section.subsections && section.subsections.length > 0 && ( )}
  • ); return (

    Table of Contents

    ); }; return (
    {/* Header */}

    Privacy Policy

    {companyName}

    Last updated: {lastUpdated}

    {enablePrint && (
    )}
    {/* Table of Contents */} {renderTableOfContents()} {/* Content */}
    {sections.map((section) => renderSection(section))}
    {/* Footer */}

    Questions or Concerns?

    If you have any questions about this Privacy Policy, please contact us at{" "} {contactEmail}

    ); } ); PrivacyPolicy.displayName = "PrivacyPolicy";