Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

frontend changes for feature playlists #3263

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useSelector, useDispatch } from 'react-redux'
import { CollectionList } from 'app/components/collection-list'

import { TabInfo } from '../components/TabInfo'
import { track } from 'app/services/analytics'
const { getExplorePlaylists, getExploreStatus, getPlaylistsStatus } =
explorePageSelectors
const { fetchPlaylists } = explorePageActions
Expand All @@ -29,6 +30,10 @@ export const PlaylistsTab = () => {
if (exploreStatus === Status.SUCCESS) {
dispatch(fetchPlaylists())
}

if(track){
setFeaturedPlaylists(track.featured_playlists || [])
}
}, [exploreStatus, dispatch])

return (
Expand Down
20 changes: 20 additions & 0 deletions packages/web/src/pages/track-page/TrackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface OwnProps {}

type TrackPageContentProps = ReturnType<typeof mapStateToProps> & OwnProps

const [featuredPlaylists, setFeaturedPlaylists] = useState<Playlist[]>([])

const TrackPage = ({ isMobile }: TrackPageContentProps) => {
const content = isMobile ? TrackPageMobileContent : TrackPageDesktopContent

Expand All @@ -23,4 +25,22 @@ function mapStateToProps(state: AppState) {
}
}

const FeaturedPlaylists: React.FC<{ playlists: Playlist[] }> = ({ playlists }) => {
if (playlists.length === 0) {
return null;
}
return (
<div className={styles.featuredPlaylists}>
<h3>Featured in these playlists:</h3>
<ul>
{playlists.map((playlist) => (
<li key={playlist.playlist_id}>
<a href={`/playlist/${playlist.playlist_id}`}>{playlist.playlist_name}</a>
</li>
))}
</ul>
</div>
);
};

export default connect(mapStateToProps)(TrackPage)