-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Package][Genetics] Fix search for Genetics #356
base: main
Are you sure you want to change the base?
Changes from all commits
36831b0
5d2b033
b368766
2fabf4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,14 +53,16 @@ export const formatSearchData = unformattedData => { | |
|
||
Object.entries(unformattedData).forEach(([key, value]) => { | ||
const typesArray = []; | ||
// OpenTargets Genetics search format | ||
if (isArray(value)) { | ||
value.map(i => | ||
typesArray.push({ | ||
type: key === "topHit" ? "topHit" : key, | ||
entity: key, | ||
type: key === "topHit" ? "topHit" : i.__typename.toLowerCase(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apollo primarily provides |
||
entity: i.__typename.toLowerCase(), | ||
...flattenObj(i), | ||
}) | ||
); | ||
// OpenTargets Platform search format | ||
} else if (isArray(value.hits)) { | ||
value.hits.map(i => | ||
typesArray.push({ | ||
|
@@ -72,7 +74,6 @@ export const formatSearchData = unformattedData => { | |
} | ||
if (typesArray.length > 0) formattedData[key] = typesArray; | ||
}); | ||
|
||
return formattedData; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { addSearchToLocalStorage } from "../components/GlobalSearch/utils/search | |
function useListOption() { | ||
const history = useHistory(); | ||
|
||
const openListItem = option => { | ||
return option => { | ||
if (!option) return; | ||
const newOption = { ...option }; | ||
newOption.type = "recent"; | ||
|
@@ -13,15 +13,19 @@ function useListOption() { | |
if (newOption.entity === "search") { | ||
history.push(`/search?q=${newOption.name}&page=1`); | ||
} else if (newOption.entity === "study") { | ||
history.push(`/${newOption.entity}/${newOption.studyId}`); | ||
if (newOption.studyId) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at this point we should use |
||
history.push(`/${newOption.entity}/${newOption.studyId}`); | ||
} else { | ||
history.push(`/${newOption.entity}/${newOption.id}`); | ||
} | ||
} else if (["gene", "variant"].includes(newOption.entity)) { | ||
history.push(`/${newOption.entity}/${newOption.id}`); | ||
} else { | ||
history.push( | ||
`/${newOption.entity}/${newOption.id}${newOption.entity !== "drug" ? "/associations" : ""}` | ||
); | ||
} | ||
}; | ||
|
||
return [openListItem]; | ||
} | ||
|
||
export default useListOption; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good to have a condition, although it is preferred that we modify and pass
EXAMPLES
fromGenetics > HomePage.tsx
so that we don't see empty search container.