top of page

CalendarApp Component Flowchart

Flowchart

The flowchart illustrates the logical flow and key functions within the CalendarApp component of the application. Below is a breakdown of each part of the process:

​

  1. Start:

    • The application begins by initializing constants such as the days of the week, months of the year, and the current date.

    • It also sets up several state variables, including currentMonth, currentYear, and selectedDate, using React's useState (Hooks). These variables manage the dynamic behavior of the calendar.
       

  2. Month and Day Calculations:

    • The functions daysInMonth() and firstDayOfMonth() calculate the number of days in the current month and determine which day of the week the month starts on, respectively. This ensures the calendar is displayed correctly.
       

  3. Navigating Between Months:

    • The prevMonth() and nextMonth() functions allow users to navigate backward and forward between months. These functions also adjust the year when transitioning from December to January or vice versa.
       

  4. Handling User Actions:

    • When a user clicks on a specific day, handleDayClick() is triggered. This function checks if the date is valid and allows users to add or edit events for the selected day.

    • The isSameDay() function ensures that the correct date is selected for event manipulation.
       

  5. Event Management:

    • Users can submit new events or update existing ones using the handleEventSubmit() function, which adds events to the calendar or updates them accordingly. Events are sorted by date.

    • Events can be edited via handleEditEvent() or deleted using handleDeleteEvent(), which enables full event management functionality.
       

  6. User Interface Display:

    • The calendar displays the current month, year, and days of the week. It also highlights the current day and any days that have scheduled events.

    • Event details, such as time and description, are shown beneath the calendar, and users can easily manage their events.
       

  7. End:

    • The flowchart ends with showing the output of the calendar and the associated events which representes a complete user interaction flow for managing calendar-based events.

daysInMonth() Function

daysInMonth() function calculates how many days are in the current month, which is essential for displaying the correct number of days in the calendar.

firstDayOfMonth() Function

firstDayOfMonth() function determines the starting day of the month (e.g., Monday, Tuesday) so the calendar layout can properly align days with the weekdays.

prevMonth() Function

prevMonth() function handles month navigation to decrease the current month. If it's January, it moves to December of the previous year.

nextMonth() Function

nextMonth() function handles month navigation to increase the current month. If it's December, it moves to January of the following year.

handleDayClick() Function

When the user clicks on a day in the calendar, the handleDayClick() function is triggered:

  • It checks if the selected date is valid (not in the past) and updates the selectedDate state.

  • It opens the event popup for the user to add or edit events on that specific day.

isSameDay() Function

isSameDay() function checks whether two dates are the same, which is used to compare event dates with the selected or current date.

handleEventSubmit() Function

handleEventSubmit() function manages the addition or updating of an event:

  • If the event is new, it creates a new event object and adds it to the list of events.

  • If an existing event is being edited, it updates the event in the list.

  • Events are sorted by date after submission.

handleEditEvent() Function

handleEditEvent() function is triggered when the user clicks to edit an existing event:

  • It loads the selected event's details into the event popup, allowing the user to modify the time or description.

handleDeleteEvent() Function

handleDeleteEvent() function removes an event from the list based on its unique ID.

handleTimeChange() Function

handleTimeChange() function updates the eventTime state as the user changes the hours and minutes for an event.

Calendar Event User Interface Control Flow

This flowchart illustrates the steps involved in navigating through the calendar interface, selecting a date, and adding an event to the calendar.

- Chan Jia Xuan
- Phung Yi Xuan
bottom of page