Skip to content

Commit 5d4ab00

Browse files
committed
Add billing account start / end date to project page
1 parent 0420acb commit 5d4ab00

File tree

6 files changed

+99
-12
lines changed

6 files changed

+99
-12
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ workflows:
150150
context : org-global
151151
filters: &filters-dev
152152
branches:
153-
only: ['develop', 'jira-vuln-2333']
153+
only: ['develop', 'jira-vuln-2333', 'justin-fixes']
154154

155155
# Production builds are exectuted only on tagged commits to the
156156
# master branch.

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

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
padding-bottom: 10px;
2121
}
2222
}
23+
24+
.title {
25+
font-weight: bold;
26+
}
27+
.error {
28+
font-weight: bold;
29+
color: #BE405E;
30+
}
2331
}
2432

2533
.header {

src/components/ChallengesComponent/ChallengeList/index.js

+31-8
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ class ChallengeList extends Component {
125125
partiallyUpdateChallengeDetails,
126126
deleteChallenge,
127127
isBillingAccountExpired,
128+
billingStartDate,
129+
billingEndDate,
130+
isBillingAccountLoadingFailed,
131+
isBillingAccountLoading,
128132
selfService
129133
} = this.props
130134
if (warnMessage) {
@@ -172,14 +176,29 @@ class ChallengeList extends Component {
172176
return (
173177
<div className={styles.list}>
174178
<div className={styles.row}>
175-
<DebounceInput
176-
className={styles.challengeInput}
177-
minLength={2}
178-
debounceTimeout={300}
179-
placeholder='Search Challenges'
180-
onChange={(e) => this.updateSearchParam(e.target.value, status)}
181-
value={searchText}
182-
/>
179+
{!isBillingAccountLoading && !isBillingAccountLoadingFailed && !isBillingAccountExpired && (
180+
<div className={'col-9'}>
181+
Billing Account: {status} Start Date {billingStartDate} End Date {billingEndDate}
182+
</div>
183+
)}
184+
{!isBillingAccountLoading && !isBillingAccountLoadingFailed && isBillingAccountExpired && (
185+
<div className={'col-9'}>
186+
Billing Account: <span className={styles.title}>INACTIVE</span> Start Date {billingStartDate} End Date {billingEndDate}
187+
</div>
188+
)}
189+
{!isBillingAccountLoading && isBillingAccountLoadingFailed && (
190+
<div className={'col-9'}><span className={styles.error}>Billing Account failed to load</span></div>
191+
)}
192+
<div className={'col-3'}>
193+
<DebounceInput
194+
className={styles.challengeInput}
195+
minLength={2}
196+
debounceTimeout={300}
197+
placeholder='Search Challenges'
198+
onChange={(e) => this.updateSearchParam(e.target.value, status)}
199+
value={searchText}
200+
/>
201+
</div>
183202
</div>
184203
{activeProject && (<Tabs
185204
selectedIndex={selectedTab}
@@ -307,6 +326,10 @@ ChallengeList.propTypes = {
307326
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
308327
deleteChallenge: PropTypes.func.isRequired,
309328
isBillingAccountExpired: PropTypes.bool,
329+
billingStartDate: PropTypes.string,
330+
billingEndDate: PropTypes.string,
331+
isBillingAccountLoadingFailed: PropTypes.bool,
332+
isBillingAccountLoading: PropTypes.bool,
310333
selfService: PropTypes.bool,
311334
auth: PropTypes.object.isRequired
312335
}

src/components/ChallengesComponent/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const ChallengesComponent = ({
2828
partiallyUpdateChallengeDetails,
2929
deleteChallenge,
3030
isBillingAccountExpired,
31+
billingStartDate,
32+
billingEndDate,
33+
isBillingAccountLoadingFailed,
34+
isBillingAccountLoading,
3135
selfService,
3236
auth
3337
}) => {
@@ -78,6 +82,10 @@ const ChallengesComponent = ({
7882
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
7983
deleteChallenge={deleteChallenge}
8084
isBillingAccountExpired={isBillingAccountExpired}
85+
billingStartDate={billingStartDate}
86+
billingEndDate={billingEndDate}
87+
isBillingAccountLoadingFailed={isBillingAccountLoadingFailed}
88+
isBillingAccountLoading={isBillingAccountLoading}
8189
selfService={selfService}
8290
auth={auth}
8391
/>
@@ -106,6 +114,10 @@ ChallengesComponent.propTypes = {
106114
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
107115
deleteChallenge: PropTypes.func.isRequired,
108116
isBillingAccountExpired: PropTypes.bool,
117+
billingStartDate: PropTypes.string,
118+
billingEndDate: PropTypes.string,
119+
isBillingAccountLoadingFailed: PropTypes.bool,
120+
isBillingAccountLoading: PropTypes.bool,
109121
selfService: PropTypes.bool,
110122
auth: PropTypes.object.isRequired
111123
}

src/containers/Challenges/index.js

+16
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class Challenges extends Component {
8787
partiallyUpdateChallengeDetails,
8888
deleteChallenge,
8989
isBillingAccountExpired,
90+
billingStartDate,
91+
billingEndDate,
92+
isBillingAccountLoadingFailed,
93+
isBillingAccountLoading,
9094
selfService,
9195
auth
9296
} = this.props
@@ -155,6 +159,10 @@ class Challenges extends Component {
155159
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
156160
deleteChallenge={deleteChallenge}
157161
isBillingAccountExpired={isBillingAccountExpired}
162+
billingStartDate={billingStartDate}
163+
billingEndDate={billingEndDate}
164+
isBillingAccountLoadingFailed={isBillingAccountLoadingFailed}
165+
isBillingAccountLoading={isBillingAccountLoading}
158166
selfService={selfService}
159167
auth={auth}
160168
/>
@@ -186,6 +194,10 @@ Challenges.propTypes = {
186194
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
187195
deleteChallenge: PropTypes.func.isRequired,
188196
isBillingAccountExpired: PropTypes.bool,
197+
billingStartDate: PropTypes.string,
198+
billingEndDate: PropTypes.string,
199+
isBillingAccountLoadingFailed: PropTypes.bool,
200+
isBillingAccountLoading: PropTypes.bool,
189201
selfService: PropTypes.bool,
190202
auth: PropTypes.object.isRequired
191203
}
@@ -197,6 +209,10 @@ const mapStateToProps = ({ challenges, sidebar, projects, auth }) => ({
197209
projects: sidebar.projects,
198210
projectDetail: projects.projectDetail,
199211
isBillingAccountExpired: projects.isBillingAccountExpired,
212+
billingStartDate: projects.billingStartDate,
213+
billingEndDate: projects.billingEndDate,
214+
isBillingAccountLoadingFailed: projects.isBillingAccountLoadingFailed,
215+
isBillingAccountLoading: projects.isBillingAccountLoading,
200216
auth: auth
201217
})
202218

src/reducers/projects.js

+31-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,32 @@ import {
1313
LOAD_PROJECT_PHASES_PENDING,
1414
LOAD_PROJECT_PHASES_SUCCESS
1515
} from '../config/constants'
16+
import moment from 'moment-timezone'
17+
18+
/**
19+
* checks if billing is expired or not
20+
* @param {boolean} active if billing account is active or not
21+
* @param {string} endDate the end date
22+
* @returns if billing expired or not
23+
*/
24+
const checkBillingExpired = (active, endDate) => {
25+
if (active) {
26+
if (moment().isBefore(endDate)) {
27+
return false
28+
}
29+
return true
30+
}
31+
return true
32+
}
1633

1734
const initialState = {
1835
isLoading: false,
1936
projectDetail: {},
2037
isBillingAccountExpired: false,
2138
isBillingAccountLoading: false,
39+
isBillingAccountLoadingFailed: false,
40+
billingStartDate: null,
41+
billingEndDate: null,
2242
isPhasesLoading: false,
2343
phases: []
2444
}
@@ -42,19 +62,27 @@ export default function (state = initialState, action) {
4262
return {
4363
...state,
4464
isBillingAccountLoading: true,
45-
isBillingAccountExpired: false
65+
isBillingAccountExpired: false,
66+
billingStartDate: '',
67+
billingEndDate: ''
4668
}
4769
case LOAD_PROJECT_BILLING_ACCOUNT_SUCCESS:
4870
return {
4971
...state,
5072
isBillingAccountLoading: false,
51-
isBillingAccountExpired: !action.payload.active
73+
isBillingAccountExpired: checkBillingExpired(action.payload.active, action.payload.endDate),
74+
billingStartDate: action.payload.startDate,
75+
billingEndDate: action.payload.endDate,
76+
isBillingAccountLoadingFailed: false
5277
}
5378
case LOAD_PROJECT_BILLING_ACCOUNT_FAILURE:
5479
return {
5580
...state,
5681
isBillingAccountLoading: false,
57-
isBillingAccountExpired: false
82+
isBillingAccountExpired: false,
83+
billingStartDate: '',
84+
billingEndDate: '',
85+
isBillingAccountLoadingFailed: true
5886
}
5987
case LOAD_PROJECT_PHASES_PENDING:
6088
return {

0 commit comments

Comments
 (0)