Skip to content

Commit

Permalink
Merge pull request #443 from NIAEFEUP/fix/cannot-remove-request-card
Browse files Browse the repository at this point in the history
fix: cannot remove request card
  • Loading branch information
tomaspalma authored Feb 7, 2025
2 parents 9e21df8 + e521750 commit c3c9dac
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const CreateRequestCard = ({
setSelectedDestinationClass(null);
setBeforePreviewClass(null);
}
}, [selectedDestinationStudent])
}, [selectedDestinationStudent, hasStudentToExchange])

useEffect(() => {
if (!originalExchangeSchedule || !courseInfo) return;
Expand Down Expand Up @@ -83,9 +83,10 @@ export const CreateRequestCard = ({
newRequests.delete(courseInfo.id)
setRequests(newRequests);
}

const newExchangeSchedule = exchangeSchedule.filter((scheduleItem) => beforePreviewClass.filter((item) => item.courseInfo.id === scheduleItem.courseInfo.id).length === 0);
setExchangeSchedule(newExchangeSchedule.concat(beforePreviewClass));

const newExchangeSchedule = exchangeSchedule.filter((scheduleItem) => scheduleItem.courseInfo.id !== courseInfo.id);
newExchangeSchedule.push(...originalExchangeSchedule.filter((scheduleItem) => scheduleItem.courseInfo.id === courseInfo.id));
setExchangeSchedule(newExchangeSchedule);

setSelectedCourseUnits((prev) => prev.filter((currentCourseInfo) => currentCourseInfo.id !== courseInfo.id));
}
Expand Down

0 comments on commit c3c9dac

Please sign in to comment.