Skip to content

Commit

Permalink
fix add/remove logic for shifts
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonfagan committed Nov 27, 2024
1 parent deb0479 commit f0bbf67
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/web/src/lib/shifts/ShiftsView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@
};
const modify = (id, remove = false) => {
modifiedShifts = [...modifiedShifts.filter((s) => s.id !== id), { id, remove }];
const enrolled = shifts.some((s) => s.id === id && s.enrolled);
let _modifiedShifts = modifiedShifts.filter((s) => s.id !== id);
if ((remove && !enrolled) || (!remove && enrolled)) {
modifiedShifts = [..._modifiedShifts];
return;
}
modifiedShifts = [..._modifiedShifts, { id, remove }];
};
</script>

Expand Down

0 comments on commit f0bbf67

Please sign in to comment.