Use Calendar
Composable for whole calendar state.
useCalendar
takes an optional parameter calendarId (useful for managing more calendar states in one page)
Init
Initialize the calendar. Set locales properly and fetches days for current selected month.
const { init } = useCalendar(calendarId);
Get Days
Re-fetches days for current date.
const { getDays } = useCalendar();
Day clicked
Set time slots for current day. Clears previously set time slot.
const { dayClicked } = useCalendar();
dayClicked(day);
Select Time Slot
Selects time slots
const { selectTimeSlot } = useCalendar();
selectTimeSlot(timeSlot: TimeSlot)
Next
Moves calendar to next month if possible. It also automatically re-fetches days for the month.
const { next } = useCalendar();
next();
Previous
Moves calendar to previous month. It also automatically re-fetches days for the month.
const { prev } = useCalendar();
prev();
Day has Time Slot
Returns true when given day has any time slot available. False otherwise.
const { dayHasTimeSlot } = useCalendar();
dayHasTimeSlot(day);
Is Time Slot Selected
Returns true when given time slot is selected. False otherwise.
const { isSelected } = useCalendar();
isSelected(timeSlot);
Is Day Selected
Returns true when given day is selected. False otherwise.
const { isSelectedDay } = useCalendar();
isSelectedDay(day);
Next Month Disabled
Returns true when next month is disabled. False otherwise.
const { nextDisabled } = useCalendar();
Previous Month Disabled
Returns true when previous month is disabled. False otherwise.
const { prevDisabled } = useCalendar();
Formatted current year
Returns formatted current year of calendar state.
const { currentYear } = useCalendar();
Formatted Month Name
Returns formatted and localized current month name
const { monthName } = useCalendar();
Calendar State
Returns the whole calendar state:
const { state } = useCalendar();
const {
date,
days,
timeSlots,
monthHasTimeSlots,
selectedDay,
loading,
headers,
dfnsConfig,
attendeeState,
} = state.value;