From 97c0992fa109b93121cdc2e120bc3013d2e803aa Mon Sep 17 00:00:00 2001 From: Sam Bao Date: Sun, 28 Jul 2024 08:07:23 -0600 Subject: [PATCH 1/2] updating spotify playlist validating regex and switch to use built in helper text --- src/GetSpotifyPlaylistArtistsWithShows.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/GetSpotifyPlaylistArtistsWithShows.js b/src/GetSpotifyPlaylistArtistsWithShows.js index 109deef..b9adc39 100644 --- a/src/GetSpotifyPlaylistArtistsWithShows.js +++ b/src/GetSpotifyPlaylistArtistsWithShows.js @@ -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."); @@ -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 && {errorMessage}} +