mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-18 08:43:14 +00:00
More fixes
This commit is contained in:
@ -115,7 +115,7 @@ const AmountRange: React.FC<AmountRangeProps> = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setHasRangeError(!minAmountError || !maxAmountError);
|
||||
setHasRangeError(minAmountError || maxAmountError);
|
||||
}, [minAmountError, maxAmountError]);
|
||||
|
||||
return (
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
InputAdornment,
|
||||
ButtonGroup,
|
||||
Slider,
|
||||
Switch,
|
||||
@ -34,7 +33,7 @@ import AmountRange from './AmountRange';
|
||||
import currencyDict from '../../../static/assets/currencies.json';
|
||||
import { amountToString, computeSats, genBase62Token, pn } from '../../utils';
|
||||
|
||||
import { SelfImprovement, Lock, HourglassTop, DeleteSweep, Edit, Map } from '@mui/icons-material';
|
||||
import { SelfImprovement, Lock, DeleteSweep, Edit, Map } from '@mui/icons-material';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
import { fiatMethods } from '../PaymentMethods';
|
||||
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
|
||||
@ -76,6 +75,8 @@ const MakerForm = ({
|
||||
const [submittingRequest, setSubmittingRequest] = useState<boolean>(false);
|
||||
const [amountRangeEnabled, setAmountRangeEnabled] = useState<boolean>(true);
|
||||
const [hasRangeError, setHasRangeError] = useState<boolean>(false);
|
||||
const [openPublicDuration, setOpenPublicDuration] = useState<boolean>(false);
|
||||
const [openEscrowTimer, setOpenEscrowTimer] = useState<boolean>(false);
|
||||
const [limits, setLimits] = useState<LimitList>({});
|
||||
|
||||
const amountSafeThresholds = [1.03, 0.98];
|
||||
@ -369,6 +370,67 @@ const MakerForm = ({
|
||||
}, [fav, maker.amount, maker.premium, federationUpdatedAt]);
|
||||
|
||||
const disableSubmit = useMemo(() => {
|
||||
const condition1 = fav.type == null;
|
||||
console.log('Condition 1 (fav.type == null):', condition1);
|
||||
|
||||
const condition2 =
|
||||
!makerHasAmountRange &&
|
||||
maker.amount &&
|
||||
(maker.amount < amountLimits[0] || maker.amount > amountLimits[1]);
|
||||
console.log(
|
||||
'Condition 2 (!makerHasAmountRange && maker.amount && (maker.amount < amountLimits[0] || maker.amount > amountLimits[1])):',
|
||||
condition2,
|
||||
);
|
||||
|
||||
const condition3 = maker.badPaymentMethod;
|
||||
console.log('Condition 3 (maker.badPaymentMethod):', condition3);
|
||||
|
||||
const condition4 =
|
||||
maker.amount == null && (!makerHasAmountRange || (Object.keys(limits)?.length ?? 0) < 1);
|
||||
console.log(
|
||||
'Condition 4 (maker.amount == null && (!makerHasAmountRange || (Object.keys(limits)?.length ?? 0) < 1)):',
|
||||
condition4,
|
||||
);
|
||||
|
||||
const condition5 = makerHasAmountRange && hasRangeError;
|
||||
console.log('Condition 5 (makerHasAmountRange && hasRangeError):', condition5);
|
||||
|
||||
const condition6 = !makerHasAmountRange && maker.amount && maker.amount <= 0;
|
||||
console.log(
|
||||
'Condition 6 (!makerHasAmountRange && maker.amount && maker.amount <= 0):',
|
||||
condition6,
|
||||
);
|
||||
|
||||
const condition7 = maker.badPremiumText !== '';
|
||||
console.log("Condition 7 (maker.badPremiumText !== ''):", condition7);
|
||||
|
||||
const condition8 = federation.getCoordinator(maker.coordinator)?.limits === undefined;
|
||||
console.log(
|
||||
'Condition 8 (federation.getCoordinator(maker.coordinator)?.limits === undefined):',
|
||||
condition8,
|
||||
);
|
||||
|
||||
const condition9 = typeof maker.premium !== 'number';
|
||||
console.log("Condition 9 (typeof maker.premium !== 'number'):", condition9);
|
||||
|
||||
const condition10 = maker.paymentMethods.length === 0;
|
||||
console.log('Condition 10 (maker.paymentMethods.length === 0):', condition10);
|
||||
|
||||
// Combine all conditions to check if any of them are true
|
||||
const anyConditionTrue =
|
||||
condition1 ||
|
||||
condition2 ||
|
||||
condition3 ||
|
||||
condition4 ||
|
||||
condition5 ||
|
||||
condition6 ||
|
||||
condition7 ||
|
||||
condition8 ||
|
||||
condition9 ||
|
||||
condition10;
|
||||
|
||||
console.log('Any condition true:', anyConditionTrue);
|
||||
|
||||
return (
|
||||
fav.type == null ||
|
||||
(!makerHasAmountRange &&
|
||||
@ -823,12 +885,12 @@ const MakerForm = ({
|
||||
<Grid item sx={{ width: '100%' }}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<MobileTimePicker
|
||||
open={openPublicDuration}
|
||||
onClose={() => setOpenPublicDuration(false)}
|
||||
ampm={false}
|
||||
localeText={{ timePickerToolbarTitle: t('Public order length') }}
|
||||
localeText={{ toolbarTitle: t('Public order length') }}
|
||||
openTo='hours'
|
||||
views={['hours', 'minutes']}
|
||||
inputFormat='HH:mm'
|
||||
mask='__:__'
|
||||
slotProps={{
|
||||
textField: {
|
||||
fullWidth: true,
|
||||
@ -838,11 +900,7 @@ const MakerForm = ({
|
||||
borderRadius: '4px',
|
||||
marginBottom: 8,
|
||||
},
|
||||
endAdornment: (
|
||||
<InputAdornment position='end'>
|
||||
<HourglassTop />
|
||||
</InputAdornment>
|
||||
),
|
||||
onClick: () => setOpenPublicDuration(true),
|
||||
},
|
||||
},
|
||||
}}
|
||||
@ -859,7 +917,9 @@ const MakerForm = ({
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<MobileTimePicker
|
||||
ampm={false}
|
||||
localeText={{ timePickerToolbarTitle: t('Escrow/invoice step length') }}
|
||||
open={openEscrowTimer}
|
||||
onClose={() => setOpenEscrowTimer(false)}
|
||||
localeText={{ toolbarTitle: t('Escrow/invoice step length') }}
|
||||
openTo='hours'
|
||||
views={['hours', 'minutes']}
|
||||
inputFormat='HH:mm'
|
||||
@ -873,11 +933,7 @@ const MakerForm = ({
|
||||
borderRadius: '4px',
|
||||
marginBottom: 8,
|
||||
},
|
||||
endAdornment: (
|
||||
<InputAdornment position='end'>
|
||||
<HourglassTop />
|
||||
</InputAdornment>
|
||||
),
|
||||
onClick: () => setOpenEscrowTimer(true),
|
||||
},
|
||||
},
|
||||
}}
|
||||
|
@ -26,12 +26,11 @@ class RoboGenerator {
|
||||
private rejects: Record<string, Array<(reason?: Error) => void>> = {};
|
||||
|
||||
constructor() {
|
||||
for (let i = 0; i < this.numberOfWorkers; i++) {
|
||||
this.workers.push(this.createWorker(i));
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.waitingForLibrary = false;
|
||||
for (let i = 0; i < this.numberOfWorkers; i++) {
|
||||
this.workers.push(this.createWorker(i));
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user