|
@@ -1,36 +1,34 @@
|
|
|
import * as action from '../../actions'
|
|
|
+import plugPic from '../../assets/default.png'
|
|
|
|
|
|
import { useState, useEffect, useCallback } from 'react';
|
|
|
import { connect } from 'react-redux';
|
|
|
import { Link } from 'react-router-dom';
|
|
|
-import { history, backendURL } from '../../App';
|
|
|
+import { backendURL } from '../../App';
|
|
|
import { useDropzone } from 'react-dropzone'
|
|
|
+import { faPlus, faBan, faSignOutAlt, faUpload} from "@fortawesome/free-solid-svg-icons";
|
|
|
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
|
|
|
const LogoutBtn = ({ onLogout }) =>
|
|
|
- <div
|
|
|
- style={{ border: '1px solid black', backgroundColor: 'red', color: 'white' }}
|
|
|
- onClick={() => { onLogout(); history.push('/login') }}
|
|
|
- >log-out[X]</div>
|
|
|
+ <Link
|
|
|
+ to='/login'
|
|
|
+ className='sidebar__link highlightRed'
|
|
|
+ onClick={() => onLogout()}
|
|
|
+ >LOG-OUT <FontAwesomeIcon icon={faSignOutAlt}/></Link>
|
|
|
|
|
|
-export const LogoutBtnConnect = connect(null, { onLogout: action.actionAuthLogout })(LogoutBtn)
|
|
|
+//export const LogoutBtnConnect = connect(null, { onLogout: action.actionAuthLogout })(LogoutBtn)
|
|
|
+export const LogoutBtnConnect = connect(null, { onLogout: action.actionFullLogout })(LogoutBtn)
|
|
|
|
|
|
const ProfileWindow = ({ user }) => {
|
|
|
let [userInfo, setUserInfo] = useState(user.payload)
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- setUserInfo(user.payload)
|
|
|
- }, [user, userInfo])
|
|
|
+ useEffect(() => setUserInfo(user.payload), [user, userInfo])
|
|
|
|
|
|
return (
|
|
|
- <section>
|
|
|
+ <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'
|
|
|
- />
|
|
|
+ {userInfo?.avatar?.url ?
|
|
|
+ <img src={backendURL + '/' + userInfo?.avatar?.url} alt='avatar'/> :
|
|
|
+ <img src={plugPic} alt='avatar' />}
|
|
|
</section>
|
|
|
)
|
|
|
}
|
|
@@ -38,15 +36,18 @@ export const ProfileWindowConnect = connect(state => ({ user: state.promise.user
|
|
|
|
|
|
const ProfileWindowDropzone = ({ onLoad }) => {
|
|
|
const onDrop = useCallback(acceptedFiles => {
|
|
|
- onLoad(acceptedFiles[0])
|
|
|
+ if(acceptedFiles[0].type === 'image/png' || acceptedFiles[0].type === 'image/jpeg') onLoad(acceptedFiles[0])
|
|
|
}, [onLoad])
|
|
|
const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop })
|
|
|
|
|
|
return (
|
|
|
- <div {...getRootProps()} style={isDragActive ? { border: '1px solid mediumseagreen' } : { border: '1px solid black' }}>
|
|
|
+ <div {...getRootProps()}
|
|
|
+ className='sidebar__profile'
|
|
|
+ style={isDragActive ? { backgroundColor: '#0e6147' } : { backgroundColor: 'transparent' }}
|
|
|
+ >
|
|
|
<input {...getInputProps()} />
|
|
|
<ProfileWindowConnect />
|
|
|
- {isDragActive ? <small>drag here...</small> : <small>change avatar</small>}
|
|
|
+ <small className='lightText'>{isDragActive ? '...drop here' : 'change avatar'}</small>
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
@@ -54,23 +55,9 @@ export const ProfileWindowDropzoneConnect = connect(null, { onLoad: action.actio
|
|
|
|
|
|
const UserTracksBtn = ({ userId }) => {
|
|
|
let [_id, setId] = useState()
|
|
|
- useEffect(() => {
|
|
|
- console.log('CHENG', userId)
|
|
|
- setId(userId)
|
|
|
- }, [userId])
|
|
|
-
|
|
|
- return (
|
|
|
- <Link
|
|
|
- to={`/player/tracks/:${_id}`}
|
|
|
- style={{
|
|
|
- display: 'block',
|
|
|
- backgroundColor: 'purple',
|
|
|
- color: 'white',
|
|
|
- margin: '5px',
|
|
|
- padding: '5px'
|
|
|
- }}
|
|
|
- >My uploads</Link>
|
|
|
- )
|
|
|
+ useEffect(() => setId(userId), [userId])
|
|
|
+
|
|
|
+ return (<Link to={`/player/tracks/:${_id}`} className='sidebar__link highlightYellow'>UPLOADS <FontAwesomeIcon icon={faUpload}/></Link>)
|
|
|
}
|
|
|
export const UserTracksBtnConnect = connect(state => ({ userId: state.promise.userData?.payload?._id || '' }))(UserTracksBtn)
|
|
|
|
|
@@ -82,28 +69,28 @@ const PlaylistAdd = ({ addPlaylist }) => {
|
|
|
{
|
|
|
!clicked ?
|
|
|
<button
|
|
|
- style={{ border: '1px solid black', backgroundColor: 'mediumseagreen', width: '95%', padding: '5px', margin: '5px' }}
|
|
|
+ className='sidebar__button highlightPaleGreen'
|
|
|
onClick={() => setClicked(true)}
|
|
|
>NEW PLAYLIST</button>
|
|
|
:
|
|
|
- <div style={{ width: '95%', margin: '0 auto' }}>
|
|
|
+ <div className='sidebar__addpanel'>
|
|
|
<input
|
|
|
- style={{ width: '72%', padding: '5px' }}
|
|
|
- placeholder='Playlist name'
|
|
|
+ placeholder='NEW PLATLIST NAME'
|
|
|
value={name}
|
|
|
onChange={(e) => setName(e.target.value)}
|
|
|
/>
|
|
|
+ <div className='sidebar__addpanel btnWrapper'>
|
|
|
+ <button
|
|
|
+ disabled={!name}
|
|
|
+ className='highlightGreen'
|
|
|
+ onClick={() => { addPlaylist(name); setClicked(false); setName(''); }}
|
|
|
+ ><FontAwesomeIcon icon={faPlus} /></button>
|
|
|
|
|
|
- <button
|
|
|
- disabled={!name}
|
|
|
- style={{ padding: '5px', backgroundColor: 'mediumseagreen' }}
|
|
|
- onClick={() => { addPlaylist(name); setClicked(false); setName(''); }}
|
|
|
- >+</button>
|
|
|
-
|
|
|
- <button
|
|
|
- style={{ padding: '5px', backgroundColor: 'red' }}
|
|
|
- onClick={() => { setClicked(false); setName('') }}
|
|
|
- >X</button>
|
|
|
+ <button
|
|
|
+ className='highlightRed'
|
|
|
+ onClick={() => { setClicked(false); setName('') }}
|
|
|
+ ><FontAwesomeIcon icon={faBan} /></button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
}
|
|
|
</div>
|
|
@@ -111,17 +98,12 @@ const PlaylistAdd = ({ addPlaylist }) => {
|
|
|
}
|
|
|
export const PlaylistAddConnect = connect(null, { addPlaylist: action.actionAddPlaylist })(PlaylistAdd)
|
|
|
|
|
|
-const Playlists = ({ playlists }) => {
|
|
|
+const Playlists = ( { playlists }) => {
|
|
|
return (
|
|
|
<div>
|
|
|
{
|
|
|
playlists?.payload ? playlists.payload.map(item => {
|
|
|
- return (
|
|
|
- <Link
|
|
|
- style={{ display: 'block', backgroundColor:'darkcyan', color: 'cyan', margin: '5px', padding: '5px' }}
|
|
|
- to={`/player/playlist/:${item._id}`}
|
|
|
- >{item.name}</Link>
|
|
|
- )
|
|
|
+ return (<Link key={item._id} className='sidebar__link' to={`/player/playlist/:${item._id}`}>{item.name}</Link> )
|
|
|
}).reverse() : ''
|
|
|
}
|
|
|
</div>
|