Fix empty invoice creation attempts
I stumbled across this while checking if anons can edit their items. I monkey patched the code to make it possible (so they can see the 'edit' button) and tried to edit an item but I got this error: Variable "$amount" of required type "Int!" was not provided. I fixed this even though this function should never be called without an amount anyway. It will return a sane error in that case now.
This commit is contained in:
parent
28b4588a12
commit
41f46cf41e
|
@ -140,6 +140,10 @@ export function EditFeeButton ({ paidSats, hadImgLink, hasImgLink, ChildButton,
|
|||
const addImgLink = hasImgLink && !hadImgLink
|
||||
const cost = (addImgLink ? paidSats * 9 : 0) + Number(boost)
|
||||
|
||||
useEffect(() => {
|
||||
formik.setFieldValue('cost', cost)
|
||||
}, [cost])
|
||||
|
||||
const show = alwaysShow || !formik?.isSubmitting
|
||||
return (
|
||||
<div className='d-flex align-items-center'>
|
||||
|
|
|
@ -215,7 +215,7 @@ export const useInvoiceable = (fn, options = defaultOptions) => {
|
|||
if (!me && options.requireSession) {
|
||||
throw new Error('you must be logged in')
|
||||
}
|
||||
if (me && !options.forceInvoice) {
|
||||
if (!amount || (me && !options.forceInvoice)) {
|
||||
try {
|
||||
return await fn(amount, ...args)
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue