-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc3352d
commit a8c89ad
Showing
46 changed files
with
4,025 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react' | ||
import { Field, } from 'formik' | ||
import { Asset, AssetEditor, } from 'golos-lib-js/lib/utils' | ||
|
||
class AmountAssetField extends React.Component { | ||
static defaultProps = { | ||
amountField: 'amount', | ||
} | ||
|
||
onChange = (e) => { | ||
const { amountField, values, setFieldValue, assets } = this.props | ||
const value = e.target.value | ||
const asset = assets[value] | ||
if (asset) { | ||
const { supply } = asset | ||
const oldValue = values[amountField].asset | ||
setFieldValue(amountField, AssetEditor(oldValue.amount, | ||
supply.precision, supply.symbol)) | ||
|
||
if (!values.author) { // if not edit mode | ||
if (asset.allow_override_transfer || value === 'GBG') { | ||
if (values.tip_cost) | ||
setFieldValue('tip_cost', false) | ||
setFieldValue('disable_tip', true) | ||
} else { | ||
setFieldValue('disable_tip', false) | ||
} | ||
} | ||
} | ||
} | ||
|
||
render() { | ||
const { name, assets, values, amountField } = this.props | ||
|
||
const options = [] | ||
for (const [ sym, asset ] of Object.entries(assets)) { | ||
options.push(<option value={sym}>{sym}</option>) | ||
} | ||
|
||
const { asset } = values[amountField] | ||
|
||
return (<Field name={name} as='select' value={asset.symbol} onChange={this.onChange} | ||
style={{ minWidth: '5rem', height: 'inherit', backgroundColor: 'transparent', border: 'none' }} | ||
autoComplete='off' autoCorrect='off' spellCheck='false'> | ||
{options} | ||
</Field>) | ||
} | ||
} | ||
|
||
export default AmountAssetField |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.