Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { type UnixTimestampInSeconds } from '@amalia/ext/dates';
import { type RuleConfiguration } from '@amalia/payout-definition/plans/types';
export type ChallengeStatus = 'future' | 'ongoing' | 'past';
export const getChallengeStatus = (
ruleConfiguration?: Pick<RuleConfiguration, 'challengeEndDate' | 'challengeStartDate'> | null,
referenceDate: UnixTimestampInSeconds = Date.now() / 1000,
): ChallengeStatus =>
ruleConfiguration?.challengeStartDate && ruleConfiguration.challengeStartDate > referenceDate
? 'future'
: ruleConfiguration?.challengeEndDate && ruleConfiguration.challengeEndDate < referenceDate
? 'past'
: 'ongoing';
|