import React, { useState, useEffect } from 'react'; import { Shield, ArrowLeft } from 'lucide-react'; import { Link } from 'react-router-dom'; import { pageContentService } from '../services/api'; import type { PageContent } from '../services/api/pageContentService'; import { useCompanySettings } from '../contexts/CompanySettingsContext'; import Loading from '../components/common/Loading'; const PrivacyPolicyPage: React.FC = () => { const { settings } = useCompanySettings(); const [pageContent, setPageContent] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { const fetchPageContent = async () => { try { setLoading(true); const response = await pageContentService.getPrivacyContent(); if (response.status === 'success' && response.data?.page_content) { const content = response.data.page_content; // Process HTML content to ensure text is visible if (content.content) { // Create a temporary div to parse HTML const tempDiv = document.createElement('div'); tempDiv.innerHTML = content.content; // Add color styles to elements that don't have them const allElements = tempDiv.querySelectorAll('*'); allElements.forEach((el) => { const htmlEl = el as HTMLElement; const tagName = htmlEl.tagName.toLowerCase(); const currentColor = htmlEl.style.color; // Only add color if not already set if (!currentColor || currentColor === 'black' || currentColor === '#000' || currentColor === '#000000') { if (['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tagName)) { htmlEl.style.color = '#ffffff'; } else if (['strong', 'b'].includes(tagName)) { htmlEl.style.color = '#d4af37'; } else if (tagName === 'a') { htmlEl.style.color = '#d4af37'; } else { htmlEl.style.color = '#d1d5db'; } } }); // Update content with processed HTML content.content = tempDiv.innerHTML; } setPageContent(content); if (content.meta_title) { document.title = content.meta_title; } if (content.meta_description) { let metaDescription = document.querySelector('meta[name="description"]'); if (!metaDescription) { metaDescription = document.createElement('meta'); metaDescription.setAttribute('name', 'description'); document.head.appendChild(metaDescription); } metaDescription.setAttribute('content', content.meta_description); } } } catch (err: any) { console.error('Error fetching page content:', err); // If page is disabled (404), set pageContent to null to show disabled message if (err.response?.status === 404) { setPageContent(null); } } finally { setLoading(false); } }; fetchPageContent(); }, []); if (loading) { return ; } if (!pageContent) { return (

Privacy Policy

This page is currently unavailable.

Back to Home
); } return (
{/* Back Link */} Back to Home {/* Header */}

{pageContent.title || 'Privacy Policy'}

{pageContent.subtitle && (

{pageContent.subtitle}

)}
{/* Content */}
No content available.

' }} />
{/* Footer Note */} {settings.company_email && (

For questions about this policy, contact us at{' '} {settings.company_email}

)}
); }; export default PrivacyPolicyPage;