Skip to content

Commit

Permalink
Merge pull request #313 from STEM-C/feature/csv_upload
Browse files Browse the repository at this point in the history
trim csv file and added example csv file
  • Loading branch information
syuChen1 authored Oct 31, 2021
2 parents 9e2e96d + 8a58f3a commit 6d45811
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions client/src/views/Classroom/Roster/AddStudents/AddStudents.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default function AddStudents(props) {
const handleCsvAdd = async () => {
const students = await uploadedRoster.map((student) => {
return {
name: student.name,
character: student.animal,
name: student.name.trim(),
character: student.animal.trim(),
};
});
const res = await addStudents(students, classroomId);
Expand Down Expand Up @@ -111,15 +111,15 @@ export default function AddStudents(props) {
let badInput = false;
let students = roster.filter((student) => {
if (student.data.name) {
if (nameIsFormatted(student.data.name)) return true;
if (nameIsFormatted(student.data.name.trim())) return true;
badInput = true;
}
return false;
});
students = await students.map((student) => {
return {
name: reformatName(student.data.name),
animal: student.data.animal,
name: reformatName(student.data.name.trim()),
animal: student.data.animal.trim(),
};
});

Expand Down Expand Up @@ -209,17 +209,26 @@ export default function AddStudents(props) {
Name/Student column should be in the format: "Last, First", "Last,
First Middle", "First L." or "First Middle L."
</p>
<p>
Sample Student Name CSV File:{' '}
<a
href='https://drive.google.com/file/d/1MeGaw3oMP_uEEvaIqp_Sa6zDN3dfy2lS/view?usp=sharing'
target='_blank'
rel='noreferrer'
>
https://drive.google.com/file/d/1MeGaw3oMP_uEEvaIqp_Sa6zDN3dfy2lS/view?usp=sharing
</a>
</p>
<CSVReader
ref={buttonRef}
onDrop={handleOnDrop}
onError={handleOnError}
onRemoveFile={handleOnRemoveFile}
progressBarColor={'#5BABDE'}
noDrag
config={{
header: true,
transformHeader: function (h) {
let header = h.toLowerCase();
let header = h.toLowerCase().trim();
if (header === 'student' || header === ['student name'])
header = 'name';
return header;
Expand Down

0 comments on commit 6d45811

Please sign in to comment.