Skip to content

Commit

Permalink
Fix sections not accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
p3rcypj committed May 2, 2024
1 parent 56bf32b commit 215755e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/domain/entities/LandingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,8 @@ export function getPrimaryRedirectUrl(
return redirectUrl;
}

export function flattenLandingNodes(nodes: LandingNode[]): LandingNode[] {
return nodes.flatMap(node => [node, ...flattenLandingNodes(node.children)]);
}

type Url = string;
9 changes: 7 additions & 2 deletions src/webapp/pages/home/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
import CircularProgress from "material-ui/CircularProgress";
import styled from "styled-components";
import { useSnackbar } from "@eyeseetea/d2-ui-components";
import { LandingNode, getPrimaryRedirectUrl as getPrimaryActionUrl } from "../../../domain/entities/LandingNode";
import {
LandingNode,
flattenLandingNodes,
getPrimaryRedirectUrl as getPrimaryActionUrl,
} from "../../../domain/entities/LandingNode";
import { LandingLayout, LandingContent } from "../../components/landing-layout";
import { useAppContext } from "../../contexts/app-context";
import { useNavigate } from "react-router-dom";
Expand Down Expand Up @@ -50,7 +54,8 @@ export const HomePage: React.FC = React.memo(() => {

const openPage = useCallback(
(page: LandingNode) => {
if (userLandings?.some(landing => landing.id === page.id)) {
const nodes = userLandings && flattenLandingNodes(userLandings);
if (nodes?.some(landing => landing.id === page.id)) {
compositionRoot.analytics.sendPageView({ title: page.name.referenceValue, location: undefined });
updateHistory(history => [page, ...history]);
} else {
Expand Down

0 comments on commit 215755e

Please sign in to comment.