import PropTypes from 'prop-types';
import React, { useState } from 'react';
import { Button } from 'react-bootstrap';
-import { withTranslation } from 'react-i18next';
+import { useTranslation } from 'react-i18next';
import DetailDialog from './DetailDialog';
import Icon from '../common/Icon';
import { getIcon, getTime } from '../../helpers/Result';
import { maySeeResults } from '../../helpers/permissions';
import { findResult } from '../../helpers/User';
-import { withUser } from '../../helpers/UserContext';
-import i18n from '../../i18n';
+import { useUser } from '../../hooks/user';
const getClassName = result => {
const classNames = ['status'];
};
const Item = ({
- authUser,
round,
tournament,
user,
}) => {
const [showDialog, setShowDialog] = useState(false);
- const result = findResult(user, round);
- const maySee = maySeeResults(authUser, tournament, round);
+
+ const { t } = useTranslation();
+ const { user: authUser } = useUser();
+
+ const result = React.useMemo(
+ () => findResult(user, round),
+ [round, user],
+ );
+ const maySee = React.useMemo(
+ () => maySeeResults(authUser, tournament, round),
+ [authUser, round, tournament],
+ );
+
return <div className="result">
<Box user={user} />
<div className="d-flex align-items-center justify-content-between">
href={result.vod}
size="sm"
target="_blank"
- title={i18n.t('results.vod')}
+ title={t('results.vod')}
variant={getVoDVariant(result)}
>
{getVoDIcon(result)}
};
Item.propTypes = {
- authUser: PropTypes.shape({
- }),
round: PropTypes.shape({
}),
tournament: PropTypes.shape({
}),
};
-export default withTranslation()(withUser(Item, 'authUser'));
+export default Item;