diff --git a/compose/neurosynth-frontend/cypress/e2e/workflows/Extraction/ExtractionTable.cy.tsx b/compose/neurosynth-frontend/cypress/e2e/workflows/Extraction/ExtractionTable.cy.tsx index 9a75dd51..a008c923 100644 --- a/compose/neurosynth-frontend/cypress/e2e/workflows/Extraction/ExtractionTable.cy.tsx +++ b/compose/neurosynth-frontend/cypress/e2e/workflows/Extraction/ExtractionTable.cy.tsx @@ -205,8 +205,7 @@ describe('ExtractionTable', () => { }); it('should sort by year desc', () => { - cy.contains('Year').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').should('exist'); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(0).click(); cy.wait('@studysetFixture').then((studysetFixture) => { const studyset = studysetFixture.response?.body as StudysetReturn; @@ -227,8 +226,8 @@ describe('ExtractionTable', () => { }); it('should sort by year asc', () => { - cy.contains('Year').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(0).click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(0).click(); cy.get('[data-testid="ArrowUpwardIcon"]').should('exist'); cy.wait('@studysetFixture').then((studysetFixture) => { @@ -250,8 +249,7 @@ describe('ExtractionTable', () => { }); it('should sort by name asc', () => { - cy.contains('Name').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').should('exist'); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(1).click(); cy.wait('@studysetFixture').then((studysetFixture) => { const studyset = studysetFixture.response?.body as StudysetReturn; @@ -272,8 +270,8 @@ describe('ExtractionTable', () => { }); it('should sort by name desc', () => { - cy.contains('Name').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(1).click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(1).click(); cy.get('[data-testid="ArrowUpwardIcon"]').should('exist'); cy.wait('@studysetFixture').then((studysetFixture) => { @@ -293,8 +291,7 @@ describe('ExtractionTable', () => { }); it('should sort by authors desc', () => { - cy.contains('Authors').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').should('exist'); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(2).click(); cy.wait('@studysetFixture').then((studysetFixture) => { const studyset = studysetFixture.response?.body as StudysetReturn; @@ -313,8 +310,8 @@ describe('ExtractionTable', () => { }); it('should sort by authors asc', () => { - cy.contains('Authors').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(2).click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(2).click(); cy.get('[data-testid="ArrowUpwardIcon"]').should('exist'); cy.wait('@studysetFixture').then((studysetFixture) => { @@ -334,8 +331,7 @@ describe('ExtractionTable', () => { }); it('should sort by journal desc', () => { - cy.contains('Journal').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').should('exist'); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(3).click(); cy.wait('@studysetFixture').then((studysetFixture) => { const studyset = studysetFixture.response?.body as StudysetReturn; @@ -354,8 +350,8 @@ describe('ExtractionTable', () => { }); it('should sort by journal desc', () => { - cy.contains('Journal').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(3).click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(3).click(); cy.get('[data-testid="ArrowUpwardIcon"]').should('exist'); cy.wait('@studysetFixture').then((studysetFixture) => { @@ -375,8 +371,7 @@ describe('ExtractionTable', () => { }); it('should sort by doi desc', () => { - cy.contains('DOI').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').should('exist'); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(4).click(); cy.wait('@studysetFixture').then((studysetFixture) => { const studyset = studysetFixture.response?.body as StudysetReturn; @@ -396,8 +391,8 @@ describe('ExtractionTable', () => { }); }); it('should sort by doi asc', () => { - cy.contains('DOI').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(4).click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(4).click(); cy.get('[data-testid="ArrowUpwardIcon"]').should('exist'); cy.wait('@studysetFixture').then((studysetFixture) => { @@ -417,8 +412,7 @@ describe('ExtractionTable', () => { }); it('should sort by pmid desc', () => { - cy.contains('PMID').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').should('exist'); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(5).click(); cy.wait('@studysetFixture').then((studysetFixture) => { const studyset = studysetFixture.response?.body as StudysetReturn; @@ -443,8 +437,8 @@ describe('ExtractionTable', () => { }); it('should sort by pmid asc', () => { - cy.contains('PMID').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(5).click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(5).click(); cy.get('[data-testid="ArrowUpwardIcon"]').should('exist'); cy.wait('@studysetFixture').then((studysetFixture) => { @@ -468,8 +462,7 @@ describe('ExtractionTable', () => { }); it('should sort by status desc', () => { - cy.contains('Status').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').should('exist'); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(6).click(); cy.wait('@projectFixture').then((projectFixture) => { const project = projectFixture?.response?.body as INeurosynthProjectReturn; @@ -525,8 +518,8 @@ describe('ExtractionTable', () => { }); it('should sort by status asc', () => { - cy.contains('Status').click(); - cy.get('[data-testid="ArrowDownwardIcon"]').click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(6).click(); + cy.get('[data-testid="ArrowDownwardIcon"]').eq(6).click(); cy.get('[data-testid="ArrowUpwardIcon"]').should('exist'); cy.wait('@projectFixture').then((projectFixture) => { @@ -583,7 +576,7 @@ describe('ExtractionTable', () => { }); }); - describe.only('pagination', () => { + describe('pagination', () => { beforeEach(() => { cy.fixture('studyset').then((studyset) => { // as we are artificially creating new studies below, the out of sync popup wil appear. That's expected and diff --git a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTable.module.css b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTable.module.css index 7a6e3849..2490da7c 100644 --- a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTable.module.css +++ b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTable.module.css @@ -1,12 +1,11 @@ .completed { - background-color: #e5ffe5; + background-color: #f8fff8; } .savedforlater { - background-color: #effbff; + background-color: #f1fbff; } .uncategorized { - /* background-color: #ffffeb; */ background-color: white; } \ No newline at end of file diff --git a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableAuthor.tsx b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableAuthor.tsx index 117ab4ed..8cfac918 100644 --- a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableAuthor.tsx +++ b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableAuthor.tsx @@ -1,8 +1,8 @@ -import { Box, IconButton, Link, Tooltip, Typography } from '@mui/material'; -import { CellContext, HeaderContext } from '@tanstack/react-table'; -import { IExtractionTableStudy } from './ExtractionTable'; import { ArrowDownward } from '@mui/icons-material'; import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; +import { Box, IconButton, Tooltip, Typography } from '@mui/material'; +import { CellContext, HeaderContext } from '@tanstack/react-table'; +import { IExtractionTableStudy } from './ExtractionTable'; export const ExtractionTableAuthorCell: React.FC> = ( props @@ -18,41 +18,35 @@ export const ExtractionTableAuthorHeader: React.FC< return ( - - { - if (!!isSorted) { - table.resetSorting(); - } else { - table.setSorting([{ id: 'authors', desc: true }]); - } - }} + + Authors + + {!isSorted ? ( + + { + if (!!isSorted) { + table.resetSorting(); + } else { + table.setSorting([{ id: 'authors', desc: true }]); + } + }} + > + + + + ) : isSorted === 'asc' ? ( + table.resetSorting()}> + + + ) : ( + table.setSorting([{ id: 'authors', desc: false }])} > - Authors - - - {!!isSorted && ( - <> - {isSorted === 'asc' ? ( - table.setSorting([{ id: 'authors', desc: true }])} - > - - - ) : ( - table.setSorting([{ id: 'authors', desc: false }])} - > - - - )} - + + )} ); diff --git a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableDOI.tsx b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableDOI.tsx index f4a21dd4..bf36cf6e 100644 --- a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableDOI.tsx +++ b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableDOI.tsx @@ -1,8 +1,8 @@ -import { Box, IconButton, Link, Tooltip, Typography } from '@mui/material'; -import { CellContext, HeaderContext } from '@tanstack/react-table'; -import { IExtractionTableStudy } from './ExtractionTable'; import { ArrowDownward } from '@mui/icons-material'; import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; +import { Box, IconButton, Tooltip, Typography } from '@mui/material'; +import { CellContext, HeaderContext } from '@tanstack/react-table'; +import { IExtractionTableStudy } from './ExtractionTable'; export const ExtractionTableDOICell: React.FC> = ( props @@ -22,41 +22,35 @@ export const ExtractionTableDOIHeader: React.FC - - { - if (!!isSorted) { - table.resetSorting(); - } else { - table.setSorting([{ id: 'doi', desc: true }]); - } - }} + + DOI + + {!isSorted ? ( + + { + if (!!isSorted) { + table.resetSorting(); + } else { + table.setSorting([{ id: 'doi', desc: true }]); + } + }} + > + + + + ) : isSorted === 'asc' ? ( + table.resetSorting()}> + + + ) : ( + table.setSorting([{ id: 'doi', desc: false }])} > - DOI - - - {!!isSorted && ( - <> - {isSorted === 'asc' ? ( - table.setSorting([{ id: 'doi', desc: true }])} - > - - - ) : ( - table.setSorting([{ id: 'doi', desc: false }])} - > - - - )} - + + )} ); diff --git a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableJournal.tsx b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableJournal.tsx index d76bc065..3a33d951 100644 --- a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableJournal.tsx +++ b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableJournal.tsx @@ -1,8 +1,8 @@ -import { Box, IconButton, Link, Tooltip, Typography } from '@mui/material'; -import { CellContext, HeaderContext } from '@tanstack/react-table'; -import { IExtractionTableStudy } from './ExtractionTable'; import { ArrowDownward } from '@mui/icons-material'; import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; +import { Box, IconButton, Tooltip, Typography } from '@mui/material'; +import { CellContext, HeaderContext } from '@tanstack/react-table'; +import { IExtractionTableStudy } from './ExtractionTable'; export const ExtractionTableJournalCell: React.FC> = ( props @@ -17,41 +17,35 @@ export const ExtractionTableJournalHeader: React.FC< const isSorted = column.getIsSorted(); return ( - - { - if (!!isSorted) { - table.resetSorting(); - } else { - table.setSorting([{ id: 'journal', desc: true }]); - } - }} + + Journal + + {!isSorted ? ( + + { + if (!!isSorted) { + table.resetSorting(); + } else { + table.setSorting([{ id: 'journal', desc: true }]); + } + }} + > + + + + ) : isSorted === 'asc' ? ( + table.resetSorting()}> + + + ) : ( + table.setSorting([{ id: 'journal', desc: false }])} > - Journal - - - {!!isSorted && ( - <> - {isSorted === 'asc' ? ( - table.setSorting([{ id: 'journal', desc: true }])} - > - - - ) : ( - table.setSorting([{ id: 'journal', desc: false }])} - > - - - )} - + + )} ); diff --git a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableName.tsx b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableName.tsx index 66f9820e..21198759 100644 --- a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableName.tsx +++ b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableName.tsx @@ -1,8 +1,8 @@ -import { Box, IconButton, Link, Tooltip, Typography } from '@mui/material'; -import { CellContext, HeaderContext } from '@tanstack/react-table'; -import { IExtractionTableStudy } from './ExtractionTable'; import { ArrowDownward } from '@mui/icons-material'; import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; +import { Box, IconButton, Tooltip, Typography } from '@mui/material'; +import { CellContext, HeaderContext } from '@tanstack/react-table'; +import { IExtractionTableStudy } from './ExtractionTable'; export const ExtractionTableNameCell: React.FC> = ( props @@ -22,41 +22,35 @@ export const ExtractionTableNameHeader: React.FC - - { - if (!!isSorted) { - table.resetSorting(); - } else { - table.setSorting([{ id: 'name', desc: true }]); - } - }} + + Name + + {!isSorted ? ( + + { + if (!!isSorted) { + table.resetSorting(); + } else { + table.setSorting([{ id: 'name', desc: true }]); + } + }} + > + + + + ) : isSorted === 'asc' ? ( + table.resetSorting()}> + + + ) : ( + table.setSorting([{ id: 'name', desc: false }])} > - Name - - - {!!isSorted && ( - <> - {isSorted === 'asc' ? ( - table.setSorting([{ id: 'name', desc: true }])} - > - - - ) : ( - table.setSorting([{ id: 'name', desc: false }])} - > - - - )} - + + )} ); diff --git a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTablePMID.tsx b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTablePMID.tsx index 8cdcb882..aefc1208 100644 --- a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTablePMID.tsx +++ b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTablePMID.tsx @@ -1,8 +1,8 @@ -import { Box, IconButton, Link, Tooltip, Typography } from '@mui/material'; -import { CellContext, HeaderContext } from '@tanstack/react-table'; -import { IExtractionTableStudy } from './ExtractionTable'; import { ArrowDownward } from '@mui/icons-material'; import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; +import { Box, IconButton, Tooltip, Typography } from '@mui/material'; +import { CellContext, HeaderContext } from '@tanstack/react-table'; +import { IExtractionTableStudy } from './ExtractionTable'; export const ExtractionTablePMIDCell: React.FC> = ( props @@ -18,41 +18,35 @@ export const ExtractionTablePMIDHeader: React.FC - - { - if (!!isSorted) { - table.resetSorting(); - } else { - table.setSorting([{ id: 'pmid', desc: true }]); - } - }} + + PMID + + {!isSorted ? ( + + { + if (!!isSorted) { + table.resetSorting(); + } else { + table.setSorting([{ id: 'pmid', desc: true }]); + } + }} + > + + + + ) : isSorted === 'asc' ? ( + table.resetSorting()}> + + + ) : ( + table.setSorting([{ id: 'pmid', desc: false }])} > - PMID - - - {!!isSorted && ( - <> - {isSorted === 'asc' ? ( - table.setSorting([{ id: 'pmid', desc: true }])} - > - - - ) : ( - table.setSorting([{ id: 'pmid', desc: false }])} - > - - - )} - + + )} ); diff --git a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableStatus.tsx b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableStatus.tsx index c8696575..0be5f302 100644 --- a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableStatus.tsx +++ b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableStatus.tsx @@ -1,11 +1,11 @@ import { ArrowDownward, CheckCircle, QuestionMark } from '@mui/icons-material'; +import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; import BookmarkIcon from '@mui/icons-material/Bookmark'; -import { Box, Button, ButtonGroup, IconButton, Link, Tooltip, Typography } from '@mui/material'; +import { Box, Button, ButtonGroup, IconButton, Tooltip, Typography } from '@mui/material'; import { CellContext, HeaderContext } from '@tanstack/react-table'; import { useProjectExtractionAddOrUpdateStudyListStatus } from 'pages/Project/store/ProjectStore'; import { EExtractionStatus } from '../ExtractionPage'; import { IExtractionTableStudy } from './ExtractionTable'; -import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; export const ExtractionTableStatusCell: React.FC< CellContext @@ -77,41 +77,35 @@ export const ExtractionTableStatusHeader: React.FC< const isSorted = column.getIsSorted(); return ( - - { - if (!!isSorted) { - table.resetSorting(); - } else { - table.setSorting([{ id: 'status', desc: true }]); - } - }} + + Status + + {!isSorted ? ( + + { + if (!!isSorted) { + table.resetSorting(); + } else { + table.setSorting([{ id: 'status', desc: true }]); + } + }} + > + + + + ) : isSorted === 'asc' ? ( + table.resetSorting()}> + + + ) : ( + table.setSorting([{ id: 'status', desc: false }])} > - Status - - - {!!isSorted && ( - <> - {isSorted === 'asc' ? ( - table.setSorting([{ id: 'status', desc: true }])} - > - - - ) : ( - table.setSorting([{ id: 'status', desc: false }])} - > - - - )} - + + )} ); diff --git a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableYear.tsx b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableYear.tsx index 5d48a275..84cd28a4 100644 --- a/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableYear.tsx +++ b/compose/neurosynth-frontend/src/pages/Extraction/components/ExtractionTableYear.tsx @@ -1,6 +1,6 @@ import { ArrowDownward } from '@mui/icons-material'; import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; -import { Box, IconButton, Link, Tooltip, Typography } from '@mui/material'; +import { Box, IconButton, Tooltip, Typography } from '@mui/material'; import { CellContext, HeaderContext } from '@tanstack/react-table'; import { IExtractionTableStudy } from './ExtractionTable'; @@ -19,41 +19,35 @@ export const ExtractionTableYearHeader: React.FC - - { - if (!!isSorted) { - table.resetSorting(); - } else { - table.setSorting([{ id: 'year', desc: true }]); - } - }} + + Year + + {!isSorted ? ( + + { + if (!!isSorted) { + table.resetSorting(); + } else { + table.setSorting([{ id: 'year', desc: true }]); + } + }} + > + + + + ) : isSorted === 'asc' ? ( + table.resetSorting()}> + + + ) : ( + table.setSorting([{ id: 'year', desc: false }])} > - Year - - - {!!isSorted && ( - <> - {isSorted === 'asc' ? ( - table.setSorting([{ id: 'year', desc: true }])} - > - - - ) : ( - table.setSorting([{ id: 'year', desc: false }])} - > - - - )} - + + )} ); diff --git a/compose/neurosynth-frontend/src/pages/Study/EditStudyPage.tsx b/compose/neurosynth-frontend/src/pages/Study/EditStudyPage.tsx index 88d8ef44..12712db2 100644 --- a/compose/neurosynth-frontend/src/pages/Study/EditStudyPage.tsx +++ b/compose/neurosynth-frontend/src/pages/Study/EditStudyPage.tsx @@ -22,6 +22,7 @@ import { useEffect } from 'react'; import { useParams } from 'react-router-dom'; import { useClearAnnotationStore, useInitAnnotationStore } from 'stores/AnnotationStore.actions'; import { useAnnotationId, useGetAnnotationIsLoading } from 'stores/AnnotationStore.getters'; +import DisplayExtractionTableState from './components/DisplayExtractionTableState'; const EditStudyPage: React.FC = (props) => { const { studyId } = useParams<{ studyId: string }>(); @@ -72,6 +73,7 @@ const EditStudyPage: React.FC = (props) => { + diff --git a/compose/neurosynth-frontend/src/pages/Study/components/DisplayExtractionTableState.tsx b/compose/neurosynth-frontend/src/pages/Study/components/DisplayExtractionTableState.tsx new file mode 100644 index 00000000..fb4f1cc7 --- /dev/null +++ b/compose/neurosynth-frontend/src/pages/Study/components/DisplayExtractionTableState.tsx @@ -0,0 +1,72 @@ +import { Box, Chip, Typography } from '@mui/material'; +import { ColumnFiltersState, SortingState } from '@tanstack/react-table'; +import { useGetStudysetById } from 'hooks'; +import { useProjectExtractionStudysetId, useProjectId } from 'pages/Project/store/ProjectStore'; +import { useMemo } from 'react'; + +const DisplayExtractionTableState: React.FC = (props) => { + const projectId = useProjectId(); + const studysetId = useProjectExtractionStudysetId(); + const { data } = useGetStudysetById(studysetId); + const { columnFilters, sorting, studies } = useMemo(() => { + try { + const state = window.sessionStorage.getItem(`${projectId}-extraction-table`); + const parsedState = JSON.parse(state || '{}') as { + columnFilters: ColumnFiltersState; + sorting: SortingState; + studies: string[]; + }; + if (!state) { + return { + columnFilters: [], + sorting: [], + studies: [], + }; + } + + return { + columnFilters: parsedState.columnFilters, + sorting: parsedState.sorting, + studies: parsedState.studies, + }; + } catch (e) { + return { + columnFilters: [], + sorting: [], + studies: [], + }; + } + }, [projectId]); + + return ( + + {columnFilters + .filter((filter) => !!filter.value) + .map((filter) => ( + + ))} + {sorting.map((sort) => ( + + ))} + + ({studies.length} / {data?.studies?.length || 0} studies) + + + ); +}; + +export default DisplayExtractionTableState; diff --git a/compose/neurosynth-frontend/src/pages/Study/components/EditStudyToolbar.tsx b/compose/neurosynth-frontend/src/pages/Study/components/EditStudyToolbar.tsx index 9ea015a5..773ef1c9 100644 --- a/compose/neurosynth-frontend/src/pages/Study/components/EditStudyToolbar.tsx +++ b/compose/neurosynth-frontend/src/pages/Study/components/EditStudyToolbar.tsx @@ -41,7 +41,7 @@ const EditStudyToolbar: React.FC<{ isViewOnly?: boolean }> = ({ isViewOnly = fal const { data, isLoading, isError } = useGetStudysetById(studysetId || '', true); // derived from the extraction table - const [studiesState, setStudiesState] = useState<{ + const [extractionTableState, setExtractionTableState] = useState<{ columnFilters: ColumnFiltersState; sorting: SortingState; studies: string[]; @@ -54,7 +54,7 @@ const EditStudyToolbar: React.FC<{ isViewOnly?: boolean }> = ({ isViewOnly = fal useEffect(() => { const stateFromSessionStorage = sessionStorage.getItem(`${projectId}-extraction-table`); if (!stateFromSessionStorage) { - setStudiesState((prev) => ({ + setExtractionTableState((prev) => ({ ...prev, studies: (data?.studies || []).map((study) => (study as StudyReturn).id as string), })); @@ -65,7 +65,7 @@ const EditStudyToolbar: React.FC<{ isViewOnly?: boolean }> = ({ isViewOnly = fal sorting: SortingState; studies: string[]; }; - setStudiesState(parsedState); + setExtractionTableState(parsedState); } catch (e) { throw new Error('couldnt parse table state from session storage'); } @@ -81,8 +81,8 @@ const EditStudyToolbar: React.FC<{ isViewOnly?: boolean }> = ({ isViewOnly = fal }; const handleMoveToPreviousStudy = () => { - const index = studiesState.studies.indexOf(studyId || ''); - const prevId = studiesState.studies[index - 1]; + const index = extractionTableState.studies.indexOf(studyId || ''); + const prevId = extractionTableState.studies[index - 1]; if (!prevId) throw new Error('no previous study'); canEdit ? navigate(`/projects/${projectId}/extraction/studies/${prevId}/edit`) @@ -90,8 +90,8 @@ const EditStudyToolbar: React.FC<{ isViewOnly?: boolean }> = ({ isViewOnly = fal }; const handleMoveToNextStudy = () => { - const index = studiesState.studies.indexOf(studyId || ''); - const nextId = studiesState.studies[index + 1]; + const index = extractionTableState.studies.indexOf(studyId || ''); + const nextId = extractionTableState.studies[index + 1]; if (!nextId) throw new Error('no next study'); canEdit ? navigate(`/projects/${projectId}/extraction/studies/${nextId}/edit`) @@ -130,16 +130,16 @@ const EditStudyToolbar: React.FC<{ isViewOnly?: boolean }> = ({ isViewOnly = fal }, [extractionSummary.completed, extractionSummary.total]); const hasPrevStudies = useMemo(() => { - const studies = studiesState.studies; + const studies = extractionTableState.studies; const index = studies.indexOf(studyId || ''); return index - 1 >= 0; - }, [studiesState.studies, studyId]); + }, [extractionTableState.studies, studyId]); const hasNextStudies = useMemo(() => { - const studies = studiesState.studies; + const studies = extractionTableState.studies; const index = studies.indexOf(studyId || ''); return index + 1 < studies.length; - }, [studiesState.studies, studyId]); + }, [extractionTableState.studies, studyId]); return (