Skip to content

Commit

Permalink
fix: do not return valid_from_date in future
Browse files Browse the repository at this point in the history
  • Loading branch information
brage-andreas committed Sep 13, 2024
1 parent ed177f0 commit bc56fa7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/profile/components/Settings/Penalties/Rules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ const getLatestRuleSet = (rules: IMarkRule[]): IMarkRule | null => {
}

if (rules.length === 1) {
return rules[0];
return inFuture(rules[0].valid_from_date) ? null : rules[0];
}

return rules.reduce((latest, rule) => {
const ruleset = rules.reduce((latest, rule) => {
if (inFuture(rule.valid_from_date)) {
return latest;
}

return rule.valid_from_date > latest.valid_from_date ? rule : latest;
}, rules[0]);

return inFuture(ruleset.valid_from_date) ? null : ruleset;
};

export const Info = ({ rules }: IProps) => {
Expand Down

0 comments on commit bc56fa7

Please sign in to comment.