Commit bae94921 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov
Browse files

Fix URL filter fetching for AccessionList page

parent 7caea5a8
......@@ -22,7 +22,7 @@ const useAccessionPageLoad = ({ initialFilter, initialFilterCode }: UseAccession
// state
const [accessions, setAccessions] = React.useState<FilteredPage<Accession, AccessionFilter>>();
const [filter, setFilter] = React.useState<AccessionFilter>(initialFilter);
const [{filter, filterCode}, setFilter] = React.useState<{filter: AccessionFilter, filterCode: string}>({filter: initialFilter, filterCode: initialFilterCode});
// callback
......@@ -30,13 +30,13 @@ const useAccessionPageLoad = ({ initialFilter, initialFilterCode }: UseAccession
return AccessionService
.list(filter, pageR)
.then((data) => {
console.log('accessions: ', data);
setFilter(data.filter);
// console.log('accessions: ', data);
setFilter({filter: data.filter, filterCode: data.filterCode});
setAccessions(data);
return data;
})
.catch((e) => {
console.log('Api call failed: ', e);
// console.log('Api call failed: ', e);
return null;
});
}, []);
......@@ -48,8 +48,12 @@ const useAccessionPageLoad = ({ initialFilter, initialFilterCode }: UseAccession
// effect
React.useEffect(() => {
loadData(filter || initialFilterCode, {});
}, [initialFilterCode]);
loadData(filterCode || filter, {}).
then((data) => {
setFilter({filter: data.filter, filterCode: data.filterCode});
return data;
});
}, []);
return {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment