Skip to content

Commit

Permalink
add integration graph
Browse files Browse the repository at this point in the history
  • Loading branch information
jerem1508 committed Feb 26, 2024
1 parent 5674937 commit 81a8fef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion client/src/pages/european-projects/charts-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"title": "Objectifs financés par Horizon 2020",
"description": "Ad duis occaecat voluptate deserunt tempor enim nulla officia.",
"source": "Commission européenne, Cordis",
"sourceURL": "https://cordis.europa.eu/"
"sourceURL": "https://cordis.europa.eu/",
"integrationURL": "./../european-projects/components/pages/analysis/overview/charts/horizon-2020-participation"
}
]
19 changes: 13 additions & 6 deletions client/src/pages/integration/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import React, { Suspense } from "react";
import { useSearchParams } from "react-router-dom";

import Template from "./template";

import { getConfig } from "../european-projects/utils";

export default function Integration() {
const [searchParams] = useSearchParams();
// const params = [...searchParams].map(([key, value]) => `${key}=${value}`).join('&');
const iso2 = searchParams.get('country_code') || 'FR';
const chartId = searchParams.get('chart_id') || null;
const theme = searchParams.get('theme') || 'light';

document.documentElement.setAttribute('data-fr-theme', theme);

if (!chartId) return <Template />;

const config = getConfig(chartId);
if (!config) {
throw new Error(`No config found for chart id ${chartId}`);
}

const LazyComponent = React.lazy(() => import(config.integrationURL));
return (
<>
graph {iso2}
</>
<Suspense fallback={<div>Loading...</div>}>
<LazyComponent />
</Suspense>
);
}

0 comments on commit 81a8fef

Please sign in to comment.