2022-04-11 12:58:48 -07:00
import React from 'react' ;
import { defineMessages , useIntl } from 'react-intl' ;
2022-11-16 05:32:32 -08:00
import { unblockDomain } from 'soapbox/actions/domain-blocks' ;
2023-01-09 14:13:12 -08:00
import { useAppDispatch } from 'soapbox/hooks' ;
2022-04-11 12:58:48 -07:00
2022-11-17 07:10:18 -08:00
import { HStack , IconButton , Text } from './ui' ;
2022-04-11 12:58:48 -07:00
const messages = defineMessages ( {
blockDomainConfirm : { id : 'confirmations.domain_block.confirm' , defaultMessage : 'Hide entire domain' } ,
unblockDomain : { id : 'account.unblock_domain' , defaultMessage : 'Unhide {domain}' } ,
} ) ;
interface IDomain {
2023-02-15 13:26:27 -08:00
domain : string
2022-04-11 12:58:48 -07:00
}
const Domain : React.FC < IDomain > = ( { domain } ) = > {
2023-01-09 14:13:12 -08:00
const dispatch = useAppDispatch ( ) ;
2022-04-11 12:58:48 -07:00
const intl = useIntl ( ) ;
// const onBlockDomain = () => {
// dispatch(openModal('CONFIRM', {
2022-07-09 09:20:02 -07:00
// icon: require('@tabler/icons/ban.svg'),
2022-04-11 12:58:48 -07:00
// heading: <FormattedMessage id='confirmations.domain_block.heading' defaultMessage='Block {domain}' values={{ domain }} />,
// message: <FormattedMessage id='confirmations.domain_block.message' defaultMessage='Are you really, really sure you want to block the entire {domain}? In most cases a few targeted blocks or mutes are sufficient and preferable.' values={{ domain: <strong>{domain}</strong> }} />,
// confirm: intl.formatMessage(messages.blockDomainConfirm),
// onConfirm: () => dispatch(blockDomain(domain)),
// }));
// }
const handleDomainUnblock = ( ) = > {
dispatch ( unblockDomain ( domain ) ) ;
} ;
return (
2022-11-17 07:10:18 -08:00
< HStack alignItems = 'center' justifyContent = 'between' space = { 1 } className = 'p-2' >
< Text tag = 'span' >
{ domain }
< / Text >
< IconButton iconClassName = 'h-5 w-5' src = { require ( '@tabler/icons/lock-open.svg' ) } title = { intl . formatMessage ( messages . unblockDomain , { domain } ) } onClick = { handleDomainUnblock } / >
< / HStack >
2022-04-11 12:58:48 -07:00
) ;
} ;
export default Domain ;