interstellar_ai/app/components/settings/PrivacySettings.tsx

60 lines
1.9 KiB
TypeScript
Raw Normal View History

import React, { useEffect } from 'react';
2024-10-01 12:45:21 +02:00
interface PrivacySettingsProps {
selectedOption: string; // The currently selected option
handleRadioChange: (option: string) => void; // Function to handle option changes
openSourceMode: boolean; // Boolean to check if the mode is open source
}
const PrivacySettings: React.FC<PrivacySettingsProps> = ({ selectedOption, handleRadioChange, openSourceMode }) => {
// Set default option based on openSourceMode if no option is selected
useEffect(() => {
if (!selectedOption) {
handleRadioChange(openSourceMode ? 'Offline' : 'None');
}
}, [selectedOption, handleRadioChange, openSourceMode]);
// Handle option click and allow all options, even in open-source mode
const handleOptionClick = (option: string) => {
handleRadioChange(option); // No restrictions on options
};
2024-10-01 12:45:21 +02:00
return (
<>
{/* AI Mode Radio Options */}
<div className="settings-option">
<p>{openSourceMode ? 'Disable Options (FOSS Mode):' : 'Disable Options:'}</p>
2024-10-01 12:45:21 +02:00
<div className="slider">
{/* Offline */}
<div
className={`slider-option ${selectedOption === 'Offline' ? 'active' : ''}`}
onClick={() => handleOptionClick('Offline')}
2024-10-01 12:45:21 +02:00
>
Offline tools{openSourceMode ? ' (FOSS)' : ''}
</div>
{/* Online (Available even in FOSS mode) */}
2024-10-01 12:45:21 +02:00
<div
className={`slider-option ${selectedOption === 'Online' ? 'active' : ''}`}
onClick={() => handleOptionClick('Online')}
2024-10-01 12:45:21 +02:00
>
Online tools{openSourceMode ? ' (FOSS)' : ''}
</div>
{/* None */}
<div
className={`slider-option ${selectedOption === 'None' ? 'active' : ''}`}
onClick={() => handleOptionClick('None')}
2024-10-01 12:45:21 +02:00
>
None{openSourceMode ? ' (FOSS)' : ''}
</div>
2024-10-01 15:34:43 +02:00
</div>
2024-10-01 12:45:21 +02:00
<br />
</div>
</>
);
};
export default PrivacySettings;