Skip to content

Commit

Permalink
fix: first load bugs in a2f dataset & grant page
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Sep 16, 2024
1 parent a409573 commit fe6cb32
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/app/pages/datasets/access-to-funding/blocks/block-1/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const AccessToFundingBlock1: React.FC<AccessToFundingBlock1Props> = (
);

const [eligibilityYear, setEligibilityYear] = React.useState(
eligibilityYears[0].value
eligibilityYears.length > 0 ? eligibilityYears[0].value : ""
);

const dataStats = useStoreState(
Expand All @@ -49,12 +49,20 @@ export const AccessToFundingBlock1: React.FC<AccessToFundingBlock1Props> = (
};

React.useEffect(() => {
fetchStats({
filterString: props.filterString,
routeParams: {
year: eligibilityYear,
},
});
if (eligibilityYears.length > 0 && eligibilityYear === "") {
setEligibilityYear(eligibilityYears[0].value);
}
}, [eligibilityYears]);

React.useEffect(() => {
if (eligibilityYears.length > 0) {
fetchStats({
filterString: props.filterString,
routeParams: {
year: eligibilityYear,
},
});
}
}, [props.filterString, eligibilityYear]);

return (
Expand Down
12 changes: 12 additions & 0 deletions src/app/pages/grant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ export const Grant: React.FC = () => {
);
}, [params.ip]);

React.useEffect(() => {
if (!dropdownSelected && dataGrant.periods.length > 0) {
setDropdownSelected(
get(
dataGrant.periods,
`[${params.ip !== undefined ? parseInt(params.ip) - 1 : 0}]`,
null
)
);
}
}, [dataGrant.periods]);

React.useEffect(() => {
if (params.id && dropdownSelected) {
fetchOverview({
Expand Down

0 comments on commit fe6cb32

Please sign in to comment.