mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 10:31:35 +00:00
Fix reset advanced option on disable
This commit is contained in:
parent
268e1259d6
commit
0ae63c50d2
@ -99,13 +99,11 @@ const OrderDetails = ({
|
|||||||
}
|
}
|
||||||
// Render a countdown, bold when less than 25%
|
// Render a countdown, bold when less than 25%
|
||||||
return fraction_left < 0.25 ? (
|
return fraction_left < 0.25 ? (
|
||||||
<Typography color={color}>
|
<a style={{ color }}>
|
||||||
<b>{`${hours}h ${zeroPad(minutes)}m ${zeroPad(seconds)}s `}</b>
|
<b>{`${hours}h ${zeroPad(minutes)}m ${zeroPad(seconds)}s `}</b>
|
||||||
</Typography>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
<Typography color={color}>
|
<a style={{ color }}>{`${hours}h ${zeroPad(minutes)}m ${zeroPad(seconds)}s `}</a>
|
||||||
{`${hours}h ${zeroPad(minutes)}m ${zeroPad(seconds)}s `}
|
|
||||||
</Typography>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@ import {
|
|||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
|
|
||||||
import { Order, Settings } from '../../../models';
|
import { Order, Settings } from '../../../models';
|
||||||
import {decode} from 'light-bolt11-decoder'
|
import { decode } from 'light-bolt11-decoder';
|
||||||
import WalletsButton from '../WalletsButton';
|
import WalletsButton from '../WalletsButton';
|
||||||
import { LoadingButton } from '@mui/lab';
|
import { LoadingButton } from '@mui/lab';
|
||||||
import { pn } from '../../../utils';
|
import { pn } from '../../../utils';
|
||||||
@ -101,16 +101,16 @@ export const LightningPayoutForm = ({
|
|||||||
|
|
||||||
const validateInvoice = function (invoice: string, targetAmount: number) {
|
const validateInvoice = function (invoice: string, targetAmount: number) {
|
||||||
try {
|
try {
|
||||||
const decoded = decode(invoice)
|
const decoded = decode(invoice);
|
||||||
const invoiceAmount = Math.floor(decoded['sections'][2]['value']/1000)
|
const invoiceAmount = Math.floor(decoded['sections'][2]['value'] / 1000);
|
||||||
if (targetAmount != invoiceAmount) {
|
if (targetAmount != invoiceAmount) {
|
||||||
return 'Invalid invoice amount';
|
return 'Invalid invoice amount';
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
const error = err.toString()
|
const error = err.toString();
|
||||||
return `${error.substring(0,100)}${error.length >100 ? '...' : ''}`
|
return `${error.substring(0, 100)}${error.length > 100 ? '...' : ''}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -196,9 +196,9 @@ export const LightningPayoutForm = ({
|
|||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((text) => {
|
.then((text) => {
|
||||||
if (text.includes('lnproxy error')) {
|
if (text.includes('lnproxy error')) {
|
||||||
setLightning({ ...lightning, badLnproxy: text});
|
setLightning({ ...lightning, badLnproxy: text });
|
||||||
} else {
|
} else {
|
||||||
const invoice = text.replace('\n',"")
|
const invoice = text.replace('\n', '');
|
||||||
setLightning({ ...lightning, invoice, badLnproxy: '' });
|
setLightning({ ...lightning, invoice, badLnproxy: '' });
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -210,6 +210,21 @@ export const LightningPayoutForm = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAdvancedOptions = function (checked: boolean) {
|
||||||
|
if (checked) {
|
||||||
|
setLightning({
|
||||||
|
...lightning,
|
||||||
|
advancedOptions: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setLightning({
|
||||||
|
...defaultLightning,
|
||||||
|
invoice: lightning.invoice,
|
||||||
|
amount: lightning.amount,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onProxyBudgetChange = function (e) {
|
const onProxyBudgetChange = function (e) {
|
||||||
if (isFinite(e.target.value) && e.target.value >= 0) {
|
if (isFinite(e.target.value) && e.target.value >= 0) {
|
||||||
let lnproxyBudgetSats;
|
let lnproxyBudgetSats;
|
||||||
@ -288,13 +303,7 @@ export const LightningPayoutForm = ({
|
|||||||
<Switch
|
<Switch
|
||||||
size='small'
|
size='small'
|
||||||
checked={lightning.advancedOptions}
|
checked={lightning.advancedOptions}
|
||||||
onChange={(e) => {
|
onChange={(e) => handleAdvancedOptions(e.target.checked)}
|
||||||
const checked = e.target.checked;
|
|
||||||
setLightning({
|
|
||||||
...lightning,
|
|
||||||
advancedOptions: checked,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<SelfImprovement sx={{ color: 'text.primary' }} />
|
<SelfImprovement sx={{ color: 'text.primary' }} />
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -521,7 +530,7 @@ export const LightningPayoutForm = ({
|
|||||||
fullWidth={true}
|
fullWidth={true}
|
||||||
disabled={!lightning.useLnproxy}
|
disabled={!lightning.useLnproxy}
|
||||||
error={lightning.badLnproxy != ''}
|
error={lightning.badLnproxy != ''}
|
||||||
FormHelperTextProps={{style:{wordBreak: 'break-all'}}}
|
FormHelperTextProps={{ style: { wordBreak: 'break-all' } }}
|
||||||
helperText={lightning.badLnproxy ? t(lightning.badLnproxy) : ''}
|
helperText={lightning.badLnproxy ? t(lightning.badLnproxy) : ''}
|
||||||
label={t('Invoice to wrap')}
|
label={t('Invoice to wrap')}
|
||||||
required
|
required
|
||||||
@ -543,7 +552,7 @@ export const LightningPayoutForm = ({
|
|||||||
disabled={lightning.useLnproxy}
|
disabled={lightning.useLnproxy}
|
||||||
error={lightning.badInvoice != ''}
|
error={lightning.badInvoice != ''}
|
||||||
helperText={lightning.badInvoice ? t(lightning.badInvoice) : ''}
|
helperText={lightning.badInvoice ? t(lightning.badInvoice) : ''}
|
||||||
FormHelperTextProps={{style:{wordBreak: 'break-all'}}}
|
FormHelperTextProps={{ style: { wordBreak: 'break-all' } }}
|
||||||
label={lightning.useLnproxy ? t('Wrapped invoice') : t('Payout Lightning Invoice')}
|
label={lightning.useLnproxy ? t('Wrapped invoice') : t('Payout Lightning Invoice')}
|
||||||
required
|
required
|
||||||
value={lightning.invoice}
|
value={lightning.invoice}
|
||||||
|
@ -287,7 +287,7 @@ const TradeBox = ({
|
|||||||
}, [order.status]);
|
}, [order.status]);
|
||||||
|
|
||||||
const statusToContract = function (order: Order) {
|
const statusToContract = function (order: Order) {
|
||||||
const status = order.status;
|
const status = 6;
|
||||||
const isBuyer = order.is_buyer;
|
const isBuyer = order.is_buyer;
|
||||||
const isMaker = order.is_maker;
|
const isMaker = order.is_maker;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user