Skip to content

Commit

Permalink
fix bug in filtering students (#31)
Browse files Browse the repository at this point in the history
Administrative Merge Commit
  • Loading branch information
jainsujay02 authored Mar 16, 2023
2 parents 7c8f7fc + f84102c commit 7edd8c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/components/CoursePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ const CourseForm = () => {

//update database
const course = id; //"CS 35L – Software Construction Lab";
console.log(filterUsers(checkValues.years, checkValues.interests, course));
// console.log(filterUsers(checkValues.years, checkValues.interests, course));

const promise = filterUsers(
checkValues.years,
checkValues.interests,
course
course,
allStudentsInCourse
);
promise.then((value) => {
setStudents(value);
Expand Down
9 changes: 7 additions & 2 deletions src/components/utils/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,17 @@ export const getUserDataFromName = async (id) => {
};

const dbRef = collection(db, "ProfileFormData");
export const filterUsers = async (filterYear, filterInterests, filterCourse) => {
export const filterUsers = async (filterYear, filterInterests, filterCourse, studentsInCourse) => {
let iList = [];
let cList = [];
let yList = [];
let retList = [];

console.log("students in course", studentsInCourse);
if (studentsInCourse.length === 0) {
console.log("no students in this course, returning early");
alert("Cannot filter students in an empty class");
return;
}
if (filterCourse.length !== 0) {
const c = query(dbRef, where("courses", "array-contains", filterCourse) );

Expand Down

0 comments on commit 7edd8c6

Please sign in to comment.