import type { SelectOption } from '@rocket.chat/fuselage'; import { AccordionItem } from '@rocket.chat/fuselage'; import { Field, FieldGroup, FieldHint, FieldLabel, FieldRow, Select, ToggleSwitch, Slider } from '@rocket.chat/fuselage-forms'; import { type TranslationKey, useCustomSound, useTranslation } from '@rocket.chat/ui-contexts'; import { Controller, useFormContext } from 'react-hook-form'; const PreferencesSoundSection = () => { const t = useTranslation(); const customSound = useCustomSound(); const soundsList: SelectOption[] = customSound.list?.map((value) => [value._id, t(value.name as TranslationKey)]) || []; const { control, watch } = useFormContext<{ newMessageNotification: string; notificationsSoundVolume: number; masterVolume: number; voipRingerVolume: number; newRoomNotification: string; muteFocusedConversations: boolean; }>(); const { newMessageNotification, notificationsSoundVolume = 100, masterVolume = 100, voipRingerVolume = 100 } = watch(); return ( {t('Master_volume')} {t('Master_volume_hint')} } /> {t('Notification_volume')} {t('Notification_volume_hint')} ( { const soundVolume = (notificationsSoundVolume * masterVolume) / 100; customSound.play(newMessageNotification, { volume: soundVolume / 100 }); onChange(value); }} /> )} /> {t('Call_ringer_volume')} {t('Call_ringer_volume_hint')} ( { const soundVolume = (voipRingerVolume * masterVolume) / 100; customSound.play('telephone', { volume: soundVolume / 100 }); onChange(value); }} /> )} /> {t('New_Room_Notification')} ( { onChange(value); customSound.play(String(value), { volume: notificationsSoundVolume / 100 }); }} /> )} /> {t('Mute_Focused_Conversations')} } /> ); }; export default PreferencesSoundSection;