Skip to content

Commit

Permalink
Merge pull request #318 from collective-service/fix/over-view-issues
Browse files Browse the repository at this point in the history
Add fixes to minor bugs in over-view
  • Loading branch information
shreeyash07 authored Nov 10, 2022
2 parents e99ddd7 + fffe903 commit 3c0dfb4
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/components/PercentageStats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Props {
totalDeaths?: string | null;
newCases?: string | null;
newDeathsPerMillion?: string | null;
statValueLoading?: boolean;
}

function PercentageStats(props: Props) {
Expand All @@ -43,6 +44,7 @@ function PercentageStats(props: Props) {
totalDeaths,
newCases,
newDeathsPerMillion,
statValueLoading,
} = props;

const empty = statValue === '0';
Expand Down Expand Up @@ -95,6 +97,8 @@ function PercentageStats(props: Props) {
<Message
empty={empty}
emptyIcon={<IoFileTraySharp />}
pending={statValueLoading}
pendingContainerClassName={styles.pendingMessage}
/>
) : (
<>
Expand Down
8 changes: 8 additions & 0 deletions app/components/PercentageStats/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,12 @@
justify-content: center;
height: 100%;
}

.pending-message {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
height: 100%;
}
}
1 change: 1 addition & 0 deletions app/views/Dashboard/Country/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ function Country(props: Props) {
'percent',
statusUncertainty?.indicatorValue ?? 0,
)}
statValueLoading={countryResponseLoading}
icon={null}
/>
)}
Expand Down
4 changes: 2 additions & 2 deletions app/views/Dashboard/Overview/MapView/MapModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ function MapModal(props: ModalProps) {
latestDate,
]);

const heading = useMemo(() => {
const totalCasesHeading = useMemo(() => {
if (filterValues?.indicator) {
return (formatNumber(
latestIndicatorValue?.format as FormatType,
Expand Down Expand Up @@ -478,7 +478,7 @@ function MapModal(props: ModalProps) {
size="extraLarge"
className={styles.countryCaseData}
>
{heading}
{totalCasesHeading}
</Heading>
<Heading
className={styles.countrySurveyDate}
Expand Down
6 changes: 5 additions & 1 deletion app/views/Dashboard/Overview/MapView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function Tooltip(props: TooltipProps) {
);
}

interface Props{
interface Props {
className?: string;
setActiveTab: React.Dispatch<React.SetStateAction<TabTypes | undefined>>;
filterValues?: FilterType | undefined;
Expand Down Expand Up @@ -489,6 +489,8 @@ function MapView(props: Props) {
<Message
emptyIcon={<IoFileTraySharp />}
empty
pending={countriesRankingLoading}
pendingContainerClassName={styles.pendingMessage}
/>
)}
</div>
Expand All @@ -514,6 +516,8 @@ function MapView(props: Props) {
<Message
emptyIcon={<IoFileTraySharp />}
empty
pending={countriesRankingLoading}
pendingContainerClassName={styles.pendingMessage}
/>
)}
</div>
Expand Down
10 changes: 9 additions & 1 deletion app/views/Dashboard/Overview/MapView/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
padding-top: none;
}

.pending-message {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
height: 100%;
}

.progress-list-header {
padding-bottom: var(--dui-spacing-medium);
}
Expand All @@ -50,4 +58,4 @@
font-size: var(--dui-font-size-extra-small);
font-weight: var(--dui-font-weight-regular);
}
}
}
26 changes: 21 additions & 5 deletions app/views/Dashboard/Overview/PercentageCardGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const OVERVIEW_STATS = gql`
}
uncertaintyGlobal: globalLevel (
filters: {
emergency: $emergency,
isTwelveMonth: true,
indicatorId: $indicatorId,
category: "Global",
Expand All @@ -161,6 +162,7 @@ const OVERVIEW_STATS = gql`
}
uncertaintyRegion: regionLevel (
filters: {
emergency: $emergency,
indicatorId: $indicatorId,
isTwelveMonth: true,
region: $region,
Expand Down Expand Up @@ -252,13 +254,26 @@ function PercentageCardGroup(props: Props) {
if ((!selectedIndicatorName && !filterValues?.region) && selectedOutbreakName) {
return `New cases per million for ${selectedOutbreakName}`;
}
if (selectedOutbreakName && filterValues?.region) {
return `New cases per million for ${selectedOutbreakName}`;
}
return 'Total percentage';
}, [
filterValues,
selectedIndicatorName,
selectedOutbreakName,
]);

const cardSubHeader = useMemo(() => {
if (selectedIndicatorName) {
return selectedIndicatorName;
}
return filterValues?.indicator;
}, [
filterValues,
selectedIndicatorName,
]);

const overviewStatsVariables = useMemo((): OverviewStatsQueryVariables => ({
emergency: filterValues?.outbreak,
indicatorId: filterValues?.indicator ?? 'new_cases_per_million',
Expand Down Expand Up @@ -430,7 +445,7 @@ function PercentageCardGroup(props: Props) {
<>
{payload?.map((entry) => (
<Element
key={`item-${entry.id}`}
key={`item - ${entry.id} `}
actions={(
<>
<IoSquare color={getLineChartColor(filterValues?.outbreak)} />
Expand Down Expand Up @@ -492,9 +507,10 @@ function PercentageCardGroup(props: Props) {
<PercentageStats
className={styles.globalStatCard}
heading={cardHeader}
subHeading={selectedIndicatorName ?? filterValues?.indicator}
subHeading={cardSubHeader}
headingSize="extraSmall"
statValue={totalCaseValue}
statValueLoading={loading}
/>
{uncertaintyChartActive
? (
Expand All @@ -507,7 +523,7 @@ function PercentageCardGroup(props: Props) {
loading={loading}
emergencyFilterValue={filterValues?.outbreak}
heading="Indicator overview over the last 12 months"
headingDescription={`Trend chart for ${selectedIndicatorName ?? filterValues?.indicator}`}
headingDescription={`Trend chart for ${selectedIndicatorName ?? filterValues?.indicator} `}
/>
) : (
<ContainerCard
Expand Down Expand Up @@ -565,7 +581,7 @@ function PercentageCardGroup(props: Props) {
heading={filterValues?.indicator ? 'Regional Percentage' : 'Regional Breakdown'}
headingSize="extraSmall"
headerDescription={filterValues?.indicator
? `${selectedIndicatorName ?? '-'}`
? `${selectedIndicatorName ?? '-'} `
: `New cases per million for ${selectedOutbreakName}`}
>
<ChartContainer
Expand Down Expand Up @@ -596,7 +612,7 @@ function PercentageCardGroup(props: Props) {
>
{regionalBreakdownRegion?.map((entry) => (
<Cell
key={`Cell -${entry.id}`}
key={`Cell - ${entry.id} `}
fill="#8DD2B1"
opacity={entry.fill}
/>
Expand Down

0 comments on commit 3c0dfb4

Please sign in to comment.