import { Table } from 'react-bootstrap' import ActionTooltip from './action-tooltip' import Info from './info' import styles from './fee-button.module.css' import { gql, useQuery } from '@apollo/client' import { useFormikContext } from 'formik' function Receipt ({ cost, repetition, hasImgLink, baseFee, parentId, boost }) { return ( {hasImgLink && } {repetition > 0 && } {boost > 0 && }
{baseFee} sats {parentId ? 'reply' : 'post'} fee
x 10 image/link fee
x 10{repetition} {repetition} {parentId ? 'repeat or self replies' : 'posts'} in 10m
+ {boost} sats boost
{cost} sats total fee
) } export default function FeeButton ({ parentId, hasImgLink, baseFee, ChildButton, variant, text, alwaysShow, disabled }) { const query = parentId ? gql`{ itemRepetition(parentId: "${parentId}") }` : gql`{ itemRepetition }` const { data } = useQuery(query, { pollInterval: 1000 }) const repetition = data?.itemRepetition || 0 const formik = useFormikContext() const boost = formik?.values?.boost || 0 const cost = baseFee * (hasImgLink ? 10 : 1) * Math.pow(10, repetition) + Number(boost) const show = alwaysShow || !formik?.isSubmitting return (
{text}{cost > baseFee && show && {cost} sats} {cost > baseFee && show && }
) } function EditReceipt ({ cost, paidSats, addImgLink, boost, parentId }) { return ( {addImgLink && <> } {boost > 0 && }
{paidSats} sats {parentId ? 'reply' : 'post'} fee
x 10 image/link fee
- {paidSats} sats already paid
+ {boost} sats boost
{cost} sats total fee
) } export function EditFeeButton ({ paidSats, hadImgLink, hasImgLink, ChildButton, variant, text, alwaysShow, parentId }) { const formik = useFormikContext() const boost = formik?.values?.boost || 0 const addImgLink = hasImgLink && !hadImgLink const cost = (addImgLink ? paidSats * 9 : 0) + Number(boost) const show = alwaysShow || !formik?.isSubmitting return (
{text}{cost > 0 && show && {cost} sats} {cost > 0 && show && }
) }