]> git.localhorst.tv Git - alttp.git/commitdiff
display forfeits with no time as DNF
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 15 Mar 2022 18:20:06 +0000 (19:20 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 15 Mar 2022 18:20:06 +0000 (19:20 +0100)
resources/js/components/results/Item.js

index 43ea91d09ca73157d299c9fa3a51075a17e145c9..0d0d34e81a11553f7535be8a883d1fabb7df378d 100644 (file)
@@ -28,6 +28,19 @@ const getIcon = (result, index) => {
        return <Icon.FINISHED className="text-success" size="lg" />;
 };
 
+const getTime = (user, tournament, round, result) => {
+       if (!result || !maySeeResults(user, tournament, round)) {
+               return null;
+       }
+       if (result.time) {
+               return formatTime(result);
+       }
+       if (result.forfeit) {
+               return 'DNF';
+       }
+       return '?';
+};
+
 const Item = ({
        index,
        participant,
@@ -36,19 +49,15 @@ const Item = ({
        user,
 }) => {
        const result = findResult(participant, round);
-       return (
-               <div className="result">
-                       <Box user={participant.user} />
-                       <div className="status">
-                               <span className="time">
-                                       {result && maySeeResults(user, tournament, round) ?
-                                               formatTime(result)
-                                       : null}
-                               </span>
-                               {getIcon(result, index)}
-                       </div>
+       return <div className="result">
+               <Box user={participant.user} />
+               <div className="status">
+                       <span className="time">
+                               {getTime(user, tournament, round, result)}
+                       </span>
+                       {getIcon(result, index)}
                </div>
-       );
+       </div>;
 };
 
 Item.propTypes = {