Skip to content

Commit

Permalink
TS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
iandebruin98 committed Oct 16, 2024
1 parent b8b8676 commit 845e567
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const formSchema = z.object({
name: z.string(),
activeOnInit: z.boolean().optional(),
})).optional(),
});
}).catchall(z.boolean().optional());

export default function WidgetResourcesMapDatalayers(
props: ResourceOverviewMapWidgetTabProps &
Expand All @@ -44,7 +44,6 @@ export default function WidgetResourcesMapDatalayers(
defaultValues: {
datalayer: props?.datalayer || '',
enableOnOffSwitching: props?.enableOnOffSwitching || false,
activeOnInit: props?.activeOnInit !== undefined ? props.activeOnInit : true,
},
});
const router = useRouter();
Expand Down Expand Up @@ -114,14 +113,14 @@ export default function WidgetResourcesMapDatalayers(
{(
form.getValues('enableOnOffSwitching') &&
Array.isArray(form.getValues('datalayer')) &&
form.getValues('datalayer').some(obj => obj.id === Number(item.id))
form.getValues('datalayer')?.some(obj => obj.id === Number(item.id))
) && (
<FormField
control={form.control}
name={`activeOnInit_${item.id}`}
render={({field}) => {
const activeOnInit = form.getValues('datalayer')
.find(obj => obj.id === Number(item.id))?.activeOnInit ?? true;
?.find(obj => obj.id === Number(item.id))?.activeOnInit ?? true;

return (
<FormItem className="flex flex-row items-start space-x-3 space-y-0">
Expand All @@ -131,7 +130,7 @@ export default function WidgetResourcesMapDatalayers(
onCheckedChange={(checked) => {
let values = form.getValues('datalayer') || [];
const updatedValues = values.map(obj =>
obj.id === Number(item.id) ? {...obj, activeOnInit: checked} : obj
obj.id === Number(item.id) ? { ...obj, activeOnInit: !!checked } : obj
);
form.setValue('datalayer', updatedValues);
props.onFieldChanged('datalayer', updatedValues);
Expand Down
2 changes: 1 addition & 1 deletion packages/leaflet-map/src/resource-overview-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const ResourceOverviewMap = ({
projectId: props.projectId,
});

const mapDataLayers: { layer: any; icon?: any, name: string, id: string }[] = [];
const mapDataLayers: { layer: any; icon?: any, name: string, id: string, activeOnInit: boolean }[] = [];
const selectedDataLayers = props?.resourceOverviewMapWidget?.datalayer || [];
const showOnOffButtons = props?.resourceOverviewMapWidget?.enableOnOffSwitching || false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ export type DataLayer = {
layer: any;
icon: any;
name: string;
activeOnInit?: boolean;
};

0 comments on commit 845e567

Please sign in to comment.