({
post,
buttonProps = {},
origin: originProp,
}: {
post: Post;
buttonProps?: ButtonProps<'button'>;
origin?: Origin;
})
| 34 | } |
| 35 | |
| 36 | export function BoostPostButton({ |
| 37 | post, |
| 38 | buttonProps = {}, |
| 39 | origin: originProp, |
| 40 | }: { |
| 41 | post: Post; |
| 42 | buttonProps?: ButtonProps<'button'>; |
| 43 | origin?: Origin; |
| 44 | }): ReactElement { |
| 45 | const router = useRouter(); |
| 46 | const { openModal } = useLazyModal(); |
| 47 | const { origin: contextOrigin } = useBoostOriginContext(); |
| 48 | const origin = originProp ?? contextOrigin ?? Origin.PostBoostButton; |
| 49 | const campaignId = post?.flags?.campaignId ?? undefined; |
| 50 | |
| 51 | const onBoost = () => |
| 52 | openModal({ type: LazyModal.BoostPost, props: { post, origin } }); |
| 53 | |
| 54 | const onViewBoost = () => router.push(getBoostManagerUrl(campaignId)); |
| 55 | |
| 56 | return ( |
| 57 | <BoostButton |
| 58 | campaignId={campaignId} |
| 59 | buttonProps={{ |
| 60 | ...buttonProps, |
| 61 | onClick: campaignId ? onViewBoost : onBoost, |
| 62 | }} |
| 63 | /> |
| 64 | ); |
| 65 | } |
nothing calls this directly
no test coverage detected