2024-10-01 12:45:21 +02:00
|
|
|
// OpenSourceModeToggle.tsx
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
interface OpenSourceModeToggleProps {
|
|
|
|
openSourceMode: boolean; // Current state of open source mode
|
|
|
|
setOpenSourceMode: (value: boolean) => void; // Function to update open source mode
|
|
|
|
setSelectedOption: (value: string) => void; // Function to update the selected option
|
|
|
|
}
|
|
|
|
|
|
|
|
const OpenSourceModeToggle: React.FC<OpenSourceModeToggleProps> = ({
|
|
|
|
openSourceMode,
|
|
|
|
setOpenSourceMode,
|
|
|
|
setSelectedOption
|
|
|
|
}) => {
|
2024-10-11 09:31:07 +02:00
|
|
|
// Handle toggle change event
|
2024-10-01 12:45:21 +02:00
|
|
|
const handleToggleChange = () => {
|
2024-10-11 09:31:07 +02:00
|
|
|
const newValue = !openSourceMode; // Toggle the current state
|
|
|
|
setOpenSourceMode(newValue); // Update the open source mode state
|
2024-10-01 12:45:21 +02:00
|
|
|
|
|
|
|
// Update radio selection based on the new openSourceMode value
|
|
|
|
if (newValue) {
|
|
|
|
setSelectedOption('FOSS'); // Set to FOSS if enabling open source mode
|
|
|
|
} else {
|
2024-10-11 09:31:07 +02:00
|
|
|
setSelectedOption('None'); // Set to a default value when disabling
|
2024-10-01 12:45:21 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2024-10-11 09:31:07 +02:00
|
|
|
<div className="settings-option"> {/* Container for the toggle setting */}
|
2024-10-01 12:45:21 +02:00
|
|
|
<label>
|
|
|
|
<input
|
2024-10-11 09:31:07 +02:00
|
|
|
type="checkbox" // Checkbox for toggling open source mode
|
|
|
|
checked={openSourceMode} // Check if the mode is currently enabled
|
|
|
|
onChange={handleToggleChange} // Handle changes to the checkbox
|
2024-10-01 12:45:21 +02:00
|
|
|
/>
|
|
|
|
Enable Open Source Mode
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default OpenSourceModeToggle;
|