diff --git a/static/js/shop.jsx b/static/js/shop.jsx index af0cdd0..1de9cf9 100644 --- a/static/js/shop.jsx +++ b/static/js/shop.jsx @@ -145,6 +145,7 @@ class Layout extends React.PureComponent { RFQBodyType: PropTypes.string, RFQBodyOrder: PropTypes.string, onClickLoadCustomConf: PropTypes.func, + items: PropTypes.object, }; } @@ -165,6 +166,12 @@ class Layout extends React.PureComponent { this.handleCustomConfig = this.handleCustomConfig.bind(this); this.handleClickLoad = this.handleClickLoad.bind(this); this.checkValidation = this.checkValidation.bind(this); + + // retrieve list of available pn + const items_keys = Object.keys(props.items); + this.list_pn = items_keys.map(function (key) { + return props.items[key].name_number; + }); } handleCustomConfig(e) { @@ -249,6 +256,22 @@ class Layout extends React.PureComponent { }; }); + const self = this; + const unknow_pn = conf_obj.items.filter(function (item_pn) { + return self.list_pn.includes(item_pn.pn) === false; + }).map(function (item_pn) { + return item_pn.pn; + }); + + if (unknow_pn.length > 0) { + return this.setState({ + ...this.state, + customconf: conf, + customconf_ready: null, + error: `${unknow_pn.join(', ')} unknown${unknow_pn.length > 1 ? 's':''} pn number`, + }); + } + this.setState({ ...this.state, customconf: conf, @@ -2293,6 +2316,7 @@ class Shop extends React.PureComponent { onClickToggleMobileSideMenu={this.handleClickToggleMobileSideMenu} onClickCloseRFQFeedback={this.handleClickCloseRFQFeedback} onClickLoadCustomConf={this.handleLoadCustomConf} + items={items} aside={