mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-09 06:55:51 +01:00
🐛 Fix default values for modules
The default value was not set correctly for modules. This has been fixed. It was also fixed in the Weather Module and the Date Module.
This commit is contained in:
@@ -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 :)
|
||||
|
||||
@@ -28,8 +28,11 @@ function getItems(module: IModule) {
|
||||
<MultiSelect
|
||||
label={module.options?.[keys[index]].name}
|
||||
data={module.options?.[keys[index]].options ?? []}
|
||||
defaultValue={(moduleInConfig?.options?.[keys[index]]?.value as string[]) ?? []}
|
||||
clearable
|
||||
defaultValue={
|
||||
(moduleInConfig?.options?.[keys[index]]?.value as string[]) ??
|
||||
(values[index].value as string[]) ??
|
||||
[]
|
||||
}
|
||||
searchable
|
||||
onChange={(value) => {
|
||||
setConfig({
|
||||
@@ -81,7 +84,11 @@ function getItems(module: IModule) {
|
||||
id={optionName}
|
||||
name={optionName}
|
||||
label={values[index].name}
|
||||
defaultValue={(moduleInConfig?.options?.[keys[index]]?.value as string) ?? ''}
|
||||
defaultValue={
|
||||
(moduleInConfig?.options?.[keys[index]]?.value as string) ??
|
||||
(values[index].value as string) ??
|
||||
''
|
||||
}
|
||||
onChange={(e) => {}}
|
||||
/>
|
||||
|
||||
@@ -96,7 +103,9 @@ function getItems(module: IModule) {
|
||||
<Switch
|
||||
defaultChecked={
|
||||
// Set default checked to the value of the option if it exists
|
||||
(moduleInConfig?.options?.[keys[index]]?.value as boolean) ?? false
|
||||
(moduleInConfig?.options?.[keys[index]]?.value as boolean) ??
|
||||
(values[index].value as boolean) ??
|
||||
false
|
||||
}
|
||||
key={keys[index]}
|
||||
onClick={(e) => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user