Skip to content

Commit

Permalink
Merge pull request #24 from xeptagondev/undp-compass-192
Browse files Browse the repository at this point in the history
update dightal-right variables
  • Loading branch information
janithr1 authored Apr 11, 2024
2 parents dd4e68c + 9eb63fd commit 40e3ecb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions ui/components/digital-right-indicator-list.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DigitalRightsPillar} from "database/ancillary";
import { Score } from "database/processed/db";
import { roundNumber } from "lib";
import { ReactChild, ReactFragment, ReactPortal } from "react";
import { FaLink, FaSourcetree } from "react-icons/fa";
import useSWR from "swr";

Expand Down Expand Up @@ -150,18 +151,18 @@ const Indicator = ({
showSources,
isShowingRawScores,
}: {
indicator: Score & { sources: Score[] };
indicator: any & { sources: any[] };
showSources: boolean;
isShowingRawScores: boolean;
}) => {
const hasNoData = indicator.data_col === null;
// we want to get the source name from the list of sources,
// but if empty, we need to fall back to the indicator's "Data Source"
const sources = (indicator.sources || [indicator]).map(indicator => ({
link: indicator["Data Link"],
source: indicator["Data Source"],
year: indicator["Year"]
})).filter(indicator => indicator.source && indicator.link)
const sources = (indicator.sources || [indicator]).map((ind: { [x: string]: any; }) => ({
link: ind["Source URL"],
source: ind["Source Name"],
year: ind["Year"]
})).filter((ind: { source: any; link: any; }) => ind.source && ind.link);
const value = +indicator.new_rank_score;
const disp_val = value == 0 ? 0 : roundNumber(value, 2);
return (
Expand Down Expand Up @@ -196,7 +197,7 @@ const Indicator = ({
)}
{showSources && sources.length > 0 && (
<ul className="mt-1 mb-2 divide-y-1">
{sources.map((source, i: number) => {
{sources.map((source: { link: string | undefined; source: boolean | ReactChild | ReactFragment | ReactPortal | null | undefined; year: boolean | ReactChild | ReactFragment | ReactPortal | null | undefined; }, i: number) => {
return (
<li className="text-slate-600 underline text-xs mb-3" key={i}>
<a
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/api/digital-right-indicators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default (req: NextApiRequest, res: NextApiResponse) => {
score["Country Name"] === country &&
score["Pillar"] === pillar &&
score["Indicator"] === index["Indicator"] &&
score["Data Source"]
score["Source Name"]
);
}),
};
Expand Down

0 comments on commit 40e3ecb

Please sign in to comment.