Skip to content

Commit

Permalink
fixed calculation for determining days left
Browse files Browse the repository at this point in the history
  • Loading branch information
mrowe009 committed Apr 28, 2020
1 parent 479891c commit ec0862f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/normalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export const formatDate = (date, format = 'M/D/YYYY') => dayjs(date).format(form

export const pluralize = (count, string) => (1 === count ? string : `${string}s`)

export const determineDays = (dueDate = 1) => {
export const determineDays = dueDate => {
const now = new Date()
const nextPaymentDate =
dayjs().date() <= dueDate ? dayjs().set('date', dueDate) : dayjs().set('date', dueDate).add(2, 'week')
dayjs().date() <= dueDate ? dayjs().set('date', dueDate) : dayjs().set('date', dueDate).add(1, 'month')
const difference = dayjs(nextPaymentDate).diff(now, 'day')

if (difference === 14 || difference === 0) {
if (difference === 15 || difference === 0) {
return 'Submit Payment Today'
}

Expand Down

0 comments on commit ec0862f

Please sign in to comment.