Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Common/EnhancedInputs.js
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | ${props => | ||||
` | ` | ||||
: `cursor: pointer;`} | : `cursor: pointer;`} | ||||
`; | `; | ||||
export const SendBchInput = ({ | export const SendBchInput = ({ | ||||
onMax, | onMax, | ||||
inputProps, | inputProps, | ||||
selectProps, | selectProps, | ||||
activeFiatCode, | |||||
...otherProps | ...otherProps | ||||
}) => { | }) => { | ||||
const { Option } = Select; | const { Option } = Select; | ||||
const currencies = [ | const currencies = [ | ||||
{ | { | ||||
value: currency.ticker, | value: currency.ticker, | ||||
label: currency.ticker, | label: currency.ticker, | ||||
}, | }, | ||||
{ value: 'USD', label: 'USD' }, | { | ||||
value: activeFiatCode ? activeFiatCode : 'USD', | |||||
label: activeFiatCode ? activeFiatCode : 'USD', | |||||
}, | |||||
]; | ]; | ||||
const currencyOptions = currencies.map(currency => { | const currencyOptions = currencies.map(currency => { | ||||
return ( | return ( | ||||
<Option | <Option | ||||
key={currency.value} | key={currency.value} | ||||
value={currency.value} | value={currency.value} | ||||
className="selectedCurrencyOption" | className="selectedCurrencyOption" | ||||
> | > | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | return ( | ||||
} | } | ||||
{...inputProps} | {...inputProps} | ||||
/> | /> | ||||
</Form.Item> | </Form.Item> | ||||
</AntdFormWrapper> | </AntdFormWrapper> | ||||
); | ); | ||||
}; | }; | ||||
export const CurrencySelectDropdown = selectProps => { | |||||
const { Option } = Select; | |||||
// Build select dropdown from currency.fiatCurrencies | |||||
const currencyMenuOptions = []; | |||||
const currencyKeys = Object.keys(currency.fiatCurrencies); | |||||
for (let i = 0; i < currencyKeys.length; i += 1) { | |||||
const currencyMenuOption = {}; | |||||
currencyMenuOption.value = | |||||
currency.fiatCurrencies[currencyKeys[i]].slug; | |||||
currencyMenuOption.label = `${ | |||||
currency.fiatCurrencies[currencyKeys[i]].name | |||||
} (${currency.fiatCurrencies[currencyKeys[i]].symbol})`; | |||||
currencyMenuOptions.push(currencyMenuOption); | |||||
} | |||||
const currencyOptions = currencyMenuOptions.map(currencyMenuOption => { | |||||
return ( | |||||
<Option | |||||
key={currencyMenuOption.value} | |||||
value={currencyMenuOption.value} | |||||
className="selectedCurrencyOption" | |||||
> | |||||
{currencyMenuOption.label} | |||||
</Option> | |||||
); | |||||
}); | |||||
return ( | |||||
<Select | |||||
className="select-after" | |||||
style={{ | |||||
width: '100%', | |||||
}} | |||||
{...selectProps} | |||||
> | |||||
{currencyOptions} | |||||
</Select> | |||||
); | |||||
}; | |||||
export const AddressValidators = () => { | export const AddressValidators = () => { | ||||
const { BCH } = useBCH(); | const { BCH } = useBCH(); | ||||
return { | return { | ||||
safelyDetectAddressFormat: value => { | safelyDetectAddressFormat: value => { | ||||
try { | try { | ||||
return BCH.Address.detectAddressFormat(value); | return BCH.Address.detectAddressFormat(value); | ||||
} catch (error) { | } catch (error) { | ||||
Show All 11 Lines |