diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index b83640dd7..8a01cf619 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -187,8 +187,18 @@ export const DatasetSearchTable = (props) => { doSearch(); }; const applyForAccess = async () => { - const darDraft = await DAR.postDarDraft({ datasetId: selected }); - history.push(`/dar_application/${darDraft.referenceId}`); + try { + const draftResponse = await DAR.postDarDraft({ datasetId: selected }); + if (draftResponse.referenceId) { + history.push(`/dar_application/${draftResponse.referenceId}`); + } else if (draftResponse.message) { + Notifications.showError({ text: draftResponse.message + ' Please contact customer support for help.' }); + } else { + Notifications.showError({ text: 'Error: Unable to create a Draft Data Access Request' }); + } + } catch (error) { + Notifications.showError({ text: 'Error: Unable to create a Draft Data Access Request' }); + } }; useEffect(() => { @@ -207,11 +217,11 @@ export const DatasetSearchTable = (props) => { -
+
{ />
- @@ -274,7 +284,7 @@ export const DatasetSearchTable = (props) => { { !isEmpty(datasets) && - } diff --git a/src/libs/ajax/DAR.js b/src/libs/ajax/DAR.js index 8239bed1b..274257bdb 100644 --- a/src/libs/ajax/DAR.js +++ b/src/libs/ajax/DAR.js @@ -33,7 +33,7 @@ export const DAR = { const url = DAAUtils.isEnabled() ? `${await getApiUrl()}/api/dar/v3/draft` : `${await getApiUrl()}/api/dar/v2/draft`; - const res = await axios.post(url, dar, Config.authOpts()); + const res = await axios.post(url, dar, Object.assign({}, Config.authOpts(), {validateStatus: () => true})); return res.data; }, diff --git a/src/pages/DatasetStatistics.jsx b/src/pages/DatasetStatistics.jsx index c2c3a13d5..7b256b3da 100644 --- a/src/pages/DatasetStatistics.jsx +++ b/src/pages/DatasetStatistics.jsx @@ -20,8 +20,18 @@ export default function DatasetStatistics(props) { const [isLoading, setIsLoading] = useState(true); const applyForAccess = async () => { - const darDraft = await DAR.postDarDraft({ datasetId: [datasetId] }); - history.push(`/dar_application/${darDraft.referenceId}`); + try { + const draftResponse = await DAR.postDarDraft({ datasetId: [datasetId] }); + if (draftResponse.referenceId) { + history.push(`/dar_application/${draftResponse.referenceId}`); + } else if (draftResponse.message) { + Notifications.showError({ text: draftResponse.message + ' Please contact customer support for help.' }); + } else { + Notifications.showError({ text: 'Error: Unable to create a Draft Data Access Request' }); + } + } catch (error) { + Notifications.showError({ text: 'Error: Unable to create a Draft Data Access Request' }); + } }; useEffect(() => { @@ -69,7 +79,7 @@ export default function DatasetStatistics(props) {
-
@@ -109,8 +119,8 @@ export default function DatasetStatistics(props) {