Skip to content

Commit

Permalink
Merge pull request #76 from globalfund/feat/DE-1389
Browse files Browse the repository at this point in the history
Cycle custom name mapping
  • Loading branch information
stephanoshadjipetrou authored Aug 5, 2024
2 parents 71d5a10 + c832d62 commit 9f2c8f1
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 121 deletions.
2 changes: 1 addition & 1 deletion src/app/components/chart-block/components/cycles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const ChartBlockCycles: React.FC<ChartBlockCyclesProps> = (
: {}
}
>
{cycle.name.replace(/ /g, "")}
{cycle.name.replace(" - ", "-")}
</Button>
))}
</Box>
Expand Down
108 changes: 60 additions & 48 deletions src/app/pages/datasets/grant-implementation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,9 @@ export const GrantImplementationPage: React.FC = () => {
case "status":
state.status = state.status.filter((item) => item !== value);
break;
case "cycle":
state.cycles = state.cycles.filter((item) => item !== value);
break;
default:
break;
}
Expand Down Expand Up @@ -1243,17 +1246,18 @@ export const GrantImplementationPage: React.FC = () => {
appliedFiltersData.cycles.length > 0 &&
location.search.includes("cycles=")
) {
const years = appliedFiltersData.cycles.map(
(cycle) => cycle.replace(/ /g, "").split("-")[0]
);
const yearsTo = appliedFiltersData.cycles.map(
(cycle) => cycle.replace(/ /g, "").split("-")[1]
);
filterString += `${
filterString.length > 0 ? "&" : ""
}years=${encodeURIComponent(
years.join(",")
)}&yearsTo=${encodeURIComponent(yearsTo.join(","))}`;
// const years = appliedFiltersData.cycles.map(
// (cycle) => cycle.replace(/ /g, "").split("-")[0]
// );
// const yearsTo = appliedFiltersData.cycles.map(
// (cycle) => cycle.replace(/ /g, "").split("-")[1]
// );
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }years=${encodeURIComponent(
// years.join(",")
// )}&yearsTo=${encodeURIComponent(yearsTo.join(","))}`;
filterString += `cycleNames=${appliedFiltersData.cycles.join(",")}`;
}
return filterString;
}, [appliedFiltersData, location.search]);
Expand Down Expand Up @@ -1347,19 +1351,23 @@ export const GrantImplementationPage: React.FC = () => {
location.search.includes("cycles=")) ||
chart1AppliedFiltersData.cycles.length > 0
) {
const years = uniq([
// const years = uniq([
// ...appliedFiltersData.cycles,
// ...chart1AppliedFiltersData.cycles,
// ]).map((cycle) => cycle.replace(/ /g, "").split("-")[0]);
// const yearsTo = uniq([
// ...appliedFiltersData.cycles,
// ...chart1AppliedFiltersData.cycles,
// ]).map((cycle) => cycle.replace(/ /g, "").split("-")[1]);
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }years=${encodeURIComponent(
// years.join(",")
// )}&yearsTo=${encodeURIComponent(yearsTo.join(","))}`;
filterString += `cycleNames=${uniq([
...appliedFiltersData.cycles,
...chart1AppliedFiltersData.cycles,
]).map((cycle) => cycle.replace(/ /g, "").split("-")[0]);
const yearsTo = uniq([
...appliedFiltersData.cycles,
...chart1AppliedFiltersData.cycles,
]).map((cycle) => cycle.replace(/ /g, "").split("-")[1]);
filterString += `${
filterString.length > 0 ? "&" : ""
}years=${encodeURIComponent(
years.join(",")
)}&yearsTo=${encodeURIComponent(yearsTo.join(","))}`;
]).join(",")}`;
}
return filterString;
}, [appliedFiltersData, chart1AppliedFiltersData, location.search]);
Expand Down Expand Up @@ -1449,13 +1457,14 @@ export const GrantImplementationPage: React.FC = () => {
)}`;
}
if (budgetCycleDropdownSelected) {
const year = budgetCycleDropdownSelected.replace(/ /g, "").split("-")[0];
const yearTo = budgetCycleDropdownSelected
.replace(/ /g, "")
.split("-")[1];
filterString += `${
filterString.length > 0 ? "&" : ""
}years=${encodeURIComponent(year)}&yearsTo=${encodeURIComponent(yearTo)}`;
// const year = budgetCycleDropdownSelected.replace(/ /g, "").split("-")[0];
// const yearTo = budgetCycleDropdownSelected
// .replace(/ /g, "")
// .split("-")[1];
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }years=${encodeURIComponent(year)}&yearsTo=${encodeURIComponent(yearTo)}`;
filterString += `cycleNames=${budgetCycleDropdownSelected}`;
}
return filterString;
}, [
Expand Down Expand Up @@ -1550,15 +1559,16 @@ export const GrantImplementationPage: React.FC = () => {
)}`;
}
if (financialMetricsCycleDropdownSelected) {
const year = financialMetricsCycleDropdownSelected
.replace(/ /g, "")
.split("-")[0];
const yearTo = financialMetricsCycleDropdownSelected
.replace(/ /g, "")
.split("-")[1];
filterString += `${
filterString.length > 0 ? "&" : ""
}years=${encodeURIComponent(year)}&yearsTo=${encodeURIComponent(yearTo)}`;
// const year = financialMetricsCycleDropdownSelected
// .replace(/ /g, "")
// .split("-")[0];
// const yearTo = financialMetricsCycleDropdownSelected
// .replace(/ /g, "")
// .split("-")[1];
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }years=${encodeURIComponent(year)}&yearsTo=${encodeURIComponent(yearTo)}`;
filterString += `cycleNames=${financialMetricsCycleDropdownSelected}`;
}
return filterString;
}, [
Expand Down Expand Up @@ -1653,15 +1663,16 @@ export const GrantImplementationPage: React.FC = () => {
)}`;
}
if (expendituresCycleDropdownSelected) {
const year = expendituresCycleDropdownSelected
.replace(/ /g, "")
.split("-")[0];
const yearTo = expendituresCycleDropdownSelected
.replace(/ /g, "")
.split("-")[1];
filterString += `${
filterString.length > 0 ? "&" : ""
}years=${encodeURIComponent(year)}&yearsTo=${encodeURIComponent(yearTo)}`;
// const year = expendituresCycleDropdownSelected
// .replace(/ /g, "")
// .split("-")[0];
// const yearTo = expendituresCycleDropdownSelected
// .replace(/ /g, "")
// .split("-")[1];
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }years=${encodeURIComponent(year)}&yearsTo=${encodeURIComponent(yearTo)}`;
filterString += `cycleNames=${expendituresCycleDropdownSelected}`;
}
return filterString;
}, [
Expand Down Expand Up @@ -1834,7 +1845,8 @@ export const GrantImplementationPage: React.FC = () => {
fetchBudgetBreakdown({
filterString,
routeParams: {
year: budgetBreakdownDropdownSelected.replace(/ /g, ""),
year: budgetBreakdownDropdownSelected,
// year: budgetBreakdownDropdownSelected.replace(/ /g, ""),
componentField:
componentsGrouping === componentsGroupingOptions[0].value
? "activityAreaGroup"
Expand Down
93 changes: 48 additions & 45 deletions src/app/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,22 @@ export const Home: React.FC = () => {
) => {
let filterString = "";
if (cycles.length > 0) {
const yearFrom: string[] = [];
const yearTo: string[] = [];
cycles.forEach((cycle) => {
const years = cycle.value.split(" - ");
yearFrom.push(years[0]);
yearTo.push(years[1]);
});
if (yearFrom.length > 0) {
filterString = `years=${yearFrom.join(",")}`;
}
if (yearTo.length > 0) {
filterString += `${
filterString.length > 0 ? "&" : ""
}yearsTo=${yearTo.join(",")}`;
}
// const yearFrom: string[] = [];
// const yearTo: string[] = [];
// cycles.forEach((cycle) => {
// const years = cycle.value.split(" - ");
// yearFrom.push(years[0]);
// yearTo.push(years[1]);
// });
// if (yearFrom.length > 0) {
// filterString = `years=${yearFrom.join(",")}`;
// }
// if (yearTo.length > 0) {
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }yearsTo=${yearTo.join(",")}`;
// }
filterString = `cycleNames=${cycles.map((c) => c.value).join(",")}`;
}
fetchBudgetsTreemap({
filterString,
Expand All @@ -362,21 +363,22 @@ export const Home: React.FC = () => {
) => {
let filterString = "";
if (cycles.length > 0) {
const yearFrom: string[] = [];
const yearTo: string[] = [];
cycles.forEach((cycle) => {
const years = cycle.value.split(" - ");
yearFrom.push(years[0]);
yearTo.push(years[1]);
});
if (yearFrom.length > 0) {
filterString = `years=${yearFrom.join(",")}`;
}
if (yearTo.length > 0) {
filterString += `${
filterString.length > 0 ? "&" : ""
}yearsTo=${yearTo.join(",")}`;
}
// const yearFrom: string[] = [];
// const yearTo: string[] = [];
// cycles.forEach((cycle) => {
// const years = cycle.value.split(" - ");
// yearFrom.push(years[0]);
// yearTo.push(years[1]);
// });
// if (yearFrom.length > 0) {
// filterString = `years=${yearFrom.join(",")}`;
// }
// if (yearTo.length > 0) {
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }yearsTo=${yearTo.join(",")}`;
// }
filterString = `cycleNames=${cycles.map((c) => c.value).join(",")}`;
}
fetchDisbursementsLineChart({
filterString,
Expand All @@ -398,21 +400,22 @@ export const Home: React.FC = () => {
) => {
let filterString = "";
if (cycles.length > 0) {
const yearFrom: string[] = [];
const yearTo: string[] = [];
cycles.forEach((cycle) => {
const years = cycle.value.split(" - ");
yearFrom.push(years[0]);
yearTo.push(years[1]);
});
if (yearFrom.length > 0) {
filterString = `years=${yearFrom.join(",")}`;
}
if (yearTo.length > 0) {
filterString += `${
filterString.length > 0 ? "&" : ""
}yearsTo=${yearTo.join(",")}`;
}
// const yearFrom: string[] = [];
// const yearTo: string[] = [];
// cycles.forEach((cycle) => {
// const years = cycle.value.split(" - ");
// yearFrom.push(years[0]);
// yearTo.push(years[1]);
// });
// if (yearFrom.length > 0) {
// filterString = `years=${yearFrom.join(",")}`;
// }
// if (yearTo.length > 0) {
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }yearsTo=${yearTo.join(",")}`;
// }
filterString = `cycleNames=${cycles.map((c) => c.value).join(",")}`;
}
fetchExpendituresHeatmap({
filterString,
Expand Down
63 changes: 36 additions & 27 deletions src/app/pages/location/views/grant-implementation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,24 @@ export const GrantImplementation = () => {
useUpdateEffect(() => {
let filterString = `geographies=${paramsId}`;
if (chart1Cycles.length > 0) {
const yearFrom: string[] = [];
const yearTo: string[] = [];
chart1Cycles.forEach((cycle) => {
const years = cycle.value.split(" - ");
yearFrom.push(years[0]);
yearTo.push(years[1]);
});
if (yearFrom.length > 0) {
filterString += `&years=${yearFrom.join(",")}`;
}
if (yearTo.length > 0) {
filterString += `${
filterString.length > 0 ? "&" : ""
}yearsTo=${yearTo.join(",")}`;
}
// const yearFrom: string[] = [];
// const yearTo: string[] = [];
// chart1Cycles.forEach((cycle) => {
// const years = cycle.value.split(" - ");
// yearFrom.push(years[0]);
// yearTo.push(years[1]);
// });
// if (yearFrom.length > 0) {
// filterString += `&years=${yearFrom.join(",")}`;
// }
// if (yearTo.length > 0) {
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }yearsTo=${yearTo.join(",")}`;
// }
filterString += `&cycleNames=${chart1Cycles
.map((c) => c.value)
.join(",")}`;
}
fetchDisbursementsLineChart({
filterString,
Expand All @@ -239,17 +242,20 @@ export const GrantImplementation = () => {
useUpdateEffect(() => {
let filterString = `geographies=${paramsId}`;
if (chart2Cycles.length > 0) {
const years = chart2Cycles.map(
(cycle) => cycle.value.replace(/ /g, "").split("-")[0]
);
const yearsTo = chart2Cycles.map(
(cycle) => cycle.value.replace(/ /g, "").split("-")[1]
);
filterString += `${
filterString.length > 0 ? "&" : ""
}years=${encodeURIComponent(
years.join(",")
)}&yearsTo=${encodeURIComponent(yearsTo.join(","))}`;
// const years = chart2Cycles.map(
// (cycle) => cycle.value.replace(/ /g, "").split("-")[0]
// );
// const yearsTo = chart2Cycles.map(
// (cycle) => cycle.value.replace(/ /g, "").split("-")[1]
// );
// filterString += `${
// filterString.length > 0 ? "&" : ""
// }years=${encodeURIComponent(
// years.join(",")
// )}&yearsTo=${encodeURIComponent(yearsTo.join(","))}`;
filterString += `&cycleNames=${chart2Cycles
.map((c) => c.value)
.join(",")}`;
}
fetchBudgetSankeyChart({
filterString,
Expand All @@ -263,7 +269,10 @@ export const GrantImplementation = () => {
useUpdateEffect(() => {
let filterString = `geographies=${paramsId}`;
if (chart3Cycles.length > 0) {
filterString += `&periods=${chart3Cycles.map((c) => c.value).join(",")}`;
// filterString += `&periods=${chart3Cycles.map((c) => c.value).join(",")}`;
filterString += `&cycleNames=${chart3Cycles
.map((c) => c.value)
.join(",")}`;
}
fetchExpendituresHeatmap({
filterString,
Expand Down

0 comments on commit 9f2c8f1

Please sign in to comment.