feat(points): show early-since date in point texts

Refs #44. Core sends earlySince in the games and wallet responses.
COMPLETION_TOO_OLD and the COMPLETED rule show it as {{date}}.
This commit is contained in:
lobo committed 2026-10-11 13:51:34 +02:00
1 parent e044959629
commit c966877b23
7 files changed
+62 -8

No files matched your search

+3 -2
View File
@@ -1,7 +1,7 @@
import {useEffect, useRef, useState} from 'react';
import {useTranslation} from 'react-i18next';
import usePointsCheck from '../hooks/usePointsCheck.js';
import {formatDate} from '../utils/format.js';
import {formatDate, formatDay} from '../utils/format.js';
import {STATUS_NOT_REACHED} from '../utils/rewards.js';
const WAITING = {NO_PROOF: 'POINTS.GAME.WAITING', NO_PLAY_AFTER_START: 'POINTS.GAME.WAITING_START'};
@@ -33,6 +33,7 @@ export default function GamePointsLine({game}) {
}, [check, game.appid, game.status]);
if (!points) return null;
const earlySinceText = points.earlySince && formatDay(points.earlySince, i18n.language, {dateStyle: 'medium'});
const kindText = (kind) => t(`POINTS.KINDS.${kind}`);
const lines = [
...points.paid.map((row) => t('POINTS.GAME.PAID', {
@@ -41,7 +42,7 @@ export default function GamePointsLine({game}) {
}) + (row.appid === game.appid ? '' : ` ${t('POINTS.GAME.OTHER_EDITION')}`)),
...Object.entries(points.missing).filter(([, reason]) => !STATUS_NOT_REACHED.includes(reason)).map(([kind, reason]) => (
waitingKey(kind, reason) ? t(waitingKey(kind, reason))
: t('POINTS.GAME.NONE', {kind: kindText(kind), reason: t(`POINTS.REASONS.${reason}`)}))),
: t('POINTS.GAME.NONE', {kind: kindText(kind), reason: t(`POINTS.REASONS.${reason}`, {date: earlySinceText})}))),
];
return lines.map((line, i) => <p key={i} className="text-sm text-muted-foreground">{line}</p>);
}