Skip to content
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

Merged
merged 7 commits into from
May 22, 2024
Merged

Conversation

scandycuz
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented May 19, 2024

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

Copy link

github-actions bot commented May 19, 2024

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

Copy link

Visit the wallet preview URL for this PR (updated for commit dfef51c):
🚀 https://6e4wvmqk4n3wzptxm7fh27o63u0qrpkc.lambda-url.us-west-2.on.aws/

Copy link

Visit the marketplace preview URL for this PR (updated for commit dfef51c):
🚀 https://jbk2bo5n6vimun5whtamqtx56y0vsqfh.lambda-url.us-west-2.on.aws/

event.preventDefault();
event.stopPropagation();
onSubtitleClick?.();
onSubtitleClick();
Copy link
Contributor Author

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.

Copy link

Visit the marketplace preview URL for this PR (updated for commit 340441d):
🚀 https://jbk2bo5n6vimun5whtamqtx56y0vsqfh.lambda-url.us-west-2.on.aws/

Copy link

Visit the wallet preview URL for this PR (updated for commit 340441d):
🚀 https://6e4wvmqk4n3wzptxm7fh27o63u0qrpkc.lambda-url.us-west-2.on.aws/

Copy link

Visit the wallet preview URL for this PR (updated for commit aec7f3a):
🚀 https://6e4wvmqk4n3wzptxm7fh27o63u0qrpkc.lambda-url.us-west-2.on.aws/

Copy link

Visit the marketplace preview URL for this PR (updated for commit aec7f3a):
🚀 https://jbk2bo5n6vimun5whtamqtx56y0vsqfh.lambda-url.us-west-2.on.aws/

Comment on lines +63 to +69
{ typeof noResultsContent === "string" ? (
<Typography sx={ { marginTop: 8, textAlign: "center" } }>
{ noResultsContent }
</Typography>
) : (
noResultsContent
) }
Copy link
Contributor

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?

Copy link
Contributor Author

@scandycuz scandycuz May 22, 2024

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.

Copy link
Contributor

@dmkirshon dmkirshon left a 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>
);
};
Copy link
Contributor

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)

Copy link
Contributor Author

@scandycuz scandycuz May 22, 2024

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) }
Copy link
Contributor

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) }

Copy link
Contributor Author

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";
Copy link
Contributor

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:

  1. In the search bar of the home page, type w and and submit the search
  2. 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
  3. 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
  4. Notice how the UI is showing 1 item(screenshot), but the network call returned an empty array
image

Copy link
Contributor Author

@scandycuz scandycuz May 22, 2024

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.

Copy link
Contributor

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

Copy link

Visit the marketplace preview URL for this PR (updated for commit 2377720):
🚀 https://jbk2bo5n6vimun5whtamqtx56y0vsqfh.lambda-url.us-west-2.on.aws/

Copy link

Visit the wallet preview URL for this PR (updated for commit 2377720):
🚀 https://6e4wvmqk4n3wzptxm7fh27o63u0qrpkc.lambda-url.us-west-2.on.aws/

@@ -1,50 +1,21 @@
"use client";
Copy link
Contributor

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

@scandycuz scandycuz merged commit 2db6ff8 into master May 22, 2024
7 checks passed
@scandycuz scandycuz deleted the MRKT-14/search-sales-by-typing branch May 22, 2024 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants