import React, { Fragment, ReactNode } from "react"; import { List } from "@components/List"; import { Alert } from "@components/ui/Alert"; import Button from "@components/ui/Button"; import CalendarSwitch from "./CalendarSwitch"; import DisconnectIntegration from "./DisconnectIntegration"; import IntegrationListItem from "./IntegrationListItem"; type CalIntersection = | { calendars: { externalId: string; name: string; isSelected: boolean; }[]; error?: never; } | { calendars?: never; error: { message: string; }; }; type Props = { onChanged: (isOpen: boolean) => void | Promise; connectedCalendars: (CalIntersection & { credentialId: number; integration: { type: string; imageSrc: string; title: string; children?: ReactNode; }; primary?: { externalId: string } | undefined | null; })[]; }; const ConnectedCalendarsList = (props: Props): JSX.Element => { const { connectedCalendars, onChanged } = props; return ( {connectedCalendars.map((item) => ( {item.calendars ? ( ( )} onOpenChange={onChanged} /> }>
    {item.calendars.map((cal) => ( ))}
) : ( ( )} onOpenChange={onChanged} /> } /> )}
))}
); }; export default ConnectedCalendarsList;