Skip to content

Commit

Permalink
fix: update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sajald77 committed Apr 29, 2024
1 parent 3d42432 commit ff2feed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
8 changes: 5 additions & 3 deletions src/hooks/useFundingFormState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,19 @@ export const useFundingFormState = ({ rewards, rewardCurrency, walletLimits }: U

if (onChain?.max && debouncedTotalAmount > onChain.max) {
setAmountWarning(
`can be funded via. Lightning invoice only. amount exceeds onChain max: ${commaFormatted(onChain.max)} sats`,
`The maximum amount for on-chain contributions is ${commaFormatted(
onChain.max,
)} Sats. For higher amounts, you can pay with Lightning.`,
)
setAmountError('')
return
}

if (onChain?.min && debouncedTotalAmount < onChain.min) {
setAmountWarning(
`can be funded via. Lightning invoice only. amount is lower than onChain min: ${commaFormatted(
`The minimum amount for on-chain contributions is ${commaFormatted(
onChain.min,
)} sats`,
)} Sats. For smaller amounts, you can pay with Lightning.`,
)
setAmountError('')
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { Button, HStack } from '@chakra-ui/react'
import { Button, HStack, Tooltip } from '@chakra-ui/react'
import { useTranslation } from 'react-i18next'

import { useFundingContext } from '../../../../../../../context'
import { useRefundFileValue } from '../../../../../../../funding/state'
import { PaymentMethods, usePaymentMethodAtom } from '../states/paymentMethodAtom'

export const PaymentMethodSelection = () => {
const { t } = useTranslation()
const [paymentMethod, setPaymentMethod] = usePaymentMethodAtom()

const {
fundForm: { amountWarning },
} = useFundingContext()
const refundFile = useRefundFileValue()

const isLightning = paymentMethod === PaymentMethods.lightning

console.log('checking refundFile', refundFile)

return (
<HStack w="full">
<Button
Expand All @@ -25,16 +27,18 @@ export const PaymentMethodSelection = () => {
>
{t('Lightning')}
</Button>
<Button
flex={1}
variant={'secondary'}
borderColor={!isLightning ? 'primary.400' : undefined}
color={!isLightning ? 'primary.400' : undefined}
onClick={() => setPaymentMethod(PaymentMethods.onChain)}
isDisabled={!refundFile}
>
{t('Onchain')}
</Button>
<Tooltip label={!refundFile && amountWarning}>
<Button
flex={1}
variant={'secondary'}
borderColor={!isLightning ? 'primary.400' : undefined}
color={!isLightning ? 'primary.400' : undefined}
onClick={() => setPaymentMethod(PaymentMethods.onChain)}
isDisabled={!refundFile}
>
{t('Onchain')}
</Button>
</Tooltip>
</HStack>
)
}

0 comments on commit ff2feed

Please sign in to comment.