Northeastern-Electric-Racing / Northeastern-Electric-Racing/FinishLine
[Maintenance] - Allow Deletion of Future Events
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 36
- Forks
- 9
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 11
Description
Description
Currently you can either delete a single instance of a recurring schedule slot or all instances of the recurring schedule slot (aka, delete the entire event). The request is to add a third option to delete all future scheduled slots of that event.
Acceptance Criteria
- Add a third option: "All future occurrences (X slots)"
- Create the API endpoint that deletes any future schedule slots
- BONUS:
CalendarWeekView.tsxandCalendarDayView.tsxboth have this function (alsoEventClickPopup.tsx):
const handleSeriesDeleteConfirm = async (deleteEntireEvent: boolean) => {
try {
setShowSeriesDeleteModal(false);
setLockedTooltipEventId(null);
if (deleteEntireEvent) {
await deleteEvent();
toast.success('Event deleted successfully!');
} else {
await deleteScheduleSlot();
toast.success('Event occurrence deleted successfully!');
}
} catch (err) {
if (err instanceof Error) toast.error(err.message);
}
};
- If possible, please merge these all into one shared function from a helper file
Proposed Solution
- Start by removing the logic that is currently in place. As it stands right now, there is a boolean: either all events, or one event. You must turn this into an Enum instead where it is either all events, future events, or the one event. For this you must reformat
setDeleteEntireEventwithinDeleteSeriesConfirmationModal.tsxwith a new name and for it must take that Enum as its state. - Add the new
FormControlLabelbelow the other options - Create the mutation similar to the one below: (name it useDeleteFutureScheduleSlots
export const useDeleteScheduleSlot = (eventId: string, scheduleSlotId: string) => {
const queryClient = useQueryClient();
return useMutation<Event, Error>(
['events', 'delete-schedule-slot', eventId, scheduleSlotId],
async () => {
const { data } = await postDeleteScheduleSlot(eventId, scheduleSlotId);
return data;
},
{
onSuccess: () => {
queryClient.invalidateQueries(['filter-events']);
queryClient.invalidateQueries(EVENT_KEY);
queryClient.invalidateQueries(['events', eventId]);
}
}
);
};
- Create the axios post similar to: (name it postDeleteFutureScheduleSlots)
export const postDeleteScheduleSlot = async (eventId: string, scheduleSlotId: string) => {
return axios.post<Event>(
apiUrls.calendarDeleteScheduleSlot(eventId, scheduleSlotId),
{},
{
transformResponse: (data) => eventTransformer(JSON.parse(data))
}
);
};
- Make a new route in
calendar.routes.tssimilar to this:
calendarRouter.post('/event/:eventId/schedule-slot/:scheduleSlotId/delete', CalendarController.deleteScheduleSlot);
- Make a new function in
CalendarController.tsnamed deleteFutureScheduleSlots - Make a function in
CalendarService.tsalso named deleteFutureScheduleSlots - It may be very helpful to follow
deleteScheduleSlotincalendar.service.ts - Do a prisma call to find all schedule slots after a "selectedDate" (gte stands for Greater Than or Equal to ensure that you also delete the current one seleted as well)
const scheduleSlots = await prisma.schedule_Slot.findMany({
where: {
startTime: {
gte: selectedDate
}
}
});
- Follow the rest of the logic that happens in
deleteScheduleSlotwithincalendar.service.ts.
Mocks
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with DeleteSeriesConfirmationModal.tsx and the existing deleteScheduleSlot flow, then trace CalendarWeekView.tsx, CalendarDayView.tsx, EventClickPopup.tsx, calendar.routes.ts, CalendarController.ts, and CalendarService.ts. Follow the named API, mutation, and service entry points; done means the modal offers future occurrences, the endpoint removes qualifying slots, and the affected views share the delete handling where practical.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend, databases, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100