X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FItem.js;h=0d73105edd21ac13268223742196ca9bbdfe3daa;hb=edb883a1c3f74383db57d6b3ee93ba4c82a38f34;hp=5cdd3be42751c1b678508a1e3800a065b080bf93;hpb=06fd14404164904304a20e2280037e83299247fa;p=alttp.git
diff --git a/resources/js/components/results/Item.js b/resources/js/components/results/Item.js
index 5cdd3be..0d73105 100644
--- a/resources/js/components/results/Item.js
+++ b/resources/js/components/results/Item.js
@@ -9,6 +9,51 @@ import { findResult } from '../../helpers/Participant';
import { maySeeResults } from '../../helpers/permissions';
import { withUser } from '../../helpers/UserContext';
+const getIcon = (result, maySee) => {
+ if (!result || !result.has_finished) {
+ return ;
+ }
+ if (result.forfeit && maySee) {
+ return ;
+ }
+ if (result.placement === 1 && maySee) {
+ return ;
+ }
+ if (result.placement === 2 && maySee) {
+ return ;
+ }
+ if (result.placement === 3 && maySee) {
+ return ;
+ }
+ return ;
+};
+
+const getTime = (result, maySee) => {
+ if (!result || !maySee) {
+ return null;
+ }
+ if (result.time) {
+ return formatTime(result);
+ }
+ if (result.forfeit) {
+ return 'DNF';
+ }
+ return '?';
+};
+
+const getClassName = result => {
+ const classNames = ['status'];
+ if (result && result.has_finished) {
+ classNames.push('finished');
+ if (result.comment) {
+ classNames.push('has-comment');
+ }
+ } else {
+ classNames.push('pending');
+ }
+ return classNames.join(' ');
+};
+
const Item = ({
participant,
round,
@@ -16,23 +61,19 @@ const Item = ({
user,
}) => {
const result = findResult(participant, round);
- return (
-
-
-
-
- {result && maySeeResults(user, tournament, round) ?
- formatTime(result)
- : null}
-
- {result && result.has_finished ?
-
- :
-
- }
-
+ const maySee = maySeeResults(user, tournament, round);
+ return
+
+
+
+ {getTime(result, maySee)}
+
+ {getIcon(result, maySee)}
- );
+
;
};
Item.propTypes = {