Skip to content

Commit

Permalink
refactor: simplify ternary
Browse files Browse the repository at this point in the history
  • Loading branch information
brage-andreas committed Sep 13, 2024
1 parent b51e53a commit b582de3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/profile/components/Settings/Penalties/Rules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ interface IProps {
const inFuture = (date: string) => new Date(date) > new Date();

const getLatestRuleSet = (rules: IMarkRule[]): IMarkRule => {
return rules.reduce(
(latest, rule) =>
!inFuture(rule.valid_from_date) && rule.valid_from_date > latest.valid_from_date ? rule : latest,
rules[0]
);
return 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]);
};

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

0 comments on commit b582de3

Please sign in to comment.