mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-30 00:50:50 +01:00
Fix input in marketplace post offer
This commit is contained in:
parent
1fafc9342a
commit
166ca6ef01
@ -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();
|
||||||
@ -64,7 +76,7 @@ export const MarketplacePostOfferView : FC<{}> = props =>
|
|||||||
setItem(null)
|
setItem(null)
|
||||||
}, null, null, LocalizeText('inventory.marketplace.confirm_offer.title'));
|
}, null, null, LocalizeText('inventory.marketplace.confirm_offer.title'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NitroCardView className="nitro-catalog-layout-marketplace-post-offer" theme="primary-slim">
|
<NitroCardView className="nitro-catalog-layout-marketplace-post-offer" theme="primary-slim">
|
||||||
<NitroCardHeaderView headerText={ LocalizeText('inventory.marketplace.make_offer.title') } onCloseClick={ event => setItem(null) } />
|
<NitroCardHeaderView headerText={ LocalizeText('inventory.marketplace.make_offer.title') } onCloseClick={ event => setItem(null) } />
|
||||||
@ -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() ]) }
|
||||||
|
Loading…
Reference in New Issue
Block a user