import PropTypes from 'prop-types'; import { useCallback, useState } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import { useDispatch } from 'react-redux'; import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react'; import CampaignIcon from '@/material-icons/400-24px/campaign.svg?react'; import ReplyIcon from '@/material-icons/400-24px/reply.svg?react'; import VisibilityOffIcon from '@/material-icons/400-24px/visibility_off.svg?react'; import VolumeOffIcon from '@/material-icons/400-24px/volume_off.svg?react'; import { muteAccount } from 'mastodon/actions/accounts'; import { closeModal } from 'mastodon/actions/modal'; import { Button } from 'mastodon/components/button'; import { CheckBox } from 'mastodon/components/check_box'; import { Icon } from 'mastodon/components/icon'; import { RadioButton } from 'mastodon/components/radio_button'; const messages = defineMessages({ minutes: { id: 'intervals.full.minutes', defaultMessage: '{number, plural, one {# minute} other {# minutes}}' }, hours: { id: 'intervals.full.hours', defaultMessage: '{number, plural, one {# hour} other {# hours}}' }, days: { id: 'intervals.full.days', defaultMessage: '{number, plural, one {# day} other {# days}}' }, indefinite: { id: 'mute_modal.indefinite', defaultMessage: 'Until I unmute them' }, hideFromNotifications: { id: 'mute_modal.hide_from_notifications', defaultMessage: 'Hide from notifications' }, }); const RadioButtonLabel = ({ name, value, currentValue, onChange, label }) => ( ); RadioButtonLabel.propTypes = { name: PropTypes.string, value: PropTypes.oneOf([PropTypes.string, PropTypes.number, PropTypes.bool]), currentValue: PropTypes.oneOf([PropTypes.string, PropTypes.number, PropTypes.bool]), checked: PropTypes.bool, onChange: PropTypes.func, label: PropTypes.node, }; export const MuteModal = ({ accountId, acct }) => { const intl = useIntl(); const dispatch = useDispatch(); const [notifications, setNotifications] = useState(true); const [muteDuration, setMuteDuration] = useState('0'); const [expanded, setExpanded] = useState(false); const handleClick = useCallback(() => { dispatch(closeModal({ modalType: undefined, ignoreFocus: false })); dispatch(muteAccount(accountId, notifications, muteDuration)); }, [dispatch, accountId, notifications, muteDuration]); const handleCancel = useCallback(() => { dispatch(closeModal({ modalType: undefined, ignoreFocus: false })); }, [dispatch]); const handleToggleNotifications = useCallback(({ target }) => { setNotifications(target.checked); }, [setNotifications]); const handleChangeMuteDuration = useCallback(({ target }) => { setMuteDuration(target.value); }, [setMuteDuration]); const handleToggleSettings = useCallback(() => { setExpanded(!expanded); }, [expanded, setExpanded]); return (

@{acct}
); }; MuteModal.propTypes = { accountId: PropTypes.string.isRequired, acct: PropTypes.string.isRequired, }; export default MuteModal;