prevent resubmission of bounty payments

This commit is contained in:
k00b 2025-03-26 10:23:17 -05:00
parent 5701bf640a
commit bb76c6a138

View File

@ -1,5 +1,4 @@
import React from 'react' import React from 'react'
import Button from 'react-bootstrap/Button'
import styles from './pay-bounty.module.css' import styles from './pay-bounty.module.css'
import ActionTooltip from './action-tooltip' import ActionTooltip from './action-tooltip'
import { useMe } from './me' import { useMe } from './me'
@ -10,6 +9,7 @@ import { ActCanceledError, useAct } from './item-act'
import { useLightning } from './lightning' import { useLightning } from './lightning'
import { useToast } from './toast' import { useToast } from './toast'
import { useSendWallets } from '@/wallets/index' import { useSendWallets } from '@/wallets/index'
import { Form, SubmitButton } from './form'
export const payBountyCacheMods = { export const payBountyCacheMods = {
onPaid: (cache, { data }) => { onPaid: (cache, { data }) => {
@ -90,11 +90,12 @@ export default function PayBounty ({ children, item }) {
<div className='text-center fw-bold text-muted'> <div className='text-center fw-bold text-muted'>
Pay this bounty to {item.user.name}? Pay this bounty to {item.user.name}?
</div> </div>
<div className='text-center'> {/* initial={{ id: item.id }} is a hack to allow SubmitButton to be used as a button */}
<Button className='mt-4' variant='primary' onClick={() => handlePayBounty(onClose)}> <Form className='text-center' onSubmit={() => handlePayBounty(onClose)} initial={{ id: item.id }}>
pay <small>{numWithUnits(root.bounty)}</small> <SubmitButton className='mt-4' variant='primary' submittingText='paying...' appendText={numWithUnits(root.bounty)}>
</Button> pay
</div> </SubmitButton>
</Form>
</> </>
)) ))
}} }}