({
type,
className,
entity,
pressed,
variant = ButtonVariant.Tertiary,
post,
flags,
copy,
}: AwardButtonProps)
| 29 | copy?: string; |
| 30 | } & Pick<ButtonProps<'button'>, 'pressed' | 'variant'>; |
| 31 | export const AwardButton = ({ |
| 32 | type, |
| 33 | className, |
| 34 | entity, |
| 35 | pressed, |
| 36 | variant = ButtonVariant.Tertiary, |
| 37 | post, |
| 38 | flags, |
| 39 | copy, |
| 40 | }: AwardButtonProps): ReactElement | null => { |
| 41 | const { user, showLogin } = useAuthContext(); |
| 42 | const { openModal } = useLazyModal(); |
| 43 | |
| 44 | const openGiveAwardModal = () => { |
| 45 | if (!user) { |
| 46 | return showLogin({ trigger: AuthTriggers.GiveAward }); |
| 47 | } |
| 48 | |
| 49 | return openModal({ |
| 50 | type: LazyModal.GiveAward, |
| 51 | props: { |
| 52 | type, |
| 53 | entity, |
| 54 | post, |
| 55 | flags, |
| 56 | }, |
| 57 | }); |
| 58 | }; |
| 59 | |
| 60 | if (user && entity.receiver?.id === user.id) { |
| 61 | return null; |
| 62 | } |
| 63 | |
| 64 | return ( |
| 65 | <Tooltip |
| 66 | content={ |
| 67 | pressed |
| 68 | ? `You already awarded this ${type.toLowerCase()}!` |
| 69 | : `Award this ${type.toLowerCase()}` |
| 70 | } |
| 71 | > |
| 72 | <div> |
| 73 | <Button |
| 74 | pressed={pressed} |
| 75 | size={ButtonSize.Small} |
| 76 | icon={<MedalBadgeIcon secondary />} |
| 77 | className={classNames(className, pressed && 'pointer-events-none')} |
| 78 | variant={variant} |
| 79 | color={ButtonColor.Cabbage} |
| 80 | onClick={openGiveAwardModal} |
| 81 | > |
| 82 | {copy} |
| 83 | </Button> |
| 84 | </div> |
| 85 | </Tooltip> |
| 86 | ); |
| 87 | }; |
nothing calls this directly
no test coverage detected