Skip to content

Commit cd9d04e

Browse files
author
mrowe009
committed
fixed ui and refactored days left calculations
1 parent bab8387 commit cd9d04e

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

src/components/Card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const useStyles = createUseStyles(theme => ({
9797
'&::before': cardTitle(theme.spacing(2), 'AMEX')
9898
},
9999
mini: {
100-
padding: '2px 6px',
100+
padding: '4px 10px',
101101
boxShadow: 'none',
102102
borderRadius: '6px',
103103
'&::before': {

src/modules/home/util.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const useHomeViewStyles = createUseStyles(theme => ({
1919
margin: theme.spacing(0, 'auto'),
2020
display: 'flex',
2121
flexDirection: 'column',
22-
justifyContent: 'space-evenly',
22+
justifyContent: 'space-around',
2323
position: 'relative',
2424
background: theme.linearGradient('var(--ion-color-primary)', 'var(--ion-color-secondary)'),
2525
boxShadow: '0px 4px 10px -4px var(--black)',
@@ -30,12 +30,10 @@ export const useHomeViewStyles = createUseStyles(theme => ({
3030
paddingBottom: theme.spacing(7)
3131
},
3232
dueDateContainer: {
33-
width: '70%',
33+
width: '100%',
3434
padding: theme.spacing(1, 0),
3535
margin: theme.spacing(2, 'auto'),
36-
backgroundColor: 'var(--alpha25)',
3736
borderRadius: 'var(--borderRadius)',
38-
boxShadow: '0px 2px 5px -2px var(--black)',
3937
'& > .swiper-pagination': {
4038
bottom: '5px'
4139
}
@@ -76,7 +74,6 @@ export const useHomeHooks = () => {
7674
)(cards),
7775
[cards]
7876
)
79-
console.log(daysLeft)
8077

8178
return {
8279
amountLeft,

src/modules/home/views/HomeView.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ const Home = () => {
5050
<IonSlide key={c._id} className={classes.slide}>
5151
<Card small type={c.type} className={classes.miniCard} />
5252
<IonText align="left">
53-
<p>{c.name}</p>
53+
<p variant="subtitle1">{c.name}</p>
5454
<p variant="caption" color="textSecondary">
5555
{c.text}
5656
</p>
5757
</IonText>
58-
<div />
5958
</IonSlide>
6059
))(daysLeft)}
6160
</IonSlides>

src/utils/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export const useToolbarTransition = () => {
55
const scrollHandler = useCallback(e => toggleStyle(e.detail.scrollTop > 30), [])
66

77
return { toolbarTransition, scrollHandler }
8-
}
8+
}

src/utils/normalizer.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
import dayjs from 'dayjs'
2+
import cond from 'lodash/fp/cond'
3+
import some from 'lodash/fp/some'
4+
import isEqual from 'lodash/fp/isEqual'
25
import replace from 'lodash/fp/replace'
6+
import stubTrue from 'lodash/fp/stubTrue'
37

48
export const formatDate = (date, format = 'M/D/YYYY') => dayjs(date).format(format)
59

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

12+
export const or = (...func) => val => some(f => f(val))(func)
13+
14+
export const customConstant = text => count => ({ text, count })
15+
16+
const _determineDays = cond([
17+
[or(isEqual(15), isEqual(0)), customConstant('Submit Payment Today')],
18+
[isEqual(1), customConstant('Payment Due Tomorrow')],
19+
[stubTrue, v => customConstant(`${v >= 15 ? v - 15 : v} days left`)(v)]
20+
])
21+
822
export const calculateDays = dueDate => {
923
const now = new Date()
1024
const nextPaymentDate =
1125
dayjs().date() <= dueDate ? dayjs().set('date', dueDate) : dayjs().set('date', dueDate).add(1, 'month')
1226
const difference = dayjs(nextPaymentDate).diff(now, 'day')
1327

14-
if (difference === 15 || difference === 0) {
15-
return 'Submit Payment Today'
16-
}
17-
18-
const _daysLeftCount = difference >= 15 ? difference - 15 : difference
19-
20-
if (_daysLeftCount === 1) return 'Payment Due Tomorrow'
21-
return { count: _daysLeftCount, text: `${_daysLeftCount} days left` }
28+
return _determineDays(difference)
2229
}
2330

2431
export const currency = number => `$${(number / 100).toFixed(2)}`

0 commit comments

Comments
 (0)