import React from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';

import JKLatencyBadge from './JKLatencyBadge';

const JKUserLatency = ({user}) => {
  const latencyData = useSelector(state => state.latency.latencies.find(l => l.user_id === user.id));
  return (
    <JKLatencyBadge latencyData={latencyData} />
  );
};

JKUserLatency.propTypes = { user: PropTypes.object.isRequired };

export default JKUserLatency;
