Skip to content

Commit

Permalink
fix: grant implementation pill
Browse files Browse the repository at this point in the history
  • Loading branch information
okorie2 committed Mar 5, 2023
1 parent 67e458b commit 9b03fbd
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/app/modules/grant-detail-module/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import { GrantDetailInvestmentsTableWrapper } from "app/modules/viz-module/sub-m
import { GrantDetailGenericBudgetsTimeCycleWrapper } from "app/modules/viz-module/sub-modules/budgets/time-cycle/data-wrappers/grantDetail";
import { GrantDetailInvestmentsDisbursedWrapper } from "app/modules/viz-module/sub-modules/investments/disbursed/data-wrappers/grantDetail";
import { GrantDetailInvestmentsTimeCycleWrapper } from "app/modules/viz-module/sub-modules/investments/time-cycle/data-wrappers/grantDetail";
import find from "lodash/find";

import { GrantDetailPeriod } from "./components/InfoContent";

export default function GrantDetail() {
useTitle("The Data Explorer - Grant");
Expand All @@ -47,6 +50,21 @@ export default function GrantDetail() {
(store) => store.GrantDetailInfo.fetch
);

const periods = useStoreState(
(state) =>
get(state.GrantDetailPeriods.data, "data", []) as GrantDetailPeriod[]
);

const selectedPeriod = find(
periods,
(p: GrantDetailPeriod) => p.number.toString() === params.period
) || { startDate: "", endDate: "" };

const formatPeriod = (date: string) => {
return date.split("-")[0];
};
console.log(formatPeriod(selectedPeriod.startDate), "start year");

const grantInfoData = useStoreState((state) =>
get(state.GrantDetailInfo.data, "data[0]", {
title: "",
Expand Down Expand Up @@ -147,7 +165,11 @@ export default function GrantDetail() {
id: v4(),
},
{
name: grantInfoData.code,
name: `${grantInfoData.code} ${
selectedPeriod ? "-" : ""
} ${formatPeriod(selectedPeriod.startDate)} - ${formatPeriod(
selectedPeriod.endDate
)}`,
path: location.pathname,
id: v4(),
vizLevel: breadCrumbList[breadCrumbList.length - 1]?.vizLevel,
Expand All @@ -158,7 +180,7 @@ export default function GrantDetail() {
}
}
}
}, [grantInfoData]);
}, [grantInfoData, selectedPeriod]);

return (
<div
Expand Down

0 comments on commit 9b03fbd

Please sign in to comment.