interstellar_ai/app/components/settings/PrivacySettings.tsx

50 lines
1.6 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) {
2024-10-03 16:11:53 +02:00
handleRadioChange(openSourceMode ? 'Offline (FOSS)' : 'None');
}
}, [selectedOption, handleRadioChange, openSourceMode]);
2024-10-03 16:11:53 +02:00
// Define your options
const options = [
{ value: 'Online', label: 'Online' },
{ value: 'Offline', label: 'Offline' },
{ value: 'None', label: 'None' },
{ value: 'Offline (FOSS)', label: 'Offline (FOSS)' },
{ value: 'Online (FOSS)', label: 'Online (FOSS)' },
{ value: 'None (FOSS)', label: 'None (FOSS)' },
];
2024-10-01 12:45:21 +02:00
return (
2024-10-03 16:11:53 +02:00
<div className="settings-option">
<p>Select Privacy Mode:</p>
{options.map((option) => (
<div key={option.value}>
<label>
<input
type="radio"
value={option.value}
checked={selectedOption === option.value}
onChange={() => handleRadioChange(option.value)}
disabled={openSourceMode && !option.label.includes('(FOSS)') && selectedOption !== option.value} // Disable non-FOSS options if FOSS is selected
/>
{option.label}
</label>
2024-10-01 15:34:43 +02:00
</div>
2024-10-03 16:11:53 +02:00
))}
</div>
2024-10-01 12:45:21 +02:00
);
};
export default PrivacySettings;