2024-03-21 02:37:21 +11:00
import PropTypes from 'prop-types' ;
import { defineMessages , FormattedMessage , useIntl } from 'react-intl' ;
2024-07-19 00:36:09 +10:00
import classNames from 'classnames' ;
2024-03-26 00:27:38 +11:00
import HeartBrokenIcon from '@/material-icons/400-24px/heart_broken-fill.svg?react' ;
import { Icon } from 'mastodon/components/icon' ;
import { domain } from 'mastodon/initial_state' ;
2024-03-21 02:37:21 +11:00
2024-03-26 00:27:38 +11:00
// This needs to be kept in sync with app/models/relationships_severance_event.rb
2024-03-21 02:37:21 +11:00
const messages = defineMessages ( {
2024-03-26 00:27:38 +11:00
account _suspension : { id : 'notification.relationships_severance_event.account_suspension' , defaultMessage : 'An admin from {from} has suspended {target}, which means you can no longer receive updates from them or interact with them.' } ,
domain _block : { id : 'notification.relationships_severance_event.domain_block' , defaultMessage : 'An admin from {from} has blocked {target}, including {followersCount} of your followers and {followingCount, plural, one {# account} other {# accounts}} you follow.' } ,
user _domain _block : { id : 'notification.relationships_severance_event.user_domain_block' , defaultMessage : 'You have blocked {target}, removing {followersCount} of your followers and {followingCount, plural, one {# account} other {# accounts}} you follow.' } ,
2024-03-21 02:37:21 +11:00
} ) ;
2024-07-19 00:36:09 +10:00
export const RelationshipsSeveranceEvent = ( { type , target , followingCount , followersCount , hidden , unread } ) => {
2024-03-21 02:37:21 +11:00
const intl = useIntl ( ) ;
2024-03-26 00:27:38 +11:00
if ( hidden ) {
2024-03-21 02:37:21 +11:00
return null ;
}
return (
2024-07-19 00:36:09 +10:00
< div role = 'button' className = { classNames ( 'notification-group notification-group--link notification-group--relationships-severance-event focusable' , { 'notification-group--unread' : unread } ) } tabIndex = '0' >
< div className = 'notification-group__icon' > < Icon id = 'heart_broken' icon = { HeartBrokenIcon } / > < / div >
2024-03-26 00:27:38 +11:00
2024-07-19 00:36:09 +10:00
< div className = 'notification-group__main' >
2024-03-26 00:27:38 +11:00
< p > { intl . formatMessage ( messages [ type ] , { from : < strong > { domain } < / strong > , target : < strong > { target } < / strong > , followingCount , followersCount } ) } < / p >
2024-07-19 00:36:09 +10:00
< a href = '/severed_relationships' target = '_blank' rel = 'noopener noreferrer' className = 'link-button' > < FormattedMessage id = 'notification.relationships_severance_event.learn_more' defaultMessage = 'Learn more' / > < / a >
2024-03-21 02:37:21 +11:00
< / div >
2024-07-19 00:36:09 +10:00
< / div >
2024-03-21 02:37:21 +11:00
) ;
} ;
RelationshipsSeveranceEvent . propTypes = {
2024-03-26 00:27:38 +11:00
type : PropTypes . oneOf ( [
'account_suspension' ,
'domain_block' ,
'user_domain_block' ,
] ) . isRequired ,
target : PropTypes . string . isRequired ,
followersCount : PropTypes . number . isRequired ,
followingCount : PropTypes . number . isRequired ,
2024-03-21 02:37:21 +11:00
hidden : PropTypes . bool ,
2024-07-19 00:36:09 +10:00
unread : PropTypes . bool ,
2024-03-21 02:37:21 +11:00
} ;