The schedules store manages both official and custom school schedules, including schedule modes, periods, and timings.
State Properties
User-defined custom schedules organized by schedule type. Each schedule type can have multiple custom schedule modes.type CustomSchedules = Record<string, Schedule[]>
The default schedule mode to use. Persisted in localStorage.
The currently active schedule mode.
Computed Properties
Merged list of official and custom schedules. Official schedules are loaded from the schedules.json data file, and custom schedules are added with an isCustom: true flag.type ScheduleCollection = {
name: string;
isSpecial: boolean;
dates: string[];
modes: Schedule[];
eventAliases?: string[];
}
Actions
initializeSchedule
function initializeSchedule(): void
Initializes the schedules store from localStorage. Loads custom schedules and default schedule mode.
Usage:
import useSchedulesStore from '@/stores/schedules'
const schedulesStore = useSchedulesStore()
schedulesStore.initializeSchedule()
addCustomScheduleMode
function addCustomScheduleMode({
scheduleType,
scheduleToAdd,
scheduleToReplace
}: {
scheduleType: string,
scheduleToAdd: {
start: string[],
end: string[],
name: string,
periods: string
},
scheduleToReplace: string
}): void
Adds a new custom schedule mode or replaces an existing custom schedule. Official schedules cannot be replaced.
Parameters:
The type of schedule (e.g., “Normal”, “Finals”)
The schedule mode to add with start times, end times, name, and periods
Name of the schedule mode to replace (if it exists and is custom)
Usage:
schedulesStore.addCustomScheduleMode({
scheduleType: 'Normal',
scheduleToAdd: {
start: ['8:00', '9:00', '10:00'],
end: ['8:50', '9:50', '10:50'],
name: 'My Custom Schedule',
periods: '1,2,3'
},
scheduleToReplace: 'Old Schedule'
})
removeCustomScheduleMode
function removeCustomScheduleMode({
scheduleType,
scheduleToRemove
}: {
scheduleType: string,
scheduleToRemove: string
}): void
Removes a custom schedule mode. If scheduleType is not provided, removes the schedule from all schedule types.
Parameters:
The schedule type to remove from. If omitted, removes from all types.
Name of the custom schedule mode to remove
setCustomSchedules
function setCustomSchedules(value: CustomSchedules): void
Sets all custom schedules. Automatically renames any custom schedules that conflict with official schedule names. Persists to localStorage.
resetSchedules
function resetSchedules(): void
Resets all custom schedules to empty, removing all user-defined schedules.
Usage:
schedulesStore.resetSchedules()
setDefaultScheduleMode
function setDefaultScheduleMode(value: string): void
Sets the default schedule mode. Persisted to localStorage.
Parameters:
The name of the schedule mode to set as default
setScheduleMode
function setScheduleMode(value: string): void
Sets the currently active schedule mode (not persisted).
Parameters:
The name of the schedule mode to activate
Type Definitions
type Schedule = {
name: string;
isCustom?: boolean;
start: string[] | string[][];
end: string[] | string[][];
periods: string[] | string[][];
}
type CustomSchedules = Record<string, Schedule[]>
type ScheduleCollection = {
name: string;
isSpecial: boolean;
dates: string[];
modes: Schedule[];
eventAliases?: string[];
}