-
Notifications
You must be signed in to change notification settings - Fork 6
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
MRKT-14: search sales by typing #632
Conversation
Visit the preview URL for this PR (updated for commit ac11ed2): https://newm-artist-portal--pr632-mrkt-14-search-sales-um90ys2g.web.app (expires Fri, 21 Jun 2024 03:59:34 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: ec3483d4c62309afc398865bfd6a9fc9e03e1d46 |
Visit the preview URL for this PR (updated for commit ac11ed2): https://fan-square--pr632-mrkt-14-search-sales-48t73add.web.app (expires Fri, 21 Jun 2024 04:02:36 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: b38f4676e459f355dcb11c95730012d43389bfd2 |
Visit the wallet preview URL for this PR (updated for commit dfef51c): |
Visit the marketplace preview URL for this PR (updated for commit dfef51c): |
event.preventDefault(); | ||
event.stopPropagation(); | ||
onSubtitleClick?.(); | ||
onSubtitleClick(); |
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.
Updated these so that clicking the element doesn't prevent the element beneath it from being clicked when handler isn't present.
Visit the marketplace preview URL for this PR (updated for commit 340441d): |
Visit the wallet preview URL for this PR (updated for commit 340441d): |
Visit the wallet preview URL for this PR (updated for commit aec7f3a): |
Visit the marketplace preview URL for this PR (updated for commit aec7f3a): |
{ typeof noResultsContent === "string" ? ( | ||
<Typography sx={ { marginTop: 8, textAlign: "center" } }> | ||
{ noResultsContent } | ||
</Typography> | ||
) : ( | ||
noResultsContent | ||
) } |
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.
Is this just prep for some other content? Is design/product working on something to place here instead of the text?
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.
There isn't a mock-up for when the search page doesn't return any results, but I implemented it so that it has custom text when no results are returned. It's also left aligned, so it's passed in as a React node with styling to make it left aligned instead of just a string, which would be center aligned by default.
Another way to do it could be to have a noResultsContent
string prop, and a noResultsContentAlignment
prop to set the text alignment, but it seemed easier to just allow passing a single React node prop.
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.
LGTM
onSubtitleClick={ () => {} } | ||
/> | ||
</Stack> | ||
<SearchResults query={ searchTerm } /> | ||
</Container> | ||
); | ||
}; |
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.
I think we should consider this if !searchTerm
is present.
"use client";
import { Container } from "@mui/material";
import { useRouter, useSearchParams } from "next/navigation";
import { SearchResults } from "../../components";
import { useAppDispatch } from "../../common";
import { setToastMessage } from "../../modules/ui";
const Search = () => {
const searchParams = useSearchParams();
const dispatch = useAppDispatch();
const router = useRouter();
const searchTerm = searchParams.get("searchTerm") || "";
if (!searchTerm) {
dispatch(
setToastMessage({
message:
"No search term provided. Please enter a search term and try again.",
severity: "error",
})
);
router.push("/");
}
return (
<Container sx={ { flexGrow: 1, mt: 5 } }>
<SearchResults query={ searchTerm } />
</Container>
);
};
export default Search;
useSearchParams();
const dispatch = useAppDispatch();
const router = useRouter();
const searchTerm = searchParams.get("searchTerm") || "";
if (!searchTerm) {
dispatch(
setToastMessage({
message:
"There is a problem with your wallet. Please try disconnecting and reconnecting it.",
severity: "error",
})
);
router.push("/");
}
return (
<Container sx={ { flexGrow: 1, mt: 5 } }>
<SearchResults query={ searchTerm } />
</Container>
);
};
export default Search;
The current implementation has unreachable code: return null;
(also gets called out by my IDE). It also leaves the app in an error state that the user might not know what to do?
With the changes suggested:
- Display a toast message letting them know the error
- Redirect the user to the home page (that also has the search available)
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's strange the linter is throwing an error about retuning a null value, it shouldn't do that if the null value will only be returned in some cases. In retrospect, I'm thinking we can probably just return an empty result if the search term is empty or missing. The user shouldn't actually ever be able to see that page with an empty or missing search string, and if they do, by manually changing the url, then I think just displaying a message that no results were returned should work.
@@ -75,7 +85,6 @@ const Sales: FunctionComponent<SalesProps> = ({ | |||
title={ song.title } | |||
onCardClick={ () => handleCardClick(id) } | |||
onPlayPauseClick={ () => playPauseAudio(song.clipUrl) } | |||
onSubtitleClick={ () => handleSubtitleClick(id) } |
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.
I see why you are removing it, however, instead of removing it we should change the subtitle from the current genresString
to subtitle={ song.artistName }
And on subtitle click it would take the user to the artist page. So these changes:
Replace:
subtitle={ song.artistName }
to
subtitle={ genresString }
Replace:
onSubtitleClick={ () => handleSubtitleClick(id) }
to
onSubtitleClick={ () => handleSubtitleClick(song.artistId) }
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.
Ah, yeah. Seems the mock-ups were updated.
@@ -1,50 +1,21 @@ | |||
"use client"; |
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.
There’s a weird bug in I noticed.
Steps:
- In the search bar of the home page, type w and and submit the search
- Now add 1 space before the letter w, so this w and submit, the url should look something like this: http://localhost:3000/search/?searchTerm=%20w
- Add 1 more space before the space and w so this: w and submit, the url should now look like this: http://localhost:3000/search/?searchTerm=%20%20w
- Notice how the UI is showing 1 item(screenshot), but the network call returned an empty array
![image](https://private-user-images.githubusercontent.com/11530120/332265467-932dd10e-da7e-48e4-a0c9-a3651851e639.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NTkyNjgsIm5iZiI6MTczOTU1ODk2OCwicGF0aCI6Ii8xMTUzMDEyMC8zMzIyNjU0NjctOTMyZGQxMGUtZGE3ZS00OGU0LWEwYzktYTM2NTE4NTFlNjM5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDE4NDkyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI2NmI0YTdmY2QwN2VlZGE0Nzk1MGQ5NzFmNTM2MDdkOWViMjFjYTc2ZGZlYWFiZWYxYTJlMGMzODIyYzI3Y2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.__IZpW9QEQ5d6gsnEU2aJzWQTPpO0hymzIHR9J6Isig)
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.
This looks to be because that song is a duplicate in the test database, which is causing issues with the React rendering because they have the same song ID, which is being used as the key
prop. I updated the key to be the sale ID, which is unique and resolved the issue.
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.
ahh, makes sense, i saw that key issue somewhere else in the console
Visit the marketplace preview URL for this PR (updated for commit 2377720): |
Visit the wallet preview URL for this PR (updated for commit 2377720): |
@@ -1,50 +1,21 @@ | |||
"use client"; |
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.
ahh, makes sense, i saw that key issue somewhere else in the console
No description provided.