fix defaultValue on widget options

This commit is contained in:
ajnart
2023-01-13 18:46:59 +09:00
parent 90ee7f2cc7
commit 454d5e53c3

View File

@@ -58,14 +58,6 @@ export const WidgetsEditModal = ({
}); });
}; };
const getMutliselectData = (option: string) => {
const currentWidgetDefinition = Widgets[innerProps.widgetId as keyof typeof Widgets];
if (!Widgets) return [];
const options = currentWidgetDefinition.options as any;
return options[option]?.data ?? [];
};
const handleSave = () => { const handleSave = () => {
updateConfig( updateConfig(
configName, configName,
@@ -85,9 +77,9 @@ export const WidgetsEditModal = ({
return ( return (
<Stack> <Stack>
{items.map(([key, defaultValue], index) => { {items.map(([key, _], index) => {
const option = (currentWidgetDefinition as any).options[key] as IWidgetOptionValue; const option = (currentWidgetDefinition as any).options[key] as IWidgetOptionValue;
const value = moduleProperties[key] ?? defaultValue; const value = moduleProperties[key] ?? option.defaultValue;
if (!option) { if (!option) {
return ( return (
@@ -183,10 +175,10 @@ function WidgetOptionTypeSwitch(
case 'slider': case 'slider':
return ( return (
<Stack spacing="xs"> <Stack spacing="xs">
<Text>{t(`descriptor.settings.${key}.label`)}</Text>
<Slider <Slider
color={primaryColor} color={primaryColor}
key={`${option.type}-${index}`} key={`${option.type}-${index}`}
label={value}
value={value as number} value={value as number}
min={option.min} min={option.min}
max={option.max} max={option.max}