diff --git a/backend/Questionnaire for Upload.xlsx b/backend/Questionnaire for Upload.xlsx new file mode 100644 index 00000000..36dbf296 Binary files /dev/null and b/backend/Questionnaire for Upload.xlsx differ diff --git a/backend/routes/admins.js b/backend/routes/admins.js index 99157a41..64fa86f9 100644 --- a/backend/routes/admins.js +++ b/backend/routes/admins.js @@ -183,8 +183,7 @@ function enforceAdminOnly(req, res, isAdminCallBack) { } //route for uploading the questionnaires spreadsheet in the database router.route('/questionnairefile').post((req, res) => { - // enforceAdminOnly(req, res, processQuestionnaireAsAdmin); - processQuestionnaireAsAdmin(); + enforceAdminOnly(req, res, processQuestionnaireAsAdmin); function processQuestionnaireAsAdmin() { console.log(req.files, req.body); if (!req.files || !req.files.questionnaire) { @@ -215,8 +214,7 @@ router.route('/questionnairefile').post((req, res) => { }); //route for deleteing a questionnaire by title router.route('/deletequestionnaire/:title').delete((req, res) => { - // enforceAdminOnly(req, res, deleteQuestionnaireByTitle); - deleteQuestionnaireByTitle(); + enforceAdminOnly(req, res, deleteQuestionnaireByTitle); function deleteQuestionnaireByTitle() { return Questionnaires.deleteMany({ title: decodeURIComponent(req.params.title), diff --git a/src/containers/EditQuestionnaires/EditQuestionnaires.js b/src/containers/EditQuestionnaires/EditQuestionnaires.js index 1d475f0c..6f81b2f3 100644 --- a/src/containers/EditQuestionnaires/EditQuestionnaires.js +++ b/src/containers/EditQuestionnaires/EditQuestionnaires.js @@ -11,7 +11,7 @@ import Navbar from '../../compositions/Navbar/Navbar'; import Button from '../../components/Button/Button'; import LanguageDropdown from '../../components/LanguageDropdown/LanguageDropdown'; import './EditQuestionnaires.css'; -import { workshopTitle } from '../../data/LanguageOptions'; + const EditQuestionnaires = () => { const [chooseFile, toggleChooseFile] = useState(false); const [questionnaireStatus, setQuestionnaireStatus] = useState(false); @@ -49,11 +49,11 @@ const EditQuestionnaires = () => { ), method: 'DELETE', }; - // const jwt = getAuthToken(); - // const headers = { - // Authorization: `Bearer ${jwt}`, - // }; - sendRequest(requestObj) + const jwt = getAuthToken(); + const headers = { + Authorization: `Bearer ${jwt}`, + }; + sendRequest(requestObj, headers) .then((response) => { setRefetch(true); }) @@ -122,8 +122,7 @@ const EditQuestionnaires = () => { qustionnaireFile, qustionnaireFile.name ); - //change from hardcoded - formData.append('title', 'CIIT_Workshop_Spring_2021'); + formData.append('title', workshopTitle); const jwt = getAuthToken(); const headers = { Authorization: `Bearer ${jwt}`, @@ -158,7 +157,6 @@ const EditQuestionnaires = () => { changeLanguage('en'); }; const switchViews = () => { - console.log('Sdfs'); toggleLanguageDropDown(false); setListOfQuestions([]); }; @@ -166,17 +164,26 @@ const EditQuestionnaires = () => { return (
-
{chooseFile ? ( - - uploadNewQuestionnaire(e.target.files[0]) - } - /> +
+ + setWorkshopTitle(e.target.value)} + required + type="text" + > +

+ + uploadNewQuestionnaire(e.target.files[0]) + } + /> +
) : (