Skip to content

Commit 7a11275

Browse files
author
dengjun
committed
ci:deploying api integration
1 parent cbe5685 commit 7a11275

File tree

6 files changed

+86
-5
lines changed

6 files changed

+86
-5
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ workflows:
340340
filters:
341341
branches:
342342
only:
343-
- recruit-proxy-api
343+
- recruit-proxy-api-aggapi
344344
# This is alternate dev env for parallel testing
345345
- "build-test":
346346
context : org-global
@@ -368,7 +368,7 @@ workflows:
368368
filters: &filters-staging
369369
branches:
370370
only:
371-
- recruit-proxy-api
371+
- recruit-proxy-api-aggapi
372372
# Production builds are exectuted
373373
# when PR is merged to the master
374374
# Don't change anything in this configuration

src/shared/actions/recruitCRM.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ async function getJobsDone(query) {
2222
};
2323
}
2424

25+
function getJobApplicationsInit() {
26+
return {};
27+
}
28+
29+
async function getJobApplicationsDone(tokenV3) {
30+
const ss = new Service();
31+
const res = await ss.getJobApplications(tokenV3);
32+
return {
33+
data: res,
34+
};
35+
}
36+
2537
/**
2638
* Job fetch init
2739
*/
@@ -163,5 +175,7 @@ export default redux.createActions({
163175
APPLY_FOR_JOB_DONE: applyForJobDone,
164176
SEARCH_CANDIDATES_INIT: searchCandidatesInit,
165177
SEARCH_CANDIDATES_DONE: searchCandidatesDone,
178+
GET_JOB_APPLICATIONS_INIT: getJobApplicationsInit,
179+
GET_JOB_APPLICATIONS_DONE: getJobApplicationsDone,
166180
},
167181
});

src/shared/components/Gigs/GigHeader/index.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from 'react';
22
import { config, Link } from 'topcoder-react-utils';
3+
import PT from 'prop-types';
34
import BannerInfoIcon from 'assets/images/banner-info.svg';
45
import './style.scss';
56

