import { useState, useEffect } from 'react'; import { PrivacySettings as IPrivacySettings } from '../lib/privacy/anonymity'; interface PrivacySettingsProps { value: IPrivacySettings; onChange: (settings: IPrivacySettings) => void; showTorStatus?: boolean; } export default function PrivacySettings({ value, onChange, showTorStatus = true, }: PrivacySettingsProps) { const [torStatus, setTorStatus] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { if (showTorStatus) { checkTorStatus(); } }, [showTorStatus]); const checkTorStatus = async () => { try { const response = await fetch('/api/privacy/tor-status'); const data = await response.json(); if (data.success) { setTorStatus(data); } } catch (error) { console.error('Error checking Tor status:', error); } finally { setLoading(false); } }; const handleChange = (field: keyof IPrivacySettings, newValue: any) => { onChange({ ...value, [field]: newValue, }); }; return (

🔒 Privacy & Anonymity Settings

{!loading && torStatus?.tor.connectionThroughTor && ( 🧅 Tor Active )}
{/* Tor Status Banner */} {showTorStatus && !loading && (
{torStatus?.tor.connectionThroughTor ? '🧅' : '⚠️'}

{torStatus?.tor.connectionThroughTor ? 'Tor Connection Active' : 'Not Using Tor'}

{torStatus?.tor.connectionThroughTor ? 'Your connection is anonymous and routed through the Tor network.' : 'For maximum privacy, consider accessing via Tor Browser.'}

{torStatus?.tor.onionAddress && (

Onion Address: {torStatus.tor.onionAddress}

)}
)} {/* Anonymous Mode Toggle */}

Generate random identifiers and hide personal information

{/* Location Privacy */}
{value.locationPrivacy === 'exact' && ( ⚠️ Warning: Exact location may reveal your home address )} {value.locationPrivacy === 'fuzzy' && ( ✓ Good balance of privacy and discoverability )} {value.locationPrivacy === 'city' && ( ✓ Only city-level information shared )} {value.locationPrivacy === 'country' && ( ✓ Only country/region visible )} {value.locationPrivacy === 'hidden' && ( 🔒 Maximum privacy: Location completely hidden )}
{/* Identity Privacy */}
{/* Share Plant Details */}

Uncheck to use generic plant identifiers

{/* Privacy Summary */}

Privacy Summary

  • • Location: {value.locationPrivacy === 'exact' ? 'Visible to all' : 'Protected'}
  • • Identity: {value.identityPrivacy === 'real' ? 'Real name' : 'Protected'}
  • • Plant Info: {value.sharePlantDetails ? 'Shared' : 'Generic'}
  • • Mode: {value.anonymousMode ? 'Anonymous 🔒' : 'Standard'}
{/* Recommendations */} {!loading && torStatus && torStatus.recommendations && (

💡 Recommendations

    {torStatus.recommendations.map((rec: string, idx: number) => (
  • • {rec}
  • ))}
)}
); }