import { Disclosure, Transition } from '@headlessui/react'; import type { UserSchedule } from '@shared/types/UserSchedule'; import List from '@views/components/common/List/List'; import Text from '@views/components/common/Text/Text'; import React from 'react'; import userScheduleHandler from 'src/pages/background/handler/userScheduleHandler'; import DropdownArrowDown from '~icons/material-symbols/arrow-drop-down'; import DropdownArrowUp from '~icons/material-symbols/arrow-drop-up'; /** * Props for the Dropdown component. */ export type Props = { style?: React.CSSProperties; // Dummy value solely for storybook dummySchedules?: UserSchedule[]; dummyActiveIndex?: number; dummyActiveSchedule?: UserSchedule; scheduleComponents?: any[]; }; /** * This is a reusable dropdown component that can be used to toggle the visiblity of information */ export default function Dropdown(props: Props) { // Expand/Hide state for dropdown let [expanded, toggle] = React.useState(false); let [activeScheduleIndex, select] = React.useState(props.dummyActiveIndex); let [activeSchedule, selectFrom] = React.useState(props.dummyActiveSchedule); let [scheduleComponents, setScheduleComponents] = React.useState(props.scheduleComponents); const schedules = props.dummySchedules; if (schedules == null) { // if no dummy values passed in // useSchedules hook here } const toggleSwitch = () => { toggle(!expanded); }; // WIP function to swap schedules. Prefer to use the hook when in production const switchSchedule = (index: number) => { const scheduleToSwitchTo = schedules[index]; select(index); selectFrom(scheduleToSwitchTo); if (scheduleToSwitchTo != null && scheduleToSwitchTo.name != null) { userScheduleHandler.switchSchedule({ data: { scheduleName: scheduleToSwitchTo.name, }, sender: null, sendResponse: null, }); } }; return (