mirror of
https://github.com/Reckless-Satoshi/robosats.git
synced 2024-09-11 11:55:26 +03:00
Small fixes (more)
This commit is contained in:
parent
78a8ab799d
commit
b2c21d4a98
@ -146,7 +146,7 @@ class BottomBar extends Component {
|
||||
const hasRewards = this.props.robot.earnedRewards > 0;
|
||||
const hasOrder = !!(
|
||||
(this.props.robot.activeOrderId > 0) &
|
||||
!this.props.infoprofileShown &
|
||||
!this.state.profileShown &
|
||||
this.props.robot.avatarLoaded
|
||||
);
|
||||
const fontSize = this.props.theme.typography.fontSize;
|
||||
@ -175,7 +175,7 @@ class BottomBar extends Component {
|
||||
<RobotAvatar
|
||||
style={{ marginTop: -13 }}
|
||||
statusColor={
|
||||
(this.props.robot.activeOrderId > 0) & !this.props.robot.profileShown
|
||||
(this.props.robot.activeOrderId > 0) & !this.state.profileShown
|
||||
? 'primary'
|
||||
: undefined
|
||||
}
|
||||
@ -439,7 +439,10 @@ class BottomBar extends Component {
|
||||
this.props.robot.avatarLoaded
|
||||
);
|
||||
return (
|
||||
<Paper elevation={6} style={{ height: '2.85em', width: '100%' }}>
|
||||
<Paper
|
||||
elevation={6}
|
||||
style={{ height: '2.85em', width: `${(this.props.windowSize.width / 16) * 14}em` }}
|
||||
>
|
||||
<Grid container>
|
||||
<Grid item xs={1.6}>
|
||||
<div style={{ display: this.showProfileButton() ? '' : 'none' }}>
|
||||
@ -458,12 +461,12 @@ class BottomBar extends Component {
|
||||
style={{ width: 55, height: 55 }}
|
||||
avatarClass='phoneFlippedSmallAvatar'
|
||||
statusColor={
|
||||
(this.props.activeOrderId > 0) & !this.props.profileShown
|
||||
(this.props.activeOrderId > 0) & !this.state.profileShown
|
||||
? 'primary'
|
||||
: undefined
|
||||
}
|
||||
nickname={this.props.nickname}
|
||||
onLoad={() => this.props.setAppState({ avatarLoaded: true })}
|
||||
nickname={this.props.robot.nickname}
|
||||
onLoad={() => this.props.setRobot({ ...this.props.robot, avatarLoaded: true })}
|
||||
/>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
@ -475,10 +478,6 @@ class BottomBar extends Component {
|
||||
<IconButton
|
||||
disabled={!this.showProfileButton()}
|
||||
color='primary'
|
||||
onClick={() =>
|
||||
this.props.setAppState({ buyChecked: false, sellChecked: true, type: 0 }) &
|
||||
this.getInfo()
|
||||
}
|
||||
to={`/book/`}
|
||||
component={LinkRouter}
|
||||
>
|
||||
@ -494,10 +493,6 @@ class BottomBar extends Component {
|
||||
<IconButton
|
||||
disabled={!this.showProfileButton()}
|
||||
color='primary'
|
||||
onClick={() =>
|
||||
this.props.setAppState({ buyChecked: true, sellChecked: false, type: 1 }) &
|
||||
this.getInfo()
|
||||
}
|
||||
to={`/book/`}
|
||||
component={LinkRouter}
|
||||
>
|
||||
@ -513,7 +508,7 @@ class BottomBar extends Component {
|
||||
<IconButton
|
||||
disabled={!this.showProfileButton()}
|
||||
color='primary'
|
||||
onClick={() => this.getInfo()}
|
||||
onClick={() => this.props.fetchInfo()}
|
||||
to={`/`}
|
||||
component={LinkRouter}
|
||||
>
|
||||
@ -578,7 +573,7 @@ class BottomBar extends Component {
|
||||
/>
|
||||
|
||||
<UpdateClientDialog
|
||||
open={this.props.info.openUpdateClient}
|
||||
open={this.state.openUpdateClient}
|
||||
coordinatorVersion={this.props.info.coordinatorVersion}
|
||||
clientVersion={this.props.info.clientVersion}
|
||||
handleClickClose={() =>
|
||||
|
@ -117,6 +117,7 @@ const Main = (): JSX.Element => {
|
||||
});
|
||||
};
|
||||
|
||||
console.log(robot);
|
||||
return (
|
||||
<Router basename={basename}>
|
||||
<div className='appCenter'>
|
||||
|
@ -75,7 +75,6 @@ const MakerForm = ({
|
||||
const theme = useTheme();
|
||||
const history = useHistory();
|
||||
const [badRequest, setBadRequest] = useState<string | null>(null);
|
||||
const [advancedOptions, setAdvancedOptions] = useState<boolean>(false);
|
||||
const [amountLimits, setAmountLimits] = useState<number[]>([1, 1000]);
|
||||
const [satoshisLimits, setSatoshisLimits] = useState<number[]>([20000, 4000000]);
|
||||
const [currentPrice, setCurrentPrice] = useState<number | string>('...');
|
||||
@ -142,7 +141,7 @@ const MakerForm = ({
|
||||
});
|
||||
updateAmountLimits(limits.list, newCurrency, maker.premium);
|
||||
updateCurrentPrice(limits.list, newCurrency, maker.premium);
|
||||
if (advancedOptions) {
|
||||
if (maker.advancedOptions) {
|
||||
setMaker({
|
||||
...maker,
|
||||
minAmount: parseFloat(Number(limits.list[newCurrency].max_amount * 0.25).toPrecision(2)),
|
||||
@ -230,7 +229,7 @@ const MakerForm = ({
|
||||
};
|
||||
|
||||
const handleClickExplicit = function () {
|
||||
if (!advancedOptions) {
|
||||
if (!maker.advancedOptions) {
|
||||
setMaker({
|
||||
...maker,
|
||||
isExplicit: true,
|
||||
@ -244,10 +243,10 @@ const MakerForm = ({
|
||||
const body = {
|
||||
type: fav.type == 0 ? 1 : 0,
|
||||
currency: fav.currency == 0 ? 1 : fav.currency,
|
||||
amount: advancedOptions ? null : maker.amount,
|
||||
has_range: advancedOptions,
|
||||
min_amount: advancedOptions ? maker.minAmount : null,
|
||||
max_amount: advancedOptions ? maker.maxAmount : null,
|
||||
amount: maker.advancedOptions ? null : maker.amount,
|
||||
has_range: maker.advancedOptions,
|
||||
min_amount: maker.advancedOptions ? maker.minAmount : null,
|
||||
max_amount: maker.advancedOptions ? maker.maxAmount : null,
|
||||
payment_method:
|
||||
maker.paymentMethodsText === '' ? 'not specified' : maker.paymentMethodsText,
|
||||
is_explicit: maker.isExplicit,
|
||||
@ -295,13 +294,12 @@ const MakerForm = ({
|
||||
};
|
||||
|
||||
const handleClickAdvanced = function () {
|
||||
if (advancedOptions) {
|
||||
if (maker.advancedOptions) {
|
||||
handleClickRelative();
|
||||
setMaker({ ...maker, advancedOptions: false });
|
||||
} else {
|
||||
resetRange();
|
||||
resetRange(true);
|
||||
}
|
||||
|
||||
setAdvancedOptions(!advancedOptions);
|
||||
};
|
||||
|
||||
const minAmountError = function () {
|
||||
@ -322,7 +320,7 @@ const MakerForm = ({
|
||||
);
|
||||
};
|
||||
|
||||
const resetRange = function () {
|
||||
const resetRange = function (advancedOptions: boolean) {
|
||||
const index = fav.currency === 0 ? 1 : fav.currency;
|
||||
const minAmount = maker.amount
|
||||
? parseFloat((maker.amount / 2).toPrecision(2))
|
||||
@ -333,6 +331,7 @@ const MakerForm = ({
|
||||
|
||||
setMaker({
|
||||
...maker,
|
||||
advancedOptions,
|
||||
minAmount,
|
||||
maxAmount,
|
||||
});
|
||||
@ -376,11 +375,11 @@ const MakerForm = ({
|
||||
return (
|
||||
fav.type == null ||
|
||||
(maker.amount != '' &&
|
||||
!advancedOptions &&
|
||||
!maker.advancedOptions &&
|
||||
(maker.amount < amountLimits[0] || maker.amount > amountLimits[1])) ||
|
||||
(maker.amount == null && (!advancedOptions || limits.loading)) ||
|
||||
(advancedOptions && (minAmountError() || maxAmountError())) ||
|
||||
(maker.amount <= 0 && !advancedOptions) ||
|
||||
(maker.amount == null && (!maker.advancedOptions || limits.loading)) ||
|
||||
(maker.advancedOptions && (minAmountError() || maxAmountError())) ||
|
||||
(maker.amount <= 0 && !maker.advancedOptions) ||
|
||||
(maker.isExplicit && (maker.badSatoshisText != '' || maker.satoshis == '')) ||
|
||||
(!maker.isExplicit && maker.badPremiumText != '')
|
||||
);
|
||||
@ -404,7 +403,7 @@ const MakerForm = ({
|
||||
: fav.type == 1
|
||||
? t('Buy order for ')
|
||||
: t('Sell order for ')}
|
||||
{advancedOptions && maker.minAmount != ''
|
||||
{maker.advancedOptions && maker.minAmount != ''
|
||||
? pn(maker.minAmount) + '-' + pn(maker.maxAmount)
|
||||
: pn(maker.amount)}
|
||||
{' ' + currencyCode}
|
||||
@ -478,7 +477,7 @@ const MakerForm = ({
|
||||
<Switch
|
||||
size='small'
|
||||
disabled={limits.list.length == 0}
|
||||
checked={advancedOptions}
|
||||
checked={maker.advancedOptions}
|
||||
onChange={handleClickAdvanced}
|
||||
/>
|
||||
<SelfImprovement sx={{ color: 'text.secondary' }} />
|
||||
@ -498,7 +497,7 @@ const MakerForm = ({
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
size={advancedOptions ? 'small' : 'large'}
|
||||
size={maker.advancedOptions ? 'small' : 'large'}
|
||||
variant='contained'
|
||||
onClick={() =>
|
||||
setFav({
|
||||
@ -518,7 +517,7 @@ const MakerForm = ({
|
||||
{t('Buy')}
|
||||
</Button>
|
||||
<Button
|
||||
size={advancedOptions ? 'small' : 'large'}
|
||||
size={maker.advancedOptions ? 'small' : 'large'}
|
||||
variant='contained'
|
||||
onClick={() =>
|
||||
setFav({
|
||||
@ -544,7 +543,7 @@ const MakerForm = ({
|
||||
</Grid>
|
||||
|
||||
<Grid item>
|
||||
<Collapse in={advancedOptions}>
|
||||
<Collapse in={maker.advancedOptions}>
|
||||
<AmountRange
|
||||
minAmount={maker.minAmount}
|
||||
handleRangeAmountChange={handleRangeAmountChange}
|
||||
@ -559,7 +558,7 @@ const MakerForm = ({
|
||||
handleMaxAmountChange={handleMaxAmountChange}
|
||||
/>
|
||||
</Collapse>
|
||||
<Collapse in={!advancedOptions}>
|
||||
<Collapse in={!maker.advancedOptions}>
|
||||
<Grid item>
|
||||
<Grid container alignItems='stretch' style={{ display: 'flex' }}>
|
||||
<Grid item xs={6}>
|
||||
@ -572,8 +571,8 @@ const MakerForm = ({
|
||||
>
|
||||
<TextField
|
||||
fullWidth
|
||||
disabled={advancedOptions}
|
||||
variant={advancedOptions ? 'filled' : 'outlined'}
|
||||
disabled={maker.advancedOptions}
|
||||
variant={maker.advancedOptions ? 'filled' : 'outlined'}
|
||||
error={
|
||||
maker.amount != '' &&
|
||||
(maker.amount < amountLimits[0] || maker.amount > amountLimits[1])
|
||||
@ -650,7 +649,7 @@ const MakerForm = ({
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
{!advancedOptions && pricingMethods ? (
|
||||
{!maker.advancedOptions && pricingMethods ? (
|
||||
<Grid item xs={12}>
|
||||
<Box
|
||||
sx={{
|
||||
@ -692,7 +691,7 @@ const MakerForm = ({
|
||||
title={t('Set a fix amount of satoshis')}
|
||||
>
|
||||
<FormControlLabel
|
||||
disabled={advancedOptions}
|
||||
disabled={maker.advancedOptions}
|
||||
value='explicit'
|
||||
control={<Radio color='secondary' />}
|
||||
label={t('Exact')}
|
||||
@ -749,7 +748,7 @@ const MakerForm = ({
|
||||
</div>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Collapse in={advancedOptions}>
|
||||
<Collapse in={maker.advancedOptions}>
|
||||
<Grid container spacing={1}>
|
||||
<Grid item xs={12}>
|
||||
<LocalizationProvider dateAdapter={DateFnsUtils}>
|
||||
|
@ -78,14 +78,6 @@ class UserGenPage extends Component {
|
||||
});
|
||||
requestBody.then((body) =>
|
||||
apiClient.post('/api/user/', body).then((data) => {
|
||||
this.props.setRobot({
|
||||
bit_entropy: data.token_bits_entropy,
|
||||
shannon_entropy: data.token_shannon_entropy,
|
||||
bad_request: data.bad_request,
|
||||
found: data.found,
|
||||
loading: false,
|
||||
stealthInvoices: data.wants_stealth,
|
||||
});
|
||||
// Add nick and token to App state (token only if not a bad request)
|
||||
data.bad_request
|
||||
? this.props.setRobot({
|
||||
@ -111,6 +103,10 @@ class UserGenPage extends Component {
|
||||
tgEnabled: data.tg_enabled,
|
||||
tgBotName: data.tg_bot_name,
|
||||
tgToken: data.tg_token,
|
||||
bitsEntropy: data.token_bits_entropy,
|
||||
shannonEntropy: data.token_shannon_entropy,
|
||||
pub_key: data.public_key,
|
||||
enc_priv_key: data.encrypted_private_key,
|
||||
}) &
|
||||
systemClient.setCookie('robot_token', token) &
|
||||
systemClient.setCookie('pub_key', data.public_key.split('\n').join('\\')) &
|
||||
@ -174,11 +170,11 @@ class UserGenPage extends Component {
|
||||
|
||||
createJsonFile = () => {
|
||||
return {
|
||||
token: systemClient.getCookie('robot_token'),
|
||||
token_shannon_entropy: this.state.shannon_entropy,
|
||||
token_bit_entropy: this.state.bit_entropy,
|
||||
public_key: systemClient.getCookie('pub_key').split('\\').join('\n'),
|
||||
encrypted_private_key: systemClient.getCookie('enc_priv_key').split('\\').join('\n'),
|
||||
token: this.props.robot.token,
|
||||
token_shannon_entropy: this.props.robot.shannonEntropy,
|
||||
token_bit_entropy: this.props.robot.bitsEntropy,
|
||||
public_key: this.props.robot.pub_key,
|
||||
encrypted_private_key: this.props.robot.enc_priv_key,
|
||||
};
|
||||
};
|
||||
|
||||
@ -356,7 +352,7 @@ class UserGenPage extends Component {
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item xs={12} align='center'>
|
||||
{this.state.inputTokenHasChanged ? (
|
||||
{this.state.tokenHasChanged ? (
|
||||
<Button type='submit' size='small' onClick={this.handleClickSubmitToken}>
|
||||
<SmartToyIcon sx={{ width: 18 * fontSizeFactor, height: 18 * fontSizeFactor }} />
|
||||
<span> {t('Generate Robot')}</span>
|
||||
|
@ -1,4 +1,5 @@
|
||||
export interface Maker {
|
||||
advancedOptions: boolean;
|
||||
isExplicit: boolean;
|
||||
amount: string;
|
||||
paymentMethods: string[];
|
||||
@ -18,6 +19,7 @@ export interface Maker {
|
||||
}
|
||||
|
||||
export const defaultMaker: Maker = {
|
||||
advancedOptions: false,
|
||||
isExplicit: false,
|
||||
amount: '',
|
||||
paymentMethods: [],
|
||||
|
@ -1,6 +1,10 @@
|
||||
import { systemClient } from '../services/System';
|
||||
|
||||
export interface Robot {
|
||||
nickname: string | null;
|
||||
token: string | null;
|
||||
pub_key: string | null;
|
||||
enc_priv_key: string | null;
|
||||
bitsEntropy: number | null;
|
||||
shannonEntropy: number | null;
|
||||
stealthInvoices: boolean;
|
||||
@ -18,7 +22,15 @@ export interface Robot {
|
||||
|
||||
export const defaultRobot: Robot = {
|
||||
nickname: null,
|
||||
token: null,
|
||||
token: systemClient.getCookie('robot_token') ?? null,
|
||||
pub_key:
|
||||
systemClient.getCookie('pub_key') === undefined
|
||||
? null
|
||||
: systemClient.getCookie('pub_key').split('\\').join('\n'),
|
||||
enc_priv_key:
|
||||
systemClient.getCookie('enc_priv_key') === undefined
|
||||
? null
|
||||
: systemClient.getCookie('enc_priv_key').split('\\').join('\n'),
|
||||
bitsEntropy: null,
|
||||
shannonEntropy: null,
|
||||
stealthInvoices: true,
|
||||
|
Loading…
Reference in New Issue
Block a user