Skip to content

Commit 84c7142

Browse files
authored
Merge pull request #50 from topcoder-platform/issue-44
fix: issue #44
2 parents 6378ed3 + e65daf2 commit 84c7142

File tree

7 files changed

+41
-8
lines changed

7 files changed

+41
-8
lines changed

src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const App = () => {
1313
<Router>
1414
<ChallengeList path="/earn/find/challenges" />
1515
<ChallengeDetail path={`/earn/find/challenges/:challengeId`} />
16-
<Submission path={`/earn/find/challenges/:challengeId/submit`} />
16+
<Submission path={`/earn/find/challenges/:challengeId/:page`} />
1717
</Router>
1818
);
1919
};

src/constants/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
export const PAGINATION_PER_PAGES = [10, 20, 50];
22
export const PAGINATION_MAX_PAGE_DISPLAY = 3;
33

4+
/*
5+
* Challenge Status
6+
*/
7+
export const CHALLENGE_STATUS = {
8+
ACTIVE: "Active",
9+
CANCELLED: "Cancelled",
10+
COMPLETED: "Completed",
11+
DRAFT: "Draft",
12+
};
13+
414
export const FILTER_BUCKETS = [
515
"All Active Challenges",
616
"Open for Registration",

src/containers/SubmissionManagement/MySubmissions/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { PrimaryButton } from "components/Buttons";
55
import SubmissionTable from "./SubmissionTable";
66
import LoadingIndicator from "components/LoadingIndicator";
77
import * as util from "../../../utils/challenge";
8-
import { CHALLENGES_URL, COMMUNITY_CHALLENGES_URL } from "../../../constants";
8+
import config from "../../../../config";
99

1010
import styles from "./styles.scss";
1111

@@ -53,7 +53,7 @@ const MySubmissions = ({
5353
<div styleName="left-col">
5454
<h4 styleName="name">{challengeName}</h4>
5555
<a
56-
href={`${COMMUNITY_CHALLENGES_URL}/${challengeId}`}
56+
href={`${config.URL.PLATFORM_WEBSITE}/earn/find/challenges/${challengeId}`}
5757
styleName="back-btn"
5858
>
5959
&lt; Back
@@ -125,7 +125,7 @@ const MySubmissions = ({
125125
theme={{
126126
button: styles["add-sub-btn"],
127127
}}
128-
to={`${CHALLENGES_URL}/${challengeId}/submit`}
128+
to={`${config.URL.PLATFORM_WEBSITE}/earn/find/challenges/${challengeId}/submit`}
129129
>
130130
{!isDevelop || !submissions || submissions.length === 0
131131
? "Add Submission"

src/containers/SubmissionManagement/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ SubmissionManagement.propTypes = {
197197
};
198198

199199
const mapStateToProps = (state, ownProps) => {
200-
const challenge = state.challenge.challenge;
200+
const challenge = (state.challenge && state.challenge.challenge) || {};
201201
const allPhases = challenge.phases || [];
202202
const submissionPhase =
203203
allPhases.find(

src/services/api.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ async function doFetch(endpoint, options = {}, v3, baseUrl) {
2525
});
2626
}
2727

28+
async function download(endpoint, baseUrl, cancellationSignal) {
29+
const options = {
30+
headers: { ["Content-Type"]: "application/json" },
31+
signal: cancellationSignal,
32+
};
33+
const response = await doFetch(endpoint, options, undefined, baseUrl);
34+
35+
return response;
36+
}
37+
2838
async function get(endpoint, baseUrl, cancellationSignal) {
2939
const options = {
3040
headers: { ["Content-Type"]: "application/json" },
@@ -108,4 +118,5 @@ export default {
108118
put,
109119
patch,
110120
upload,
121+
download,
111122
};

src/services/submission.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ function deleteSubmission(submissionId) {
3535

3636
function downloadSubmission(track, submissionId) {
3737
return api
38-
.get(`/submissions/${submissionId}/download`)
38+
.download(`/submissions/${submissionId}/download`)
3939
.then(util.tryThrowError)
40-
.then((res) => res.blob());
40+
.then((res) => {
41+
return res.blob();
42+
});
4143
}
4244

4345
function getSubmissions(filter) {
4446
return api
4547
.get(`/submissions?${qs.stringify(filter, { encode: false })}`)
4648
.then(util.tryThrowError)
47-
.then((res) => res.json());
49+
.then((res) => res);
4850
}
4951

5052
export default {

src/utils/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,13 @@ export function parseTotalPrizes(s) {
169169
}
170170
if (valid) return n;
171171
}
172+
173+
export function triggerDownload(fileName,blob) {
174+
const url = window.URL.createObjectURL(new Blob([blob]));
175+
const link = document.createElement('a');
176+
link.href = url;
177+
link.setAttribute('download', fileName);
178+
document.body.appendChild(link);
179+
link.click();
180+
link.parentNode.removeChild(link);
181+
}

0 commit comments

Comments
 (0)