2022-05-10 19:03:41 +02:00
|
|
|
import { Card, useMantineTheme } from '@mantine/core';
|
2022-05-10 20:33:11 +02:00
|
|
|
import { useConfig } from '../../tools/state';
|
2022-05-10 18:57:04 +02:00
|
|
|
import { IModule } from './modules';
|
|
|
|
|
|
|
|
|
|
export default function ModuleWrapper(props: any) {
|
|
|
|
|
const { module }: { module: IModule } = props;
|
2022-05-10 20:33:11 +02:00
|
|
|
const { config } = useConfig();
|
|
|
|
|
const enabledModules = config.settings.enabledModules ?? [];
|
|
|
|
|
// Remove 'Module' from enabled modules titles
|
2022-05-10 20:56:48 +02:00
|
|
|
const isShown = enabledModules.includes(module.title);
|
2022-05-10 18:57:04 +02:00
|
|
|
const theme = useMantineTheme();
|
2022-05-10 20:56:48 +02:00
|
|
|
if (!isShown) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-05-10 18:57:04 +02:00
|
|
|
return (
|
|
|
|
|
<Card
|
2022-05-10 20:33:11 +02:00
|
|
|
hidden={!isShown}
|
2022-05-10 18:57:04 +02:00
|
|
|
mx="sm"
|
|
|
|
|
radius="lg"
|
|
|
|
|
shadow="sm"
|
|
|
|
|
style={{
|
|
|
|
|
// Make background color of the card depend on the theme
|
2022-05-10 19:03:41 +02:00
|
|
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : 'white',
|
2022-05-10 18:57:04 +02:00
|
|
|
}}
|
|
|
|
|
>
|
2022-05-10 19:03:41 +02:00
|
|
|
<module.component />
|
2022-05-10 18:57:04 +02:00
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
}
|