diff --git a/react/lib/altpayment/index.ts b/react/lib/altpayment/index.ts index aef982ff..cfc223e2 100644 --- a/react/lib/altpayment/index.ts +++ b/react/lib/altpayment/index.ts @@ -3,6 +3,8 @@ import { SideshiftClient, SideshiftCoin, SideshiftError, SideshiftPair, Sideshif import config from '../../../paybutton-config.json' export const MINIMUM_ALTPAYMENT_DOLLAR_AMOUNT = 10 +export const MINIMUM_ALTPAYMENT_CAD_AMOUNT = 15 + export const SOCKET_MESSAGES = { GET_ALTPAYMENT_RATE: 'get-altpayment-rate', diff --git a/react/lib/components/Widget/Widget.tsx b/react/lib/components/Widget/Widget.tsx index 28a77c8d..5631de57 100644 --- a/react/lib/components/Widget/Widget.tsx +++ b/react/lib/components/Widget/Widget.tsx @@ -37,7 +37,7 @@ import { isPropsTrue } from '../../util'; import AltpaymentWidget from './AltpaymentWidget'; -import { AltpaymentPair, AltpaymentShift, AltpaymentError, AltpaymentCoin, MINIMUM_ALTPAYMENT_DOLLAR_AMOUNT } from '../../altpayment'; +import { AltpaymentPair, AltpaymentShift, AltpaymentError, AltpaymentCoin, MINIMUM_ALTPAYMENT_DOLLAR_AMOUNT, MINIMUM_ALTPAYMENT_CAD_AMOUNT } from '../../altpayment'; type QRCodeProps = BaseQRCodeProps & { renderAs: 'svg' }; @@ -341,7 +341,7 @@ export const Widget: React.FunctionComponent = props => { const [loadingShift, setLoadingShift] = useState(false); const [altpaymentError, setAltpaymentError] = useState(undefined); const [altpaymentEditable, setAltpaymentEditable] = useState(false); - const [isAboveMinimumAltpaymentUSDAmount, setIsAboveMinimumAltpaymentUSDAmount] = useState(null); + const [isAboveMinimumAltpaymentAmount, setIsAboveMinimumAltpaymentAmount] = useState(null); const theme = useTheme(props.theme, isValidXecAddress(to)); const classes = useStyles({ success, loading, theme, recentlyCopied, copied }); @@ -477,7 +477,17 @@ export const Widget: React.FunctionComponent = props => { } if (usdPrice && thisAmount) { const usdAmount = usdPrice * +thisAmount - setIsAboveMinimumAltpaymentUSDAmount(usdAmount >= MINIMUM_ALTPAYMENT_DOLLAR_AMOUNT) + setIsAboveMinimumAltpaymentAmount(usdAmount >= MINIMUM_ALTPAYMENT_DOLLAR_AMOUNT) + } else if (currency === 'USD'){ + if (thisAmount && +thisAmount >= MINIMUM_ALTPAYMENT_DOLLAR_AMOUNT){ + setIsAboveMinimumAltpaymentAmount(true) + } + + } else if (currency === 'CAD'){ + if (thisAmount && +thisAmount >= MINIMUM_ALTPAYMENT_CAD_AMOUNT){ + setIsAboveMinimumAltpaymentAmount(true) + } + } }, [to, thisAmount, usdPrice]); @@ -889,9 +899,9 @@ export const Widget: React.FunctionComponent = props => { {!isPropsTrue(disableAltpayment) && ( Don't have any {addressType}?