From 0363be0b5696efd46eacb5b3a1457e17df6144e3 Mon Sep 17 00:00:00 2001 From: James Kent Date: Thu, 26 Oct 2023 16:53:21 -0500 Subject: [PATCH] delete new files --- .../cypress/fixtures/baseStudy.json | 18 - .../cypress/fixtures/project.json | 47 -- .../cypress/fixtures/semanticScholar.json | 18 - .../NeurosynthAvatar/NeurosynthAvatar.tsx | 73 --- .../SearchBarAccessories/SearchBarFilters.tsx | 178 -------- .../SearchBarAccessories/SearchSelectChip.tsx | 61 --- .../SearchSelectSortChip.tsx | 103 ----- .../src/hooks/analyses/useCreateAnalysis.tsx | 25 -- .../hooks/analyses/useCreateAnnotation.tsx | 42 -- .../src/hooks/analyses/useCreateCondition.tsx | 18 - .../src/hooks/analyses/useCreatePoint.tsx | 21 - .../src/hooks/analyses/useDeleteAnalysis.tsx | 16 - .../hooks/analyses/useDeleteAnnotation.tsx | 22 - .../src/hooks/analyses/useDeletePoint.tsx | 14 - .../src/hooks/analyses/useGetAnalysisById.tsx | 17 - .../hooks/analyses/useGetAnnotationById.tsx | 16 - .../useGetAnnotationsByStudysetId.tsx | 15 - .../src/hooks/analyses/useGetConditions.tsx | 11 - .../src/hooks/analyses/useUpdateAnalysis.tsx | 33 -- .../analyses/useUpdateAnnotationById.tsx | 36 -- .../src/hooks/analyses/useUpdatePoint.tsx | 23 - .../src/hooks/external/useGetFullText.tsx | 49 -- .../src/hooks/external/useGetPubMedIds.tsx | 417 ------------------ .../useCreateAlgorithmSpecification.tsx | 141 ------ .../useGetMetaAnalysesByProjectId.tsx | 17 - .../metaAnalyses/useGetMetaAnalysisById.tsx | 20 - .../useGetMetaAnalysisResultById.tsx | 20 - .../metaAnalyses/useGetSpecificationById.tsx | 18 - .../metaAnalyses/useUpdateMetaAnalysis.tsx | 39 -- .../metaAnalyses/useUpdateSpecification.tsx | 38 -- .../src/hooks/projects/useCreateProject.tsx | 26 -- .../src/hooks/projects/useGetProjectById.tsx | 19 - .../src/hooks/projects/useGetProjects.tsx | 97 ---- .../src/hooks/projects/useUpdateProject.tsx | 30 -- .../src/hooks/studies/useCreateStudy.tsx | 24 - .../src/hooks/studies/useDeleteStudy.tsx | 20 - .../src/hooks/studies/useGetBaseStudyById.tsx | 16 - .../src/hooks/studies/useGetStudyById.tsx | 30 -- .../src/hooks/studies/useUpdateStudy.tsx | 29 -- .../src/hooks/studysets/useCreateStudyset.tsx | 19 - .../src/hooks/studysets/useDeleteStudyset.tsx | 23 - .../hooks/studysets/useGetStudysetById.tsx | 36 -- .../src/hooks/studysets/useGetStudysets.tsx | 44 -- .../src/hooks/studysets/useUpdateStudyset.tsx | 32 -- .../Studies/BaseStudyPage/BaseStudyPage.tsx | 101 ----- .../src/pages/Studies/StudiesPage/models.ts | 64 --- .../pages/UserProfilePage/UserProfilePage.tsx | 59 --- .../src/utils/utilitytypes.ts | 6 - 48 files changed, 2241 deletions(-) delete mode 100644 compose/neurosynth-frontend/cypress/fixtures/baseStudy.json delete mode 100644 compose/neurosynth-frontend/cypress/fixtures/project.json delete mode 100644 compose/neurosynth-frontend/cypress/fixtures/semanticScholar.json delete mode 100644 compose/neurosynth-frontend/src/components/Navbar/NeurosynthAvatar/NeurosynthAvatar.tsx delete mode 100644 compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchBarFilters.tsx delete mode 100644 compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchSelectChip.tsx delete mode 100644 compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchSelectSortChip.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useCreateAnalysis.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useCreateAnnotation.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useCreateCondition.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useCreatePoint.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useDeleteAnalysis.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useDeleteAnnotation.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useDeletePoint.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useGetAnalysisById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useGetAnnotationById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useGetAnnotationsByStudysetId.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useGetConditions.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useUpdateAnalysis.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useUpdateAnnotationById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/analyses/useUpdatePoint.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/external/useGetFullText.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/external/useGetPubMedIds.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/metaAnalyses/useCreateAlgorithmSpecification.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysesByProjectId.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysisById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysisResultById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetSpecificationById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/metaAnalyses/useUpdateMetaAnalysis.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/metaAnalyses/useUpdateSpecification.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/projects/useCreateProject.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/projects/useGetProjectById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/projects/useGetProjects.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/projects/useUpdateProject.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studies/useCreateStudy.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studies/useDeleteStudy.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studies/useGetBaseStudyById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studies/useGetStudyById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studies/useUpdateStudy.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studysets/useCreateStudyset.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studysets/useDeleteStudyset.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studysets/useGetStudysetById.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studysets/useGetStudysets.tsx delete mode 100644 compose/neurosynth-frontend/src/hooks/studysets/useUpdateStudyset.tsx delete mode 100644 compose/neurosynth-frontend/src/pages/Studies/BaseStudyPage/BaseStudyPage.tsx delete mode 100644 compose/neurosynth-frontend/src/pages/Studies/StudiesPage/models.ts delete mode 100644 compose/neurosynth-frontend/src/pages/UserProfilePage/UserProfilePage.tsx delete mode 100644 compose/neurosynth-frontend/src/utils/utilitytypes.ts diff --git a/compose/neurosynth-frontend/cypress/fixtures/baseStudy.json b/compose/neurosynth-frontend/cypress/fixtures/baseStudy.json deleted file mode 100644 index 1e2641613..000000000 --- a/compose/neurosynth-frontend/cypress/fixtures/baseStudy.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "authors": "Bi Y, Zhang Y, Li Y, Yu D, Yuan K, Tian J", - "created_at": "2023-06-21T22:17:27.973390+00:00", - "description": "lorem ipsum dolor sit amet consectetur adipiscing elit", - "doi": "10.1016/j.drugalcdep.2017.02.019", - "id": "3Y2tJw6Vuy6n", - "level": "group", - "metadata": null, - "name": "12h abstinence-induced right anterior insula network pattern changes in young smokers.", - "pmid": "28544994", - "publication": "Drug and alcohol dependence", - "updated_at": "2023-08-24T14:30:22.320233+00:00", - "user": null, - "versions": [ - { "created_at": "2023-07-12T22:43:18.184264+00:00", "id": "66neUWorzjTc", "source": "neurostore", "updated_at": "2023-07-12T22:43:18.184264+00:00", "user": "github|2441214" } - ], - "year": null -} \ No newline at end of file diff --git a/compose/neurosynth-frontend/cypress/fixtures/project.json b/compose/neurosynth-frontend/cypress/fixtures/project.json deleted file mode 100644 index 82ba1094a..000000000 --- a/compose/neurosynth-frontend/cypress/fixtures/project.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "created_at": "2023-09-14T18:04:28.079423+00:00", - "description": "", - "id": "4HxF4g4WC5zj", - "meta_analyses": [], - "name": "My project name", - "neurostore_study": { - "created_at": "2023-09-14T18:04:28.090521+00:00", - "exception": null, - "neurostore_id": "4PG9x8gYaoWd", - "status": "PENDING", - "traceback": null, - "updated_at": "2023-09-14T18:04:28.111166+00:00" - }, - "neurostore_url": "https://neurostore.org/api/studies/4PG9x8gYaoWd", - "provenance": { - "curationMetadata": { - "columns": [], - "exclusionTags": [], - "identificationSources": [], - "infoTags": [], - "prismaConfig": { - "eligibility": { - "exclusionTags": [] - }, - "identification": { - "exclusionTags": [] - }, - "isPrisma": false, - "screening": { - "exclusionTags": [] - } - } - }, - "extractionMetadata": { - "studyStatusList": [] - }, - "metaAnalysisMetadata": { - "canEditMetaAnalyses": false - } - }, - "public": false, - "updated_at": "2023-09-14T18:04:34.184976+00:00", - "user": "github|12387943", - "username": "Nicholas Lee" - } - \ No newline at end of file diff --git a/compose/neurosynth-frontend/cypress/fixtures/semanticScholar.json b/compose/neurosynth-frontend/cypress/fixtures/semanticScholar.json deleted file mode 100644 index 09005523a..000000000 --- a/compose/neurosynth-frontend/cypress/fixtures/semanticScholar.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "total": 2, - "offset": 0, - "next": 1, - "data": [ - { - "paperId": "123abc", - "externalIds": { - "MAG": "2616323245", - "DOI": "10.1016/j.drugalcdep.2017.02.019", - "CorpusId": 4669249, - "PubMed": "28544994" - }, - "isOpenAccess": false, - "openAccessPdf": null - } - ] -} \ No newline at end of file diff --git a/compose/neurosynth-frontend/src/components/Navbar/NeurosynthAvatar/NeurosynthAvatar.tsx b/compose/neurosynth-frontend/src/components/Navbar/NeurosynthAvatar/NeurosynthAvatar.tsx deleted file mode 100644 index 5fdfe56a8..000000000 --- a/compose/neurosynth-frontend/src/components/Navbar/NeurosynthAvatar/NeurosynthAvatar.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import { useAuth0 } from '@auth0/auth0-react'; -import { - Avatar, - Button, - IconButton, - ListItem, - ListItemButton, - ListItemText, - Menu, -} from '@mui/material'; -import { useState } from 'react'; -import { useHistory } from 'react-router-dom'; -import NavToolbarStyles from 'components/Navbar/NavToolbar/NavToolbar.styles'; - -const NeurosynthAvatar: React.FC<{ onLogin: () => void; onLogout: () => void }> = (props) => { - const history = useHistory(); - const { user, isAuthenticated } = useAuth0(); - const [anchorEl, setAnchorEl] = useState(null); - - const handleOpenAvatarMenu = (event: React.MouseEvent) => { - setAnchorEl(event.currentTarget); - }; - - const handleCloseAvatarMenu = () => { - setAnchorEl(null); - }; - - const handleDirectToUserProfile = () => { - history.push('/user-profile'); - handleCloseAvatarMenu(); - }; - - return ( - <> - {isAuthenticated ? ( - <> - - - - - - - PROFILE - - - - - LOGOUT - - - - - ) : ( - - )} - - ); -}; - -export default NeurosynthAvatar; diff --git a/compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchBarFilters.tsx b/compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchBarFilters.tsx deleted file mode 100644 index 9bf36a07f..000000000 --- a/compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchBarFilters.tsx +++ /dev/null @@ -1,178 +0,0 @@ -import { Add } from '@mui/icons-material'; -import { - Box, - Button, - Chip, - FormControl, - InputLabel, - MenuItem, - Select, - TextField, -} from '@mui/material'; -import NeurosynthPopper from 'components/NeurosynthPopper/NeurosynthPopper'; -import { SearchBy } from 'pages/Studies/StudiesPage/models'; -import { useEffect, useRef, useState } from 'react'; - -const SearchBarFilters: React.FC<{ - nameSearch: string | undefined; - publicationSearch: string | undefined; - descriptionSearch: string | undefined; - authorSearch: string | undefined; - onAddFilter: (newFilter: { filter: SearchBy; value: string }) => void; - onRemoveFilter: (filter: { filter: SearchBy; value: string }) => void; -}> = (props) => { - const { - nameSearch, - publicationSearch, - descriptionSearch, - authorSearch, - onAddFilter, - onRemoveFilter, - } = props; - - const buttonElRef = useRef(null); - const [addFilterPopupIsOpen, setAddFilterPopupIsOpen] = useState(false); - // unfortunately we have to explicitly set the state of select - // if we don't do this, the popper will close when you try and click select - // setting disablePortal: false does not seem to be work so this is the solution: - // https://stackoverflow.com/questions/69741515/closing-a-popper-mui-using-clickawaylistener-affects-everything-inside - const [selectIsOpen, setSelectIsOpen] = useState(false); - - // used to display the filters - const [existingFilters, setExistingFilters] = useState<{ filter: SearchBy; value: string }[]>( - [] - ); - - const filterOptions = Object.keys(SearchBy) - .map((filterOption) => SearchBy[filterOption as keyof typeof SearchBy]) - .filter( - (filterOption) => - filterOption !== SearchBy.ALL && - !existingFilters.find((existingFilter) => existingFilter.filter === filterOption) - ); - - // used when creating a new filter in the popup - const [newFilter, setNewFilter] = useState<{ - filter: SearchBy | undefined; - value: string; - }>({ - filter: undefined, - value: '', - }); - - useEffect(() => { - setExistingFilters(() => { - const filters = []; - if (nameSearch) filters.push({ filter: SearchBy.TITLE, value: nameSearch }); - if (publicationSearch) - filters.push({ filter: SearchBy.PUBLICATION, value: publicationSearch }); - if (descriptionSearch) - filters.push({ filter: SearchBy.DESCRIPTION, value: descriptionSearch }); - if (authorSearch) filters.push({ filter: SearchBy.AUTHORS, value: authorSearch }); - return filters; - }); - }, [nameSearch, publicationSearch, descriptionSearch, authorSearch]); - - const handleAddFilter = () => { - if (newFilter.filter !== undefined && newFilter.value) { - onAddFilter({ - filter: newFilter.filter, - value: newFilter.value, - }); - closePopper(); - } - }; - - const closePopper = () => { - setAddFilterPopupIsOpen(false); - setSelectIsOpen(false); - setNewFilter({ filter: undefined, value: '' }); - }; - - return ( - <> - {existingFilters.map((filter) => ( - onRemoveFilter(filter)} - /> - ))} - {filterOptions.length > 0 && ( - <> - { - if (selectIsOpen) return; - closePopper(); - }} - > - { - event.preventDefault(); - handleAddFilter(); - }} - > - - Field to filter By - - - - - setNewFilter((prev) => ({ - ...prev, - value: e.target.value || '', - })) - } - label="Text to filter by" - size="small" - /> - - - - - - - - - )} - - ); -}; - -export default SearchBarFilters; diff --git a/compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchSelectChip.tsx b/compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchSelectChip.tsx deleted file mode 100644 index 77d3c884d..000000000 --- a/compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchSelectChip.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { ArrowDropDown } from '@mui/icons-material'; -import { Box, Chip, MenuItem, MenuList } from '@mui/material'; -import NeurosynthPopper from 'components/NeurosynthPopper/NeurosynthPopper'; -import { useRef, useState } from 'react'; - -interface ISearchSelectChip { - chipLabel: string; - onSelectSearch: (searchParams: T) => void; - options: { - value: T; - label: string; - }[]; -} - -const SearchSelectChip = (props: ISearchSelectChip) => { - const { chipLabel, onSelectSearch, options } = props; - - const dataTypeSelectRef = useRef(null); - const [isOpen, setIsOpen] = useState(false); - - const onSelect = (value: T) => { - setIsOpen(false); - onSelectSearch(value); - }; - - return ( - <> - setIsOpen(false)} - open={isOpen} - > - - - {options.map((option) => ( - onSelect(option.value)} - key={option.label} - value={option.value} - > - {option.label} - - ))} - - - - setIsOpen(true)} - icon={} - sx={{ marginLeft: '5px', width: '220px' }} - label={chipLabel} - /> - - ); -}; - -export default SearchSelectChip; diff --git a/compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchSelectSortChip.tsx b/compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchSelectSortChip.tsx deleted file mode 100644 index 41908b596..000000000 --- a/compose/neurosynth-frontend/src/components/Search/SearchBar/SearchBarAccessories/SearchSelectSortChip.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import { ArrowDropDown } from '@mui/icons-material'; -import { Chip, MenuItem, MenuList } from '@mui/material'; -import { Box } from '@mui/system'; -import NeurosynthPopper from 'components/NeurosynthPopper/NeurosynthPopper'; -import { SortBy } from 'pages/Studies/StudiesPage/models'; -import { useRef, useState } from 'react'; - -const SearchSelectSortChip: React.FC<{ - onSelectSort: (searchBy: SortBy) => void; - onSelectDescOrder: (descOrder: boolean) => void; - chipLabel: string; - descOrderChipLabel: string; -}> = (props) => { - const sortByRef = useRef(null); - const descOrderRef = useRef(null); - const [sortByPopperIsOpen, setSortByPopperIsOpen] = useState(false); - const [descOrderPopperIsOpen, setDescOrderPopperIsOpen] = useState(false); - - const handleSelectSortBy = (sortBy: SortBy) => { - props.onSelectSort(sortBy); - setSortByPopperIsOpen(false); - }; - - const handleSelectIsDescOrder = (isDescOrder: boolean) => { - props.onSelectDescOrder(isDescOrder); - setDescOrderPopperIsOpen(false); - }; - - // get string values of the ENUM instead of the enum keys - const sortByList = Object.keys(SortBy).map((sortBy) => SortBy[sortBy as keyof typeof SortBy]); - - return ( - <> - setSortByPopperIsOpen(false)} - open={sortByPopperIsOpen} - > - - - {sortByList.map((sortBy) => ( - handleSelectSortBy(sortBy as SortBy)} - key={sortBy} - value={sortBy} - > - {sortBy} - - ))} - - - - setSortByPopperIsOpen(true)} - icon={} - sx={{ - borderTopRightRadius: 0, - borderBottomRightRadius: 0, - width: '160px', - marginLeft: '5px', - }} - label={props.chipLabel} - /> - setDescOrderPopperIsOpen(false)} - open={descOrderPopperIsOpen} - > - - - handleSelectIsDescOrder(false)}> - Ascending Order - - handleSelectIsDescOrder(true)}> - Descending Order - - - - - setDescOrderPopperIsOpen(true)} - icon={} - sx={{ - borderTopLeftRadius: 0, - borderBottomLeftRadius: 0, - borderLeft: 0, - width: '80px', - }} - label={props.descOrderChipLabel} - /> - - ); -}; - -export default SearchSelectSortChip; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useCreateAnalysis.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useCreateAnalysis.tsx deleted file mode 100644 index e39fb2a32..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useCreateAnalysis.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { AxiosResponse, AxiosError } from 'axios'; -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import { AnalysisRequest, AnalysisReturn } from 'neurostore-typescript-sdk'; -import API from 'utils/api'; - -const useCreateAnalysis = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - return useMutation, AxiosError, AnalysisRequest, unknown>( - (analysis) => API.NeurostoreServices.AnalysesService.analysesPost(analysis), - { - onSuccess: () => { - // update study - queryClient.invalidateQueries('studies'); - enqueueSnackbar('new analysis created successfully', { variant: 'success' }); - }, - onError: () => { - enqueueSnackbar('there was an error creating the analysis', { variant: 'error' }); - }, - } - ); -}; - -export default useCreateAnalysis; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useCreateAnnotation.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useCreateAnnotation.tsx deleted file mode 100644 index 6a072f509..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useCreateAnnotation.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import API, { NeurostoreAnnotation } from 'utils/api'; - -const useCreateAnnotation = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - return useMutation< - AxiosResponse, - AxiosError, - { - source?: - | 'neurostore' - | 'neurovault' - | 'pubmed' - | 'neurosynth' - | 'neuroquery' - | undefined; - sourceId?: string; - annotation: Partial; - }, - unknown - >( - (args) => - API.NeurostoreServices.AnnotationsService.annotationsPost( - args.source, - args.sourceId, - args.annotation - ), - { - onSuccess: () => { - queryClient.invalidateQueries('annotations'); - }, - onError: () => { - enqueueSnackbar('there was an error creating the annotation', { variant: 'error' }); - }, - } - ); -}; - -export default useCreateAnnotation; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useCreateCondition.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useCreateCondition.tsx deleted file mode 100644 index c32bd21d7..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useCreateCondition.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { ConditionRequest, ConditionReturn } from 'neurostore-typescript-sdk'; -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useCreateCondition = () => { - const queryClient = useQueryClient(); - return useMutation, AxiosError, ConditionRequest, unknown>( - (condition) => API.NeurostoreServices.ConditionsService.conditionsPost(condition), - { - onSuccess: () => { - queryClient.invalidateQueries('conditions'); - }, - } - ); -}; - -export default useCreateCondition; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useCreatePoint.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useCreatePoint.tsx deleted file mode 100644 index fb30a4f0f..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useCreatePoint.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useCreatePoint = () => { - const queryClient = useQueryClient(); - return useMutation( - (analysisId: string) => - API.NeurostoreServices.PointsService.pointsPost({ - coordinates: [0, 0, 0], - analysis: analysisId, - }), - { - onSuccess: () => { - // we need to send a request to retrieve studies again with its associated analyses and points - queryClient.invalidateQueries('studies'); - }, - } - ); -}; - -export default useCreatePoint; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useDeleteAnalysis.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useDeleteAnalysis.tsx deleted file mode 100644 index 33f1bfc4a..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useDeleteAnalysis.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useDeleteAnalysis = () => { - const queryClient = useQueryClient(); - return useMutation( - (id: string) => API.NeurostoreServices.AnalysesService.analysesIdDelete(id), - { - onSuccess: () => { - queryClient.invalidateQueries('studies'); - }, - } - ); -}; - -export default useDeleteAnalysis; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useDeleteAnnotation.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useDeleteAnnotation.tsx deleted file mode 100644 index 2451ff575..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useDeleteAnnotation.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useDeleteAnnotation = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - return useMutation( - (id: string) => API.NeurostoreServices.AnnotationsService.annotationsIdDelete(id), - { - onSuccess: () => { - queryClient.invalidateQueries('studies'); - enqueueSnackbar('Annotation deleted successfully', { variant: 'success' }); - }, - onError: () => { - enqueueSnackbar('there was an error deleting the annotation', { variant: 'error' }); - }, - } - ); -}; - -export default useDeleteAnnotation; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useDeletePoint.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useDeletePoint.tsx deleted file mode 100644 index f9da1749c..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useDeletePoint.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useDeletePoint = () => { - const queryClient = useQueryClient(); - return useMutation((id: string) => API.NeurostoreServices.PointsService.pointsIdDelete(id), { - onSuccess: () => { - // we need to send a request to retrieve studies again with its associated analyses and points - queryClient.invalidateQueries('studies'); - }, - }); -}; - -export default useDeletePoint; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useGetAnalysisById.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useGetAnalysisById.tsx deleted file mode 100644 index 8396f847d..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useGetAnalysisById.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { AxiosResponse } from 'axios'; -import { AnalysisReturn } from 'neurostore-typescript-sdk'; -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetAnalysisById = (analysisId: string | undefined) => { - return useQuery( - ['analyses', analysisId], - () => API.NeurostoreServices.AnalysesService.analysesIdGet(analysisId || '', true), - { - select: (res: AxiosResponse) => res.data, - enabled: !!analysisId, - } - ); -}; - -export default useGetAnalysisById; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useGetAnnotationById.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useGetAnnotationById.tsx deleted file mode 100644 index dc2c96096..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useGetAnnotationById.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { AxiosResponse } from 'axios'; -import { useQuery } from 'react-query'; -import API, { NeurostoreAnnotation } from '../../utils/api'; - -const useGetAnnotationById = (annotationId: string | undefined | null) => { - return useQuery( - ['annotation', annotationId], - () => API.NeurostoreServices.AnnotationsService.annotationsIdGet(annotationId || ''), - { - select: (res: AxiosResponse) => res.data, - enabled: !!annotationId, - } - ); -}; - -export default useGetAnnotationById; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useGetAnnotationsByStudysetId.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useGetAnnotationsByStudysetId.tsx deleted file mode 100644 index e132356ba..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useGetAnnotationsByStudysetId.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { useQuery } from 'react-query'; -import API, { NeurostoreAnnotation } from 'utils/api'; - -const useGetAnnotationsByStudysetId = (studyId: string | undefined | null) => { - return useQuery( - ['annotations', studyId], - () => API.NeurostoreServices.AnnotationsService.annotationsGet(studyId || ''), - { - select: (res) => res.data.results as NeurostoreAnnotation[], - enabled: !!studyId, - } - ); -}; - -export default useGetAnnotationsByStudysetId; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useGetConditions.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useGetConditions.tsx deleted file mode 100644 index 3219cb44b..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useGetConditions.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetConditions = () => { - return useQuery('conditions', () => API.NeurostoreServices.ConditionsService.conditionsGet(), { - select: (res) => res.data.results, - staleTime: 5000, - }); -}; - -export default useGetConditions; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useUpdateAnalysis.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useUpdateAnalysis.tsx deleted file mode 100644 index 2d815a963..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useUpdateAnalysis.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { useMutation, useQueryClient } from 'react-query'; -import { AnalysisRequest, AnalysisReturn } from 'neurostore-typescript-sdk'; -import API from 'utils/api'; -import { useSnackbar } from 'notistack'; - -const useUpdateAnalysis = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - - return useMutation< - AxiosResponse, - AxiosError, - { - analysisId: string; - analysis: AnalysisRequest; - }, - unknown - >( - (args) => - API.NeurostoreServices.AnalysesService.analysesIdPut(args.analysisId, args.analysis), - { - onSuccess: (res) => { - queryClient.invalidateQueries('studies'); - }, - onError: () => { - enqueueSnackbar('there was an error updating the analysis', { variant: 'error' }); - }, - } - ); -}; - -export default useUpdateAnalysis; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useUpdateAnnotationById.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useUpdateAnnotationById.tsx deleted file mode 100644 index bd49f7ed0..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useUpdateAnnotationById.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { useMutation, useQueryClient } from 'react-query'; -import API, { NeurostoreAnnotation } from 'utils/api'; -import { useSnackbar } from 'notistack'; - -const useUpdateAnnotationById = (annotationId: string | undefined | null) => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - - return useMutation< - AxiosResponse, - AxiosError, - { - argAnnotationId: string; - annotation: NeurostoreAnnotation; - }, - unknown - >( - (update) => - API.NeurostoreServices.AnnotationsService.annotationsIdPut( - update.argAnnotationId, - update.annotation - ), - { - onSuccess: (res) => { - queryClient.invalidateQueries(['annotation', annotationId]); - enqueueSnackbar('annotation updated successfully', { variant: 'success' }); - }, - onError: () => { - enqueueSnackbar('there was an error updating the annotation', { variant: 'error' }); - }, - } - ); -}; - -export default useUpdateAnnotationById; diff --git a/compose/neurosynth-frontend/src/hooks/analyses/useUpdatePoint.tsx b/compose/neurosynth-frontend/src/hooks/analyses/useUpdatePoint.tsx deleted file mode 100644 index f4fb6641f..000000000 --- a/compose/neurosynth-frontend/src/hooks/analyses/useUpdatePoint.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { AxiosResponse, AxiosError } from 'axios'; -import { PointRequest, PointReturn } from 'neurostore-typescript-sdk'; -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useUpdatePoint = () => { - const queryClient = useQueryClient(); - return useMutation< - AxiosResponse, - AxiosError, - { - pointId: string; - point: PointRequest; - }, - unknown - >((args) => API.NeurostoreServices.PointsService.pointsIdPut(args.pointId, args.point), { - onSuccess: () => { - queryClient.invalidateQueries('studies'); - }, - }); -}; - -export default useUpdatePoint; diff --git a/compose/neurosynth-frontend/src/hooks/external/useGetFullText.tsx b/compose/neurosynth-frontend/src/hooks/external/useGetFullText.tsx deleted file mode 100644 index 8573e8e71..000000000 --- a/compose/neurosynth-frontend/src/hooks/external/useGetFullText.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import axios from 'axios'; -import { AxiosResponse } from 'axios'; -import { useQuery } from 'react-query'; - -interface ISemanticScholarResponse { - data: { - externalIds: { - CorpusId?: number; - DOI?: string; - PubMed?: string; - }[]; - isOpenAccess: boolean; - openAccessPdf: null | { status: string; url: string }; - paperId: string; - }[]; -} - -const useGetFullText = (paperTitle?: string) => { - return useQuery( - [paperTitle], - () => - axios.get( - `https://api.semanticscholar.org/graph/v1/paper/search?query=${paperTitle}&fields=isOpenAccess,openAccessPdf,externalIds&limit=1` - ), - { - refetchOnWindowFocus: false, - retry: 1, - cacheTime: 120 * (60 * 1000), // 120 minutes - staleTime: 100 * (60 * 1000), // 120 minutes - select: (res: AxiosResponse) => { - const paperList = res.data.data || []; - - if ( - paperList.length === 0 || - !paperList[0].isOpenAccess || - paperList[0].openAccessPdf === null || - !paperList[0].openAccessPdf?.url - ) { - return ''; - } else { - return paperList[0].openAccessPdf.url; - } - }, - enabled: !!paperTitle, - } - ); -}; - -export default useGetFullText; diff --git a/compose/neurosynth-frontend/src/hooks/external/useGetPubMedIds.tsx b/compose/neurosynth-frontend/src/hooks/external/useGetPubMedIds.tsx deleted file mode 100644 index 55e079740..000000000 --- a/compose/neurosynth-frontend/src/hooks/external/useGetPubMedIds.tsx +++ /dev/null @@ -1,417 +0,0 @@ -import axios, { AxiosError, AxiosResponse } from 'axios'; -import { useQueries, UseQueryOptions } from 'react-query'; -import * as fxparser from 'fast-xml-parser'; -const { XMLParser } = fxparser; - -type PubMedYN = 'Y' | 'N'; - -interface IPubMedArticleId { - '#text'?: number | string; - '@_IdType'?: 'pubmed' | 'doi' | 'pii' | 'pmc'; -} - -interface IPubmedAbstractText { - '@_Label'?: string; - '#text'?: string; - i?: string | string[]; -} - -interface IPubmedAuthor { - '@_CompleteYN'?: PubMedYN; - AffiliationInfo?: { - Affiliation?: string; - }; - ForeName?: string; - Initials?: string; - LastName?: string; -} - -interface IPubmedKeyword { - '#text'?: string; - '@_MajorTopicYN'?: PubMedYN; -} - -interface IPubmedTitle { - '#text'?: string; - i: string; -} - -interface IPubMedArticle { - MedlineCitation?: { - '@_IndexingMethod'?: string; - '@_Owner'?: string; - '@_Status'?: string; - Article?: { - '@_PubModel'?: string; - Abstract?: { - AbstractText?: string[] | IPubmedAbstractText[]; - }; - ArticleDate?: { - '@_DateType'?: string; - Year?: number; - Month?: number; - Day?: number; - }; - ArticleTitle?: string | IPubmedTitle; - AuthorList?: { - '@_CompleteYN'?: PubMedYN; - Author?: IPubmedAuthor[]; - }; - ELocationID?: { - '#text'?: string; - '@_EidType'?: string; - '@_ValidYN'?: PubMedYN; - }; - Journal?: { - ISOAbbreviation?: string; - ISSN?: { - '#text'?: string; - '@_IssnType'?: string; - }; - JournalIssue?: { - '@_CitedMedium'?: string; - Issue?: number; - PubDate?: { - Year?: number; - Month?: string; - }; - Volume?: number; - }; - Title?: string; - }; - Language?: string; - Pagination?: { - MedlinePgn?: string; - }; - PublicationTypeList?: { - PublicationType?: { - '#text'?: string; - '@_UI'?: string; - }[]; - }; - }; - CitationSubset?: string; - DateCompleted?: { - Year?: number; - Month?: number; - Day?: number; - }; - DateRevised?: { - Year?: number; - Month?: number; - Day?: number; - }; - KeywordList?: { - '@_Owner'?: string; - Keyword?: string[] | IPubmedKeyword[]; - }; - MedlineJournalInfo: { - Country?: string; - ISSNLinking?: string; - MedlineTA?: string; - NlmUniqueID?: number; - }; - MeshHeadingList?: { - MeshHeading?: { - DescriptorName?: { - '#text'?: string; - '@_MajorTopicYN'?: PubMedYN; - '@_UI'?: string; - }; - QualifierName?: { - '#text'?: string; - '@_MajorTopicYN'?: PubMedYN; - '@_UI'?: string; - }[]; - }[]; - }; - PMID?: { - '#text'?: number; - '@_Version'?: string; - }; - }; - PubmedData?: { - ArticleIdList?: { - ArticleId?: IPubMedArticleId[]; - }; - History: { - PubMedPubDate: { - '@_PubStatus': string; - Year?: number; - Month?: number; - Day?: number; - }[]; - }; - PublicationStatus?: string; - ReferenceList?: { - Reference?: { - ArticleIdList?: { - ArticleId?: { - '#text': number; - '@_IdType': string; - }; - }; - Citation?: string; - }[]; - }; - }; -} - -interface IArticleListFromPubmed { - '?xml': { - '@_version': string; - }; - PubmedArticleSet?: { - PubmedArticle?: IPubMedArticle[]; - }; -} - -export interface INeurosynthParsedPubmedArticle { - title: string; - keywords: string[]; - authors: { - ForeName: string; - Initials: string; - LastName: string; - }[]; - abstractText: string; - DOI: string; - PMID: string; - articleYear: string | undefined; - journal: { - title: string; - volume: number; - issue: number; - date: { - year: string; - month: string; - }; - }; - articleLink: string; -} - -const extractAuthorsHelper = (authors: IPubmedAuthor[] | undefined): IPubmedAuthor[] => { - const authorList = authors || []; - return authorList.map((author) => ({ - ForeName: author?.ForeName || '', - Initials: author?.Initials || '', - LastName: author?.LastName || '', - })); -}; - -const extractDOIHelper = (articleIds: IPubMedArticleId[] | undefined): string => { - const articleIdList = articleIds || []; - - const doiArticleId = articleIdList.find( - (article) => (article['@_IdType'] || '').toLocaleLowerCase() === 'doi' - ); - const extractedDOI = doiArticleId?.['#text']; - if (!doiArticleId || !extractedDOI) return ''; - - return typeof extractedDOI === 'number' ? extractedDOI.toString() : extractedDOI; -}; - -const extractPMIDHelper = ( - medlineCitationPmid: string | undefined | number, - articleIds: IPubMedArticleId[] | undefined -): string => { - if (medlineCitationPmid) return medlineCitationPmid.toString(); - - const articleIdList = articleIds || []; - - const pmidArticleId = articleIdList.find( - (article) => (article['@_IdType'] || '').toLocaleLowerCase() === 'pubmed' - ); - const extractedPMID = pmidArticleId?.['#text']; - if (!pmidArticleId || !extractedPMID) return ''; - - return typeof extractedPMID === 'number' ? extractedPMID.toString() : extractedPMID; -}; - -const extractAbstractHelper = ( - abstractTextSections: string[] | IPubmedAbstractText[] | undefined -): string => { - if (!abstractTextSections || abstractTextSections.length === 0) return ''; - - if (typeof abstractTextSections[0] === 'string') { - return (abstractTextSections as string[]).reduce((acc, curr) => `${acc}\n${curr}`, ''); - } else { - return (abstractTextSections as IPubmedAbstractText[]).reduce( - (acc, curr) => `${acc}${curr['@_Label'] || ''}\n${curr['#text'] || ''}\n`, - '' - ); - } -}; - -const extractKeywordsHelper = (keywords: string[] | IPubmedKeyword[] | undefined): string[] => { - if (!keywords || keywords.length === 0) return []; - - if (typeof keywords[0] === 'string') { - return keywords as string[]; - } else { - return (keywords as IPubmedKeyword[]).map((x) => x?.['#text'] || '') as string[]; - } -}; - -const extractTitleHelper = (title: string | IPubmedTitle | undefined): string => { - if (typeof title === 'string') { - return title; - } else if (typeof title === 'object') { - return title['#text'] || ''; - } else { - return ''; - } -}; - -// we take advantage of the HTML Entities already encoded to convert: https://www.w3.org/TR/html4/sgml/entities.html -const hexCodeToHTMLEntity = (hexCode: string): string => { - const tempElement = document.createElement('div'); - tempElement.innerHTML = hexCode; - return tempElement.childNodes[0].nodeValue || ''; -}; - -// Documentation: https://dataguide.nlm.nih.gov/eutilities/utilities.html#efetch -const EFETCH_URL = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi'; - -export const PUBMED_ARTICLE_URL_PREFIX = 'https://pubmed.ncbi.nlm.nih.gov/'; - -const parser = new XMLParser({ - ignoreAttributes: false, - ignoreDeclaration: true, - tagValueProcessor(tagName, tagValue, jPath, hasAttributes, isLeafNode) { - // by default, pubmed gives us hex codes in the XML for special characters. We need to modify them here - if ( - isLeafNode && - (tagName === 'LastName' || - tagName === 'ForeName' || - tagName === 'Initials' || - tagName === 'Keyword' || - tagName === 'ArticleTitle' || - tagName === 'Title' || // journal title - tagName === 'AbstractText') - ) { - return hexCodeToHTMLEntity(tagValue); - } - }, - isArray(tagName, jPath, isLeafNode, isAttribute) { - return [ - `PubmedArticleSet.PubmedArticle.MedlineCitation.Article.AuthorList.Author`, - `PubmedArticleSet.PubmedArticle`, - `PubmedArticleSet.PubmedArticle.PubmedData.ArticleIdList.ArticleId`, - `PubmedArticleSet.PubmedArticle.MedlineCitation.Article.Abstract.AbstractText`, - `PubmedArticleSet.PubmedArticle.MedlineCitation.KeywordList.Keyword`, - ].includes(jPath); - }, -}); - -const getQueryFn = (ids: string, startIndex: number) => - axios.post( - `${EFETCH_URL}`, - `db=pubmed&rettype=abstract&retmode=xml&retmax=500&retstart=${startIndex}&id=${ids}`, - { - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', - }, - } - ); - -const splitIdsIntoSeparateRequests = ( - pubmedIds: string[] -): UseQueryOptions< - AxiosResponse, - AxiosError, - INeurosynthParsedPubmedArticle[], - ['pubmed', string, number] ->[] => { - if (pubmedIds.length > 1500 || pubmedIds.length === 0) return []; - - // adds a comma in between each id except for the last one - const appendedIdStr = pubmedIds.reduce( - (prev, curr, index, arr) => `${prev}${curr}${index === arr.length - 1 ? '' : ','}`, - '' - ); - - const queries: UseQueryOptions< - AxiosResponse, - AxiosError, - INeurosynthParsedPubmedArticle[], - ['pubmed', string, number] - >[] = []; - - for (let i = 0; i < pubmedIds.length; i += 500) { - queries.push({ - queryKey: ['pubmed', appendedIdStr, i], - queryFn: ({ queryKey }) => getQueryFn(queryKey[1], queryKey[2]), - enabled: pubmedIds.length > 0, - select: (res) => { - if (!res.data) return []; - const withoutItalics = (res.data as string).replaceAll(/<\/?i>/g, ''); - const parsedJSON = parser.parse(withoutItalics) as IArticleListFromPubmed; - - if (!parsedJSON?.PubmedArticleSet?.PubmedArticle) return []; - - const articleList = parsedJSON.PubmedArticleSet.PubmedArticle; - - return articleList.map((article) => { - const pubmedArticleRef = article?.MedlineCitation?.Article; - const pubmedArticleIdRef = article?.PubmedData?.ArticleIdList; - - const title = extractTitleHelper(pubmedArticleRef?.ArticleTitle); - const authors = extractAuthorsHelper(pubmedArticleRef?.AuthorList?.Author); - const doi = extractDOIHelper(pubmedArticleIdRef?.ArticleId); - const pmid = extractPMIDHelper( - article?.MedlineCitation?.PMID?.['#text'], - pubmedArticleIdRef?.ArticleId - ); - const abstract = extractAbstractHelper( - pubmedArticleRef?.Abstract?.AbstractText - ); - const year = ( - pubmedArticleRef?.Journal?.JournalIssue?.PubDate?.Year || - pubmedArticleRef?.ArticleDate?.Year || - 0 - )?.toString(); - const keywords = extractKeywordsHelper( - article?.MedlineCitation?.KeywordList?.Keyword - ); - - return { - title: title, - authors: authors, - abstractText: abstract, - DOI: doi, - keywords: keywords, - PMID: pmid, - articleYear: year, - journal: { - title: pubmedArticleRef?.Journal?.Title || '', - volume: pubmedArticleRef?.Journal?.JournalIssue?.Volume || 0, - issue: pubmedArticleRef?.Journal?.JournalIssue?.Issue || 0, - date: { - year: ( - pubmedArticleRef?.Journal?.JournalIssue?.PubDate?.Year || 0 - ).toString(), - month: - pubmedArticleRef?.Journal?.JournalIssue?.PubDate?.Month || '', - }, - }, - articleLink: `${PUBMED_ARTICLE_URL_PREFIX}${pmid}`, - } as INeurosynthParsedPubmedArticle; - }); - }, - }); - } - - return queries; -}; - -const useGetPubmedIDs = (pubmedIds: string[]) => { - // the pubmed API only supports 500 ids per request and only 3 requests per second. - // TODO: for those with a valid API key, this increases to 10 requests per second. We should - // allow the user to optionally include an API key. - const requests = splitIdsIntoSeparateRequests(pubmedIds); - - return useQueries(requests); -}; - -export default useGetPubmedIDs; diff --git a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useCreateAlgorithmSpecification.tsx b/compose/neurosynth-frontend/src/hooks/metaAnalyses/useCreateAlgorithmSpecification.tsx deleted file mode 100644 index 5fd0ab020..000000000 --- a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useCreateAlgorithmSpecification.tsx +++ /dev/null @@ -1,141 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { IDynamicValueType } from 'components/MetaAnalysisConfigComponents'; -import { IAutocompleteObject } from 'components/NeurosynthAutocomplete/NeurosynthAutocomplete'; -import { - AnnotationPostBody, - MetaAnalysisPostBody, - MetaAnalysisReturn, - SpecificationPostBody, - SpecificationReturn, - StudysetPostBody, - StudysetReturn, -} from 'neurosynth-compose-typescript-sdk'; -import { useMutation } from 'react-query'; -import API, { NeurostoreAnnotation } from 'utils/api'; - -export enum EAnalysisType { - CBMA = 'CBMA', - IBMA = 'IBMA', -} - -const useCreateAlgorithmSpecification = () => { - const createSpecificationMutation = useMutation< - AxiosResponse, - AxiosError, - SpecificationPostBody, - unknown - >((spec: SpecificationPostBody) => - API.NeurosynthServices.SpecificationsService.specificationsPost(spec) - ); - const createSynthStudysetMutation = useMutation< - AxiosResponse, - AxiosError, - StudysetPostBody, - unknown - >((studyset) => API.NeurosynthServices.StudysetsService.studysetsPost(studyset)); - const createSynthAnnotationMutation = useMutation< - AxiosResponse, - AxiosError, - AnnotationPostBody, - unknown - >((annotation) => API.NeurosynthServices.AnnotationsService.annotationsPost(annotation)); - const createMetaAnalysisMutation = useMutation< - AxiosResponse, - AxiosError, - MetaAnalysisPostBody, - unknown - >((metaAnalysis: MetaAnalysisPostBody) => - API.NeurosynthServices.MetaAnalysisService.metaAnalysesPost(metaAnalysis) - ); - - const createMetaAnalysis = async ( - projectId: string | undefined, - analysisType: EAnalysisType | undefined, - estimator: IAutocompleteObject | undefined | null, - corrector: IAutocompleteObject | undefined | null, - studysetId: string | undefined | null, - annotationId: string | undefined | null, - inclusionColumn: string | undefined | null, - metaAnalysisName: string | undefined, - metaAnalysisDescription: string | undefined, - estimatorArgs: IDynamicValueType | undefined, - correctorArgs: IDynamicValueType | undefined - ) => { - try { - if (!projectId) throw new Error('no id from project'); - if (!studysetId) throw new Error('no id from studyset'); - if (!annotationId) throw new Error('no id from annotation'); - - const createdSpec = await createSpecificationMutation.mutateAsync({ - type: analysisType as EAnalysisType, - estimator: { - type: estimator?.label, - args: estimatorArgs, - }, - mask: '', // TODO: handle these cases - contrast: '', // TODO: handle these cases - transformer: '', // TODO: handle these cases - corrector: corrector - ? { - type: corrector?.label, - args: correctorArgs, - } - : null, - filter: inclusionColumn, - }); - if (!createdSpec.data.id) throw new Error('no id from created spec'); - - const createdSynthStudyset = await createSynthStudysetMutation.mutateAsync({ - neurostore_id: studysetId, - }); - if (!createdSynthStudyset.data.id) throw new Error('no id from created synth studyset'); - - const createdSynthAnnotation = await createSynthAnnotationMutation.mutateAsync({ - neurostore_id: annotationId, - cached_studyset_id: createdSynthStudyset.data.id, - }); - if (!createdSynthAnnotation.data.id) - throw new Error('no id from created synth annotation'); - - const createdMetaAnalysis = await createMetaAnalysisMutation.mutateAsync({ - name: metaAnalysisName, - description: metaAnalysisDescription, - cached_studyset_id: createdSynthStudyset.data.id, - cached_annotation_id: createdSynthAnnotation.data.id, - specification: createdSpec.data.id, - project: projectId, - }); - - return createdMetaAnalysis; - } catch (e) { - return Promise.reject(e); - } - }; - - const isLoading = - createSpecificationMutation.isLoading || - createSynthStudysetMutation.isLoading || - createSynthAnnotationMutation.isLoading || - createMetaAnalysisMutation.isLoading; - - const isError = - createSpecificationMutation.isError || - createSynthStudysetMutation.isError || - createSynthAnnotationMutation.isError || - createMetaAnalysisMutation.isError; - - const error = - createSpecificationMutation.error || - createSynthStudysetMutation.error || - createSynthAnnotationMutation.error || - createMetaAnalysisMutation.error; - - return { - error, - isLoading, - isError, - createMetaAnalysis, - }; -}; - -export default useCreateAlgorithmSpecification; diff --git a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysesByProjectId.tsx b/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysesByProjectId.tsx deleted file mode 100644 index 0b14d38d4..000000000 --- a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysesByProjectId.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetMetaAnalysesByProjectId = (projectId?: string) => { - return useQuery( - ['meta-analyses', projectId], - () => API.NeurosynthServices.MetaAnalysisService.metaAnalysesGet(false), - { - select: (axiosResponse) => { - const res = axiosResponse.data.results || []; - return projectId ? res.filter((x) => x.project === projectId) : res; - }, - } - ); -}; - -export default useGetMetaAnalysesByProjectId; diff --git a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysisById.tsx b/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysisById.tsx deleted file mode 100644 index d4234a739..000000000 --- a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysisById.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetMetaAnalysisById = (metaAnalysisId: string | undefined) => { - const query = useQuery( - ['meta-analyses', metaAnalysisId], - () => - API.NeurosynthServices.MetaAnalysisService.metaAnalysesIdGet( - metaAnalysisId || '', - true - ), - { - enabled: !!metaAnalysisId, - select: (data) => data.data, - } - ); - return query; -}; - -export default useGetMetaAnalysisById; diff --git a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysisResultById.tsx b/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysisResultById.tsx deleted file mode 100644 index e9779ce6f..000000000 --- a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetMetaAnalysisResultById.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { AxiosResponse } from 'axios'; -import { ResultReturn } from 'neurosynth-compose-typescript-sdk'; -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetMetaAnalysisResultById = (metaAnalysisResultId: string | undefined | null) => { - return useQuery( - ['meta-analyses-results', metaAnalysisResultId], - () => - API.NeurosynthServices.MetaAnalysisService.metaAnalysisResultsIdGet( - metaAnalysisResultId || '' - ), - { - select: (res: AxiosResponse) => res.data, - enabled: !!metaAnalysisResultId, - } - ); -}; - -export default useGetMetaAnalysisResultById; diff --git a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetSpecificationById.tsx b/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetSpecificationById.tsx deleted file mode 100644 index 959ac3b9d..000000000 --- a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetSpecificationById.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetSpecificationById = (specificationId?: string) => { - return useQuery( - ['specifications', specificationId], - () => - API.NeurosynthServices.SpecificationsService.specificationsIdGet(specificationId || ''), - { - select: (res) => { - return res.data; - }, - enabled: !!specificationId, - } - ); -}; - -export default useGetSpecificationById; diff --git a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useUpdateMetaAnalysis.tsx b/compose/neurosynth-frontend/src/hooks/metaAnalyses/useUpdateMetaAnalysis.tsx deleted file mode 100644 index 809098c3e..000000000 --- a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useUpdateMetaAnalysis.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import { MetaAnalysisPostBody, MetaAnalysisReturn } from 'neurosynth-compose-typescript-sdk'; -import API from 'utils/api'; - -const useUpdateMetaAnalysis = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - const updateMetaAnalysisMutation = useMutation< - AxiosResponse, - AxiosError, - { - metaAnalysisId: string; - metaAnalysis: Partial; - }, - unknown - >( - (update) => - API.NeurosynthServices.MetaAnalysisService.metaAnalysesIdPut( - update.metaAnalysisId, - update.metaAnalysis - ), - { - onSuccess: () => { - queryClient.invalidateQueries('meta-analyses'); - }, - onError: () => { - enqueueSnackbar('there was an error updating the meta-analysis', { - variant: 'error', - }); - }, - } - ); - - return updateMetaAnalysisMutation; -}; - -export default useUpdateMetaAnalysis; diff --git a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useUpdateSpecification.tsx b/compose/neurosynth-frontend/src/hooks/metaAnalyses/useUpdateSpecification.tsx deleted file mode 100644 index f3d3b5952..000000000 --- a/compose/neurosynth-frontend/src/hooks/metaAnalyses/useUpdateSpecification.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { SpecificationPostBody, SpecificationReturn } from 'neurosynth-compose-typescript-sdk'; -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useUpdateSpecification = () => { - const { enqueueSnackbar } = useSnackbar(); - const queryClient = useQueryClient(); - return useMutation< - AxiosResponse, - AxiosError, - { - specificationId: string; - specification: SpecificationPostBody; - }, - unknown - >( - (args) => - API.NeurosynthServices.SpecificationsService.specificationsIdPut( - args.specificationId, - args.specification - ), - { - onSuccess: () => { - queryClient.invalidateQueries('specifications'); - enqueueSnackbar('specification updated successfully', { variant: 'success' }); - }, - onError: () => { - enqueueSnackbar('there was an error updating the specification', { - variant: 'error', - }); - }, - } - ); -}; - -export default useUpdateSpecification; diff --git a/compose/neurosynth-frontend/src/hooks/projects/useCreateProject.tsx b/compose/neurosynth-frontend/src/hooks/projects/useCreateProject.tsx deleted file mode 100644 index 2207bb468..000000000 --- a/compose/neurosynth-frontend/src/hooks/projects/useCreateProject.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { Project, ProjectReturn } from 'neurosynth-compose-typescript-sdk'; -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useCreateProject = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - return useMutation, AxiosError, Project, unknown>( - (project) => API.NeurosynthServices.ProjectsService.projectsPost(project), - { - onSuccess: () => { - // update queries - queryClient.invalidateQueries('projects'); - enqueueSnackbar('Created new project successfully', { variant: 'success' }); - }, - onError: () => { - enqueueSnackbar('There was an error creating the project', { variant: 'error' }); - }, - mutationKey: 'create-project', - } - ); -}; - -export default useCreateProject; diff --git a/compose/neurosynth-frontend/src/hooks/projects/useGetProjectById.tsx b/compose/neurosynth-frontend/src/hooks/projects/useGetProjectById.tsx deleted file mode 100644 index 9e616bc47..000000000 --- a/compose/neurosynth-frontend/src/hooks/projects/useGetProjectById.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { useQuery } from 'react-query'; -import API from 'utils/api'; -import { INeurosynthProjectReturn } from './useGetProjects'; - -const useGetProjectById = (projectId: string | undefined) => { - return useQuery( - ['projects', projectId], - () => - API.NeurosynthServices.ProjectsService.projectsIdGet(projectId || '').then((res) => { - return res; - }), - { - select: (axiosResponse) => axiosResponse.data as INeurosynthProjectReturn, - enabled: !!projectId, - } - ); -}; - -export default useGetProjectById; diff --git a/compose/neurosynth-frontend/src/hooks/projects/useGetProjects.tsx b/compose/neurosynth-frontend/src/hooks/projects/useGetProjects.tsx deleted file mode 100644 index 103db60a4..000000000 --- a/compose/neurosynth-frontend/src/hooks/projects/useGetProjects.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import { ICurationColumn } from 'components/CurationComponents/CurationColumn/CurationColumn'; -import { Project, ProjectReturn } from 'neurosynth-compose-typescript-sdk'; -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -export interface ITag { - label: string; - id: string; - isExclusionTag: boolean; - isAssignable: boolean; // whether or not this tag can be attached to a study -} - -export interface ISource { - label: string; - id: string; -} - -export interface IPRISMAConfig { - isPrisma: boolean; - identification: { - exclusionTags: ITag[]; - }; - screening: { - exclusionTags: ITag[]; - }; - eligibility: { - exclusionTags: ITag[]; - }; -} - -export interface ICurationMetadata { - columns: ICurationColumn[]; - prismaConfig: IPRISMAConfig; - infoTags: ITag[]; - exclusionTags: ITag[]; // for non prisma workflows, we ignore prismaConfig and use exclusionTags. This property will not be used for the prisma workflow. - identificationSources: ISource[]; -} - -export interface IStudyExtractionStatus { - status: 'COMPLETE' | 'SAVEFORLATER'; - id: string; -} - -export interface IExtractionMetadata { - studyStatusList: IStudyExtractionStatus[]; - annotationId: string | undefined; - studysetId: string | undefined; -} - -export interface IMetaAnalysisMetadata { - canEditMetaAnalyses: boolean; -} - -export interface IProvenance { - curationMetadata: ICurationMetadata; - extractionMetadata: IExtractionMetadata; - metaAnalysisMetadata: IMetaAnalysisMetadata; -} - -// define this interface to overwrite provenance type -export interface INeurosynthProject extends Omit { - provenance: IProvenance; -} - -// define this interface to overwrite provenance type -export interface INeurosynthProjectReturn extends Omit { - provenance: IProvenance; -} - -export const indexToPRISMAMapping = ( - index: number -): keyof Omit | undefined => { - switch (index) { - case 0: - return 'identification'; - case 1: - return 'screening'; - case 2: - return 'eligibility'; - default: - return undefined; - } -}; - -const useGetProjects = (authenticatedUser?: string) => { - return useQuery( - ['projects', authenticatedUser], - () => API.NeurosynthServices.ProjectsService.projectsGet(), - { - select: (axiosResponse) => - (axiosResponse.data.results as INeurosynthProjectReturn[]) || [], - enabled: !!authenticatedUser, - } - ); -}; - -export default useGetProjects; diff --git a/compose/neurosynth-frontend/src/hooks/projects/useUpdateProject.tsx b/compose/neurosynth-frontend/src/hooks/projects/useUpdateProject.tsx deleted file mode 100644 index 2010c5388..000000000 --- a/compose/neurosynth-frontend/src/hooks/projects/useUpdateProject.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { ProjectReturn } from 'neurosynth-compose-typescript-sdk'; -import { useMutation } from 'react-query'; -import API from 'utils/api'; -import { INeurosynthProject } from './useGetProjects'; - -const useUpdateProject = () => { - return useMutation< - AxiosResponse, - AxiosError, - { projectId: string; project: INeurosynthProject }, - unknown - >( - (args) => - API.NeurosynthServices.ProjectsService.projectsIdPut(args.projectId, args.project), - { - // onSuccess: (res) => { - // const x = queryClient.isMutating({ - // predicate: (m) => m.options.mutationKey === 'projects', - // }); - // if (x <= 1) { - // queryClient.invalidateQueries('projects'); - // } - // }, - // mutationKey: 'projects', - } - ); -}; - -export default useUpdateProject; diff --git a/compose/neurosynth-frontend/src/hooks/studies/useCreateStudy.tsx b/compose/neurosynth-frontend/src/hooks/studies/useCreateStudy.tsx deleted file mode 100644 index 686db9f48..000000000 --- a/compose/neurosynth-frontend/src/hooks/studies/useCreateStudy.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { StudyReturn } from 'neurostore-typescript-sdk'; -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useCreateStudy = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - return useMutation, AxiosError, string, unknown>( - (studyId) => - API.NeurostoreServices.StudiesService.studiesPost(undefined, studyId, undefined), - { - onSuccess: () => { - queryClient.invalidateQueries('studies'); - }, - onError: () => { - enqueueSnackbar('There was an error creating the study', { variant: 'error' }); - }, - } - ); -}; - -export default useCreateStudy; diff --git a/compose/neurosynth-frontend/src/hooks/studies/useDeleteStudy.tsx b/compose/neurosynth-frontend/src/hooks/studies/useDeleteStudy.tsx deleted file mode 100644 index aec0130b7..000000000 --- a/compose/neurosynth-frontend/src/hooks/studies/useDeleteStudy.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useDeleteStudy = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - return useMutation((id: string) => API.NeurostoreServices.StudiesService.studiesIdDelete(id), { - onSuccess: () => { - // we need to send a request to retrieve studies again with its associated analyses and points - queryClient.invalidateQueries('studies'); - enqueueSnackbar('study deleted successfully', { variant: 'success' }); - }, - onError: () => { - enqueueSnackbar('there was an error deleting the study', { variant: 'error' }); - }, - }); -}; - -export default useDeleteStudy; diff --git a/compose/neurosynth-frontend/src/hooks/studies/useGetBaseStudyById.tsx b/compose/neurosynth-frontend/src/hooks/studies/useGetBaseStudyById.tsx deleted file mode 100644 index f32b5ee6a..000000000 --- a/compose/neurosynth-frontend/src/hooks/studies/useGetBaseStudyById.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetBaseStudyById = (baseStudyId: string) => { - return useQuery( - ['studies', baseStudyId], - () => API.NeurostoreServices.BaseStudiesService.baseStudiesIdGet(baseStudyId, true, true), - { - select: (res) => { - return res.data; - }, - } - ); -}; - -export default useGetBaseStudyById; diff --git a/compose/neurosynth-frontend/src/hooks/studies/useGetStudyById.tsx b/compose/neurosynth-frontend/src/hooks/studies/useGetStudyById.tsx deleted file mode 100644 index 1b7f45aae..000000000 --- a/compose/neurosynth-frontend/src/hooks/studies/useGetStudyById.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { AnalysisReturn } from 'neurostore-typescript-sdk'; -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetStudyById = (studyId: string | undefined) => { - return useQuery( - ['studies', studyId], - () => API.NeurostoreServices.StudiesService.studiesIdGet(studyId || '', true), - { - select: (res) => { - const analyses = res.data.analyses as AnalysisReturn[]; - - const sortedAnalyses = (analyses || []).sort((a, b) => { - return (a.name || '').localeCompare(b.name || ''); - // this sorts by creation date: we may want this later - // const dateA = Date.parse(a.created_at || ''); - // const dateB = Date.parse(b.created_at || ''); - // if (isNaN(dateA) || isNaN(dateB)) return 0; - // return dateB - dateA; - }); - - res.data.analyses = sortedAnalyses; - return res.data; - }, - enabled: !!studyId, - } - ); -}; - -export default useGetStudyById; diff --git a/compose/neurosynth-frontend/src/hooks/studies/useUpdateStudy.tsx b/compose/neurosynth-frontend/src/hooks/studies/useUpdateStudy.tsx deleted file mode 100644 index 5438b8979..000000000 --- a/compose/neurosynth-frontend/src/hooks/studies/useUpdateStudy.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import { StudyRequest, StudyReturn } from 'neurostore-typescript-sdk'; -import API from 'utils/api'; - -const useUpdateStudy = () => { - const { enqueueSnackbar } = useSnackbar(); - const queryClient = useQueryClient(); - return useMutation< - AxiosResponse, - AxiosError, - { - studyId: string; - study: StudyRequest; - }, - unknown - >((args) => API.NeurostoreServices.StudiesService.studiesIdPut(args.studyId, args.study), { - onSuccess: () => { - queryClient.invalidateQueries('studies'); - enqueueSnackbar('study updated successfully', { variant: 'success' }); - }, - onError: () => { - enqueueSnackbar('there was an error updating the study', { variant: 'error' }); - }, - }); -}; - -export default useUpdateStudy; diff --git a/compose/neurosynth-frontend/src/hooks/studysets/useCreateStudyset.tsx b/compose/neurosynth-frontend/src/hooks/studysets/useCreateStudyset.tsx deleted file mode 100644 index 88545455c..000000000 --- a/compose/neurosynth-frontend/src/hooks/studysets/useCreateStudyset.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { StudysetRequest, StudysetReturn } from 'neurostore-typescript-sdk'; -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useCreateStudyset = () => { - const queryClient = useQueryClient(); - return useMutation, AxiosError, StudysetRequest, unknown>( - (studyset) => API.NeurostoreServices.StudySetsService.studysetsPost(studyset), - { - onSuccess: () => { - // update study - queryClient.invalidateQueries('studysets'); - }, - } - ); -}; - -export default useCreateStudyset; diff --git a/compose/neurosynth-frontend/src/hooks/studysets/useDeleteStudyset.tsx b/compose/neurosynth-frontend/src/hooks/studysets/useDeleteStudyset.tsx deleted file mode 100644 index 67ab6742b..000000000 --- a/compose/neurosynth-frontend/src/hooks/studysets/useDeleteStudyset.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { useSnackbar } from 'notistack'; -import { useMutation, useQueryClient } from 'react-query'; -import API from 'utils/api'; - -const useDeleteStudyset = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - return useMutation( - (id: string) => API.NeurostoreServices.StudySetsService.studysetsIdDelete(id), - { - onSuccess: () => { - // we need to send a request to retrieve studies again with its associated analyses and points - queryClient.invalidateQueries('studysets'); - enqueueSnackbar('studyset deleted successfully', { variant: 'success' }); - }, - onError: () => { - enqueueSnackbar('there was an error deleting the studyset', { variant: 'error' }); - }, - } - ); -}; - -export default useDeleteStudyset; diff --git a/compose/neurosynth-frontend/src/hooks/studysets/useGetStudysetById.tsx b/compose/neurosynth-frontend/src/hooks/studysets/useGetStudysetById.tsx deleted file mode 100644 index 820dc9c4f..000000000 --- a/compose/neurosynth-frontend/src/hooks/studysets/useGetStudysetById.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { StudysetReturn } from 'neurostore-typescript-sdk'; -import { useSnackbar } from 'notistack'; -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetStudysetById = (studysetId?: string, nested?: boolean) => { - const { enqueueSnackbar } = useSnackbar(); - const { data, isLoading, isError, error, refetch, isRefetching } = useQuery< - AxiosResponse, - AxiosError, - StudysetReturn, - [string, string | undefined, boolean | undefined] - >( - ['studysets', studysetId, nested], - () => API.NeurostoreServices.StudySetsService.studysetsIdGet(studysetId || '', nested), - { - enabled: !!studysetId, - onError: (err) => { - enqueueSnackbar('there was an error retrieving the studyset', { variant: 'error' }); - }, - select: (res) => res.data, - } - ); - - return { - data, - isLoading, - isError, - error, - refetch, - isRefetching, - }; -}; - -export default useGetStudysetById; diff --git a/compose/neurosynth-frontend/src/hooks/studysets/useGetStudysets.tsx b/compose/neurosynth-frontend/src/hooks/studysets/useGetStudysets.tsx deleted file mode 100644 index a4f5ba75c..000000000 --- a/compose/neurosynth-frontend/src/hooks/studysets/useGetStudysets.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { Source, SearchCriteria } from 'pages/Studies/StudiesPage/models'; -import { useQuery } from 'react-query'; -import API from 'utils/api'; - -const useGetStudysets = ( - searchCriteria: Partial>, - enabled?: boolean -) => { - return useQuery( - ['studysets', { ...searchCriteria }], - () => { - return API.NeurostoreServices.StudySetsService.studysetsGet( - undefined, - searchCriteria.sortBy, - searchCriteria.pageOfResults, - searchCriteria.descOrder, - searchCriteria.pageSize, - searchCriteria.isNested, - searchCriteria.genericSearchStr, - undefined, - undefined, - searchCriteria.showUnique, - searchCriteria.source === Source.ALL ? undefined : searchCriteria.source, - searchCriteria.authorSearch, - searchCriteria.userId - ); - }, - { - enabled, - select: (axiosResponse) => { - if (axiosResponse?.data?.results) { - axiosResponse.data.results.sort((a, b) => { - const firstStudysetId = a.id as string; - const secondStudysetId = b.id as string; - return firstStudysetId.localeCompare(secondStudysetId); - }); - } - return axiosResponse.data; - }, - } - ); -}; - -export default useGetStudysets; diff --git a/compose/neurosynth-frontend/src/hooks/studysets/useUpdateStudyset.tsx b/compose/neurosynth-frontend/src/hooks/studysets/useUpdateStudyset.tsx deleted file mode 100644 index 8abce75ea..000000000 --- a/compose/neurosynth-frontend/src/hooks/studysets/useUpdateStudyset.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { AxiosError, AxiosResponse } from 'axios'; -import { useMutation, useQueryClient } from 'react-query'; -import { StudysetRequest, StudysetReturn } from 'neurostore-typescript-sdk'; -import API from 'utils/api'; -import { useSnackbar } from 'notistack'; - -const useUpdateStudyset = () => { - const queryClient = useQueryClient(); - const { enqueueSnackbar } = useSnackbar(); - return useMutation< - AxiosResponse, - AxiosError, - { - studysetId: string; - studyset: StudysetRequest; - }, - unknown - >( - (args) => - API.NeurostoreServices.StudySetsService.studysetsIdPut(args.studysetId, args.studyset), - { - onSuccess: () => { - queryClient.invalidateQueries('studysets'); - }, - onError: () => { - enqueueSnackbar('there was an error updating the studyset', { variant: 'error' }); - }, - } - ); -}; - -export default useUpdateStudyset; diff --git a/compose/neurosynth-frontend/src/pages/Studies/BaseStudyPage/BaseStudyPage.tsx b/compose/neurosynth-frontend/src/pages/Studies/BaseStudyPage/BaseStudyPage.tsx deleted file mode 100644 index b538d2307..000000000 --- a/compose/neurosynth-frontend/src/pages/Studies/BaseStudyPage/BaseStudyPage.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import { Box, FormControl, InputLabel, MenuItem, Select } from '@mui/material'; -import DisplayStudy from 'components/DisplayStudy/DisplayStudy'; -import StateHandlerComponent from 'components/StateHandlerComponent/StateHandlerComponent'; -import { useGetStudyById } from 'hooks'; -import useGetBaseStudyById from 'hooks/studies/useGetBaseStudyById'; -import { AnalysisReturn, StudyReturn } from 'neurostore-typescript-sdk'; -import React, { useEffect } from 'react'; -import { useHistory, useParams } from 'react-router-dom'; -import { useInitStudyStore } from '../StudyStore'; -import { studyAnalysesToStoreAnalyses } from '../StudyStore.helpers'; - -const BaseStudyPage: React.FC = (props) => { - const history = useHistory(); - const initStudyStore = useInitStudyStore(); - - const { baseStudyId, studyVersionId }: { baseStudyId: string; studyVersionId?: string } = - useParams<{ - baseStudyId: string; - studyVersionId?: string; - }>(); - const { - data: baseStudy, - isLoading: baseStudyIsLoading, - isError: baseStudyIsError, - } = useGetBaseStudyById(baseStudyId); - - // if studyVersionId doesnt exist, then it will not be queried. - // In the second useEffect hook below, we keep trying to set the studyVersionId - const { - data: study, - isLoading: studyIsLoading, - isError: studyIsError, - } = useGetStudyById(studyVersionId || ''); - - // init the study store with the given version when a new one is set - useEffect(() => { - initStudyStore(studyVersionId); - }, [initStudyStore, studyVersionId]); - - // on initial load, we keep trying to set the URL with the study version until one is set - useEffect(() => { - if (baseStudy && baseStudy.versions && baseStudy.versions.length > 0 && !studyVersionId) { - history.replace( - `/base-studies/${baseStudyId}/${(baseStudy.versions as StudyReturn[])[0].id}` - ); - } - }, [baseStudy, baseStudyId, history, studyVersionId]); - - const analyses = studyAnalysesToStoreAnalyses((study?.analyses || []) as Array); - return ( - - - - Select version to view - - - - - - ); -}; - -export default BaseStudyPage; diff --git a/compose/neurosynth-frontend/src/pages/Studies/StudiesPage/models.ts b/compose/neurosynth-frontend/src/pages/Studies/StudiesPage/models.ts deleted file mode 100644 index 7bae4ccaf..000000000 --- a/compose/neurosynth-frontend/src/pages/Studies/StudiesPage/models.ts +++ /dev/null @@ -1,64 +0,0 @@ -export enum SortBy { - RELEVANCE = 'relevance', - TITLE = 'name', - AUTHORS = 'authors', - DESCRIPTION = 'description', - CREATEDAT = 'created_at', - SOURCE = 'source', - PUBLICATION = 'publication', -} - -export enum Source { - NEUROSTORE = 'neurostore', - NEUROVAULT = 'neurovault', - PUBMED = 'pubmed', - NEUROSYNTH = 'neurosynth', - NEUROQUERY = 'neuroquery', - ALL = 'all', -} -export enum SearchBy { - ALL = 'all fields', - TITLE = 'title', - DESCRIPTION = 'description', - AUTHORS = 'authors', - PUBLICATION = 'publication', -} - -export enum SearchDataType { - COORDINATE = 'coordinate', - IMAGE = 'image', - ALL = 'all', -} - -export const SearchByMapping = { - [SearchBy.ALL]: 'genericSearchStr', - [SearchBy.AUTHORS]: 'authorSearch', - [SearchBy.DESCRIPTION]: 'descriptionSearch', - [SearchBy.TITLE]: 'nameSearch', - [SearchBy.PUBLICATION]: 'publicationSearch', -}; - -export class SearchCriteria { - constructor( - public genericSearchStr: string | undefined = undefined, - public sortBy: SortBy | undefined = undefined, - public pageOfResults: number = 1, - public descOrder: boolean = true, - public pageSize: number = 10, - public isNested: boolean | undefined = undefined, - public nameSearch: string | undefined = undefined, - public descriptionSearch: string | undefined = undefined, - public authorSearch: string | undefined = undefined, - public showUnique: boolean | undefined = undefined, - public source: Source | undefined = undefined, - public publicationSearch: string | undefined = undefined, - public userId: string | undefined = undefined, - public dataType: SearchDataType | undefined = SearchDataType.ALL, - public studysetOwner: string | undefined = undefined, - public level: 'group' | 'meta' | undefined = undefined, - public pmid: string | undefined = undefined, - public doi: string | undefined = undefined, - public flat: boolean | undefined = true, - public info: boolean | undefined = true - ) {} -} diff --git a/compose/neurosynth-frontend/src/pages/UserProfilePage/UserProfilePage.tsx b/compose/neurosynth-frontend/src/pages/UserProfilePage/UserProfilePage.tsx deleted file mode 100644 index f1813319b..000000000 --- a/compose/neurosynth-frontend/src/pages/UserProfilePage/UserProfilePage.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { LocalStorageCache, useAuth0 } from '@auth0/auth0-react'; -import { Typography } from '@mui/material'; -import { Box } from '@mui/system'; -import CodeSnippet from 'components/CodeSnippet/CodeSnippet'; -import NeurosynthAccordion from 'components/NeurosynthAccordion/NeurosynthAccordion'; -import { useEffect, useState } from 'react'; - -const UserProfilePage: React.FC = (props) => { - const { user, getAccessTokenSilently } = useAuth0(); - const [refreshToken, setRefreshToken] = useState(''); - - useEffect(() => { - const localStorageCache = new LocalStorageCache(); - const keys = localStorageCache.allKeys(); - if (keys.length === 0) { - setRefreshToken(''); - } else { - const auth0Res = localStorageCache.get<{ body?: { refresh_token?: string } }>(keys[0]); - setRefreshToken(auth0Res?.body?.refresh_token || ''); - } - }, [getAccessTokenSilently]); - - return ( - - - User Profile - - - - User: - - - {user?.name} - -
- - - Email: - - - {user?.email} - -
-
- - {refreshToken && ( - Refresh Token} - expandIconColor="black" - > - - - )} -
-
- ); -}; - -export default UserProfilePage; diff --git a/compose/neurosynth-frontend/src/utils/utilitytypes.ts b/compose/neurosynth-frontend/src/utils/utilitytypes.ts deleted file mode 100644 index b97c53b01..000000000 --- a/compose/neurosynth-frontend/src/utils/utilitytypes.ts +++ /dev/null @@ -1,6 +0,0 @@ -// The Optional Type takes a type and sets the given properties as optional. -// How does it work? -// Pick, K> selects the optional (K) properties from Partial. -// Omit selects all the properties except for (K). -// The & creates a union, effectively combining all optional K properties with the original object minus K properties. -export type Optional = Pick, K> & Omit;