Skip to content

Commit

Permalink
questionnaire updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara Greene committed Aug 3, 2021
1 parent 49955eb commit 71b2791
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
Binary file added backend/Questionnaire for Upload.xlsx
Binary file not shown.
6 changes: 2 additions & 4 deletions backend/routes/admins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
Expand Down
43 changes: 25 additions & 18 deletions src/containers/EditQuestionnaires/EditQuestionnaires.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
})
Expand Down Expand Up @@ -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}`,
Expand Down Expand Up @@ -158,25 +157,33 @@ const EditQuestionnaires = () => {
changeLanguage('en');
};
const switchViews = () => {
console.log('Sdfs');
toggleLanguageDropDown(false);
setListOfQuestions([]);
};

return (
<section>
<Navbar content={content} dashboard={true} />
<Navbar />
<section>
{chooseFile ? (
<input
required
type="file"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
onChange={(e) =>
uploadNewQuestionnaire(e.target.files[0])
}
/>
<form>
<label>WorkshopTitle</label>
<input
onChange={(e) => setWorkshopTitle(e.target.value)}
required
type="text"
></input>
<br></br>
<input
disabled={!workshopTitle}
required
type="file"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
onChange={(e) =>
uploadNewQuestionnaire(e.target.files[0])
}
/>
</form>
) : (
<Button
label="Upload New Questionnaire"
Expand Down

0 comments on commit 71b2791

Please sign in to comment.