2023-02-06 10:01:03 -08:00
|
|
|
import clsx from 'clsx';
|
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';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2024-08-28 04:41:08 -07:00
|
|
|
import { Icon } from 'pl-fe/components/ui';
|
|
|
|
import { usePlFeConfig } from 'pl-fe/hooks';
|
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 {
|
2023-10-02 11:54:02 -07:00
|
|
|
className?: string;
|
2022-03-07 10:42:00 -08:00
|
|
|
}
|
|
|
|
|
2022-04-05 10:32:41 -07:00
|
|
|
const VerificationBadge: React.FC<IVerificationBadge> = ({ className }) => {
|
2022-03-05 11:16:11 -08:00
|
|
|
const intl = useIntl();
|
2024-08-28 04:41:08 -07:00
|
|
|
const plFeConfig = usePlFeConfig();
|
2022-03-05 11:16:11 -08:00
|
|
|
|
2022-03-05 11:55:41 -08:00
|
|
|
// Prefer a custom icon if found
|
2024-08-28 04:41:08 -07:00
|
|
|
const icon = plFeConfig.verifiedIcon || require('pl-fe/assets/icons/verified.svg');
|
2022-03-05 11:55:41 -08:00
|
|
|
|
|
|
|
// Render component based on file extension
|
2022-03-21 11:09:01 -07:00
|
|
|
const Element = icon.endsWith('.svg') ? Icon : 'img';
|
2022-03-05 11:55:41 -08:00
|
|
|
|
2022-03-05 11:16:11 -08:00
|
|
|
return (
|
2022-05-17 10:10:40 -07:00
|
|
|
<span className='verified-icon' data-testid='verified-badge'>
|
2023-02-06 10:01:03 -08:00
|
|
|
<Element className={clsx('w-4 text-accent-500', 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
|
|
|
|
2024-05-13 10:00:42 -07:00
|
|
|
export { VerificationBadge as default };
|