diff --git a/src/App.jsx b/src/App.jsx
index 639097f..40ef5ea 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -13,7 +13,7 @@ const App = () => {
-
+
);
};
diff --git a/src/constants/index.js b/src/constants/index.js
index 896cd85..f679d1d 100644
--- a/src/constants/index.js
+++ b/src/constants/index.js
@@ -1,6 +1,16 @@
export const PAGINATION_PER_PAGES = [10, 20, 50];
export const PAGINATION_MAX_PAGE_DISPLAY = 3;
+/*
+ * Challenge Status
+ */
+export const CHALLENGE_STATUS = {
+ ACTIVE: "Active",
+ CANCELLED: "Cancelled",
+ COMPLETED: "Completed",
+ DRAFT: "Draft",
+};
+
export const FILTER_BUCKETS = [
"All Active Challenges",
"Open for Registration",
diff --git a/src/containers/SubmissionManagement/MySubmissions/index.jsx b/src/containers/SubmissionManagement/MySubmissions/index.jsx
index 807c678..7b21c7f 100644
--- a/src/containers/SubmissionManagement/MySubmissions/index.jsx
+++ b/src/containers/SubmissionManagement/MySubmissions/index.jsx
@@ -5,7 +5,7 @@ import { PrimaryButton } from "components/Buttons";
import SubmissionTable from "./SubmissionTable";
import LoadingIndicator from "components/LoadingIndicator";
import * as util from "../../../utils/challenge";
-import { CHALLENGES_URL, COMMUNITY_CHALLENGES_URL } from "../../../constants";
+import config from "../../../../config";
import styles from "./styles.scss";
@@ -53,7 +53,7 @@ const MySubmissions = ({
{challengeName}
< Back
@@ -125,7 +125,7 @@ const MySubmissions = ({
theme={{
button: styles["add-sub-btn"],
}}
- to={`${CHALLENGES_URL}/${challengeId}/submit`}
+ to={`${config.URL.PLATFORM_WEBSITE}/earn/find/challenges/${challengeId}/submit`}
>
{!isDevelop || !submissions || submissions.length === 0
? "Add Submission"
diff --git a/src/containers/SubmissionManagement/index.jsx b/src/containers/SubmissionManagement/index.jsx
index 6eedcf7..a582958 100644
--- a/src/containers/SubmissionManagement/index.jsx
+++ b/src/containers/SubmissionManagement/index.jsx
@@ -197,7 +197,7 @@ SubmissionManagement.propTypes = {
};
const mapStateToProps = (state, ownProps) => {
- const challenge = state.challenge.challenge;
+ const challenge = (state.challenge && state.challenge.challenge) || {};
const allPhases = challenge.phases || [];
const submissionPhase =
allPhases.find(
diff --git a/src/services/api.js b/src/services/api.js
index 78216bb..dc85cbd 100644
--- a/src/services/api.js
+++ b/src/services/api.js
@@ -25,6 +25,16 @@ async function doFetch(endpoint, options = {}, v3, baseUrl) {
});
}
+async function download(endpoint, baseUrl, cancellationSignal) {
+ const options = {
+ headers: { ["Content-Type"]: "application/json" },
+ signal: cancellationSignal,
+ };
+ const response = await doFetch(endpoint, options, undefined, baseUrl);
+
+ return response;
+}
+
async function get(endpoint, baseUrl, cancellationSignal) {
const options = {
headers: { ["Content-Type"]: "application/json" },
@@ -108,4 +118,5 @@ export default {
put,
patch,
upload,
+ download,
};
diff --git a/src/services/submission.js b/src/services/submission.js
index 539f92e..a67dd64 100644
--- a/src/services/submission.js
+++ b/src/services/submission.js
@@ -35,16 +35,18 @@ function deleteSubmission(submissionId) {
function downloadSubmission(track, submissionId) {
return api
- .get(`/submissions/${submissionId}/download`)
+ .download(`/submissions/${submissionId}/download`)
.then(util.tryThrowError)
- .then((res) => res.blob());
+ .then((res) => {
+ return res.blob();
+ });
}
function getSubmissions(filter) {
return api
.get(`/submissions?${qs.stringify(filter, { encode: false })}`)
.then(util.tryThrowError)
- .then((res) => res.json());
+ .then((res) => res);
}
export default {
diff --git a/src/utils/index.js b/src/utils/index.js
index f8cbb73..b3fc4e1 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -169,3 +169,13 @@ export function parseTotalPrizes(s) {
}
if (valid) return n;
}
+
+export function triggerDownload(fileName,blob) {
+ const url = window.URL.createObjectURL(new Blob([blob]));
+ const link = document.createElement('a');
+ link.href = url;
+ link.setAttribute('download', fileName);
+ document.body.appendChild(link);
+ link.click();
+ link.parentNode.removeChild(link);
+}