|
|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
import React, {useState} from 'react';
|
|
|
|
|
import React, {useEffect, useState} from 'react';
|
|
|
|
|
import {Grid, RowCol} from "../components/Grid";
|
|
|
|
|
import {getUser} from "../services/user_service";
|
|
|
|
|
import {capitalize} from "../services/utils";
|
|
|
|
|
@@ -9,6 +9,12 @@ import {Tab, TabList, TabPanel, Tabs} from "react-tabs";
|
|
|
|
|
import {NoRoute} from "../components/NoRoute";
|
|
|
|
|
import {getArtist, getDisc, getRelease, getSong} from "../services/entity_service";
|
|
|
|
|
import {CoverArt} from "../components/CoverArt";
|
|
|
|
|
import {useStateValue} from "../services/State";
|
|
|
|
|
import {FaCheck} from 'react-icons/fa';
|
|
|
|
|
|
|
|
|
|
const InList = (props) => {
|
|
|
|
|
return <div>Ya esta en tu lista! <FaCheck/></div>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ArtistsList = (props) => {
|
|
|
|
|
const ids = props.ids;
|
|
|
|
|
@@ -21,13 +27,13 @@ const ArtistsList = (props) => {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(artists);
|
|
|
|
|
|
|
|
|
|
const items = artists.map((artist) => ({
|
|
|
|
|
'cover': null,
|
|
|
|
|
'link': `/artist/${artist.id}`,
|
|
|
|
|
'title': artist.name,
|
|
|
|
|
'subtitle': [artist.type, artist.country].filter(Boolean).join(' - ')
|
|
|
|
|
'subtitle': [artist.type, artist.country].filter(Boolean).join(' - '),
|
|
|
|
|
'widget': props.logged_ids.includes(artist.id) ? <InList/> : null,
|
|
|
|
|
'className': props.logged_ids.includes(artist.id) ? 'disabled' : null
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
const list = [{'items': items}]
|
|
|
|
|
@@ -50,7 +56,9 @@ const ReleasesList = (props) => {
|
|
|
|
|
'cover': (<CoverArt release={release} size={3}/>),
|
|
|
|
|
'link': `/release/${release.id}`,
|
|
|
|
|
'title': release.title,
|
|
|
|
|
'subtitle': [release.artist.name, release.date].filter(Boolean).join(' - ')
|
|
|
|
|
'subtitle': [release.artist.name, release.date].filter(Boolean).join(' - '),
|
|
|
|
|
'widget': props.logged_ids.includes(release.id) ? <InList/> : null,
|
|
|
|
|
'className': props.logged_ids.includes(release.id) ? 'disabled' : null
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
const list = [{'items': items}]
|
|
|
|
|
@@ -73,7 +81,9 @@ const DiscsList = (props) => {
|
|
|
|
|
'cover': (<CoverArt disc={disc} size={3}/>),
|
|
|
|
|
'link': `/disc/${disc.id}`,
|
|
|
|
|
'title': disc.title,
|
|
|
|
|
'subtitle': disc.artist.name
|
|
|
|
|
'subtitle': disc.artist.name,
|
|
|
|
|
'widget': props.logged_ids.includes(disc.id) ? <InList/> : null,
|
|
|
|
|
'className': props.logged_ids.includes(disc.id) ? 'disabled' : null
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
const list = [{'items': items}]
|
|
|
|
|
@@ -92,11 +102,13 @@ const SongsList = (props) => {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const items = songs.map((disc) => ({
|
|
|
|
|
const items = songs.map((song) => ({
|
|
|
|
|
'cover': null,
|
|
|
|
|
'link': `/song/${disc.id}`,
|
|
|
|
|
'title': disc.title,
|
|
|
|
|
'subtitle': disc.artist.name
|
|
|
|
|
'link': `/song/${song.id}`,
|
|
|
|
|
'title': song.title,
|
|
|
|
|
'subtitle': song.artist.name,
|
|
|
|
|
'widget': props.logged_ids.includes(song.id) ? <InList/> : null,
|
|
|
|
|
'className': props.logged_ids.includes(song.id) ? 'disabled' : null
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
const list = [{'items': items}]
|
|
|
|
|
@@ -135,10 +147,10 @@ const ListTabs = (props) => {
|
|
|
|
|
<Tab className='tab' selectedClassName='selected'>Lanzamientos</Tab>
|
|
|
|
|
<Tab className='tab' selectedClassName='selected'>Canciones</Tab>
|
|
|
|
|
</TabList>
|
|
|
|
|
<TabPanel><ArtistsList ids={props.artists}/></TabPanel>
|
|
|
|
|
<TabPanel><DiscsList ids={props.discs}/></TabPanel>
|
|
|
|
|
<TabPanel><ReleasesList ids={props.releases}/></TabPanel>
|
|
|
|
|
<TabPanel><SongsList ids={props.songs}/></TabPanel>
|
|
|
|
|
<TabPanel><ArtistsList ids={props.artists} logged_ids={props.logged_list}/></TabPanel>
|
|
|
|
|
<TabPanel><DiscsList ids={props.discs} logged_ids={props.logged_list}/></TabPanel>
|
|
|
|
|
<TabPanel><ReleasesList ids={props.releases} logged_ids={props.logged_list}/></TabPanel>
|
|
|
|
|
<TabPanel><SongsList ids={props.songs} logged_ids={props.logged_list}/></TabPanel>
|
|
|
|
|
</Tabs>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
@@ -151,28 +163,46 @@ const UserList = (props) => {
|
|
|
|
|
const release_list = props.list.filter((item) => item.entity.type === 'release').map((item => item.entity.mbid));
|
|
|
|
|
const song_list = props.list.filter((item) => item.entity.type === 'recording').map((item => item.entity.mbid));
|
|
|
|
|
|
|
|
|
|
let logged_list = []
|
|
|
|
|
if (props.logged_list !== null) {
|
|
|
|
|
logged_list = props.logged_list.map(item => item.entity.mbid)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<h2>Lista</h2>
|
|
|
|
|
<ListTabs artists={artist_list} discs={disc_list} releases={release_list} songs={song_list}/>
|
|
|
|
|
<ListTabs artists={artist_list} discs={disc_list} releases={release_list}
|
|
|
|
|
songs={song_list} logged_list={logged_list}/>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const UserView = (props) => {
|
|
|
|
|
const context = useStateValue()[0];
|
|
|
|
|
const [user, setUser] = useState(null);
|
|
|
|
|
const [list, setList] = useState(null);
|
|
|
|
|
const [logged_list, setLoggedList] = useState(null);
|
|
|
|
|
|
|
|
|
|
if (user === null) {
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
getUser(null, props.match.params.id).then(setUser)
|
|
|
|
|
}
|
|
|
|
|
}, [props.match.params.id])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user === null) {
|
|
|
|
|
return <NoRoute/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (list === null) {
|
|
|
|
|
get_list(user.id).then((response) => setList(response.data.list)).catch((error) => {
|
|
|
|
|
if (list === null || list.user_id !== user.id) {
|
|
|
|
|
get_list(user.id).then((response) => setList(response.data)).catch((error) => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const logged_user = JSON.parse(window.localStorage.getItem('user'))
|
|
|
|
|
if ((logged_list === null && context.user.auth) && (user.id !== logged_user.id)) {
|
|
|
|
|
get_list(logged_user.id).then((response) => {
|
|
|
|
|
setLoggedList(response.data.list)
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
@@ -186,7 +216,7 @@ export const UserView = (props) => {
|
|
|
|
|
<SocialNetworks user={user.id}/>
|
|
|
|
|
</RowCol>
|
|
|
|
|
<RowCol>
|
|
|
|
|
<UserList list={list}/>
|
|
|
|
|
{list && <UserList list={list.list} logged_list={logged_list}/>}
|
|
|
|
|
</RowCol>
|
|
|
|
|
</Grid>
|
|
|
|
|
)
|
|
|
|
|
|