Skip to content

Commit

Permalink
fetch dataset names for consent name validation
Browse files Browse the repository at this point in the history
  • Loading branch information
rushtong committed Oct 19, 2023
1 parent f6b7380 commit dc98e14
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ beforeEach(() => {
cy.stub(Institution, 'list').returns([{name: 'Test Institution'}]);
cy.stub(Schema, 'datasetRegistrationV1').returns({});
cy.stub(Study, 'getStudyNames').returns([]);
cy.stub(DataSet, 'getDatasetNames').returns([]);
cy.fixture('dataset-registration-v1').then(function (data) {
cy.stub(DataSet, 'getRegistrationSchema').returns(data);
});
Expand Down
6 changes: 6 additions & 0 deletions src/libs/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ export const DAR = {

export const DataSet = {

getDatasetNames: async () => {
const url = `${await getApiUrl()}/api/dataset/datasetNames`;
const res = await axios.get(url, Config.authOpts());
return await res.data;
},

getRegistrationSchema: async () => {
const url = `${await getApiUrl()}/schemas/dataset-registration/v1`;
const res = await axios.get(url, Config.authOpts());
Expand Down
7 changes: 7 additions & 0 deletions src/pages/data_submission/DataSubmissionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const DataSubmissionForm = (props) => {
const [registrationSchema, setRegistrationSchema] = useState({});
const [institutions, setInstitutions] = useState([]);
const [studyNames, setStudyNames] = useState([]);
const [datasetNames, setDatasetNames] = useState([]);
const [failedInit, setFailedInit] = useState(false);

const [allConsentGroupsSaved, setAllConsentGroupsSaved] = useState(false);
Expand All @@ -44,11 +45,17 @@ export const DataSubmissionForm = (props) => {
setStudyNames(studyNames);
};

const getAllDatasetNames = async() => {
const datasetNames = await DataSet.getDatasetNames();
setDatasetNames(datasetNames);
};

const init = async () => {
try {
await getRegistrationSchema();
await getAllInstitutions();
await getAllStudies();
await getAllDatasetNames();
} catch (error) {
setFailedInit(true);
Notifications.showError({
Expand Down

0 comments on commit dc98e14

Please sign in to comment.