Skip to content

Commit

Permalink
Merge pull request #300 from spartan-protocol/#294
Browse files Browse the repository at this point in the history
  • Loading branch information
SamusElderg committed Nov 24, 2020
2 parents 9556cf1 + 20194af commit 6ddb928
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/components/Sections/InputPaneJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ export const InputPaneJoin = (props) => {
<Col sm="12">
<InputGroup className="mb-3">
<InputGroupAddon addonType="prepend">
<Label className="input-group-text">{props.t("Total")}</Label>
<Label className="input-group-text">{props.t("Input")}</Label>
</InputGroupAddon>
<Input type="text" className="form-control" onChange={props.onInputChange}
placeholder={formatAllUnits(convertFromWei(props.paneData?.input))}
bssize={'large'}
bssize={'large'} id={"manualInput" + props.tabId}
placeholder={'Manually input ' + props.paneData?.symbol + ' here'}
// defaultValue={convertFromWei(props.paneData?.input)}
// allowClear={true}
// addonAfter={<TokenDropDown default={props.paneData?.address}
Expand All @@ -93,7 +93,7 @@ export const InputPaneJoin = (props) => {
</FormGroup>
<br/>
<div className="text-center">
<PercentButtonRow changeAmount={props.changeAmount}/>
<PercentButtonRow changeAmount={props.changeAmount} tabId={props.tabId} />
</div>
<br/>
</div>
Expand Down
28 changes: 23 additions & 5 deletions src/components/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const OutputPane = (props) => {
return (
<div className="text-center">

<PercentButtonRow changeAmount={props.changeAmount}/>
<PercentButtonRow changeAmount={props.changeAmount} tabId={props.tabId} />
{/* // eslint-disable-next-line
<Center>
{!secondToken &&
Expand Down Expand Up @@ -165,13 +165,31 @@ export const PercentButtonRow = (props) => {
marginTop: 10,
minWidth: '15%',
}

const clearManualInput = () => {
const inputEl = document.getElementById('manualInput' + props.tabId)
if (inputEl) {inputEl.value = ''}
}

return (
<>
<Col xs={24}>
<Button color="primary" type="button" style={btnStyle} onClick={change25}>25%</Button>
<Button color="primary" type="button" style={btnStyle} onClick={change50}>50%</Button>
<Button color="primary" type="button" style={btnStyle} onClick={change75}>75%</Button>
<Button color="primary" style={btnStyle} onClick={change100}>All</Button>
<Button color="primary" type="button" style={btnStyle} onClick={()=>{
clearManualInput();
change25();
}}>25%</Button>
<Button color="primary" type="button" style={btnStyle} onClick={()=>{
clearManualInput();
change50();
}}>50%</Button>
<Button color="primary" type="button" style={btnStyle} onClick={()=>{
clearManualInput();
change75();
}}>75%</Button>
<Button color="primary" style={btnStyle} onClick={()=>{
clearManualInput();
change100();
}}>All</Button>
</Col>
</>
)
Expand Down
27 changes: 23 additions & 4 deletions src/pages/AddLiquidity.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ const AddLiquidity = (props) => {
</NavItem>
</Nav>
<TabContent activeTab={activeTab} className="crypto-buy-sell-nav-content p-4">
<TabPane tabId="1" id="buy">
<TabPane tabId="1" id="buy-tab">
<AddSymmPane
pool={pool}
userData={userData}
Expand All @@ -494,6 +494,7 @@ const AddLiquidity = (props) => {
startTx={startTx}
endTx={endTx}
activeTab={activeTab}
tabId='1'
/>
</TabPane>
<TabPane tabId="2" id="sell-tab">
Expand All @@ -514,9 +515,10 @@ const AddLiquidity = (props) => {
endTx={endTx}
activeTab={activeTab}
toggleTab={toggleTab}
tabId='2'
/>
</TabPane>
<TabPane tabId="3" id="sell-tab">
<TabPane tabId="3" id="remove-tab">
<RemoveLiquidityPane
pool={pool}
userData={userData}
Expand All @@ -527,6 +529,7 @@ const AddLiquidity = (props) => {
withdrawData={withdrawData}
startTx={startTx}
endTx={endTx}
tabId='3'
location={props.location.search}
/>
</TabPane>
Expand Down Expand Up @@ -558,7 +561,7 @@ const AddSymmPane = (props) => {

const [showModal, setShowModal] = useState(false);
const toggle = () => setShowModal(!showModal);
const remainder = convertFromWei(props.userData.balance - props.userData.input)
const remainder = convertFromWei(props.userData.balance - props.liquidityData.tokenAmnt)

const checkEnoughForGas = () => {
if (props.userData.symbol === 'BNB') { // if input Symbol is BNB
Expand All @@ -581,6 +584,7 @@ const AddSymmPane = (props) => {
onInputChange={props.onAddChange}
changeAmount={props.changeAmount}
activeTab={props.activeTab}
tabId={props.tabId}
/>
<br/>
<div className="table-responsive mt-6">
Expand Down Expand Up @@ -755,6 +759,7 @@ const AddAsymmPane = (props) => {
paneData={props.userData}
onInputChange={props.onAddChange}
changeAmount={props.changeAmount}
tabId={props.tabId}
/>
<br/>
<UncontrolledAlert color="secondary" className="alert-dismissible fade show" role="alert">
Expand All @@ -764,6 +769,20 @@ const AddAsymmPane = (props) => {
<div className="table-responsive mt-6">
<table className="table table-centered table-nowrap mb-0">
<tbody>
<tr>
<td style={{width: "100%"}}>
<div className="mb-0 text-left">
<span id="tooltipAddBaseAsym">Add {props.userData.symbol} <i className="bx bx-info-circle align-middle"/></span>
<UncontrolledTooltip placement="right" target="tooltipAddBaseAsym">
The quantity of {props.userData.symbol} you are adding to the pool.
</UncontrolledTooltip>
<h6 className="d-block d-lg-none mb-0 text-left">{formatAllUnits(convertFromWei(props.liquidityData.tokenAmount))}</h6>
</div>
</td>
<td className="d-none d-lg-table-cell">
<h5 className="mb-0 text-right">{formatAllUnits(convertFromWei(props.liquidityData.tokenAmount))}</h5>
</td>
</tr>
<tr>
<td style={{width: "100%"}}>
<div className="mb-0 text-left">
Expand Down Expand Up @@ -946,7 +965,7 @@ const RemoveLiquidityPane = (props) => {
return (
<>

<OutputPane changeAmount={props.changeWithdrawAmount}/>
<OutputPane changeAmount={props.changeWithdrawAmount} tabId={props.tabId} />

<div className="table-responsive mt-6">
<table className="table table-centered table-nowrap mb-0">
Expand Down

0 comments on commit 6ddb928

Please sign in to comment.