Skip to content

Commit

Permalink
feat: change expenditures & budgets settings
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Jul 22, 2024
1 parent 3ac9a45 commit 71d5a10
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/app/components/charts/heatmap/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface HeatmapProps {
columnHeader?: string;
rowHeader?: string;
noLegend?: boolean;
expandAll?: boolean;
}

export function getPercentageColor(item?: HeatmapDataItem) {
Expand Down
21 changes: 18 additions & 3 deletions src/app/components/charts/heatmap/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import get from "lodash/get";
import filter from "lodash/filter";
import uniqBy from "lodash/uniqBy";
import Box from "@mui/material/Box";
import orderBy from "lodash/orderBy";
Expand All @@ -13,6 +14,7 @@ import {
LEGENDS,
ItemModel,
HeatmapProps,
HeatmapDataItem,
} from "app/components/charts/heatmap/data";
import {
Row,
Expand Down Expand Up @@ -50,9 +52,22 @@ export function Heatmap(props: HeatmapProps) {
};

React.useEffect(() => {
setExpandedRows([]);
setExpandedColumns([]);
}, [props.data, props.rowCategory, props.columnCategory]);
if (props.expandAll) {
setExpandedRows(
filter(props.data, (item: HeatmapDataItem) => !item.parentRow).map(
(item: HeatmapDataItem) => item.row
)
);
setExpandedColumns(
filter(props.data, (item: HeatmapDataItem) => !item.parentColumn).map(
(item: HeatmapDataItem) => item.column
)
);
} else {
setExpandedRows([]);
setExpandedColumns([]);
}
}, [props.data, props.rowCategory, props.columnCategory, props.expandAll]);

React.useEffect(() => {
setVisibleRows(
Expand Down
41 changes: 27 additions & 14 deletions src/app/pages/datasets/grant-implementation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -970,19 +970,16 @@ export const GrantImplementationPage: React.FC = () => {
}, [cycles, budgetCycleDropdownSelected]);

const budgetsTableDataTypeDropdown = React.useMemo(() => {
if (budgetsDropdownSelected === dropdownItemsBudgets[2].value) {
return (
<Box gap="10px" display="flex" flexDirection="row">
{budgetsCycleDropdown}
<Dropdown
dropdownSelected={budgetTableDataType}
dropdownItems={dropdownItemsBudgetsTableDataTypes}
handleDropdownChange={handleBudgetTableDataTypeChange}
/>
</Box>
);
}
return budgetsCycleDropdown;
return (
<Box gap="10px" display="flex" flexDirection="row">
{budgetsCycleDropdown}
<Dropdown
dropdownSelected={budgetTableDataType}
dropdownItems={dropdownItemsBudgetsTableDataTypes}
handleDropdownChange={handleBudgetTableDataTypeChange}
/>
</Box>
);
}, [budgetsDropdownSelected, budgetTableDataType, budgetsCycleDropdown]);

const financialMetricsCycleDropdown = React.useMemo(() => {
Expand Down Expand Up @@ -1911,6 +1908,15 @@ export const GrantImplementationPage: React.FC = () => {
}
}, [cycles]);

React.useEffect(() => {
if (
budgetTableDataType === dropdownItemsBudgetsTableDataTypes[1].value &&
budgetsDropdownSelected !== dropdownItemsBudgets[2].value
) {
setBudgetsDropdownSelected(dropdownItemsBudgets[2].value);
}
}, [budgetTableDataType]);

useUnmount(() => {
fetchLocationFilterOptions({
routeParams: {
Expand Down Expand Up @@ -2055,7 +2061,14 @@ export const GrantImplementationPage: React.FC = () => {
subtitle={`${totalBudget} total budget.`}
dropdownItems={dropdownItemsBudgets}
dropdownSelected={budgetsDropdownSelected}
handleDropdownChange={(value) => setBudgetsDropdownSelected(value)}
handleDropdownChange={(value) => {
if (value !== dropdownItemsBudgets[2].value) {
setBudgetTableDataType(
dropdownItemsBudgetsTableDataTypes[0].value
);
}
setBudgetsDropdownSelected(value);
}}
loading={loadingBudget}
disableCollapse={
budgetsDropdownSelected === dropdownItemsBudgets[2].value
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ export const Home: React.FC = () => {
fetchExpendituresHeatmap({
filterString,
routeParams: {
row: "principalRecipientType,principalRecipientSubType,principalRecipient",
row: "principalRecipientType,principalRecipientSubType",
column: "component",
componentField:
componentField === CHART_5_DROPDOWN_ITEMS[0].value
Expand Down Expand Up @@ -774,6 +774,7 @@ export const Home: React.FC = () => {
infoType="expenditures"
>
<Heatmap
expandAll
data={dataExpendituresHeatmap}
hoveredLegend={null}
valueType={chart5Unit}
Expand Down

0 comments on commit 71d5a10

Please sign in to comment.