2022-03-07 10:42:00 -08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import { Map as ImmutableMap } from 'immutable';
|
2020-03-27 13:59:38 -07:00
|
|
|
import React from 'react';
|
2022-03-05 11:16:11 -08:00
|
|
|
import { useIntl, defineMessages } from 'react-intl';
|
2022-03-05 11:55:41 -08:00
|
|
|
import { useSelector } from 'react-redux';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2022-03-05 11:55:41 -08:00
|
|
|
import SvgIcon from 'soapbox/components/svg_icon';
|
2022-03-05 11:16:11 -08:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
verified: { id: 'account.verified', defaultMessage: 'Verified Account' },
|
|
|
|
});
|
|
|
|
|
2022-03-07 10:42:00 -08:00
|
|
|
interface IVerificationBadge {
|
|
|
|
className?: string,
|
|
|
|
}
|
|
|
|
|
|
|
|
const VerificationBadge = ({ className }: IVerificationBadge) => {
|
2022-03-05 11:16:11 -08:00
|
|
|
const intl = useIntl();
|
|
|
|
|
2022-03-05 11:55:41 -08:00
|
|
|
// Prefer a custom icon if found
|
2022-03-07 10:42:00 -08:00
|
|
|
const customIcon = useSelector((state: ImmutableMap<string, any>) => state.getIn(['soapbox', 'verifiedIcon']));
|
2022-03-05 11:55:41 -08:00
|
|
|
const icon = customIcon || require('icons/verified.svg');
|
|
|
|
|
|
|
|
// Render component based on file extension
|
|
|
|
const Icon = icon.endsWith('.svg') ? SvgIcon : 'img';
|
|
|
|
|
2022-03-05 11:16:11 -08:00
|
|
|
return (
|
|
|
|
<span className='verified-icon'>
|
2022-03-07 10:42:00 -08:00
|
|
|
<Icon className={classNames(className)} src={icon} alt={intl.formatMessage(messages.verified)} />
|
2022-03-05 11:16:11 -08:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
};
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
export default VerificationBadge;
|