Skip to content

Commit 14786d3

Browse files
Add signals to all the pages
1 parent 82f8325 commit 14786d3

12 files changed

+124
-38
lines changed

src/Apps/AccessAllDataApp.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tabs } from 'antd';
22
import { useEffect, useState } from 'react';
3-
import DataExplorer from '../Components/DataExplorer';
4-
import { DataSetList } from '../Components/DataSetList';
3+
import DataExplorer from '../DataExplorer';
4+
import { DataSetList } from '../DataSetList';
55
import { AggregatedRegionVisualization } from '../RegionVisualization';
66
import { CheckIfLoginOrNot } from '../Utils/CheckIfLoginOrNot';
77
import { LoginBanner } from '../Components/LoginBanner';

src/Apps/CountryApp/TabSection.tsx

+38-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ import { SubNationalVisualization } from '../../CountryPage/SubNationalVisualiza
1010
import { CountryHomePageForCountryPage } from '../../CountryPage';
1111
import { SubNationalMetaDataType } from '../../Types';
1212
import { WDLVisualization } from '../../WDLVisualization';
13+
import { SignalsPage } from '../../SignalsPage';
1314

1415
interface Props {
1516
countryId: string;
1617
loginState: boolean;
18+
countryName: string;
1719
}
1820

1921
export function TabSection(props: Props) {
20-
const { countryId, loginState } = props;
22+
const { countryId, loginState, countryName } = props;
2123
const [subNationalDataAvailability, setSubNationalDataAvailability] =
2224
useState<SubNationalMetaDataType[] | undefined | 'error'>(undefined);
2325
useEffect(() => {
@@ -57,6 +59,18 @@ export function TabSection(props: Props) {
5759
/>
5860
),
5961
},
62+
{
63+
key: 'signals',
64+
label: 'UNDP Signals 🔒',
65+
children: (
66+
<SignalsPage
67+
id={countryName}
68+
loginState={loginState}
69+
link={`/countries-and-territories/${countryId || 'AFG'}`}
70+
type='country'
71+
/>
72+
),
73+
},
6074
{
6175
key: 'sdgTracker',
6276
label: 'SDG Tracker',
@@ -89,6 +103,17 @@ export function TabSection(props: Props) {
89103
/>
90104
),
91105
},
106+
{
107+
key: 'demographicData',
108+
label: 'Demographic Data 🔒',
109+
children: (
110+
<WDLVisualization
111+
loginState={loginState}
112+
link={`/countries-and-territories/${countryId || 'AFG'}`}
113+
countryCode={countryId || 'AFG'}
114+
/>
115+
),
116+
},
92117
{
93118
key: 'subNationalVisualization',
94119
label: 'Sub National Data',
@@ -99,6 +124,18 @@ export function TabSection(props: Props) {
99124
/>
100125
),
101126
},
127+
{
128+
key: 'signals',
129+
label: 'UNDP Signals 🔒',
130+
children: (
131+
<SignalsPage
132+
id={countryName}
133+
loginState={loginState}
134+
link={`/countries-and-territories/${countryId || 'AFG'}`}
135+
type='country'
136+
/>
137+
),
138+
},
102139
{
103140
key: 'sdgTracker',
104141
label: 'SDG Tracker',

src/Apps/CountryApp/index.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ export function CountryApp(props: CountryProps) {
103103
<TabSection
104104
countryId={countryId || 'AFG'}
105105
loginState={loginState}
106+
countryName={
107+
countryData[
108+
countryData.findIndex(d => d['Alpha-3 code'] === countryId)
109+
]['Country or Area']
110+
}
106111
/>
107112
</>
108113
)}

src/Apps/RegionApp.tsx

+27-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { Tabs } from 'antd';
22
import { useState, useEffect } from 'react';
3-
import { DataSetList } from '../Components/DataSetList';
4-
import DataExplorer from '../Components/DataExplorer';
3+
import { DataSetList } from '../DataSetList';
4+
import DataExplorer from '../DataExplorer';
55
import { COUNTRIES_BY_UNDP_REGIONS } from '../Constants';
66
import { AboutPage } from '../AboutPage';
77
import { AggregatedRegionVisualization } from '../RegionVisualization';
88
import { INTRO_TEXT } from '../IntroductionText';
99
import { CheckIfLoginOrNot } from '../Utils/CheckIfLoginOrNot';
1010
import { LoginBanner } from '../Components/LoginBanner';
11+
import { SignalsPage } from '../SignalsPage';
1112

1213
interface Props {
1314
region?: string;
@@ -48,6 +49,30 @@ export function RegionApp(props: Props) {
4849
/>
4950
),
5051
},
52+
{
53+
key: 'signals',
54+
label: 'UNDP Signals 🔒',
55+
children: (
56+
<SignalsPage
57+
id={
58+
COUNTRIES_BY_UNDP_REGIONS[
59+
COUNTRIES_BY_UNDP_REGIONS.findIndex(
60+
el => el.region === `UNDP_${region}`,
61+
)
62+
].bureauName
63+
}
64+
loginState={d}
65+
link={
66+
COUNTRIES_BY_UNDP_REGIONS[
67+
COUNTRIES_BY_UNDP_REGIONS.findIndex(
68+
el => el.region === `UNDP_${region}`,
69+
)
70+
].link
71+
}
72+
type='region'
73+
/>
74+
),
75+
},
5176
{
5277
key: 'datasets',
5378
label: 'Datasets',

src/Apps/SignatureSolutionApp.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tabs } from 'antd';
22
import { useState, useEffect } from 'react';
3-
import DataExplorer from '../Components/DataExplorer';
4-
import { DataSetList } from '../Components/DataSetList';
3+
import DataExplorer from '../DataExplorer';
4+
import { DataSetList } from '../DataSetList';
55
import { AboutPage } from '../AboutPage';
66
import { INTRO_TEXT } from '../IntroductionText';
77
import { PovertyAndInequalityKeyInsights } from '../KeyInsights/PovertyAndInequalityKeyInsights';
@@ -52,7 +52,7 @@ export function SignatureSolutionApp(props: Props) {
5252
children: (
5353
<SignalsPage
5454
id={signatureSolution || 'Poverty and Inequality'}
55-
loginState
55+
loginState={d}
5656
link={
5757
INTRO_TEXT[
5858
INTRO_TEXT.findIndex(el => el.id === signatureSolution)

src/Constants.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ export const COUNTRIES_BY_UNDP_REGIONS = [
9898
{
9999
region: 'UNDP_AP',
100100
name: 'Asia and the Pacific',
101+
link: '/regions/asi-and-the-pacific',
102+
bureauName: 'RBAP',
101103
Countries: [
102104
'AFG',
103105
'BGD',
@@ -139,6 +141,8 @@ export const COUNTRIES_BY_UNDP_REGIONS = [
139141
{
140142
region: 'UNDP_AS',
141143
name: 'Arab States',
144+
link: '/regions/arab-states',
145+
bureauName: 'RBAS',
142146
Countries: [
143147
'ARE',
144148
'BHR',
@@ -165,6 +169,8 @@ export const COUNTRIES_BY_UNDP_REGIONS = [
165169
{
166170
region: 'UNDP_ECA',
167171
name: 'Europe and Central Asia',
172+
link: '/regions/europe-and-central-asia',
173+
bureauName: 'RBEC',
168174
Countries: [
169175
'ALB',
170176
'ARM',
@@ -189,6 +195,8 @@ export const COUNTRIES_BY_UNDP_REGIONS = [
189195
{
190196
region: 'UNDP_LAC',
191197
name: 'Latin America and the Caribbean',
198+
link: '/regions/latin-america-and-the-caribbean',
199+
bureauName: 'RBLAC',
192200
Countries: [
193201
'ARG',
194202
'ATG',
@@ -228,6 +236,8 @@ export const COUNTRIES_BY_UNDP_REGIONS = [
228236
{
229237
region: 'UNDP_SSA',
230238
name: 'Africa',
239+
bureauName: 'RBA',
240+
link: '/regions/africa',
231241
Countries: [
232242
'AGO',
233243
'BDI',

src/CountryPage/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
METADATALINK,
2121
SIGNATURE_SOLUTIONS_LIST,
2222
} from '../Constants';
23-
import CountryVisualization from '../Components/CountryVisualization';
23+
import CountryVisualization from '../DataExplorer/CountryVisualization';
2424

2525
interface PropsWithoutSS {
2626
countryId?: string;
File renamed without changes.

src/Components/DataSetList/DownloadModal.tsx src/DataSetList/DownloadModal.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import {
1212
CountryTaxonomyDataType,
1313
IndicatorMetaDataType,
1414
IndicatorSimplifiedDataType,
15-
} from '../../Types';
15+
} from '../Types';
1616
import {
1717
COUNTRIES_BY_UNDP_REGIONS,
1818
SDG_GOALS,
1919
TAGS_LIST,
2020
DATALINK,
21-
} from '../../Constants';
22-
import { GetYearsArrayFromIndicator } from '../../Utils/GetYearsArray';
21+
} from '../Constants';
22+
import { GetYearsArrayFromIndicator } from '../Utils/GetYearsArray';
2323

2424
interface Props {
2525
indicatorsListMain: IndicatorMetaDataType[];

src/Components/DataSetList/index.tsx src/DataSetList/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import {
1414
CountryTaxonomyDataType,
1515
IndicatorMetaDataType,
1616
IndicatorSimplifiedDataType,
17-
} from '../../Types';
17+
} from '../Types';
1818
import {
1919
COUNTRYTAXONOMYLINK,
2020
METADATALINK,
2121
SDG_GOALS,
2222
SIGNATURE_SOLUTIONS_LIST,
2323
TAGS_LIST,
2424
DATALINK,
25-
} from '../../Constants';
25+
} from '../Constants';
2626
import { DownloadModal } from './DownloadModal';
2727

2828
interface Props {

src/SignalsPage/index.tsx

+33-24
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ export function SignalsPage(props: Props) {
2828
);
2929

3030
const GetURL = (queryParameter: string) => {
31-
const ss1QueryParameter = `&${queryParameter}=${id.replaceAll(' ', '%20')}`;
32-
const urlForListing = `${SIGNAL_API_LINK}signals/list?page=${paginationValue}&per_page=${pageSize}${ss1QueryParameter}&statuses=Approved`;
31+
const linkQueryParameter = `&${queryParameter}=${id.replaceAll(
32+
' ',
33+
'%20',
34+
)}`;
35+
console.log(linkQueryParameter);
36+
const urlForListing = `${SIGNAL_API_LINK}signals/list?page=${paginationValue}&per_page=${pageSize}${linkQueryParameter}&statuses=Approved`;
3337
return urlForListing;
3438
};
3539

@@ -61,11 +65,20 @@ export function SignalsPage(props: Props) {
6165
useEffect(() => {
6266
setSignalList(undefined);
6367
axios
64-
.get(GetURL('signature_primary'), {
65-
headers: {
66-
access_token: SIGNAL_ACCESS_CODE,
68+
.get(
69+
GetURL(
70+
type === 'signatureSolution'
71+
? 'signature_primary'
72+
: type === 'region'
73+
? 'bureau'
74+
: 'location',
75+
),
76+
{
77+
headers: {
78+
access_token: SIGNAL_ACCESS_CODE,
79+
},
6780
},
68-
})
81+
)
6982
.then((response: AxiosResponse) => {
7083
setSignalList(
7184
sortBy(response.data.data, d => Date.parse(d.created_at)).reverse(),
@@ -90,11 +103,20 @@ export function SignalsPage(props: Props) {
90103
setError(undefined);
91104
setSignalList(undefined);
92105
axios
93-
.get(GetURL('signature_primary'), {
94-
headers: {
95-
access_token: SIGNAL_ACCESS_CODE,
106+
.get(
107+
GetURL(
108+
type === 'signatureSolution'
109+
? 'signature_primary'
110+
: type === 'region'
111+
? 'bureau'
112+
: 'location',
113+
),
114+
{
115+
headers: {
116+
access_token: SIGNAL_ACCESS_CODE,
117+
},
96118
},
97-
})
119+
)
98120
.then((response: AxiosResponse) => {
99121
setSignalList(
100122
sortBy(response.data.data, d => Date.parse(d.created_at)).reverse(),
@@ -176,20 +198,7 @@ export function SignalsPage(props: Props) {
176198
<div className='flex-div flex-wrap listing'>
177199
{signalList.length > 0 ? (
178200
<CardList data={signalList} choices={choices} />
179-
) : (
180-
<h5
181-
className='undp-typography bold'
182-
style={{
183-
backgroundColor: 'var(--gray-200)',
184-
textAlign: 'center',
185-
padding: 'var(--spacing-07)',
186-
width: 'calc(100% - 4rem)',
187-
border: '1px solid var(--gray-400)',
188-
}}
189-
>
190-
No signals available matching your criteria
191-
</h5>
192-
)}
201+
) : null}
193202
</div>
194203
{signalList.length > 0 ? (
195204
<div className='flex-div flex-hor-align-center margin-top-07'>

0 commit comments

Comments
 (0)