import type { ICustomSound } from '@rocket.chat/core-typings'; import { Box, IconButton } from '@rocket.chat/fuselage'; import { GenericTableCell, GenericTableRow } from '@rocket.chat/ui-client'; import { useCustomSound } from '@rocket.chat/ui-contexts'; import { useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; export type CustomSoundRowProps = { onClick: (soundId: ICustomSound['_id']) => () => void; sound: { name: string; _id: string; }; }; const CustomSoundRow = ({ onClick, sound }: CustomSoundRowProps) => { const { t } = useTranslation(); const [isPlay, setPlayAudio] = useState(false); const customSound = useCustomSound(); const handleToggle = useCallback( (sound: ICustomSound['_id']) => { setPlayAudio(!isPlay); if (!isPlay) { return customSound.play(sound); } return customSound.pause(sound); }, [customSound, isPlay], ); return ( {sound.name} { e.preventDefault(); e.stopPropagation(); handleToggle(sound._id); }} /> ); }; export default CustomSoundRow;