]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/results/Item.js
basic result display
[alttp.git] / resources / js / components / results / Item.js
diff --git a/resources/js/components/results/Item.js b/resources/js/components/results/Item.js
new file mode 100644 (file)
index 0000000..993a382
--- /dev/null
@@ -0,0 +1,38 @@
+import PropTypes from 'prop-types';
+import React from 'react';
+import { withTranslation } from 'react-i18next';
+
+import Box from '../users/Box';
+import { formatTime } from '../../helpers/Result';
+import { findResult } from '../../helpers/Participant';
+import i18n from '../../i18n';
+
+const Item = ({
+       participant,
+       round,
+}) => {
+       const result = findResult(participant, round);
+       return (
+               <div className="result">
+                       <Box user={participant.user} />
+                       {result ?
+                               <div>
+                                       {i18n.t('results.time', { time: formatTime(result) })}
+                               </div>
+                       : null}
+               </div>
+       );
+};
+
+Item.propTypes = {
+       participant: PropTypes.shape({
+               user: PropTypes.shape({
+               }),
+       }),
+       round: PropTypes.shape({
+       }),
+       tournament: PropTypes.shape({
+       }),
+};
+
+export default withTranslation()(Item);