-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating
DatastoreMain
and separating logic.
- Loading branch information
1 parent
c8cab29
commit f55c76d
Showing
6 changed files
with
87 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { DatastoreNavigation, FlintAlerts, Landing } from '../../../datastores'; | ||
import { RecordFull, Results } from '../../../records'; | ||
import { Route, Routes } from 'react-router-dom'; | ||
import { GetThisPage } from '../../../getthis'; | ||
import { List } from '../../../lists'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import { SearchBox } from '../../../search'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
const DatastoreMain = ({ activeDatastore, currentDatastore, datastores, query }) => { | ||
const { active: activeFilters } = useSelector((state) => { | ||
return state.filters; | ||
}); | ||
const { active: activeInstitution, defaultInstitution, options } = useSelector((state) => { | ||
return state.institution; | ||
}); | ||
const { page, searching, sort } = useSelector((state) => { | ||
return state.search; | ||
}); | ||
const currentFilters = activeFilters[currentDatastore]; | ||
const activeFilterCount = currentFilters ? Object.keys(currentFilters).length : 0; | ||
|
||
return ( | ||
<> | ||
<SearchBox {...{ activeDatastore, query }} /> | ||
<DatastoreNavigation {...{ activeFilters, activeInstitution, currentDatastore, datastores, page, query, sort }} /> | ||
<FlintAlerts {...{ currentDatastore }} /> | ||
<Routes> | ||
<Route | ||
path='record/:recordUid/get-this/:barcode' | ||
element={<GetThisPage />} | ||
/> | ||
<Route | ||
path='record/:recordUid' | ||
element={<RecordFull />} | ||
/> | ||
<Route | ||
path='list' | ||
element={<List {...{ activeDatastore, currentDatastore }} />} | ||
/> | ||
<Route | ||
index | ||
element={searching ? <Results {...{ activeDatastore, activeFilterCount }} /> : <Landing {...{ activeDatastore, defaultInstitution, options }} />} | ||
/> | ||
</Routes> | ||
</> | ||
); | ||
}; | ||
|
||
DatastoreMain.propTypes = { | ||
activeDatastore: PropTypes.object, | ||
currentDatastore: PropTypes.string, | ||
datastores: PropTypes.array, | ||
query: PropTypes.string | ||
}; | ||
|
||
export default DatastoreMain; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters