Skip to content

Commit

Permalink
chore: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 committed May 22, 2024
1 parent 98495d7 commit 563051b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const useExpiry = (enterpriseId, budgets, modalOpen, modalClose, alertOpen, aler
const [notification, setNotification] = useState(null);
const [expirationThreshold, setExpirationThreshold] = useState(null);
const [modal, setModal] = useState(null);
const [isNonExpiredBudget, setisNonExpiredBudget] = useState(false);
const [isNonExpiredBudget, setIsNonExpiredBudget] = useState(false);

useEffect(() => {
if (!budgets || budgets.length === 0) {
Expand All @@ -31,7 +31,7 @@ const useExpiry = (enterpriseId, budgets, modalOpen, modalClose, alertOpen, aler
// If an unexpired budget exists, set budgetsToConsiderForExpirationMessaging to nonExpiredBudgets
if (hasNonExpiredBudgets) {
budgetsToConsiderForExpirationMessaging = nonExpiredBudgets;
setisNonExpiredBudget(true);
setIsNonExpiredBudget(true);
} else {
budgetsToConsiderForExpirationMessaging = expiredBudgets;
}
Expand Down
13 changes: 11 additions & 2 deletions src/components/BudgetExpiryAlertAndModal/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ dayjs.extend(duration);

export const getExpiredAndNonExpiredBudgets = (budgets) => {
const today = dayjs();
const nonExpiredBudgets = [];
const expiredBudgets = [];
budgets.forEach((budget) => {
if (today <= dayjs(budget.end)) {
nonExpiredBudgets.push(budget);
} else {
expiredBudgets.push(budget);
}
});
return {
nonExpiredBudgets: budgets.filter((budget) => today <= dayjs(budget.end)),
expiredBudgets: budgets.filter((budget) => today > dayjs(budget.end)),
nonExpiredBudgets,
expiredBudgets,
};
};

Expand Down

0 comments on commit 563051b

Please sign in to comment.