Skip to content

Commit

Permalink
chore: adjust AutosuggestSearchResult logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MounirDhahri committed Oct 11, 2023
1 parent d080ad2 commit 0db8691
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe(AutosuggestSearchResult, () => {
tree.root.findByType(Touchable).props.onPress()
await new Promise((r) => setTimeout(r, 50))
expect(inputBlurMock).toHaveBeenCalled()
expect(navigate).toHaveBeenCalledWith(result.href, { passProps: undefined })
expect(navigate).toHaveBeenCalledWith(`${result.href}`)
})

it(`highlights a part of the string even when the string has diacritics but the highlight doesn't`, async () => {
Expand Down Expand Up @@ -253,15 +253,15 @@ describe(AutosuggestSearchResult, () => {
tree.root.findAllByType(Pressable)[0].props.onPress()
})
await new Promise((r) => setTimeout(r, 50))
expect(navigate).toHaveBeenCalledWith("/artist/anto-carte", {
passProps: { initialTab: "Artworks", scrollToArtworksGrid: true },
expect(navigate).toHaveBeenCalledWith("/artist/anto-carte/artworks", {
passProps: { initialTab: "Artworks" },
})

act(() => {
tree.root.findAllByType(Pressable)[1].props.onPress()
})
await new Promise((r) => setTimeout(r, 50))
expect(navigate).toHaveBeenCalledWith("/artist/anto-carte", {
expect(navigate).toHaveBeenCalledWith("/artist/anto-carte/auction-results", {
passProps: { initialTab: "Insights" },
})
})
Expand Down
11 changes: 8 additions & 3 deletions src/app/Scenes/Search/components/AutosuggestSearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type ArtistTabs = "Insights" | "Artworks"

type PassedProps = {
initialTab: ArtistTabs
scrollToArtworksGrid?: boolean
}

type HandleResultPress = (passProps?: PassedProps) => void
Expand Down Expand Up @@ -167,7 +166,7 @@ export const AutosuggestSearchResult: React.FC<{
highlightEnabled
Icon={ArtworkIcon}
rounded
onPress={() => onPress({ initialTab: "Artworks", scrollToArtworksGrid: true })}
onPress={() => onPress({ initialTab: "Artworks" })}
block
>
Artworks
Expand Down Expand Up @@ -200,7 +199,13 @@ function navigateToResult(result: AutosuggestResult, props?: PassedProps) {
} else if (result.displayType === "Fair") {
navigateToEntity(result.href!, EntityType.Fair, SlugType.ProfileID)
} else if (result.__typename === "Artist") {
navigate(`${result.href!}/artworks`, { passProps: props })
if (props?.initialTab === "Insights") {
navigate(`${result.href!}/auction-results`, { passProps: props })
}
if (props?.initialTab === "Artworks") {
navigate(`${result.href!}/artworks`, { passProps: props })
}
navigate(result.href!)
} else {
navigate(result.href!)
}
Expand Down

0 comments on commit 0db8691

Please sign in to comment.