Fix input in marketplace post offer

This commit is contained in:
Bill 2022-08-18 12:30:03 -04:00
parent 1fafc9342a
commit 166ca6ef01

View File

@ -9,10 +9,22 @@ export const MarketplacePostOfferView : FC<{}> = props =>
{ {
const [ item, setItem ] = useState<FurnitureItem>(null); const [ item, setItem ] = useState<FurnitureItem>(null);
const [ askingPrice, setAskingPrice ] = useState(0); const [ askingPrice, setAskingPrice ] = useState(0);
const [ tempAskingPrice, setTempAskingPrice ] = useState('0');
const { catalogOptions = null, setCatalogOptions = null } = useCatalog(); const { catalogOptions = null, setCatalogOptions = null } = useCatalog();
const { marketplaceConfiguration = null } = catalogOptions; const { marketplaceConfiguration = null } = catalogOptions;
const { showConfirm = null } = useNotification(); const { showConfirm = null } = useNotification();
const updateAskingPrice = (price: string) =>
{
setTempAskingPrice(price);
const newValue = parseInt(price);
if(isNaN(newValue) || (newValue === askingPrice)) return;
setAskingPrice(parseInt(price));
}
useMessageEvent<MarketplaceConfigurationEvent>(MarketplaceConfigurationEvent, event => useMessageEvent<MarketplaceConfigurationEvent>(MarketplaceConfigurationEvent, event =>
{ {
const parser = event.getParser(); const parser = event.getParser();
@ -83,7 +95,7 @@ export const MarketplacePostOfferView : FC<{}> = props =>
{ LocalizeText('inventory.marketplace.make_offer.expiration_info', [ 'time' ], [ marketplaceConfiguration.offerTime.toString() ]) } { LocalizeText('inventory.marketplace.make_offer.expiration_info', [ 'time' ], [ marketplaceConfiguration.offerTime.toString() ]) }
</Text> </Text>
<div className="input-group has-validation"> <div className="input-group has-validation">
<input className="form-control form-control-sm" type="number" min={ 0 } value={ askingPrice } onChange={ event => setAskingPrice(parseInt(event.target.value)) } placeholder={ LocalizeText('inventory.marketplace.make_offer.price_request') } /> <input className="form-control form-control-sm" type="number" min={ 0 } value={ tempAskingPrice } onChange={ event => updateAskingPrice(event.target.value) } placeholder={ LocalizeText('inventory.marketplace.make_offer.price_request') } />
{ ((askingPrice < marketplaceConfiguration.minimumPrice) || isNaN(askingPrice)) && { ((askingPrice < marketplaceConfiguration.minimumPrice) || isNaN(askingPrice)) &&
<Base className="invalid-feedback d-block"> <Base className="invalid-feedback d-block">
{ LocalizeText('inventory.marketplace.make_offer.min_price', [ 'minprice' ], [ marketplaceConfiguration.minimumPrice.toString() ]) } { LocalizeText('inventory.marketplace.make_offer.min_price', [ 'minprice' ], [ marketplaceConfiguration.minimumPrice.toString() ]) }