Skip to content

Commit

Permalink
Merge pull request #87 from taver-ca/fix/reset-error-status-when-user…
Browse files Browse the repository at this point in the history
…-enter-valid-playlist-url

Fix/reset error status when user enter valid playlist url
  • Loading branch information
sam9116 authored Jul 28, 2024
2 parents 47db606 + 76d2ef1 commit 3588aa1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions src/GetSpotifyPlaylistArtistsWithShows.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ function GetSpotifyPlaylistArtistsWithShows({ followedArtists, setFollowedArtist

let handleSubmit = async (e) => {
e.preventDefault();


const url = spotifyPlayList;
const urlValidate = new RegExp("^https://open\\.spotify\\.com/playlist/[a-zA-Z0-9]{22}$");
const urlValidate = new RegExp("^https://open\\.spotify\\.com/playlist/[a-zA-Z0-9]{22}(\\?si=.*)?$");
if (urlValidate.test(spotifyPlayList)) {

return spotifyPlayList;
setErrorMessage("");
}
else {
setErrorMessage("Please enter a valid Spotify playlist URL.");
Expand Down Expand Up @@ -67,11 +64,10 @@ function GetSpotifyPlaylistArtistsWithShows({ followedArtists, setFollowedArtist
}}
label="Spotify Playlist URL:"
value={spotifyPlayList} onChange={(e) => setSpotifyPlaylist(e.target.value)}

error={Boolean(errorMessage)}

helperText={errorMessage}
error={errorMessage}
/>
{errorMessage && <Typography color="error">{errorMessage}</Typography>}

<Button
type="submit"
variant="contained"
Expand Down

0 comments on commit 3588aa1

Please sign in to comment.