Skip to content

Commit

Permalink
Merge pull request #25 from xeptagondev/undp-compass-192
Browse files Browse the repository at this point in the history
Undp compass 192
  • Loading branch information
janithr1 authored Apr 11, 2024
2 parents 40e3ecb + d82d131 commit 714c783
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions ui/components/digital-right-indicator-list.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { DigitalRightsPillar} from "database/ancillary";
import { Score } from "database/processed/db";
import { DigitalRightScore } 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 @@ -103,7 +102,7 @@ const MissingIndicators = ({
showSources,
isShowingRawScores,
}: {
filledIndicators: Score[];
filledIndicators: DigitalRightScore[];
country: string;
pillar: DigitalRightsPillar;
showSources: boolean;
Expand All @@ -120,12 +119,12 @@ const MissingIndicators = ({

const missingIndicators = allIndicators
.filter(
(indicator: Score) =>
(indicator: DigitalRightScore) =>
!filledIndicators.find(
({ Indicator }: Score) => Indicator === indicator["Indicator"]
({ Indicator }: DigitalRightScore) => Indicator === indicator["Indicator"]
)
)
.map((indicator: Score) => ({
.map((indicator: DigitalRightScore) => ({
...indicator,
new_rank_score: null,
data_col: null,
Expand All @@ -151,18 +150,18 @@ const Indicator = ({
showSources,
isShowingRawScores,
}: {
indicator: any & { sources: any[] };
indicator: DigitalRightScore & { sources: DigitalRightScore[] };
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((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 sources = (indicator.sources || [indicator]).map(indicator => ({
link: indicator["Source URL"],
source: indicator["Source Name"],
year: indicator["Year"]
})).filter(indicator => indicator.source && indicator.link)
const value = +indicator.new_rank_score;
const disp_val = value == 0 ? 0 : roundNumber(value, 2);
return (
Expand Down Expand Up @@ -197,7 +196,7 @@ const Indicator = ({
)}
{showSources && sources.length > 0 && (
<ul className="mt-1 mb-2 divide-y-1">
{sources.map((source: { link: string | undefined; source: boolean | ReactChild | ReactFragment | ReactPortal | null | undefined; year: boolean | ReactChild | ReactFragment | ReactPortal | null | undefined; }, i: number) => {
{sources.map((source, i: number) => {
return (
<li className="text-slate-600 underline text-xs mb-3" key={i}>
<a
Expand Down

0 comments on commit 714c783

Please sign in to comment.