Fix cards state being not updated on touchables
Signed-off-by: Egor Savkin <es@m-labs.hk>
parent
fda37da6d5
commit
b95256d13d
|
@ -540,6 +540,7 @@ class ProductCartItem extends React.PureComponent {
|
||||||
onToggleWarning: PropTypes.func,
|
onToggleWarning: PropTypes.func,
|
||||||
onToggleOverlayRemove: PropTypes.func,
|
onToggleOverlayRemove: PropTypes.func,
|
||||||
onClickRemoveItem: PropTypes.func,
|
onClickRemoveItem: PropTypes.func,
|
||||||
|
onCardUpdate: PropTypes.func,
|
||||||
shouldTooltipWarningClassInverted: PropTypes.bool,
|
shouldTooltipWarningClassInverted: PropTypes.bool,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -623,6 +624,7 @@ class ProductCartItem extends React.PureComponent {
|
||||||
index,
|
index,
|
||||||
ext_data,
|
ext_data,
|
||||||
shouldTooltipWarningClassInverted,
|
shouldTooltipWarningClassInverted,
|
||||||
|
onCardUpdate,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
let warning, options, options_data;
|
let warning, options, options_data;
|
||||||
|
@ -723,12 +725,12 @@ class ProductCartItem extends React.PureComponent {
|
||||||
construct: ((outvar, value) => {
|
construct: ((outvar, value) => {
|
||||||
// console.log("construct", outvar, value, options_data);
|
// console.log("construct", outvar, value, options_data);
|
||||||
options_data[outvar] = value;
|
options_data[outvar] = value;
|
||||||
this.setState(options_data);
|
onCardUpdate();
|
||||||
}),
|
}),
|
||||||
update: ((outvar, value) => {
|
update: ((outvar, value) => {
|
||||||
// console.log("update", outvar, value, options_data);
|
// console.log("update", outvar, value, options_data);
|
||||||
if (outvar in options_data) options_data[outvar] = value;
|
if (outvar in options_data) options_data[outvar] = value;
|
||||||
this.setState(options_data);
|
onCardUpdate();
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
/>) : null) }
|
/>) : null) }
|
||||||
|
@ -857,6 +859,7 @@ class Cart extends React.PureComponent {
|
||||||
onToggleWarning: PropTypes.func,
|
onToggleWarning: PropTypes.func,
|
||||||
onToggleOverlayRemove: PropTypes.func,
|
onToggleOverlayRemove: PropTypes.func,
|
||||||
onClickRemoveItem: PropTypes.func,
|
onClickRemoveItem: PropTypes.func,
|
||||||
|
onCardUpdate: PropTypes.func,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -870,6 +873,7 @@ class Cart extends React.PureComponent {
|
||||||
onToggleWarning,
|
onToggleWarning,
|
||||||
onToggleOverlayRemove,
|
onToggleOverlayRemove,
|
||||||
onClickRemoveItem,
|
onClickRemoveItem,
|
||||||
|
onCardUpdate,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const nbrOccupied = nbrOccupiedSlotsInCrate(data.items);
|
const nbrOccupied = nbrOccupiedSlotsInCrate(data.items);
|
||||||
|
@ -897,6 +901,7 @@ class Cart extends React.PureComponent {
|
||||||
onToggleWarning={onToggleWarning}
|
onToggleWarning={onToggleWarning}
|
||||||
onToggleOverlayRemove={onToggleOverlayRemove}
|
onToggleOverlayRemove={onToggleOverlayRemove}
|
||||||
onClickRemoveItem={onClickRemoveItem}
|
onClickRemoveItem={onClickRemoveItem}
|
||||||
|
onCardUpdate={onCardUpdate}
|
||||||
model={item}>
|
model={item}>
|
||||||
</ProductCartItem>
|
</ProductCartItem>
|
||||||
);
|
);
|
||||||
|
@ -1668,6 +1673,7 @@ class Shop extends React.PureComponent {
|
||||||
this.handleClickShowOrder = this.handleClickShowOrder.bind(this);
|
this.handleClickShowOrder = this.handleClickShowOrder.bind(this);
|
||||||
this.handleClickOpenImport = this.handleClickOpenImport.bind(this);
|
this.handleClickOpenImport = this.handleClickOpenImport.bind(this);
|
||||||
this.handleLoadCustomConf = this.handleLoadCustomConf.bind(this);
|
this.handleLoadCustomConf = this.handleLoadCustomConf.bind(this);
|
||||||
|
this.handleCardsUpdated = this.handleCardsUpdated.bind(this);
|
||||||
|
|
||||||
this.timer = null;
|
this.timer = null;
|
||||||
}
|
}
|
||||||
|
@ -1702,9 +1708,7 @@ class Shop extends React.PureComponent {
|
||||||
(prevState.columns.cart.items !== this.state.columns.cart.items) ||
|
(prevState.columns.cart.items !== this.state.columns.cart.items) ||
|
||||||
(prevState.currentMode !== this.state.currentMode)
|
(prevState.currentMode !== this.state.currentMode)
|
||||||
) {
|
) {
|
||||||
this.checkAlerts(
|
this.checkAlerts(this.state.columns.cart.items);
|
||||||
prevState.columns.cart.items,
|
|
||||||
this.state.columns.cart.items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.newCardJustAdded) {
|
if (this.state.newCardJustAdded) {
|
||||||
|
@ -1720,6 +1724,10 @@ class Shop extends React.PureComponent {
|
||||||
clearTimeout(this.timer);
|
clearTimeout(this.timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleCardsUpdated() {
|
||||||
|
this.checkAlerts(this.state.columns.cart.items);
|
||||||
|
}
|
||||||
|
|
||||||
handleCrateModeChange(mode) {
|
handleCrateModeChange(mode) {
|
||||||
this.setState({
|
this.setState({
|
||||||
currentMode: mode,
|
currentMode: mode,
|
||||||
|
@ -2091,7 +2099,7 @@ class Shop extends React.PureComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
checkAlerts(prevItems, newItems) {
|
checkAlerts(newItems) {
|
||||||
console.log('--- START CHECKING CRATE WARNING ---');
|
console.log('--- START CHECKING CRATE WARNING ---');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -2481,7 +2489,8 @@ class Shop extends React.PureComponent {
|
||||||
onToggleProgress={this.handleToggleItemProgress}
|
onToggleProgress={this.handleToggleItemProgress}
|
||||||
onToggleWarning={this.handleToggleItemWarning}
|
onToggleWarning={this.handleToggleItemWarning}
|
||||||
onToggleOverlayRemove={this.handleToggleOverlayRemove}
|
onToggleOverlayRemove={this.handleToggleOverlayRemove}
|
||||||
onClickRemoveItem={this.handleDeleteItem}>
|
onClickRemoveItem={this.handleDeleteItem}
|
||||||
|
onCardUpdate={this.handleCardsUpdated}>
|
||||||
</Cart>
|
</Cart>
|
||||||
}
|
}
|
||||||
rules={Object.values(rules).filter(rule => rule)}>
|
rules={Object.values(rules).filter(rule => rule)}>
|
||||||
|
|
Loading…
Reference in New Issue