({
post,
buttonProps = {},
}: {
post: Post;
buttonProps?: ButtonProps<'button'>;
})
| 31 | } |
| 32 | |
| 33 | export function BoostPostButton({ |
| 34 | post, |
| 35 | buttonProps = {}, |
| 36 | }: { |
| 37 | post: Post; |
| 38 | buttonProps?: ButtonProps<'button'>; |
| 39 | }): ReactElement { |
| 40 | const { openModal } = useLazyModal(); |
| 41 | const campaignId = post?.flags?.campaignId; |
| 42 | const { data: campaign, isFetched } = useCampaignById(campaignId); |
| 43 | |
| 44 | const onBoost = () => |
| 45 | openModal({ type: LazyModal.BoostPost, props: { post } }); |
| 46 | |
| 47 | const onViewBoost = () => |
| 48 | openModal({ type: LazyModal.BoostedCampaignView, props: { campaign } }); |
| 49 | |
| 50 | return ( |
| 51 | <BoostButton |
| 52 | campaignId={campaignId} |
| 53 | buttonProps={{ |
| 54 | ...buttonProps, |
| 55 | loading: campaignId && !isFetched, |
| 56 | onClick: campaignId ? onViewBoost : onBoost, |
| 57 | }} |
| 58 | /> |
| 59 | ); |
| 60 | } |
nothing calls this directly
no test coverage detected