2023-12-13 22:49:25 +00:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import JKProfileAvatar from '../profile/JKProfileAvatar';
|
|
|
|
|
import JKConnectButton from '../profile/JKConnectButton';
|
|
|
|
|
import JKMessageButton from '../profile/JKMessageButton';
|
|
|
|
|
import JKMoreDetailsButton from '../profile/JKMoreDetailsButton';
|
2024-01-01 20:53:21 +00:00
|
|
|
import JKLatencyBadge from '../profile/JKLatencyBadge';
|
|
|
|
|
import JKProfileInstrumentsList from '../profile/JKProfileInstrumentsList';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-12-13 22:49:25 +00:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
|
import JKProfileSidePanel from '../profile/JKProfileSidePanel';
|
|
|
|
|
import { useSelector, useDispatch } from 'react-redux';
|
|
|
|
|
import { fetchPerson } from '../../store/features/peopleSlice';
|
2024-01-01 20:53:21 +00:00
|
|
|
import { useResponsive } from '@farfetch/react-context-responsive';
|
2023-12-13 22:49:25 +00:00
|
|
|
|
|
|
|
|
import { useAuth } from '../../context/UserAuth';
|
|
|
|
|
|
2024-01-01 20:53:21 +00:00
|
|
|
function JKLobbyUser({ user, setSelectedUsers }) {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const [showSidePanel, setShowSidePanel] = useState(false);
|
2023-12-13 22:49:25 +00:00
|
|
|
const { currentUser } = useAuth();
|
|
|
|
|
const dispatch = useDispatch();
|
2024-01-01 20:53:21 +00:00
|
|
|
const { greaterThan } = useResponsive();
|
2023-12-13 22:49:25 +00:00
|
|
|
const latencyData = useSelector(state => state.latency.latencies.find(l => l.user_id === user.id));
|
|
|
|
|
const userData = useSelector(state => state.people.people.find(p => p.id === user.id));
|
|
|
|
|
|
2024-01-01 20:53:21 +00:00
|
|
|
const toggleMoreDetails = async e => {
|
2023-12-13 22:49:25 +00:00
|
|
|
e.preventDefault();
|
|
|
|
|
try {
|
|
|
|
|
await dispatch(fetchPerson({ userId: user.id })).unwrap();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
setShowSidePanel(prev => !prev);
|
|
|
|
|
};
|
2023-12-05 22:53:17 +00:00
|
|
|
|
2024-01-01 20:53:21 +00:00
|
|
|
const setSelection = e => {
|
|
|
|
|
if (e.target.checked) {
|
|
|
|
|
setSelectedUsers(prev => [...prev, user.id]);
|
|
|
|
|
} else {
|
|
|
|
|
setSelectedUsers(prev => prev.filter(u => u !== user.id));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-05 22:53:17 +00:00
|
|
|
return (
|
2023-12-13 22:49:25 +00:00
|
|
|
<>
|
2024-01-01 20:53:21 +00:00
|
|
|
{greaterThan.sm ? (
|
|
|
|
|
<tr>
|
|
|
|
|
<td className="align-middle">
|
|
|
|
|
<div className="d-flex">
|
|
|
|
|
<div className="mr-2 pt-2">
|
|
|
|
|
<input type="checkbox" className="align-middle" onClick={setSelection} />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="">
|
|
|
|
|
<div className="d-flex align-items-center">
|
|
|
|
|
<div className="avatar avatar-sm mr-2">
|
|
|
|
|
<JKProfileAvatar src={user.photo_url} />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="">
|
|
|
|
|
<a href="/#" onClick={toggleMoreDetails}>
|
|
|
|
|
<strong>{user.name}</strong>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<strong>{t('person_attributes.latency_to_me', { ns: 'people' })}:</strong>{' '}
|
|
|
|
|
<JKLatencyBadge latencyData={latencyData} />
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<strong>{t('person_attributes.instruments', { ns: 'people' })}</strong>
|
|
|
|
|
{/* <JKProfileInstrumentsList instruments={user.instruments} toggleMoreDetails={toggleMoreDetails} /> */}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
<td className="align-middle text-center">
|
|
|
|
|
<JKConnectButton
|
|
|
|
|
currentUser={currentUser}
|
|
|
|
|
user={user}
|
|
|
|
|
addContent={<FontAwesomeIcon icon="plus" transform="shrink-4 down-1" className="mr-1" />}
|
|
|
|
|
removeContent={<FontAwesomeIcon icon="minus" transform="shrink-4 down-1" className="mr-1" />}
|
|
|
|
|
cssClasses="fs--1 px-2 py-1 mr-1"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<JKMessageButton currentUser={currentUser} user={user} cssClasses="fs--1 px-2 py-1 mr-1">
|
|
|
|
|
<FontAwesomeIcon icon="comments" transform="shrink-4 down-1" className="mr-1" />
|
|
|
|
|
</JKMessageButton>
|
|
|
|
|
|
|
|
|
|
<JKMoreDetailsButton toggleMoreDetails={toggleMoreDetails} cssClasses="btn btn-primary fs--1 px-2 py-1">
|
|
|
|
|
<FontAwesomeIcon icon="user" transform="shrink-4 down-1" className="mr-1" />
|
|
|
|
|
</JKMoreDetailsButton>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<div>
|
|
|
|
|
<strong>{t('person_attributes.latency_to_me', { ns: 'people' })}:</strong>{' '}
|
|
|
|
|
<JKLatencyBadge latencyData={latencyData} />
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<h5>{t('person_attributes.instruments', { ns: 'people' })}</h5>
|
|
|
|
|
{/* <JKProfileInstrumentsList instruments={instruments} toggleMoreDetails={toggleMoreDetails} /> */}
|
2023-12-13 22:49:25 +00:00
|
|
|
</div>
|
2024-01-01 20:53:21 +00:00
|
|
|
<div>
|
|
|
|
|
<h5>{t('person_attributes.genres', { ns: 'people' })}</h5>
|
|
|
|
|
{/* <JKProfileGenres genres={genres} toggleMoreDetails={toggleMoreDetails} /> */}
|
2023-12-13 22:49:25 +00:00
|
|
|
</div>
|
2024-01-01 20:53:21 +00:00
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
<JKConnectButton
|
|
|
|
|
currentUser={currentUser}
|
|
|
|
|
user={user}
|
|
|
|
|
addContent={<FontAwesomeIcon icon="plus" transform="shrink-4 down-1" className="mr-1" />}
|
|
|
|
|
removeContent={<FontAwesomeIcon icon="minus" transform="shrink-4 down-1" className="mr-1" />}
|
|
|
|
|
cssClasses="fs--1 px-2 py-1 mr-1"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<JKMessageButton currentUser={currentUser} user={user} cssClasses="fs--1 px-2 py-1 mr-1">
|
|
|
|
|
<FontAwesomeIcon icon="comments" transform="shrink-4 down-1" className="mr-1" />
|
|
|
|
|
</JKMessageButton>
|
2023-12-13 22:49:25 +00:00
|
|
|
|
2024-01-01 20:53:21 +00:00
|
|
|
<a href="/#" onClick={toggleMoreDetails} data-testid="btnMore">
|
|
|
|
|
<span
|
|
|
|
|
className="btn btn-primary fs--1 px-2 py-1"
|
|
|
|
|
data-bs-toggle="tooltip"
|
|
|
|
|
title={t('view_profile', { ns: 'people' })}
|
|
|
|
|
>
|
|
|
|
|
<FontAwesomeIcon icon="user" transform="shrink-4 down-1" className="mr-1" />
|
|
|
|
|
</span>
|
|
|
|
|
</a>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2023-12-13 22:49:25 +00:00
|
|
|
|
2024-01-01 20:53:21 +00:00
|
|
|
<JKProfileSidePanel user={userData} latencyData={latencyData} show={showSidePanel} setShow={setShowSidePanel} />
|
2023-12-13 22:49:25 +00:00
|
|
|
</>
|
2023-12-05 22:53:17 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default JKLobbyUser;
|