Commit d783770d authored by Axel Bocciarelli's avatar Axel Bocciarelli

Fetch parcel investigations by IDs

parent f15f283f
Pipeline #33314 passed with stage
in 2 minutes and 58 seconds
......@@ -6,8 +6,8 @@ import { beamlineFormatter, dateFormatter } from '../Investigation/utils';
import ParcelTable from './ParcelTable';
import styles from './MyParcelsSummary.module.css';
import { itemsFormatter } from '../../helpers';
import { useAllInvestigations } from '../../helpers/hooks';
import ParcelCondensedView from './ParcelCondensedView';
import InvestigationResource from '../../resources/investigation';
function getColumns(investigations) {
return [
......@@ -159,7 +159,11 @@ function getColumns(investigations) {
function MyParcelsSummary() {
const parcels = useResource(ParcelResource.listShape(), {});
const { investigations } = useAllInvestigations();
const investigationIds = parcels.map((p) => p.investigationId);
const investigations = useResource(InvestigationResource.listShape(), {
ids: investigationIds,
});
return (
<ParcelTable
......
import { useLocation } from 'react-router';
import { useSelector } from 'react-redux';
export function useQuery() {
return new URLSearchParams(useLocation().search);
}
export function useAllInvestigations() {
return useSelector(() => {
// const {
// scientistInstrumentInvestigations,
// myInvestigations,
// releasedInvestigations,
// investigations,
// } = state;
return {
investigations: [
// ...scientistInstrumentInvestigations.data,
// ...myInvestigations.data,
// ...releasedInvestigations.data,
// ...investigations.data,
],
fetching: false,
// scientistInstrumentInvestigations.fetching ||
// myInvestigations.fetching ||
// releasedInvestigations.fetching ||
// investigations.fetching,
};
});
}
Markdown is supported
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