Skip to content

Commit b5dc8cb

Browse files
committed
update render to not display wavy if the quiz hasn't been attempted
1 parent d5ed995 commit b5dc8cb

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/queries/training-matrix/render.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@ import { tooltipWith} from '../shared-render/tool-tip';
55
import { FullQuizResultsForMember } from '../../read-models/external-state/equipment-quiz';
66
import { UUID } from 'io-ts-types';
77

8-
const GREEN_TICK = '✅' as Safe;
9-
const WAVY_DASH = '〰️' as Safe;
8+
const GREEN_TICK = html`✅`;
9+
const WAVY_DASH = html`〰️`;
10+
const PLACEHOLDER = html`-`;
1011

11-
const renderYes = (when: O.Option<Date>) => O.isSome(when) ? html`
12-
${tooltipWith(html`Since ${when.value.toLocaleDateString() as Safe}`, GREEN_TICK)}
13-
` : html`-`;
12+
const renderYes = (when: O.Option<Date>) => O.isSome(when) ? tooltipWith(html`Since ${when.value.toLocaleDateString() as Safe}`, GREEN_TICK) : PLACEHOLDER;
13+
14+
const renderEquipmentQuizStatus = (equipment_quiz: TrainingMatrix[0]['equipment'][0]['equipment_quiz']) => {
15+
if (equipment_quiz.passedAt.length > 0) {
16+
return tooltipWith(equipment_quiz.passedAt.map(d => d.toLocaleDateString()).join(',') as Safe, GREEN_TICK);
17+
}
18+
if (equipment_quiz.attempted.length > 0) {
19+
return tooltipWith(equipment_quiz.attempted.map(d => html`${d.percentage}% - ${d.response_submitted.toLocaleDateString() as Safe}`).join(',') as Safe, WAVY_DASH);
20+
}
21+
return PLACEHOLDER;
22+
};
1423

1524
const renderTrainingMatrixRow = (areaColumn: HtmlSubstitution, ownerColumn: HtmlSubstitution, row: TrainingMatrix[0]['equipment'][0]) => html`
1625
<tr>
@@ -22,13 +31,7 @@ const renderTrainingMatrixRow = (areaColumn: HtmlSubstitution, ownerColumn: Html
2231
</a>
2332
</th>
2433
<th scope="row">
25-
${
26-
row.equipment_quiz.passedAt.length > 0 ? html`
27-
${tooltipWith(row.equipment_quiz.passedAt.map(d => d.toLocaleDateString()).join(',') as Safe, GREEN_TICK)}
28-
` : html`
29-
${tooltipWith(row.equipment_quiz.attempted.map(d => html`${d.percentage}% - ${d.response_submitted.toLocaleDateString() as Safe}`).join(',') as Safe, WAVY_DASH)}
30-
`
31-
}
34+
${renderEquipmentQuizStatus(row.equipment_quiz)}
3235
</th>
3336
<th scope="row">
3437
${renderYes(row.is_trained)}

0 commit comments

Comments
 (0)