Skip to content

Commit

Permalink
Fix grouped layers causing crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo-Duke committed May 3, 2024
1 parent 7d78ddb commit 6cd31a2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/map-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function MapFilters() {

if (
settings === null ||
settings.layersTree.length === 0 ||
settings?.layersTree?.length === 0 ||
layers === null
) {
return (
Expand All @@ -43,8 +43,8 @@ export default function MapFilters() {
}

const [grouped, [notGrouped]] = partition(
settings.layersTree,
layer => layer.label !== null,
settings?.layersTree,
layer => layer?.label !== null,
);

const activatedLayers = layers
Expand All @@ -53,13 +53,13 @@ export default function MapFilters() {

return (
<>
{grouped.length !== 0 && (
{grouped?.length !== 0 && (
<Accordion
type="multiple"
className="w-full bg-background"
defaultValue={grouped.map((_, index) => `item-${index}`)}
defaultValue={grouped?.map((_, index) => `item-${index}`)}
>
{grouped.map((group, index) => (
{grouped?.map((group, index) => (
<AccordionItem key={index} value={`item-${index}`} className="px-4">
<AccordionTrigger>{group.label}</AccordionTrigger>
<AccordionContent>
Expand Down Expand Up @@ -94,9 +94,9 @@ export default function MapFilters() {
))}
</Accordion>
)}
{notGrouped.layers.length !== 0 && (
{notGrouped?.layers.length !== 0 && (
<ul className="bg-background px-4">
{notGrouped.layers.map(layer => (
{notGrouped?.layers.map(layer => (
<li
key={layer.id}
className="flex flex-1 items-center justify-between border-b py-4 font-medium hover:underline"
Expand Down

0 comments on commit 6cd31a2

Please sign in to comment.