2022-03-09 19:05:37 +01:00
|
|
|
// @flow
|
|
|
|
import 'scss/component/_comment-badge.scss';
|
|
|
|
|
2022-07-01 21:40:06 +02:00
|
|
|
import React from 'react';
|
2022-03-09 19:05:37 +01:00
|
|
|
import * as ICONS from 'constants/icons';
|
2022-03-18 08:43:11 +01:00
|
|
|
import * as PAGES from 'constants/pages';
|
2022-07-01 21:40:06 +02:00
|
|
|
import CommentBadge from 'component/common/comment-badge';
|
2022-03-09 19:05:37 +01:00
|
|
|
import Button from 'component/button';
|
|
|
|
|
|
|
|
type Props = {
|
2022-07-01 21:40:06 +02:00
|
|
|
uri?: string,
|
|
|
|
membership: ?string, // Retrieved from redux if `uri` is provided; else uses the given `membership` directly.
|
2022-03-09 19:05:37 +01:00
|
|
|
linkPage?: boolean,
|
|
|
|
placement?: string,
|
|
|
|
className?: string,
|
|
|
|
hideTooltip?: boolean,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function PremiumBadge(props: Props) {
|
|
|
|
const { membership, linkPage, placement, className, hideTooltip } = props;
|
|
|
|
|
|
|
|
const badgeToShow = membership === 'Premium' ? 'silver' : membership === 'Premium+' ? 'gold' : null;
|
|
|
|
|
|
|
|
if (!badgeToShow) return null;
|
|
|
|
|
|
|
|
const badgeProps = { size: 40, placement, hideTooltip, className };
|
|
|
|
|
|
|
|
return (
|
|
|
|
<BadgeWrapper linkPage={linkPage}>
|
|
|
|
{badgeToShow === 'silver' ? (
|
2022-03-18 08:43:11 +01:00
|
|
|
<CommentBadge label="Premium" icon={ICONS.PREMIUM} {...badgeProps} />
|
2022-03-09 19:05:37 +01:00
|
|
|
) : (
|
2022-03-18 08:43:11 +01:00
|
|
|
badgeToShow === 'gold' && <CommentBadge label="Premium+" icon={ICONS.PREMIUM_PLUS} {...badgeProps} />
|
2022-03-09 19:05:37 +01:00
|
|
|
)}
|
|
|
|
</BadgeWrapper>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
type WrapperProps = {
|
|
|
|
linkPage?: boolean,
|
|
|
|
children: any,
|
|
|
|
};
|
|
|
|
|
|
|
|
const BadgeWrapper = (props: WrapperProps) => {
|
|
|
|
const { linkPage, children } = props;
|
|
|
|
|
2022-03-18 08:43:11 +01:00
|
|
|
return linkPage ? <Button navigate={`/$/${PAGES.ODYSEE_MEMBERSHIP}`}>{children}</Button> : children;
|
2022-03-09 19:05:37 +01:00
|
|
|
};
|