"use client"; import { useEffect, useState } from 'react'; import { useSearchParams, usePathname } from 'next/navigation'; import Header from "@/components/shared/layout/header/Header"; import Footer from "@/components/shared/layout/footer/Footer"; import { usePolicy } from '@/lib/hooks/usePolicy'; import { sanitizeHTML } from "@/lib/security/sanitize"; // Component that reads type from URL using Next.js hooks (safe in client components) const PolicyContentClient = () => { const searchParams = useSearchParams(); const pathname = usePathname(); const [type, setType] = useState<'privacy' | 'terms' | 'support'>('privacy'); const [mounted, setMounted] = useState(false); useEffect(() => { // Only run on client side if (typeof window === 'undefined') return; setMounted(true); // Get type from URL search params try { const urlType = searchParams?.get('type'); if (urlType && ['privacy', 'terms', 'support'].includes(urlType)) { setType(urlType as 'privacy' | 'terms' | 'support'); } else { setType('privacy'); // Default fallback } } catch (error) { console.error('Error reading URL type:', error); setType('privacy'); // Fallback to default } }, [searchParams, pathname]); // If not mounted yet, show loading state if (!mounted) { return (
Loading policy...
Loading policy...
{error?.message || 'The requested policy could not be found.'}
Return to Support CenterLast Updated: {(() => { try { return new Date(policy.last_updated).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); } catch { return new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); } })()}
)} {policy.version && (Version {policy.version}
)} {policy.effective_date && (Effective Date: {(() => { try { return new Date(policy.effective_date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); } catch { return new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); } })()}
)}{policy.description}
)}No content available.
If you have any questions about this policy, please don't hesitate to contact us.
Contact Us