diff --git a/src/components/modules/date/DateModule.tsx b/src/components/modules/date/DateModule.tsx index ad5991736..3e212af83 100644 --- a/src/components/modules/date/DateModule.tsx +++ b/src/components/modules/date/DateModule.tsx @@ -23,7 +23,7 @@ export default function DateComponent(props: any) { const [date, setDate] = useState(new Date()); const setSafeInterval = useSetSafeInterval(); const { config } = useConfig(); - const isFullTime = config?.modules?.[DateModule.title]?.options?.full?.value ?? false; + const isFullTime = config?.modules?.[DateModule.title]?.options?.full?.value ?? true; const formatString = isFullTime ? 'HH:mm' : 'h:mm A'; // Change date on minute change // Note: Using 10 000ms instead of 1000ms to chill a little :) diff --git a/src/components/modules/moduleWrapper.tsx b/src/components/modules/moduleWrapper.tsx index a28cde8a8..6bbd69c86 100644 --- a/src/components/modules/moduleWrapper.tsx +++ b/src/components/modules/moduleWrapper.tsx @@ -1,10 +1,18 @@ -import { Button, Card, Group, Menu, Switch, TextInput, useMantineColorScheme } from '@mantine/core'; +import { + Button, + Card, + Group, + Menu, + MultiSelect, + Switch, + TextInput, + useMantineColorScheme, +} from '@mantine/core'; import { useConfig } from '../../tools/state'; import { IModule } from './modules'; function getItems(module: IModule) { const { config, setConfig } = useConfig(); - const enabledModules = config.modules ?? {}; const items: JSX.Element[] = []; if (module.options) { const keys = Object.keys(module.options); @@ -15,6 +23,38 @@ function getItems(module: IModule) { types.forEach((type, index) => { const optionName = `${module.title}.${keys[index]}`; const moduleInConfig = config.modules?.[module.title]; + if (type === 'object') { + items.push( + { + setConfig({ + ...config, + modules: { + ...config.modules, + [module.title]: { + ...moduleInConfig, + options: { + ...moduleInConfig?.options, + [keys[index]]: { + ...moduleInConfig?.options?.[keys[index]], + value, + }, + }, + }, + }, + }); + }} + /> + ); + } if (type === 'string') { items.push(
{}} /> @@ -59,7 +103,9 @@ function getItems(module: IModule) { { diff --git a/src/components/modules/modules.tsx b/src/components/modules/modules.tsx index 7e0617063..e1303ae33 100644 --- a/src/components/modules/modules.tsx +++ b/src/components/modules/modules.tsx @@ -16,5 +16,6 @@ interface Option { export interface OptionValues { name: string; - value: boolean | string; + value: boolean | string | string[]; + options?: string[]; } diff --git a/src/components/modules/weather/WeatherModule.tsx b/src/components/modules/weather/WeatherModule.tsx index 1d2a522a0..8a6f6c98f 100644 --- a/src/components/modules/weather/WeatherModule.tsx +++ b/src/components/modules/weather/WeatherModule.tsx @@ -29,7 +29,7 @@ export const WeatherModule: IModule = { }, location: { name: 'Current location', - value: '', + value: 'Paris', }, }, }; @@ -135,7 +135,7 @@ export default function WeatherComponent(props: any) { const { config } = useConfig(); const [weather, setWeather] = useState({} as WeatherResponse); const cityInput: string = - (config?.modules?.[WeatherModule.title]?.options?.location?.value as string) ?? ''; + (config?.modules?.[WeatherModule.title]?.options?.location?.value as string) ?? 'Paris'; const isFahrenheit: boolean = (config?.modules?.[WeatherModule.title]?.options?.freedomunit?.value as boolean) ?? false;