import { Card, Menu, Switch, useMantineTheme } from '@mantine/core'; import { useConfig } from '../../tools/state'; import { IModule } from './modules'; export function ModuleWrapper(props: any) { const { module }: { module: IModule } = props; const { config, setConfig } = useConfig(); const enabledModules = config.settings.enabledModules ?? []; // Remove 'Module' from enabled modules titles const isShown = enabledModules.includes(module.title); const theme = useMantineTheme(); const items: JSX.Element[] = []; if (module.options) { const keys = Object.keys(module.options); const values = Object.values(module.options); // Get the value and the name of the option const types = values.map((v) => typeof v.value); // Loop over all the types with a for each loop types.forEach((type, index) => { const optionName = `${module.title}.${keys[index]}`; // TODO: Add support for other types if (type === 'boolean') { items.push( { setConfig({ ...config, settings: { ...config.settings, enabledModules: [...config.settings.enabledModules], [optionName]: e.currentTarget.checked, }, }); }} label={values[index].name} /> ); } }); } // Sussy baka if (!isShown) { return null; } return ( ); }