Skip to content

Commit ed16b1a

Browse files
committed
Fix double API call for billing account and billing account look and feel
1 parent 5d4ab00 commit ed16b1a

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

src/components/ChallengesComponent/ChallengeList/ChallengeList.module.scss

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
font-weight: bold;
2929
color: #BE405E;
3030
}
31+
.active {
32+
color: #008000;
33+
}
34+
.inactive {
35+
color: #BE405E;
36+
}
3137
}
3238

3339
.header {

src/components/ChallengesComponent/ChallengeList/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ class ChallengeList extends Component {
178178
<div className={styles.row}>
179179
{!isBillingAccountLoading && !isBillingAccountLoadingFailed && !isBillingAccountExpired && (
180180
<div className={'col-9'}>
181-
Billing Account: {status} Start Date {billingStartDate} End Date {billingEndDate}
181+
Billing Account: <span className={styles.active}>{status}</span> Start Date: {billingStartDate} End Date: {billingEndDate}
182182
</div>
183183
)}
184184
{!isBillingAccountLoading && !isBillingAccountLoadingFailed && isBillingAccountExpired && (
185185
<div className={'col-9'}>
186-
Billing Account: <span className={styles.title}>INACTIVE</span> Start Date {billingStartDate} End Date {billingEndDate}
186+
Billing Account: <span className={styles.inactive}>INACTIVE</span> Start Date: {billingStartDate} End Date: {billingEndDate}
187187
</div>
188188
)}
189189
{!isBillingAccountLoading && isBillingAccountLoadingFailed && (

src/containers/Challenges/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Challenges extends Component {
3434
resetSidebarActiveParams()
3535
} else if (projectId || selfService) {
3636
if (projectId) {
37+
window.localStorage.setItem('projectLoading', 'true')
3738
this.props.loadProject(projectId)
3839
}
3940
this.reloadChallenges(this.props)
@@ -51,9 +52,12 @@ class Challenges extends Component {
5152
if (activeProjectId !== challengeProjectId || selfService) {
5253
const isAdmin = checkAdmin(this.props.auth.token)
5354
this.props.loadChallengesByPage(1, projectId ? parseInt(projectId) : -1, CHALLENGE_STATUS.ACTIVE, '', selfService, isAdmin ? null : this.props.auth.user.handle)
54-
if (!selfService && (!reduxProjectInfo || `${reduxProjectInfo.id}` !== projectId)
55+
const projectLoading = window.localStorage.getItem('projectLoading') !== null
56+
if (!selfService && (!reduxProjectInfo || `${reduxProjectInfo.id}` !== projectId) && !projectLoading
5557
) {
5658
loadProject(projectId)
59+
} else {
60+
window.localStorage.removeItem('projectLoading')
5761
}
5862
}
5963
}

src/reducers/projects.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const checkBillingExpired = (active, endDate) => {
3030
}
3131
return true
3232
}
33+
const dateFormat = 'MMM DD, YYYY'
3334

3435
const initialState = {
3536
isLoading: false,
@@ -71,8 +72,8 @@ export default function (state = initialState, action) {
7172
...state,
7273
isBillingAccountLoading: false,
7374
isBillingAccountExpired: checkBillingExpired(action.payload.active, action.payload.endDate),
74-
billingStartDate: action.payload.startDate,
75-
billingEndDate: action.payload.endDate,
75+
billingStartDate: moment(action.payload.startDate).format(dateFormat),
76+
billingEndDate: moment(action.payload.endDate).format(dateFormat),
7677
isBillingAccountLoadingFailed: false
7778
}
7879
case LOAD_PROJECT_BILLING_ACCOUNT_FAILURE:

0 commit comments

Comments
 (0)