Having a page of adding auction , while add auction the auction number should be display by default while opens add auction page .
In my case the number is displayed only after clicking and trying to add number or while exiting the field. And the number will come from fire base as per the count already we added and the current auction number should be like existing auction plus one(existing auctions count + 1). Thanks in advance!!
render() {
const { handleSubmit } = this.props;
let chittieAuctionNumber = Object.keys(this.props.chittieAuctions).length;
let chittieAuctionUsers = [];
let chittieId = this.props.match.params.chittieId;
let chittieUsers = this.props.chitties[chittieId].chittieUsers;
Object.keys(this.props.chittieAuctions).map((key) => {
chittieAuctionUsers.push(this.props.chittieAuctions[key].userData);
});
Object.keys(this.props.chitties[chittieId].chittieUsers).map((key) => {
let existingUserData = find(chittieAuctionUsers, ['id', key]);
if (existingUserData && existingUserData.id === key) {
delete chittieUsers[key];
}
});
const auctionNumber = (value) =>
value == null ? '' : chittieAuctionNumber + 1;
return (
<form onSubmit={handleSubmit}>
<Card>
<CardHeader>
<Row>
<Col xs="6" lg="5">
<Button color="primary" onClick={this.goBack}>
<i className="fa fa-chevron-left" />
Back
</Button>
</Col>
<Col xs="6" lg="7">
<h4 className="font-weight-bold">Add Auction</h4>
</Col>
</Row>
</CardHeader>
<CardBody>
<FormGroup row className="my-0">
<Col xs="12" lg="6">
<Field
name="auctionNumber"
type="text"
component={FormInput}
label="Auction Number *"
normalize={auctionNumber}
/>
</Col>
