|
@@ -6,53 +6,53 @@ import { Link } from 'react-router-dom';
|
|
|
import { history, backendURL } from '../../App';
|
|
|
import { useDropzone } from 'react-dropzone'
|
|
|
|
|
|
-const LogoutBtn = ({onLogout}) =>
|
|
|
+const LogoutBtn = ({ onLogout }) =>
|
|
|
<div
|
|
|
- style={{ border: '1px solid black', backgroundColor: 'red', color: 'white' }}
|
|
|
- onClick={() => { onLogout(); history.push('/login') }}
|
|
|
+ style={{ border: '1px solid black', backgroundColor: 'red', color: 'white' }}
|
|
|
+ onClick={() => { onLogout(); history.push('/login') }}
|
|
|
>log-out[X]</div>
|
|
|
|
|
|
-export const LogoutBtnConnect = connect(null, {onLogout: action.actionAuthLogout })(LogoutBtn)
|
|
|
+export const LogoutBtnConnect = connect(null, { onLogout: action.actionAuthLogout })(LogoutBtn)
|
|
|
|
|
|
-const ProfileWindow = ({user}) => {
|
|
|
+const ProfileWindow = ({ user }) => {
|
|
|
let [userInfo, setUserInfo] = useState(user.payload)
|
|
|
|
|
|
- useEffect(()=> {
|
|
|
+ useEffect(() => {
|
|
|
setUserInfo(user.payload)
|
|
|
- },[user, userInfo])
|
|
|
+ }, [user, userInfo])
|
|
|
|
|
|
- return(
|
|
|
+ return (
|
|
|
<section>
|
|
|
- <h3>{userInfo?.login || 'user'}</h3>
|
|
|
- <img
|
|
|
- width={100}
|
|
|
- height={100}
|
|
|
- style={{ border: '1px solid black', display:'block', margin:'5% auto', marginBottom:'2px'}}
|
|
|
- src={ userInfo?.avatar?.url ? backendURL + '/' + userInfo?.avatar?.url : ''}
|
|
|
- alt='avatar'
|
|
|
+ <h3>{userInfo?.login || 'user'}</h3>
|
|
|
+ <img
|
|
|
+ width={100}
|
|
|
+ height={100}
|
|
|
+ style={{ border: '1px solid black', display: 'block', margin: '5% auto', marginBottom: '2px' }}
|
|
|
+ src={userInfo?.avatar?.url ? backendURL + '/' + userInfo?.avatar?.url : ''}
|
|
|
+ alt='avatar'
|
|
|
/>
|
|
|
</section>
|
|
|
- )
|
|
|
+ )
|
|
|
}
|
|
|
export const ProfileWindowConnect = connect(state => ({ user: state.promise.userData || {} }))(ProfileWindow)
|
|
|
|
|
|
-const ProfileWindowDropzone = ({onLoad}) => {
|
|
|
+const ProfileWindowDropzone = ({ onLoad }) => {
|
|
|
const onDrop = useCallback(acceptedFiles => {
|
|
|
onLoad(acceptedFiles[0])
|
|
|
}, [onLoad])
|
|
|
- const {getRootProps, getInputProps, isDragActive} = useDropzone({onDrop})
|
|
|
+ const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop })
|
|
|
|
|
|
return (
|
|
|
- <div {...getRootProps()} style={isDragActive? {border:'1px solid mediumseagreen'} : {border:'1px solid black'}}>
|
|
|
- <input {...getInputProps()} />
|
|
|
- <ProfileWindowConnect />
|
|
|
- {isDragActive? <small>drag here...</small> : <small>change avatar</small>}
|
|
|
- </div>
|
|
|
+ <div {...getRootProps()} style={isDragActive ? { border: '1px solid mediumseagreen' } : { border: '1px solid black' }}>
|
|
|
+ <input {...getInputProps()} />
|
|
|
+ <ProfileWindowConnect />
|
|
|
+ {isDragActive ? <small>drag here...</small> : <small>change avatar</small>}
|
|
|
+ </div>
|
|
|
)
|
|
|
}
|
|
|
-export const ProfileWindowDropzoneConnect = connect(null, {onLoad: action.actionUploadAvatar})(ProfileWindowDropzone)
|
|
|
+export const ProfileWindowDropzoneConnect = connect(null, { onLoad: action.actionUploadAvatar })(ProfileWindowDropzone)
|
|
|
|
|
|
-const UserTracksBtn = ({userId}) => {
|
|
|
+const UserTracksBtn = ({ userId }) => {
|
|
|
let [_id, setId] = useState()
|
|
|
useEffect(() => {
|
|
|
console.log('CHENG', userId)
|
|
@@ -61,34 +61,34 @@ const UserTracksBtn = ({userId}) => {
|
|
|
|
|
|
return (
|
|
|
<Link
|
|
|
- to={`/player/tracks/:${_id}`}
|
|
|
- style={{
|
|
|
- display:'block',
|
|
|
- backgroundColor: 'purple',
|
|
|
- color: 'white',
|
|
|
- margin: '5px',
|
|
|
- padding:'5px'
|
|
|
- }}
|
|
|
- >MY TRACKS</Link>
|
|
|
+ to={`/player/tracks/:${_id}`}
|
|
|
+ style={{
|
|
|
+ display: 'block',
|
|
|
+ backgroundColor: 'purple',
|
|
|
+ color: 'white',
|
|
|
+ margin: '5px',
|
|
|
+ padding: '5px'
|
|
|
+ }}
|
|
|
+ >My tracks</Link>
|
|
|
)
|
|
|
}
|
|
|
-export const UserTracksBtnConnect = connect(state => ({userId: state.promise.userData?.payload?._id || ''}))(UserTracksBtn)
|
|
|
+export const UserTracksBtnConnect = connect(state => ({ userId: state.promise.userData?.payload?._id || '' }))(UserTracksBtn)
|
|
|
|
|
|
-const PlaylistAdd = ({addPlaylist}) => {
|
|
|
+const PlaylistAdd = ({ addPlaylist }) => {
|
|
|
let [clicked, setClicked] = useState(false)
|
|
|
let [name, setName] = useState()
|
|
|
return (
|
|
|
<div>
|
|
|
{
|
|
|
- !clicked?
|
|
|
- <button
|
|
|
- style={{backgroundColor: 'mediumseagreen',width : '95%',padding: '5px', margin: '5px', fontSize:'21px' }}
|
|
|
+ !clicked ?
|
|
|
+ <button
|
|
|
+ style={{ border: '1px solid black', backgroundColor: 'mediumseagreen', width: '95%', padding: '5px', margin: '5px' }}
|
|
|
onClick={() => setClicked(true)}
|
|
|
>NEW PLAYLIST</button>
|
|
|
:
|
|
|
- <div style={{width : '95%', margin:'0 auto'}}>
|
|
|
- <input
|
|
|
- style={{width:'72%', padding:'5px'}}
|
|
|
+ <div style={{ width: '95%', margin: '0 auto' }}>
|
|
|
+ <input
|
|
|
+ style={{ width: '72%', padding: '5px' }}
|
|
|
placeholder='Playlist name'
|
|
|
value={name}
|
|
|
onChange={(e) => setName(e.target.value)}
|
|
@@ -96,36 +96,35 @@ const PlaylistAdd = ({addPlaylist}) => {
|
|
|
|
|
|
<button
|
|
|
disabled={!name}
|
|
|
- style={{padding:'5px', backgroundColor:'mediumseagreen'}}
|
|
|
- onClick={() => {addPlaylist(name); setClicked(false); setName('');}}
|
|
|
+ style={{ padding: '5px', backgroundColor: 'mediumseagreen' }}
|
|
|
+ onClick={() => { addPlaylist(name); setClicked(false); setName(''); }}
|
|
|
>+</button>
|
|
|
|
|
|
<button
|
|
|
- style={{padding:'5px', backgroundColor:'red'}}
|
|
|
- onClick={() => {setClicked(false); setName('')}}
|
|
|
+ style={{ padding: '5px', backgroundColor: 'red' }}
|
|
|
+ onClick={() => { setClicked(false); setName('') }}
|
|
|
>X</button>
|
|
|
</div>
|
|
|
}
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
-const PlaylistAddConnect = connect(null, {addPlaylist: action.actionAddPlaylist})(PlaylistAdd)
|
|
|
+export const PlaylistAddConnect = connect(null, { addPlaylist: action.actionAddPlaylist })(PlaylistAdd)
|
|
|
|
|
|
-const Playlists = ({playlists}) => {
|
|
|
+const Playlists = ({ playlists }) => {
|
|
|
return (
|
|
|
- <div style={{backgroundColor: 'lightcyan'}}>
|
|
|
- <PlaylistAddConnect />
|
|
|
+ <div>
|
|
|
{
|
|
|
- playlists?.payload? playlists.payload.map(item => {
|
|
|
+ playlists?.payload ? playlists.payload.map(item => {
|
|
|
return (
|
|
|
- <Link
|
|
|
- style={{display:'block', backgroundColor: 'darkcyan', color: 'cyan', margin: '5px', padding:'5px'}}
|
|
|
- to={`/player/playlist/:${item._id}`}
|
|
|
+ <Link
|
|
|
+ style={{ display: 'block', backgroundColor:'darkcyan', color: 'cyan', margin: '5px', padding: '5px' }}
|
|
|
+ to={`${history.location.pathname}/playlist/:${item._id}`}
|
|
|
>{item.name}</Link>
|
|
|
)
|
|
|
- }) : ''
|
|
|
+ }).reverse() : ''
|
|
|
}
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
-export const PlaylistsConnect = connect(state => ({playlists: state.promise.userPlaylists || {}}))(Playlists)
|
|
|
+export const PlaylistsConnect = connect(state => ({ playlists: state.promise.userPlaylists || {} }))(Playlists)
|