import type { IRoom } from '@rocket.chat/core-typings'; import type { SelectOption } from '@rocket.chat/fuselage'; import { Box, Icon, TextInput, Select, Throbber, ButtonGroup, Button } from '@rocket.chat/fuselage'; import { useStableCallback, useAutoFocus, useDebouncedCallback } from '@rocket.chat/fuselage-hooks'; import { VirtualizedScrollbars, ContextualbarHeader, ContextualbarIcon, ContextualbarTitle, ContextualbarClose, ContextualbarContent, ContextualbarFooter, ContextualbarEmptyContent, ContextualbarSection, ContextualbarDialog, } from '@rocket.chat/ui-client'; import type { ChangeEvent, Dispatch, SetStateAction, SyntheticEvent } from 'react'; import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { Virtuoso } from 'react-virtuoso'; import TeamsChannelItem from './TeamsChannelItem'; import InfiniteListAnchor from '../../../../components/InfiniteListAnchor'; export type TeamsChannelsProps = { loading: boolean; channels: IRoom[]; mainRoom: IRoom; text: string; type: 'all' | 'autoJoin'; setText: (e: ChangeEvent) => void; setType: Dispatch>; onClickClose: () => void; onClickAddExisting: false | ((e: SyntheticEvent) => void); onClickCreateNew: false | ((e: SyntheticEvent) => void); total: number; loadMoreItems: () => void; onClickView: (room: IRoom) => void; reload: () => void; }; const TeamsChannels = ({ loading, channels = [], mainRoom, text, type, setText, setType, onClickClose, onClickAddExisting, onClickCreateNew, total, loadMoreItems, onClickView, reload, }: TeamsChannelsProps) => { const { t } = useTranslation(); const inputRef = useAutoFocus(true); const options: SelectOption[] = useMemo( () => [ ['all', t('All')], ['autoJoin', t('Team_Auto-join')], ], [t], ); const lm = useStableCallback(() => !loading && loadMoreItems()); const loadMoreChannels = useDebouncedCallback( () => { if (channels.length >= total) { return; } lm(); }, 300, [lm, channels], ); return ( {t('Team_Channels')} {onClickClose && } } />