Skip to content

Commit

Permalink
Merge pull request #2990 from OpenNeuroOrg/homepage-search-dataset-sh…
Browse files Browse the repository at this point in the history
…ortcut

feat(app): Add a quick shortcut for accession number -> dataset page to homepage
  • Loading branch information
rwblair authored Feb 6, 2024
2 parents a1ee9c1 + c0da256 commit fd7e047
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/openneuro-app/src/scripts/common/containers/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ export const HeaderContainer: FC = () => {
const [newKeyword, setNewKeyword, newKeywordRef] = useState("")

const handleSubmit = () => {
const query = JSON.stringify({
const newQuery = {
keywords: newKeywordRef.current ? [newKeywordRef.current] : [],
})
}
const query = JSON.stringify(newQuery)
setNewKeyword("")
navigate(`/search?query=${query}`)
if (
newQuery?.keywords?.length && newQuery.keywords[0].match(/^ds[0-9]{6,6}$/)
) {
navigate(`/datasets/${newQuery.keywords[0]}`)
} else {
navigate(`/search?query=${query}`)
}
}

const toggleLoginModal = (): void => {
Expand Down

0 comments on commit fd7e047

Please sign in to comment.