jelhan/croodle

View on GitHub
app/components/poll-evaluation-summary.hbs

Summary

Maintainability
Test Coverage
<div class="evaluation-summary">
  <h2>
    {{t "poll.evaluation.label"}}
  </h2>

  <p class="participants">
    {{t "poll.evaluation.participants" count=@poll.users.length}}
  </p>

  <p class="best-options">
    {{#if @poll.isFindADate}}
      {{t
        "poll.evaluation.bestOption.label.findADate"
        count=this.bestOptions.length
      }}
    {{else}}
      {{t
        "poll.evaluation.bestOption.label.makeAPoll"
        count=this.bestOptions.length
      }}
    {{/if}}

    {{#if (gt this.bestOptions.length 1)}}
      <ul>
        {{#each this.bestOptions as |evaluationBestOption|}}
          <li>
            <PollEvaluationSummaryOption
              @evaluationBestOption={{evaluationBestOption}}
              @isFindADate={{@poll.isFindADate}}
              @timeZone={{@timeZone}}
            />
          </li>
        {{/each}}
      </ul>
    {{else}}
      <PollEvaluationSummaryOption
        {{!
          @glint-ignore
          We can be sure that `this.bestOptions` contains at least one item
          as a poll must always have at least one option.
        }}
        @evaluationBestOption={{get this.bestOptions 0}}
        @isFindADate={{@poll.isFindADate}}
        @timeZone={{@timeZone}}
      />
    {{/if}}
  </p>

  <p class="last-participation">
    {{#if this.lastParticipationAt}}
      {{t
        "poll.evaluation.lastParticipation"
        ago=(format-date-relative this.lastParticipationAt)
      }}
    {{else}}
      {{!
        No need for the else block as user cannot enter evaluation page if
        no one participated in the poll yet.
      }}
    {{/if}}
  </p>
</div>