2022-05-10 20:33:11 +02:00
|
|
|
import { Group, Switch } from '@mantine/core';
|
|
|
|
|
import * as Modules from '../modules';
|
|
|
|
|
import { useConfig } from '../../tools/state';
|
|
|
|
|
|
|
|
|
|
export default function ModuleEnabler(props: any) {
|
|
|
|
|
const { config, setConfig } = useConfig();
|
2022-05-10 20:56:48 +02:00
|
|
|
const modules = Object.values(Modules).map((module) => module);
|
2022-05-10 20:33:11 +02:00
|
|
|
return (
|
|
|
|
|
<Group direction="column">
|
2022-05-10 20:56:48 +02:00
|
|
|
{modules.map((module) => (
|
2022-05-10 20:33:11 +02:00
|
|
|
<Switch
|
2022-05-10 20:56:48 +02:00
|
|
|
key={module.title}
|
2022-05-10 20:33:11 +02:00
|
|
|
size="md"
|
2022-05-22 20:42:10 +02:00
|
|
|
checked={config.modules?.[module.title]?.enabled ?? false}
|
2022-05-10 20:56:48 +02:00
|
|
|
label={`Enable ${module.title} module`}
|
2022-05-10 20:33:11 +02:00
|
|
|
onChange={(e) => {
|
2022-05-22 20:42:10 +02:00
|
|
|
setConfig({
|
|
|
|
|
...config,
|
|
|
|
|
modules: {
|
|
|
|
|
...config.modules,
|
|
|
|
|
[module.title]: {
|
|
|
|
|
...config.modules?.[module.title],
|
|
|
|
|
enabled: e.currentTarget.checked,
|
2022-05-10 20:33:11 +02:00
|
|
|
},
|
2022-05-22 20:42:10 +02:00
|
|
|
},
|
|
|
|
|
});
|
2022-05-10 20:33:11 +02:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</Group>
|
|
|
|
|
);
|
|
|
|
|
}
|