6-
const GigHeader = () => (
7+
const GigHeader = ({ appNum }) => (
78
<div
89
styleName="gig-header"
910
>
@@ -12,7 +13,7 @@ const GigHeader = () => (
1213
<BannerInfoIcon />
1314
</div>
1415
<span>
15-
You have 3 applied Gigs in the system
16+
You have {appNum} applied Gigs in the system
1617
</span>
1718
</div>
1819

@@ -22,4 +23,11 @@ const GigHeader = () => (
2223
</div>
2324
);
2425

26+
GigHeader.defaultProps = {
27+
appNum: 0,
28+
};
29+
30+
GigHeader.propTypes = {
31+
appNum: PT.number,
32+
};
2533
export default GigHeader;

src/shared/containers/Gigs/RecruitCRMJobs.jsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class RecruitCRMJobsContainer extends React.Component {
5656
const {
5757
getJobs,
5858
jobs,
59+
getJobApplications,
60+
auth,
5961
} = this.props;
6062
const { state } = this;
6163
const q = getQuery();
@@ -74,6 +76,9 @@ class RecruitCRMJobsContainer extends React.Component {
7476
};
7577
this.setState(stateUpdate);
7678
}
79+
if (auth.tokenV3) {
80+
getJobApplications(auth.tokenV3);
81+
}
7782
}
7883

7984
/**
@@ -138,6 +143,7 @@ class RecruitCRMJobsContainer extends React.Component {
138143
loading,
139144
jobs,
140145
optimizely,
146+
applications,
141147
} = this.props;
142148
const {
143149
term,
@@ -250,7 +256,7 @@ class RecruitCRMJobsContainer extends React.Component {
250256
<Dropdown label="Location" onChange={this.onLocation} options={locations} size="xs" />
251257
<Dropdown label="Sort by" onChange={this.onSort} options={sortByOptions} size="xs" />
252258
</div>
253-
<GigHeader />
259+
<GigHeader appNum={applications} />
254260
<div styleName="jobs-list-container">
255261
{
256262
jobsToDisplay.length
@@ -290,20 +296,29 @@ class RecruitCRMJobsContainer extends React.Component {
290296
RecruitCRMJobsContainer.defaultProps = {
291297
jobs: [],
292298
loading: true,
299+
applications: 0,
300+
auth: {},
293301
};
294302

295303
RecruitCRMJobsContainer.propTypes = {
296304
getJobs: PT.func.isRequired,
297305
loading: PT.bool,
298306
jobs: PT.arrayOf(PT.shape),
299307
optimizely: PT.shape().isRequired,
308+
getJobApplications: PT.func.isRequired,
309+
applications: PT.number,
310+
auth: PT.object,
300311
};
301312

302313
function mapStateToProps(state) {
303314
const data = state.recruitCRM;
304315
return {
305316
jobs: data ? data.jobs : [],
306317
loading: data ? data.loading : true,
318+
applications: data.applications,
319+
auth: {
320+
...state.auth,
321+
},
307322
};
308323
}
309324

@@ -314,6 +329,10 @@ function mapDispatchToActions(dispatch) {
314329
dispatch(a.getJobsInit(ownProps));
315330
dispatch(a.getJobsDone(ownProps));
316331
},
332+
getJobApplications: (tokenV3) => {
333+
dispatch(a.getJobApplicationsInit());
334+
dispatch(a.getJobApplicationsDone(tokenV3));
335+
},
317336
};
318337
}
319338

src/shared/reducers/recruitCRM.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@ function onSearchCandidatesDone(state, { payload }) {
112112
return r;
113113
}
114114

115+
function onGetJobApplicationsInit(state) {
116+
return {
117+
...state,
118+
applications: 0,
119+
};
120+
}
121+
122+
function onGetJobApplicationsDone(state, { payload }) {
123+
return {
124+
...state,
125+
applications: payload.data,
126+
};
127+
}
128+
115129
/**
116130
* Creates recruitCRM reducer with the specified initial state.
117131
* @param {Object} state Optional. If not given, the default one is
@@ -128,6 +142,8 @@ function create(state = {}) {
128142
[actions.recruit.applyForJobDone]: onApplyForJobDone,
129143
[actions.recruit.searchCandidatesInit]: onSearchCandidatesInit,
130144
[actions.recruit.searchCandidatesDone]: onSearchCandidatesDone,
145+
[actions.recruit.getJobApplicationsInit]: onGetJobApplicationsInit,
146+
[actions.recruit.getJobApplicationsDone]: onGetJobApplicationsDone,
131147
}, state);
132148
}
133149

src/shared/services/recruitCRM.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fetch from 'isomorphic-fetch';
22
import { logger } from 'topcoder-react-lib';
3+
import { config } from 'topcoder-react-utils';
34
import qs from 'qs';
45
import _ from 'lodash';
56

@@ -47,6 +48,29 @@ export default class Service {
4748
return res.json();
4849
}
4950

51+
/**
52+
* get member applications
53+
* @param {*} tokenV3
54+
* @returns
55+
*/
56+
/* eslint-disable class-methods-use-this */
57+
async getJobApplications(tokenV3) {
58+
const res = await fetch(
59+
`${config.PLATFORM_SITE_URL}/earn-app/api/my-gigs/myJobApplications?page=1&perPage=1`,
60+
{
61+
method: 'GET',
62+
headers: new Headers({
63+
Authorization: `Bearer ${tokenV3}`,
64+
}),
65+
},
66+
);
67+
if (!res.ok) {
68+
const error = new Error('Failed to get job applications');
69+
logger.error(error, res);
70+
}
71+
return parseInt(res.headers.get('x-total'), 10) || 0;
72+
}
73+
5074
/**
5175
* applyForJob for candidate
5276
* @param {string} id The job id to apply to

0 commit comments

Comments
 (0)