Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions frontend/src/components/MakerForm/MakerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ const MakerForm = ({
const handleCurrencyChange = function (newCurrency: number): void {
const currencyCode: string = currencyDict[newCurrency];
setCurrencyCode(currencyCode);
setFav({
...fav,
currency: newCurrency,
mode: newCurrency === 1000 ? 'swap' : 'fiat',
setFav((prev) => {
return {
...prev,
currency: newCurrency,
mode: newCurrency === 1000 ? 'swap' : 'fiat',
};
});
updateAmountLimits(limits, newCurrency, maker.premium);
updateCurrentPrice(limits, newCurrency, maker.premium);
Expand Down Expand Up @@ -260,6 +262,7 @@ const MakerForm = ({
.then((order: Order) => {
if (order.id) {
navigateToPage(`order/${order.shortAlias}/${order.id}`, navigate);
clearMaker();
} else if (order?.bad_request) {
setBadRequest(order?.bad_request);
}
Expand Down Expand Up @@ -409,8 +412,12 @@ const MakerForm = ({
}, [maker, maker.premium, amountLimits, federationUpdatedAt, fav.type, makerHasAmountRange]);

const clearMaker = function (): void {
setFav({ ...fav, type: null });
setFav((prev) => {
return { ...prev, type: null, currency: 0, mode: 'fiat' };
});
setMaker(defaultMaker);
handleCurrencyChange(0);
handlePaymentMethodChange([]);
};

const handleAddLocation = (pos: [number, number]): void => {
Expand Down Expand Up @@ -645,9 +652,11 @@ const MakerForm = ({
size={maker.advancedOptions ? 'small' : 'large'}
variant='contained'
onClick={() => {
setFav({
...fav,
type: 1,
setFav((prev) => {
return {
...prev,
type: 1,
};
});
}}
disableElevation={fav.type === 1}
Expand Down Expand Up @@ -677,9 +686,11 @@ const MakerForm = ({
size={maker.advancedOptions ? 'small' : 'large'}
variant='contained'
onClick={() => {
setFav({
...fav,
type: 0,
setFav((prev) => {
return {
...prev,
type: 0,
};
});
}}
color='secondary'
Expand Down Expand Up @@ -769,7 +780,7 @@ const MakerForm = ({
}
label={amountLabel.label}
required={true}
value={maker.amount}
value={maker.amount ?? ''}
type='number'
onChange={(e) => {
setMaker({ ...maker, amount: Number(e.target.value) });
Expand Down Expand Up @@ -909,7 +920,7 @@ const MakerForm = ({
helperText={maker.badPremiumText === '' ? null : maker.badPremiumText}
label={`${t('Premium over Market (%)')} *`}
type='number'
value={maker.premium}
value={maker.premium ?? ''}
inputProps={{
min: -100,
max: 999,
Expand All @@ -935,7 +946,7 @@ const MakerForm = ({
fullWidth
label={`${t('Description')}`}
type='description'
value={maker.description}
value={maker.description ?? ''}
style={{ marginBottom: 8 }}
inputProps={{
style: {
Expand Down Expand Up @@ -969,7 +980,7 @@ const MakerForm = ({
fullWidth
label={`${t('Password')}`}
type='password'
value={maker.password}
value={maker.password ?? ''}
style={{ marginBottom: 8 }}
inputProps={{
style: {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/models/Maker.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export const defaultMaker: Maker = {
maxAmount: null,
badPremiumText: '',
badSatoshisText: '',
latitude: 0,
longitude: 0,
latitude: null,
longitude: null,
password: null,
description: null,
badDescription: false,
Expand Down
Loading