2020-01-23 18:39:56 +08:00
'use strict' ;
2023-06-29 11:49:24 +08:00
function _typeof ( obj ) { "@babel/helpers - typeof" ; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol . iterator ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && "function" == typeof Symbol && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } , _typeof ( obj ) ; }
function _extends ( ) { _extends = Object . assign ? Object . assign . bind ( ) : function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ; return _extends . apply ( this , arguments ) ; }
2020-01-23 18:39:56 +08:00
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
2023-06-29 11:49:24 +08:00
function _defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , _toPropertyKey ( descriptor . key ) , descriptor ) ; } }
function _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) _defineProperties ( Constructor , staticProps ) ; Object . defineProperty ( Constructor , "prototype" , { writable : false } ) ; return Constructor ; }
function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function" ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , writable : true , configurable : true } } ) ; Object . defineProperty ( subClass , "prototype" , { writable : false } ) ; if ( superClass ) _setPrototypeOf ( subClass , superClass ) ; }
function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf ? Object . setPrototypeOf . bind ( ) : function _setPrototypeOf ( o , p ) { o . _ _proto _ _ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
function _createSuper ( Derived ) { var hasNativeReflectConstruct = _isNativeReflectConstruct ( ) ; return function _createSuperInternal ( ) { var Super = _getPrototypeOf ( Derived ) , result ; if ( hasNativeReflectConstruct ) { var NewTarget = _getPrototypeOf ( this ) . constructor ; result = Reflect . construct ( Super , arguments , NewTarget ) ; } else { result = Super . apply ( this , arguments ) ; } return _possibleConstructorReturn ( this , result ) ; } ; }
function _possibleConstructorReturn ( self , call ) { if ( call && ( _typeof ( call ) === "object" || typeof call === "function" ) ) { return call ; } else if ( call !== void 0 ) { throw new TypeError ( "Derived constructors may only return object or undefined" ) ; } return _assertThisInitialized ( self ) ; }
2020-04-15 21:17:48 +08:00
function _assertThisInitialized ( self ) { if ( self === void 0 ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return self ; }
2023-06-29 11:49:24 +08:00
function _isNativeReflectConstruct ( ) { if ( typeof Reflect === "undefined" || ! Reflect . construct ) return false ; if ( Reflect . construct . sham ) return false ; if ( typeof Proxy === "function" ) return true ; try { Boolean . prototype . valueOf . call ( Reflect . construct ( Boolean , [ ] , function ( ) { } ) ) ; return true ; } catch ( e ) { return false ; } }
function _getPrototypeOf ( o ) { _getPrototypeOf = Object . setPrototypeOf ? Object . getPrototypeOf . bind ( ) : function _getPrototypeOf ( o ) { return o . _ _proto _ _ || Object . getPrototypeOf ( o ) ; } ; return _getPrototypeOf ( o ) ; }
2020-04-15 21:17:48 +08:00
function _slicedToArray ( arr , i ) { return _arrayWithHoles ( arr ) || _iterableToArrayLimit ( arr , i ) || _unsupportedIterableToArray ( arr , i ) || _nonIterableRest ( ) ; }
function _nonIterableRest ( ) { throw new TypeError ( "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ; }
2023-06-29 11:49:24 +08:00
function _unsupportedIterableToArray ( o , minLen ) { if ( ! o ) return ; if ( typeof o === "string" ) return _arrayLikeToArray ( o , minLen ) ; var n = Object . prototype . toString . call ( o ) . slice ( 8 , - 1 ) ; if ( n === "Object" && o . constructor ) n = o . constructor . name ; if ( n === "Map" || n === "Set" ) return Array . from ( o ) ; if ( n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/ . test ( n ) ) return _arrayLikeToArray ( o , minLen ) ; }
2020-04-15 21:17:48 +08:00
function _arrayLikeToArray ( arr , len ) { if ( len == null || len > arr . length ) len = arr . length ; for ( var i = 0 , arr2 = new Array ( len ) ; i < len ; i ++ ) { arr2 [ i ] = arr [ i ] ; } return arr2 ; }
2023-06-29 11:49:24 +08:00
function _iterableToArrayLimit ( arr , i ) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr [ Symbol . iterator ] || arr [ "@@iterator" ] ; if ( null != _i ) { var _s , _e , _x , _r , _arr = [ ] , _n = ! 0 , _d = ! 1 ; try { if ( _x = ( _i = _i . call ( arr ) ) . next , 0 === i ) { if ( Object ( _i ) !== _i ) return ; _n = ! 1 ; } else for ( ; ! ( _n = ( _s = _x . call ( _i ) ) . done ) && ( _arr . push ( _s . value ) , _arr . length !== i ) ; _n = ! 0 ) { ; } } catch ( err ) { _d = ! 0 , _e = err ; } finally { try { if ( ! _n && null != _i [ "return" ] && ( _r = _i [ "return" ] ( ) , Object ( _r ) !== _r ) ) return ; } finally { if ( _d ) throw _e ; } } return _arr ; } }
2020-01-23 18:39:56 +08:00
function _arrayWithHoles ( arr ) { if ( Array . isArray ( arr ) ) return arr ; }
2023-06-29 11:49:24 +08:00
function ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; enumerableOnly && ( symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ) , keys . push . apply ( keys , symbols ) ; } return keys ; }
function _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = null != arguments [ i ] ? arguments [ i ] : { } ; i % 2 ? ownKeys ( Object ( source ) , ! 0 ) . forEach ( function ( key ) { _defineProperty ( target , key , source [ key ] ) ; } ) : Object . getOwnPropertyDescriptors ? Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) : ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } return target ; }
function _defineProperty ( obj , key , value ) { key = _toPropertyKey ( key ) ; if ( key in obj ) { Object . defineProperty ( obj , key , { value : value , enumerable : true , configurable : true , writable : true } ) ; } else { obj [ key ] = value ; } return obj ; }
function _toPropertyKey ( arg ) { var key = _toPrimitive ( arg , "string" ) ; return _typeof ( key ) === "symbol" ? key : String ( key ) ; }
function _toPrimitive ( input , hint ) { if ( _typeof ( input ) !== "object" || input === null ) return input ; var prim = input [ Symbol . toPrimitive ] ; if ( prim !== undefined ) { var res = prim . call ( input , hint || "default" ) ; if ( _typeof ( res ) !== "object" ) return res ; throw new TypeError ( "@@toPrimitive must return a primitive value." ) ; } return ( hint === "string" ? String : Number ) ( input ) ; }
2020-01-23 18:39:56 +08:00
var _window$ReactBeautifu = window . ReactBeautifulDnd ,
2023-06-29 11:49:24 +08:00
DragDropContext = _window$ReactBeautifu . DragDropContext ,
Draggable = _window$ReactBeautifu . Draggable ,
Droppable = _window$ReactBeautifu . Droppable ;
2020-01-23 18:39:56 +08:00
var data = window . shop _data ;
2020-04-14 17:54:59 +08:00
var axios = window . axios ;
2020-01-23 18:39:56 +08:00
var productStyle = function productStyle ( style , snapshot , removeAnim , hovered , selected ) {
var custom = {
opacity : snapshot . isDragging ? . 7 : 1 ,
backgroundColor : hovered || selected ? '#eae7f7' : 'initial'
} ;
if ( ! snapshot . isDropAnimating ) {
return _objectSpread ( { } , style , { } , custom ) ;
}
if ( removeAnim ) {
// cannot be 0, but make it super tiny
custom . transitionDuration = '0.001s' ;
}
return _objectSpread ( { } , style , { } , custom ) ;
} ;
var cartStyle = function cartStyle ( style , snapshot ) {
var isDraggingOver = snapshot . isDraggingOver ;
return _objectSpread ( { } , style , { } , {
backgroundColor : isDraggingOver ? '#f2f2f2' : '#f9f9f9' ,
border : isDraggingOver ? '1px dashed #ccc' : '0'
} ) ;
} ;
var nbrConnectorsStyle = function nbrConnectorsStyle ( data ) {
if ( ! data || ! data . nbrCurrentSlot ) {
return { } ;
}
var p = data . nbrCurrentSlot * 100 / data . nbrSlotMax ;
if ( p > 100 ) {
p = 100 ;
}
return {
width : "" . concat ( p , "%" )
} ;
} ;
var nbrClocksStyle = function nbrClocksStyle ( data ) {
if ( ! data || ! data . nbrCurrentClock ) {
return { } ;
}
var p = data . nbrCurrentClock * 100 / data . nbrClockMax ;
if ( p > 100 ) {
p = 100 ;
}
return {
width : "" . concat ( p , "%" )
} ;
} ;
2023-06-29 11:49:24 +08:00
var copy = function copy ( model , source , destination , draggableSource , droppableDestination ) {
2020-01-23 18:39:56 +08:00
var destClone = Array . from ( destination . items ) ;
2023-06-29 11:49:24 +08:00
destClone . splice ( droppableDestination . index , 0 , _objectSpread ( { } , model [ draggableSource ] , {
2020-01-23 18:39:56 +08:00
id : uuidv4 ( )
} ) ) ;
return destClone ;
} ;
var reorder = function reorder ( list , startIndex , endIndex ) {
var result = Array . from ( list ) ;
var _result$splice = result . splice ( startIndex , 1 ) ,
2023-06-29 11:49:24 +08:00
_result$splice2 = _slicedToArray ( _result$splice , 1 ) ,
removed = _result$splice2 [ 0 ] ;
2020-01-23 18:39:56 +08:00
result . splice ( endIndex , 0 , removed ) ;
return result ;
} ;
var remove = function remove ( list , startIndex ) {
var result = Array . from ( list ) ;
result . splice ( startIndex , 1 ) ;
return result ;
} ;
var nbrOccupiedSlotsInCrate = function nbrOccupiedSlotsInCrate ( items ) {
return items . reduce ( function ( prev , next ) {
return prev + ( next . hp === 8 ? 2 : 1 ) ;
} , 0 ) ;
} ;
function formatMoney ( amount ) {
var decimalCount = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 2 ;
var decimal = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : "." ;
var thousands = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : "," ;
// https://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-currency-string-in-javascript
// changes: return amount if error in order to avoid empty value
try {
decimalCount = Math . abs ( decimalCount ) ;
decimalCount = isNaN ( decimalCount ) ? 2 : decimalCount ;
var negativeSign = amount < 0 ? "-" : "" ;
var i = parseInt ( amount = Math . abs ( Number ( amount ) || 0 ) . toFixed ( decimalCount ) ) . toString ( ) ;
var j = i . length > 3 ? i . length % 3 : 0 ;
return negativeSign + ( j ? i . substr ( 0 , j ) + thousands : '' ) + i . substr ( j ) . replace ( /(\d{3})(?=\d)/g , "$1" + thousands ) + ( decimalCount ? decimal + Math . abs ( amount - i ) . toFixed ( decimalCount ) . slice ( 2 ) : "" ) ;
} catch ( e ) {
return amount ;
}
}
;
2023-06-29 11:49:24 +08:00
2020-01-23 18:39:56 +08:00
/ * *
2019-11-13 10:47:39 +08:00
* Component that provides a base layout ( aside / main ) for the page .
2020-01-23 18:39:56 +08:00
* /
2020-04-15 21:17:48 +08:00
var Layout = /*#__PURE__*/ function ( _React$PureComponent ) {
2020-01-23 18:39:56 +08:00
_inherits ( Layout , _React$PureComponent ) ;
2020-04-15 21:17:48 +08:00
var _super = _createSuper ( Layout ) ;
2020-04-14 17:54:59 +08:00
_createClass ( Layout , null , [ {
key : "propTypes" ,
get : function get ( ) {
return {
aside : PropTypes . any ,
main : PropTypes . any ,
mobileSideMenuShouldOpen : PropTypes . bool ,
isMobile : PropTypes . bool ,
newCardJustAdded : PropTypes . bool ,
onClickToggleMobileSideMenu : PropTypes . func ,
onClickCloseRFQFeedback : PropTypes . func ,
RFQBodyType : PropTypes . string ,
RFQBodyOrder : PropTypes . string ,
2020-04-20 22:53:32 +08:00
onClickLoadCustomConf : PropTypes . func ,
items : PropTypes . object
2020-04-14 17:54:59 +08:00
} ;
}
} , {
key : "defaultProps" ,
get : function get ( ) {
return {
mobileSideMenuShouldOpen : false
} ;
}
} ] ) ;
function Layout ( props ) {
var _this ;
2020-01-23 18:39:56 +08:00
_classCallCheck ( this , Layout ) ;
2020-04-15 21:17:48 +08:00
_this = _super . call ( this , props ) ;
2020-04-14 17:54:59 +08:00
_this . state = {
customconf : '' ,
error : null
} ;
_this . handleCustomConfig = _this . handleCustomConfig . bind ( _assertThisInitialized ( _this ) ) ;
_this . handleClickLoad = _this . handleClickLoad . bind ( _assertThisInitialized ( _this ) ) ;
2023-06-29 11:49:24 +08:00
_this . checkValidation = _this . checkValidation . bind ( _assertThisInitialized ( _this ) ) ;
2020-04-20 22:53:32 +08:00
2023-06-29 11:49:24 +08:00
// retrieve list of available pn
2020-04-20 22:53:32 +08:00
var items _keys = Object . keys ( props . items ) ;
_this . list _pn = items _keys . map ( function ( key ) {
return props . items [ key ] . name _number ;
} ) ;
2020-04-14 17:54:59 +08:00
return _this ;
2020-01-23 18:39:56 +08:00
}
_createClass ( Layout , [ {
2020-04-14 17:54:59 +08:00
key : "handleCustomConfig" ,
value : function handleCustomConfig ( e ) {
var value = e . target . value ;
this . checkValidation ( value ) ;
}
} , {
key : "checkValidation" ,
value : function checkValidation ( conf ) {
var conf _obj ;
try {
conf _obj = JSON . parse ( conf ) ;
} catch ( e ) {
return this . setState ( _objectSpread ( { } , this . state , {
customconf : conf ,
customconf _ready : null ,
error : 'invalid format'
} ) ) ;
}
if ( ! conf _obj ) {
return this . setState ( _objectSpread ( { } , this . state , {
customconf : conf ,
customconf _ready : null ,
error : 'invalid format'
} ) ) ;
}
if ( ( ! conf _obj . items || ! conf _obj . type ) && ( Object . prototype . toString . call ( conf _obj . items ) !== '[object Array]' || Object . prototype . toString . call ( conf _obj . type ) !== '[object String]' ) ) {
return this . setState ( _objectSpread ( { } , this . state , {
customconf : conf ,
customconf _ready : null ,
error : 'invalid format'
} ) ) ;
}
if ( conf _obj . type !== "desktop" && conf _obj . type !== "rack" ) {
return this . setState ( _objectSpread ( { } , this . state , {
customconf : conf ,
customconf _ready : null ,
error : 'invalid format'
} ) ) ;
}
conf _obj . items . map ( function ( item ) {
try {
return JSON . parse ( item ) ;
} catch ( e ) {
return null ;
}
} ) ;
conf _obj . items = conf _obj . items . filter ( function ( item ) {
return item ;
} ) ;
if ( conf _obj . items . filter ( function ( item ) {
return Object . prototype . toString . call ( item ) !== '[object Object]' || ! item . pn || Object . prototype . toString . call ( item . pn ) !== '[object String]' ;
} ) . length > 0 ) {
return this . setState ( _objectSpread ( { } , this . state , {
customconf : conf ,
customconf _ready : null ,
error : 'invalid format'
} ) ) ;
}
conf _obj . items = conf _obj . items . map ( function ( item ) {
return {
pn : item . pn
} ;
} ) ;
2020-04-20 22:53:32 +08:00
var self = this ;
var 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 ( _objectSpread ( { } , this . state , {
customconf : conf ,
customconf _ready : null ,
error : "" . concat ( unknow _pn . join ( ', ' ) , " unknown" ) . concat ( unknow _pn . length > 1 ? 's' : '' , " pn number" )
} ) ) ;
}
2020-04-14 17:54:59 +08:00
this . setState ( _objectSpread ( { } , this . state , {
customconf : conf ,
error : null ,
customconf _ready : conf _obj
} ) ) ;
}
} , {
key : "handleClickLoad" ,
value : function handleClickLoad ( ) {
2021-06-01 11:42:46 +08:00
this . checkValidation ( this . state . customconf ) ;
2020-04-14 17:54:59 +08:00
if ( this . props . onClickLoadCustomConf ) {
this . props . onClickLoadCustomConf ( this . state . customconf _ready ) ;
}
}
} , {
2020-01-23 18:39:56 +08:00
key : "render" ,
value : function render ( ) {
var _this$props = this . props ,
2023-06-29 11:49:24 +08:00
aside = _this$props . aside ,
main = _this$props . main ,
mobileSideMenuShouldOpen = _this$props . mobileSideMenuShouldOpen ,
isMobile = _this$props . isMobile ,
newCardJustAdded = _this$props . newCardJustAdded ,
onClickToggleMobileSideMenu = _this$props . onClickToggleMobileSideMenu ,
onClickCloseRFQFeedback = _this$props . onClickCloseRFQFeedback ,
showRFQFeedback = _this$props . showRFQFeedback ,
RFQBodyType = _this$props . RFQBodyType ,
RFQBodyOrder = _this$props . RFQBodyOrder ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "layout"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "aside" , {
2020-01-23 18:39:56 +08:00
className : 'aside ' + ( mobileSideMenuShouldOpen ? 'menu-opened' : '' )
2020-04-15 21:17:48 +08:00
} , aside ) , mobileSideMenuShouldOpen ? /*#__PURE__*/ React . createElement ( "section" , {
2020-01-23 18:39:56 +08:00
className : "main" ,
onClick : onClickToggleMobileSideMenu
2020-04-15 21:17:48 +08:00
} , main ) : /*#__PURE__*/ React . createElement ( "section" , {
2020-01-23 18:39:56 +08:00
className : "main"
2020-04-15 21:17:48 +08:00
} , main ) , isMobile && newCardJustAdded ? /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "feedback-add-success"
2020-04-15 21:17:48 +08:00
} , "\u2713 added" ) : null , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
"class" : "modal fade " . concat ( showRFQFeedback ? 'show' : '' ) ,
style : {
'display' : showRFQFeedback ? 'block' : 'none'
} ,
id : "exampleModal" ,
tabindex : "-1" ,
role : "dialog" ,
"aria-labelledby" : "exampleModalLabel" ,
"aria-hidden" : "true"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
"class" : "modal-dialog" ,
role : "document"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
"class" : "modal-content"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
"class" : "modal-body rfqFeedback"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "d-flex w-100"
2020-04-15 21:17:48 +08:00
} , RFQBodyType === 'email' ? /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "d-flex"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , null , /*#__PURE__*/ React . createElement ( "img" , {
2020-04-14 17:54:59 +08:00
width : "30px" ,
src : "/images/shop/icon-done.svg" ,
alt : "close"
2020-04-15 21:17:48 +08:00
} ) ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
style : {
'padding' : '0 .5em'
}
2020-04-15 21:17:48 +08:00
} , "We've received your request and will be in contact soon." ) ) : null , RFQBodyType === 'show' ? /*#__PURE__*/ React . createElement ( "p" , null , RFQBodyOrder ) : null , RFQBodyType === 'import' ? /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "w-100"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "form" , {
2020-04-14 17:54:59 +08:00
className : "form w-100"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "form-group"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "p" , {
2020-04-14 17:54:59 +08:00
className : "small"
2020-04-16 10:33:49 +08:00
} , "Input the JSON description below. Should be something like:" , /*#__PURE__*/ React . createElement ( "br" , null ) , JSON . stringify ( {
2020-04-14 17:54:59 +08:00
"items" : [ {
2021-03-23 00:40:59 +08:00
"pn" : "1124"
2020-04-14 17:54:59 +08:00
} , {
"pn" : "2118"
} , {
"pn" : "2118"
} , {
"pn" : "2128"
} ] ,
"type" : "desktop"
2020-04-15 21:17:48 +08:00
} ) ) ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "form-group w-100"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "textarea" , {
2020-04-14 17:54:59 +08:00
onChange : this . handleCustomConfig ,
value : this . state . customconf ,
className : "form-control w-100" ,
rows : "5" ,
2020-04-16 10:33:49 +08:00
placeholder : "Input JSON description here."
2020-04-15 21:17:48 +08:00
} ) ) , this . state . error ? /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "form-group"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "p" , {
2020-04-14 17:54:59 +08:00
className : "text-danger"
2020-04-15 21:17:48 +08:00
} , this . state . error ) ) : null ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "d-flex flex-column flex-sm-row justify-content-end"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "a" , {
2020-04-14 17:54:59 +08:00
type : "button" ,
onClick : onClickCloseRFQFeedback ,
"class" : "btn btn-sm btn-outline-primary m-0 mb-2 mb-sm-0 mr-sm-2"
2020-04-15 21:17:48 +08:00
} , "Close" ) , /*#__PURE__*/ React . createElement ( "a" , {
2020-04-14 17:54:59 +08:00
type : "button" ,
onClick : this . handleClickLoad ,
"class" : "btn btn-sm btn-primary m-0 ml-sm-2 " . concat ( this . state . error ? 'disabled' : '' )
2020-04-15 21:17:48 +08:00
} , "Load configuration" ) ) ) : null , /*#__PURE__*/ React . createElement ( "div" , null , /*#__PURE__*/ React . createElement ( "button" , {
2020-04-14 17:54:59 +08:00
onClick : onClickCloseRFQFeedback
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-04-14 17:54:59 +08:00
src : "/images/shop/icon-close.svg" ,
alt : "close"
2020-04-15 21:17:48 +08:00
} ) ) ) ) ) ) ) ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
onClick : onClickCloseRFQFeedback ,
className : "modal-backdrop fade " . concat ( showRFQFeedback ? 'show' : '' ) ,
style : {
'display' : showRFQFeedback ? 'initial' : 'none'
}
} ) ) ;
2020-01-23 18:39:56 +08:00
}
} ] ) ;
return Layout ;
} ( React . PureComponent ) ;
/ * *
2019-11-13 10:47:39 +08:00
* Component that renders a product .
* Used in the aside ( e . g backlog of product )
2020-01-23 18:39:56 +08:00
* /
2020-04-15 21:17:48 +08:00
var ProductItem = /*#__PURE__*/ function ( _React$PureComponent2 ) {
2020-01-23 18:39:56 +08:00
_inherits ( ProductItem , _React$PureComponent2 ) ;
2020-04-15 21:17:48 +08:00
var _super2 = _createSuper ( ProductItem ) ;
2020-01-23 18:39:56 +08:00
_createClass ( ProductItem , null , [ {
key : "propTypes" ,
get : function get ( ) {
return {
id : PropTypes . string . isRequired ,
name : PropTypes . string . isRequired ,
2020-03-10 16:41:54 +08:00
name _codename : PropTypes . string ,
2020-01-23 18:39:56 +08:00
price : PropTypes . number . isRequired ,
currency : PropTypes . string . isRequired ,
image : PropTypes . string . isRequired ,
specs : PropTypes . array ,
2022-01-19 14:27:09 +08:00
datasheet _file : PropTypes . string ,
datasheet _name : PropTypes . string ,
2020-01-23 18:39:56 +08:00
onClickAddItem : PropTypes . func
} ;
}
} ] ) ;
function ProductItem ( props ) {
2020-04-14 17:54:59 +08:00
var _this2 ;
2020-01-23 18:39:56 +08:00
_classCallCheck ( this , ProductItem ) ;
2020-04-15 21:17:48 +08:00
_this2 = _super2 . call ( this , props ) ;
2020-04-14 17:54:59 +08:00
_this2 . handleOnClickAddItem = _this2 . handleOnClickAddItem . bind ( _assertThisInitialized ( _this2 ) ) ;
return _this2 ;
2020-01-23 18:39:56 +08:00
}
_createClass ( ProductItem , [ {
key : "handleOnClickAddItem" ,
2023-06-29 11:49:24 +08:00
value : function handleOnClickAddItem ( id , tap , e ) {
2020-01-23 18:39:56 +08:00
if ( this . props . onClickAddItem ) {
2023-06-29 11:49:24 +08:00
this . props . onClickAddItem ( id , tap ) ;
2020-01-23 18:39:56 +08:00
}
e . preventDefault ( ) ;
}
} , {
key : "render" ,
value : function render ( ) {
var _this$props2 = this . props ,
2023-06-29 11:49:24 +08:00
id = _this$props2 . id ,
name = _this$props2 . name ,
name _codename = _this$props2 . name _codename ,
price = _this$props2 . price ,
currency = _this$props2 . currency ,
image = _this$props2 . image ,
specs = _this$props2 . specs ,
datasheet _file = _this$props2 . datasheet _file ,
datasheet _name = _this$props2 . datasheet _name ;
2020-04-15 21:17:48 +08:00
var render _specs = specs && specs . length > 0 && /*#__PURE__*/ React . createElement ( "ul" , null , specs . map ( function ( spec , index ) {
return /*#__PURE__*/ React . createElement ( "li" , {
2020-01-23 18:39:56 +08:00
key : index
} , spec ) ;
} ) ) ;
2022-01-19 14:27:09 +08:00
var render _datasheet _link = datasheet _file && datasheet _name && /*#__PURE__*/ React . createElement ( "div" , {
className : "ds"
} , /*#__PURE__*/ React . createElement ( "span" , {
"class" : "doc-icon"
} ) , /*#__PURE__*/ React . createElement ( "a" , {
href : datasheet _file ,
target : "_blank" ,
rel : "noopener noreferrer"
} , datasheet _name ) ) ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "section" , {
2020-01-23 18:39:56 +08:00
className : "productItem"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "content"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "h3" , {
2020-03-10 16:41:54 +08:00
style : {
'margin-bottom' : name _codename ? '5px' : '20px'
}
2020-04-15 21:17:48 +08:00
} , name ) , name _codename ? /*#__PURE__*/ React . createElement ( "p" , null , name _codename ) : null , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "price"
2022-01-19 14:27:09 +08:00
} , "" . concat ( currency , " " ) . concat ( formatMoney ( price ) ) ) , render _specs , render _datasheet _link ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "content"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "button" , {
2023-06-29 11:49:24 +08:00
onClick : this . handleOnClickAddItem . bind ( this , id , true )
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
src : "/images/shop/icon-add.svg" ,
alt : "add"
2020-04-15 21:17:48 +08:00
} ) ) , /*#__PURE__*/ React . createElement ( Draggable , {
2023-06-29 11:49:24 +08:00
draggableId : id
2020-01-23 18:39:56 +08:00
} , function ( provided , snapshot ) {
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( React . Fragment , null , /*#__PURE__*/ React . createElement ( "img" , _extends ( {
2020-01-23 18:39:56 +08:00
ref : provided . innerRef
} , provided . draggableProps , provided . dragHandleProps , {
style : productStyle ( provided . draggableProps . style , snapshot , true // hack: remove weird animation after a drop
) ,
2023-06-29 11:49:24 +08:00
2020-01-23 18:39:56 +08:00
src : image
2020-04-15 21:17:48 +08:00
} ) ) , snapshot . isDragging && /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
className : "simclone" ,
src : image
} ) ) ;
} ) ) ) ;
}
} ] ) ;
return ProductItem ;
} ( React . PureComponent ) ;
/ * *
* Component that renders a product .
* Used in the crate
* /
2020-04-15 21:17:48 +08:00
var ProductCartItem = /*#__PURE__*/ function ( _React$PureComponent3 ) {
2020-01-23 18:39:56 +08:00
_inherits ( ProductCartItem , _React$PureComponent3 ) ;
2020-04-15 21:17:48 +08:00
var _super3 = _createSuper ( ProductCartItem ) ;
2020-01-23 18:39:56 +08:00
_createClass ( ProductCartItem , null , [ {
key : "propTypes" ,
get : function get ( ) {
return {
isMobile : PropTypes . bool ,
hovered : PropTypes . bool ,
index : PropTypes . number . isRequired ,
model : PropTypes . object . isRequired ,
data : PropTypes . object ,
onToggleProgress : PropTypes . func ,
onToggleWarning : PropTypes . func ,
onToggleOverlayRemove : PropTypes . func ,
2020-04-20 22:53:32 +08:00
onClickRemoveItem : PropTypes . func ,
shouldTooltipWarningClassInverted : PropTypes . bool
2020-01-23 18:39:56 +08:00
} ;
}
} , {
key : "defaultProps" ,
get : function get ( ) {
return {
hovered : false
} ;
}
} ] ) ;
function ProductCartItem ( props ) {
2020-04-14 17:54:59 +08:00
var _this3 ;
2020-01-23 18:39:56 +08:00
_classCallCheck ( this , ProductCartItem ) ;
2020-04-15 21:17:48 +08:00
_this3 = _super3 . call ( this , props ) ;
2020-04-14 17:54:59 +08:00
_this3 . handleOnMouseEnterItem = _this3 . handleOnMouseEnterItem . bind ( _assertThisInitialized ( _this3 ) ) ;
_this3 . handleOnMouseLeaveItem = _this3 . handleOnMouseLeaveItem . bind ( _assertThisInitialized ( _this3 ) ) ;
_this3 . handleOnMouseEnterWarningItem = _this3 . handleOnMouseEnterWarningItem . bind ( _assertThisInitialized ( _this3 ) ) ;
_this3 . handleOnMouseLeaveWarningItem = _this3 . handleOnMouseLeaveWarningItem . bind ( _assertThisInitialized ( _this3 ) ) ;
_this3 . handleOnMouseEnterRemoveItem = _this3 . handleOnMouseEnterRemoveItem . bind ( _assertThisInitialized ( _this3 ) ) ;
_this3 . handleOnMouseLeaveRemoveItem = _this3 . handleOnMouseLeaveRemoveItem . bind ( _assertThisInitialized ( _this3 ) ) ;
_this3 . handleOnClickRemoveItem = _this3 . handleOnClickRemoveItem . bind ( _assertThisInitialized ( _this3 ) ) ;
return _this3 ;
2020-01-23 18:39:56 +08:00
}
_createClass ( ProductCartItem , [ {
key : "handleOnMouseEnterItem" ,
value : function handleOnMouseEnterItem ( index , e ) {
if ( this . props . onToggleProgress ) {
this . props . onToggleProgress ( index , true ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnMouseLeaveItem" ,
value : function handleOnMouseLeaveItem ( index , e ) {
if ( this . props . onToggleProgress ) {
this . props . onToggleProgress ( index , false ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnMouseEnterWarningItem" ,
value : function handleOnMouseEnterWarningItem ( index , isWarning , e ) {
if ( ! isWarning ) {
return ;
}
if ( this . props . onToggleWarning ) {
this . props . onToggleWarning ( index , true ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnMouseLeaveWarningItem" ,
value : function handleOnMouseLeaveWarningItem ( index , isWarning , e ) {
if ( ! isWarning ) {
return ;
}
if ( this . props . onToggleWarning ) {
this . props . onToggleWarning ( index , false ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnMouseEnterRemoveItem" ,
value : function handleOnMouseEnterRemoveItem ( index , e ) {
if ( this . props . onToggleOverlayRemove && ! this . props . isMobile ) {
this . props . onToggleOverlayRemove ( index , true ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnMouseLeaveRemoveItem" ,
value : function handleOnMouseLeaveRemoveItem ( index , e ) {
if ( this . props . onToggleOverlayRemove && ! this . props . isMobile ) {
this . props . onToggleOverlayRemove ( index , false ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnClickRemoveItem" ,
value : function handleOnClickRemoveItem ( index , e ) {
if ( this . props . onClickRemoveItem ) {
this . props . onClickRemoveItem ( index ) ;
}
}
} , {
key : "render" ,
value : function render ( ) {
2020-04-14 17:54:59 +08:00
var _this4 = this ;
2020-01-23 18:39:56 +08:00
var _this$props3 = this . props ,
2023-06-29 11:49:24 +08:00
hovered = _this$props3 . hovered ,
model = _this$props3 . model ,
data = _this$props3 . data ,
index = _this$props3 . index ,
shouldTooltipWarningClassInverted = _this$props3 . shouldTooltipWarningClassInverted ;
2020-01-23 18:39:56 +08:00
var warning ;
if ( data && data . warnings ) {
var warningsKeys = Object . keys ( data . warnings ) ;
if ( warningsKeys && warningsKeys . length > 0 ) {
// we display only the first warning
warning = data . warnings [ warningsKeys [ 0 ] ] ;
}
}
var render _progress ;
if ( model . showProgress && data ) {
switch ( model . type ) {
case 'kasli' :
2020-04-15 21:17:48 +08:00
render _progress = /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "k-popup-connectors"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "p" , null , "" . concat ( data . nbrCurrentSlot , "/" ) . concat ( model . nbrSlotMax , " EEM connectors used" ) ) , /*#__PURE__*/ React . createElement ( "p" , null , "" . concat ( data . nbrCurrentClock , "/" ) . concat ( model . nbrClockMax , " Clock connectors used" ) ) ) ;
2020-01-23 18:39:56 +08:00
break ;
2021-03-23 00:40:59 +08:00
case 'vhdcicarrier' :
render _progress = /*#__PURE__*/ React . createElement ( "div" , {
className : "k-popup-connectors"
} , /*#__PURE__*/ React . createElement ( "p" , null , "" . concat ( data . nbrCurrentSlot , "/" ) . concat ( model . nbrSlotMax , " EEM connectors used" ) ) ) ;
break ;
2020-01-23 18:39:56 +08:00
case 'zotino' :
case 'hd68' :
2020-04-15 21:17:48 +08:00
render _progress = /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "k-popup-connectors"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "p" , null , "" . concat ( data . nbrCurrentSlot , "/" ) . concat ( model . nbrSlotMax , " connectors used" ) ) ) ;
2020-01-23 18:39:56 +08:00
break ;
case 'clocker' :
2020-04-15 21:17:48 +08:00
render _progress = /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "k-popup-connectors"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "p" , null , "" . concat ( data . nbrCurrentClock , "/" ) . concat ( model . nbrClockMax , " Clock connectors used" ) ) ) ;
2020-01-23 18:39:56 +08:00
break ;
default :
break ;
}
}
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( Draggable , {
2020-01-23 18:39:56 +08:00
draggableId : model . id ,
index : index
} , function ( provided , snapshot ) {
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "div" , _extends ( {
2020-01-23 18:39:56 +08:00
ref : provided . innerRef
} , provided . draggableProps , provided . dragHandleProps , {
style : _objectSpread ( { } , productStyle ( provided . draggableProps . style , snapshot , true , hovered ? true : false , model . selected ? true : false ) ) ,
2020-04-14 17:54:59 +08:00
onMouseEnter : _this4 . handleOnMouseEnterRemoveItem . bind ( _this4 , index ) ,
onMouseLeave : _this4 . handleOnMouseLeaveRemoveItem . bind ( _this4 , index )
2020-04-15 21:17:48 +08:00
} ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
style : {
'height' : '24px'
} ,
className : "progress-container warning" ,
2020-04-14 17:54:59 +08:00
onMouseEnter : _this4 . handleOnMouseEnterWarningItem . bind ( _this4 , index , warning ) ,
onMouseLeave : _this4 . handleOnMouseLeaveWarningItem . bind ( _this4 , index , warning )
2020-04-15 21:17:48 +08:00
} , warning && /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
className : "alert-warning" ,
src : warning ? "/images" . concat ( warning . icon ) : null
2020-04-21 10:22:24 +08:00
} ) , warning && model . showWarning && /*#__PURE__*/ React . createElement ( "div" , {
2020-04-20 22:53:32 +08:00
className : "k-popup-warning " . concat ( shouldTooltipWarningClassInverted ? 'inverted' : '' )
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "p" , {
2020-01-23 18:39:56 +08:00
className : "rule warning"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "i" , null , warning . message ) ) ) ) , /*#__PURE__*/ React . createElement ( "h6" , null , model . name _number ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
style : {
2020-03-10 16:41:54 +08:00
'height' : '350px'
2020-01-23 18:39:56 +08:00
} ,
2020-04-14 17:54:59 +08:00
onMouseEnter : _this4 . handleOnMouseEnterRemoveItem . bind ( _this4 , index )
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
className : "item-cart" ,
src : "/images" . concat ( model . image )
2020-04-15 21:17:48 +08:00
} ) ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
style : {
'display' : model . showOverlayRemove ? 'flex' : 'none'
} ,
className : "overlayRemove" ,
2020-04-14 17:54:59 +08:00
onClick : _this4 . handleOnClickRemoveItem . bind ( _this4 , index )
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
src : "/images/shop/icon-remove.svg" ,
alt : "rm"
2020-04-15 21:17:48 +08:00
} ) , /*#__PURE__*/ React . createElement ( "p" , null , "Remove" ) ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
style : {
'height' : '22px'
} ,
className : "progress-container" ,
2020-04-14 17:54:59 +08:00
onMouseEnter : _this4 . handleOnMouseEnterItem . bind ( _this4 , index ) ,
onMouseLeave : _this4 . handleOnMouseLeaveItem . bind ( _this4 , index )
2020-04-15 21:17:48 +08:00
} , model . nbrSlotMax > 0 && /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "nbr-connectors"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
style : _objectSpread ( { } , nbrConnectorsStyle ( data ) )
2020-04-15 21:17:48 +08:00
} ) ) , model . nbrClockMax > 0 && /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "nbr-clocks"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
style : _objectSpread ( { } , nbrClocksStyle ( data ) )
} ) ) , render _progress ) ) ;
} ) ;
}
} ] ) ;
return ProductCartItem ;
} ( React . PureComponent ) ;
/ * *
* Component that displays a placeholder inside crate .
* Allows to display how it remains space for the current crate .
* /
2020-04-15 21:17:48 +08:00
var FakePlaceholder = /*#__PURE__*/ function ( _React$PureComponent4 ) {
2020-01-23 18:39:56 +08:00
_inherits ( FakePlaceholder , _React$PureComponent4 ) ;
2020-04-15 21:17:48 +08:00
var _super4 = _createSuper ( FakePlaceholder ) ;
2020-01-23 18:39:56 +08:00
function FakePlaceholder ( ) {
_classCallCheck ( this , FakePlaceholder ) ;
2020-04-15 21:17:48 +08:00
return _super4 . apply ( this , arguments ) ;
2020-01-23 18:39:56 +08:00
}
_createClass ( FakePlaceholder , [ {
key : "render" ,
value : function render ( ) {
var _this$props4 = this . props ,
2023-06-29 11:49:24 +08:00
isDraggingOver = _this$props4 . isDraggingOver ,
nbrSlots = _this$props4 . nbrSlots ,
items = _this$props4 . items ;
2020-01-23 18:39:56 +08:00
var fakePlaceholder = [ ] ;
var nbrOccupied = nbrOccupiedSlotsInCrate ( items ) ;
for ( var i = nbrSlots - nbrOccupied ; i > 0 ; i -- ) {
2020-04-15 21:17:48 +08:00
fakePlaceholder . push ( /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
key : i ,
style : {
display : isDraggingOver ? 'none' : 'block' ,
border : '1px dashed #ccc' ,
width : '45px' ,
marginBottom : '5px'
}
} ) ) ;
}
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( React . Fragment , null , fakePlaceholder ) ;
2020-01-23 18:39:56 +08:00
}
} ] , [ {
key : "propTypes" ,
get : function get ( ) {
return {
isDraggingOver : PropTypes . bool ,
nbrSlots : PropTypes . number . isRequired ,
items : PropTypes . array . isRequired
} ;
}
} ] ) ;
return FakePlaceholder ;
} ( React . PureComponent ) ;
/ * *
* Component that displays a list of < ProductCartItem >
* /
2020-04-15 21:17:48 +08:00
var Cart = /*#__PURE__*/ function ( _React$PureComponent5 ) {
2020-01-23 18:39:56 +08:00
_inherits ( Cart , _React$PureComponent5 ) ;
2020-04-15 21:17:48 +08:00
var _super5 = _createSuper ( Cart ) ;
2020-01-23 18:39:56 +08:00
function Cart ( ) {
_classCallCheck ( this , Cart ) ;
2020-04-15 21:17:48 +08:00
return _super5 . apply ( this , arguments ) ;
2020-01-23 18:39:56 +08:00
}
_createClass ( Cart , [ {
key : "render" ,
value : function render ( ) {
var _this$props5 = this . props ,
2023-06-29 11:49:24 +08:00
isMobile = _this$props5 . isMobile ,
nbrSlots = _this$props5 . nbrSlots ,
itemHovered = _this$props5 . itemHovered ,
data = _this$props5 . data ,
onToggleProgress = _this$props5 . onToggleProgress ,
onToggleWarning = _this$props5 . onToggleWarning ,
onToggleOverlayRemove = _this$props5 . onToggleOverlayRemove ,
onClickRemoveItem = _this$props5 . onClickRemoveItem ;
2020-04-20 22:53:32 +08:00
var nbrOccupied = nbrOccupiedSlotsInCrate ( data . items ) ;
var shouldTooltipWarningClassInverted = nbrSlots - nbrOccupied < 5 ;
2020-01-23 18:39:56 +08:00
var products = data . items . map ( function ( item , index ) {
var itemData ;
if ( data . itemsData && index in data . itemsData ) {
itemData = data . itemsData [ index ] ;
}
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( ProductCartItem , {
2020-01-23 18:39:56 +08:00
isMobile : isMobile ,
hovered : item . id === itemHovered ,
key : item . id ,
index : index ,
data : itemData ,
2020-04-20 22:53:32 +08:00
shouldTooltipWarningClassInverted : shouldTooltipWarningClassInverted && index > 10 ,
2020-01-23 18:39:56 +08:00
onToggleProgress : onToggleProgress ,
onToggleWarning : onToggleWarning ,
onToggleOverlayRemove : onToggleOverlayRemove ,
onClickRemoveItem : onClickRemoveItem ,
model : item
} ) ;
} ) ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( Droppable , {
2020-01-23 18:39:56 +08:00
droppableId : data . id ,
direction : "horizontal"
} , function ( provided , snapshot ) {
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "div" , _extends ( {
2020-01-23 18:39:56 +08:00
ref : provided . innerRef
} , provided . droppableProps , {
style : cartStyle ( provided . droppableProps . style , snapshot ) ,
className : "items-cart-list"
2020-04-15 21:17:48 +08:00
} ) , products , provided . placeholder && /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
style : {
display : 'none'
}
2020-04-15 21:17:48 +08:00
} , provided . placeholder ) , /*#__PURE__*/ React . createElement ( FakePlaceholder , {
2020-01-23 18:39:56 +08:00
nbrSlots : nbrSlots ,
items : data . items ,
isDraggingOver : snapshot . isDraggingOver
} ) ) ;
} ) ;
}
} ] , [ {
key : "propTypes" ,
get : function get ( ) {
return {
isMobile : PropTypes . bool ,
nbrSlots : PropTypes . number ,
itemHovered : PropTypes . string ,
data : PropTypes . object . isRequired ,
onToggleProgress : PropTypes . func ,
onToggleWarning : PropTypes . func ,
onToggleOverlayRemove : PropTypes . func ,
onClickRemoveItem : PropTypes . func
} ;
}
} ] ) ;
return Cart ;
} ( React . PureComponent ) ;
/ * *
* Component that displays crate modes
* /
2020-04-15 21:17:48 +08:00
var CrateMode = /*#__PURE__*/ function ( _React$PureComponent6 ) {
2020-01-23 18:39:56 +08:00
_inherits ( CrateMode , _React$PureComponent6 ) ;
2020-04-15 21:17:48 +08:00
var _super6 = _createSuper ( CrateMode ) ;
2020-01-23 18:39:56 +08:00
_createClass ( CrateMode , null , [ {
key : "propTypes" ,
get : function get ( ) {
return {
items : PropTypes . array . isRequired ,
mode : PropTypes . string . isRequired ,
onClickMode : PropTypes . func
} ;
}
} ] ) ;
function CrateMode ( props ) {
2020-04-14 17:54:59 +08:00
var _this5 ;
2020-01-23 18:39:56 +08:00
_classCallCheck ( this , CrateMode ) ;
2020-04-15 21:17:48 +08:00
_this5 = _super6 . call ( this , props ) ;
2020-04-14 17:54:59 +08:00
_this5 . handleOnClickMode = _this5 . handleOnClickMode . bind ( _assertThisInitialized ( _this5 ) ) ;
return _this5 ;
2020-01-23 18:39:56 +08:00
}
_createClass ( CrateMode , [ {
key : "handleOnClickMode" ,
value : function handleOnClickMode ( mode , e ) {
if ( this . props . onClickMode ) {
this . props . onClickMode ( mode ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "render" ,
value : function render ( ) {
2020-04-14 17:54:59 +08:00
var _this6 = this ;
2020-01-23 18:39:56 +08:00
var _this$props6 = this . props ,
2023-06-29 11:49:24 +08:00
mode = _this$props6 . mode ,
items = _this$props6 . items ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "crate-mode"
} , items . map ( function ( item ) {
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "a" , {
2020-01-23 18:39:56 +08:00
key : item . id ,
className : mode == item . id ? 'active' : '' ,
2020-04-14 17:54:59 +08:00
onClick : _this6 . handleOnClickMode . bind ( _this6 , item . id ) ,
2020-01-23 18:39:56 +08:00
href : "#" ,
role : "button"
} , item . name ) ;
} ) ) ;
}
} ] ) ;
return CrateMode ;
} ( React . PureComponent ) ;
/ * *
* Component that displays the main crate with reminder rules .
* It includes < Cart > and rules
* /
2020-04-15 21:17:48 +08:00
var Crate = /*#__PURE__*/ function ( _React$PureComponent7 ) {
2020-01-23 18:39:56 +08:00
_inherits ( Crate , _React$PureComponent7 ) ;
2020-04-15 21:17:48 +08:00
var _super7 = _createSuper ( Crate ) ;
2020-01-23 18:39:56 +08:00
function Crate ( ) {
_classCallCheck ( this , Crate ) ;
2020-04-15 21:17:48 +08:00
return _super7 . apply ( this , arguments ) ;
2020-01-23 18:39:56 +08:00
}
_createClass ( Crate , [ {
key : "render" ,
value : function render ( ) {
var _this$props7 = this . props ,
2023-06-29 11:49:24 +08:00
rules = _this$props7 . rules ,
cart = _this$props7 . cart ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "crate"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "crate-products"
2020-04-15 21:17:48 +08:00
} , cart , rules && rules . length > 0 && /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "crate-info"
} , rules . map ( function ( rule , index ) {
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "p" , {
2020-01-23 18:39:56 +08:00
key : index ,
className : "rule" ,
style : {
'color' : rule . color ? rule . color : 'inherit'
}
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
src : "/images" . concat ( rule . icon )
2020-04-15 21:17:48 +08:00
} ) , " " , /*#__PURE__*/ React . createElement ( "i" , null , /*#__PURE__*/ React . createElement ( "strong" , null , rule . name , ":" ) , " " , rule . message ) ) ;
2020-01-23 18:39:56 +08:00
} ) ) ) ) ;
}
} ] , [ {
key : "propTypes" ,
get : function get ( ) {
return {
rules : PropTypes . array ,
cart : PropTypes . element
} ;
}
} ] ) ;
return Crate ;
} ( React . PureComponent ) ;
/ * *
* Component that renders all things for order .
* It acts like - a layout , this component do nothing more .
* /
2020-04-15 21:17:48 +08:00
var OrderPanel = /*#__PURE__*/ function ( _React$PureComponent8 ) {
2020-01-23 18:39:56 +08:00
_inherits ( OrderPanel , _React$PureComponent8 ) ;
2020-04-15 21:17:48 +08:00
var _super8 = _createSuper ( OrderPanel ) ;
2020-01-23 18:39:56 +08:00
function OrderPanel ( ) {
_classCallCheck ( this , OrderPanel ) ;
2020-04-15 21:17:48 +08:00
return _super8 . apply ( this , arguments ) ;
2020-01-23 18:39:56 +08:00
}
_createClass ( OrderPanel , [ {
key : "render" ,
value : function render ( ) {
var _this$props8 = this . props ,
2023-06-29 11:49:24 +08:00
title = _this$props8 . title ,
description = _this$props8 . description ,
crateMode = _this$props8 . crateMode ,
crate = _this$props8 . crate ,
summaryPrice = _this$props8 . summaryPrice ,
form = _this$props8 . form ,
isMobile = _this$props8 . isMobile ,
onClickToggleMobileSideMenu = _this$props8 . onClickToggleMobileSideMenu ,
onClickOpenImport = _this$props8 . onClickOpenImport ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "section" , {
2020-01-23 18:39:56 +08:00
className : "panel"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "h2" , null , title ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "control"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "p" , {
2020-01-23 18:39:56 +08:00
className : "description"
2020-04-15 21:17:48 +08:00
} , description ) , crateMode ) , /*#__PURE__*/ React . createElement ( "div" , null , /*#__PURE__*/ React . createElement ( "input" , {
2020-04-14 17:54:59 +08:00
className : "btn btn-sm btn-outline-primary m-0 mb-2" ,
style : {
'cursor' : 'pointer'
} ,
2020-04-16 10:33:49 +08:00
value : "Import JSON" ,
2020-04-14 17:54:59 +08:00
onClick : onClickOpenImport
2020-04-15 21:17:48 +08:00
} ) ) , isMobile ? /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "mobileBtnDisplaySideMenu"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "button" , {
2020-01-23 18:39:56 +08:00
onClick : onClickToggleMobileSideMenu
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
src : "/images/shop/icon-add.svg" ,
alt : "add"
2020-04-15 21:17:48 +08:00
} ) ) ) : null , crate , /*#__PURE__*/ React . createElement ( "section" , {
2020-01-23 18:39:56 +08:00
className : "summary"
} , summaryPrice , form ) ) ;
}
} ] , [ {
key : "propTypes" ,
get : function get ( ) {
return {
title : PropTypes . string ,
description : PropTypes . string ,
crateMode : PropTypes . element ,
crate : PropTypes . element ,
summaryPrice : PropTypes . element ,
form : PropTypes . element ,
isMobile : PropTypes . bool ,
2020-04-14 17:54:59 +08:00
onClickToggleMobileSideMenu : PropTypes . func ,
onClickOpenImport : PropTypes . func
2020-01-23 18:39:56 +08:00
} ;
}
} ] ) ;
return OrderPanel ;
} ( React . PureComponent ) ;
/ * *
* Components that renders the form to request quote .
* /
2020-04-15 21:17:48 +08:00
var OrderForm = /*#__PURE__*/ function ( _React$PureComponent9 ) {
2020-01-23 18:39:56 +08:00
_inherits ( OrderForm , _React$PureComponent9 ) ;
2020-04-15 21:17:48 +08:00
var _super9 = _createSuper ( OrderForm ) ;
2020-01-23 18:39:56 +08:00
_createClass ( OrderForm , null , [ {
key : "propTypes" ,
get : function get ( ) {
return {
2020-04-14 17:54:59 +08:00
isProcessing : PropTypes . bool ,
isProcessingComplete : PropTypes . bool ,
2020-01-23 18:39:56 +08:00
onClickSubmit : PropTypes . func
} ;
}
} ] ) ;
function OrderForm ( props ) {
2020-04-14 17:54:59 +08:00
var _this7 ;
2020-01-23 18:39:56 +08:00
_classCallCheck ( this , OrderForm ) ;
2020-04-15 21:17:48 +08:00
_this7 = _super9 . call ( this , props ) ;
2020-04-14 17:54:59 +08:00
_this7 . state = {
note : '' ,
email : '' ,
error : {
note : null ,
email : null
} ,
empty : {
note : null ,
email : null
}
2020-01-23 18:39:56 +08:00
} ;
2020-04-14 17:54:59 +08:00
_this7 . handleEmail = _this7 . handleEmail . bind ( _assertThisInitialized ( _this7 ) ) ;
_this7 . handleNote = _this7 . handleNote . bind ( _assertThisInitialized ( _this7 ) ) ;
_this7 . handleSubmit = _this7 . handleSubmit . bind ( _assertThisInitialized ( _this7 ) ) ;
_this7 . resetEmptyError = _this7 . resetEmptyError . bind ( _assertThisInitialized ( _this7 ) ) ;
_this7 . checkValidation = _this7 . checkValidation . bind ( _assertThisInitialized ( _this7 ) ) ;
return _this7 ;
2020-01-23 18:39:56 +08:00
}
_createClass ( OrderForm , [ {
2020-04-14 17:54:59 +08:00
key : "checkValidation" ,
value : function checkValidation ( ) {
var isValid = true ;
var validationFields = _objectSpread ( { } , this . state ) ;
var _this$validateEmail = this . validateEmail ( this . state . email ) ,
2023-06-29 11:49:24 +08:00
isEmailEmpty = _this$validateEmail . isEmpty ,
isEmailError = _this$validateEmail . isError ;
2020-04-14 17:54:59 +08:00
validationFields = _objectSpread ( { } , validationFields , {
error : _objectSpread ( { } , this . state . error , {
email : isEmailError
} ) ,
empty : _objectSpread ( { } , this . state . empty , {
email : isEmailEmpty
} )
2020-01-23 18:39:56 +08:00
} ) ;
2020-04-14 17:54:59 +08:00
this . setState ( validationFields ) ;
isValid = ! isEmailEmpty && ! isEmailError ;
return isValid ;
}
} , {
key : "validateEmail" ,
value : function validateEmail ( value ) {
var isEmpty = null ;
var isError = null ;
var t = this . props . t ;
if ( ! value || value . trim ( ) === '' ) {
isEmpty = true ;
} else if ( value && ! value . match ( /^\w+([\+\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/ ) ) {
isError = {
message : 'Your email is incomplete'
} ;
}
return {
isEmpty : isEmpty ,
isError : isError
} ;
}
} , {
key : "validateNote" ,
value : function validateNote ( value ) {
var isEmpty = null ;
if ( ! value || value . trim ( ) === '' ) {
isEmpty = true ;
}
return {
isEmpty : isEmpty
} ;
}
} , {
key : "resetEmptyError" ,
value : function resetEmptyError ( key ) {
this . setState ( _objectSpread ( { } , this . state , {
error : _objectSpread ( { } , this . state . error , _defineProperty ( { } , key , null ) ) ,
empty : _objectSpread ( { } , this . state . empty , _defineProperty ( { } , key , null ) )
} ) ) ;
}
} , {
key : "handleEmail" ,
value : function handleEmail ( e ) {
var value = e . target . value ;
var _this$validateEmail2 = this . validateEmail ( value ) ,
2023-06-29 11:49:24 +08:00
isEmpty = _this$validateEmail2 . isEmpty ,
isError = _this$validateEmail2 . isError ;
2020-04-14 17:54:59 +08:00
this . setState ( _objectSpread ( { } , this . state , {
email : value ,
error : _objectSpread ( { } , this . state . error , {
email : isError
} ) ,
empty : _objectSpread ( { } , this . state . empty , {
email : isEmpty
} )
} ) ) ;
}
} , {
key : "handleNote" ,
value : function handleNote ( e ) {
var value = e . target . value ;
this . setState ( _objectSpread ( { } , this . state , {
note : value
} ) ) ;
2020-01-23 18:39:56 +08:00
}
} , {
key : "handleSubmit" ,
value : function handleSubmit ( event ) {
2020-04-14 17:54:59 +08:00
event . preventDefault ( ) ;
2020-01-23 18:39:56 +08:00
if ( this . props . onClickSubmit ) {
2020-04-14 17:54:59 +08:00
// check validation input fields
var isValidated = this . checkValidation ( ) ;
if ( ! isValidated ) {
return false ;
}
this . props . onClickSubmit ( this . state . note , this . state . email ) ;
}
2020-01-23 18:39:56 +08:00
}
} , {
key : "render" ,
value : function render ( ) {
2020-04-14 17:54:59 +08:00
var handleEmail = this . handleEmail ,
2023-06-29 11:49:24 +08:00
handleNote = this . handleNote ,
resetEmptyError = this . resetEmptyError ,
handleSubmit = this . handleSubmit ;
2020-04-14 17:54:59 +08:00
var onClickShow = this . props . onClickShow ;
var _this$state = this . state ,
2023-06-29 11:49:24 +08:00
email = _this$state . email ,
note = _this$state . note ,
error = _this$state . error ,
empty = _this$state . empty ;
2020-04-14 17:54:59 +08:00
var _this$props9 = this . props ,
2023-06-29 11:49:24 +08:00
isProcessing = _this$props9 . isProcessing ,
isProcessingComplete = _this$props9 . isProcessingComplete ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "summary-form"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "form" , {
2020-04-14 17:54:59 +08:00
onSubmit : handleSubmit ,
noValidate : true
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "input" , {
2020-04-14 17:54:59 +08:00
className : "" . concat ( error && error . email ? 'errorField' : '' ) ,
type : "email" ,
placeholder : "Email" ,
onFocus : function onFocus ( ) {
return resetEmptyError ( 'email' ) ;
} ,
onChange : handleEmail ,
onBlur : handleEmail ,
value : email
2020-04-15 21:17:48 +08:00
} ) , empty && empty . email ? /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "error"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "small" , null , "Required" ) ) : null , error && error . email ? /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "error"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "small" , null , "Your email is incomplete" ) ) : null , /*#__PURE__*/ React . createElement ( "textarea" , {
2020-04-14 17:54:59 +08:00
onChange : handleNote ,
value : note ,
2020-01-23 18:39:56 +08:00
rows : "5" ,
placeholder : "Additional notes"
2020-04-15 21:17:48 +08:00
} ) , /*#__PURE__*/ React . createElement ( "div" , {
2020-04-14 17:54:59 +08:00
className : "d-flex flex-column flex-sm-row justify-content-between"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "input" , {
2020-04-14 17:54:59 +08:00
className : "btn btn-outline-primary w-100 m-0 mb-2 mb-sm-0 mr-sm-2" ,
style : {
'cursor' : 'pointer' ,
'fontWeight' : '700'
} ,
2020-04-16 10:33:49 +08:00
value : "Show JSON" ,
2020-04-14 17:54:59 +08:00
onClick : onClickShow
2020-04-15 21:17:48 +08:00
} ) , /*#__PURE__*/ React . createElement ( "input" , {
2020-04-14 17:54:59 +08:00
className : "btn btn-primary w-100 m-0 ml-sm-2" ,
2020-01-23 18:39:56 +08:00
type : "submit" ,
2020-04-14 17:54:59 +08:00
value : "" . concat ( isProcessing ? 'Processing ...' : 'Request quote' )
} ) ) ) ) ;
2020-01-23 18:39:56 +08:00
}
} ] ) ;
return OrderForm ;
} ( React . PureComponent ) ;
/ * *
* Components that displays the list of card that are used in the crate .
* It is a summary of purchase
* /
2020-04-15 21:17:48 +08:00
var OrderSumary = /*#__PURE__*/ function ( _React$PureComponent10 ) {
2020-01-23 18:39:56 +08:00
_inherits ( OrderSumary , _React$PureComponent10 ) ;
2020-04-15 21:17:48 +08:00
var _super10 = _createSuper ( OrderSumary ) ;
2020-01-23 18:39:56 +08:00
_createClass ( OrderSumary , null , [ {
key : "propTypes" ,
get : function get ( ) {
return {
currency : PropTypes . string ,
modes : PropTypes . array ,
currentMode : PropTypes . string ,
summary : PropTypes . array ,
itemsData : PropTypes . array ,
onDeleteItem : PropTypes . func ,
onDeleteAllItems : PropTypes . func ,
onMouseEnterItem : PropTypes . func ,
onMouseLeaveItem : PropTypes . func ,
onClickSelectItem : PropTypes . func
} ;
}
} ] ) ;
function OrderSumary ( props ) {
2020-04-14 17:54:59 +08:00
var _this8 ;
2020-01-23 18:39:56 +08:00
_classCallCheck ( this , OrderSumary ) ;
2020-04-15 21:17:48 +08:00
_this8 = _super10 . call ( this , props ) ;
2020-04-14 17:54:59 +08:00
_this8 . handleOnDeleteItem = _this8 . handleOnDeleteItem . bind ( _assertThisInitialized ( _this8 ) ) ;
_this8 . handleOnDeleteAllItems = _this8 . handleOnDeleteAllItems . bind ( _assertThisInitialized ( _this8 ) ) ;
_this8 . handleOnMouseEnterItem = _this8 . handleOnMouseEnterItem . bind ( _assertThisInitialized ( _this8 ) ) ;
_this8 . handleOnMouseLeaveItem = _this8 . handleOnMouseLeaveItem . bind ( _assertThisInitialized ( _this8 ) ) ;
_this8 . handleOnClickSelectItem = _this8 . handleOnClickSelectItem . bind ( _assertThisInitialized ( _this8 ) ) ;
return _this8 ;
2020-01-23 18:39:56 +08:00
}
_createClass ( OrderSumary , [ {
key : "handleOnDeleteItem" ,
value : function handleOnDeleteItem ( index , e ) {
if ( this . props . onDeleteItem ) {
this . props . onDeleteItem ( index ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnDeleteAllItems" ,
value : function handleOnDeleteAllItems ( e ) {
if ( this . props . onDeleteAllItems ) {
this . props . onDeleteAllItems ( ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnMouseEnterItem" ,
value : function handleOnMouseEnterItem ( id , e ) {
if ( this . props . onMouseEnterItem ) {
this . props . onMouseEnterItem ( id ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnMouseLeaveItem" ,
value : function handleOnMouseLeaveItem ( e ) {
if ( this . props . onMouseLeaveItem ) {
this . props . onMouseLeaveItem ( ) ;
}
e . preventDefault ( ) ;
}
} , {
key : "handleOnClickSelectItem" ,
value : function handleOnClickSelectItem ( index , e ) {
if ( e . target . tagName !== 'IMG' ) {
if ( this . props . onClickSelectItem ) {
this . props . onClickSelectItem ( index ) ;
}
}
return e . preventDefault ( ) ;
}
} , {
key : "render" ,
value : function render ( ) {
2020-04-14 17:54:59 +08:00
var _this9 = this ;
var _this$props10 = this . props ,
2023-06-29 11:49:24 +08:00
currency = _this$props10 . currency ,
modes = _this$props10 . modes ,
currentMode = _this$props10 . currentMode ,
summary = _this$props10 . summary ,
itemsData = _this$props10 . itemsData ;
2020-01-23 18:39:56 +08:00
var mode = modes . find ( function ( elem ) {
return elem . id === currentMode ;
} ) ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "summary-price"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "table" , null , /*#__PURE__*/ React . createElement ( "thead" , null , /*#__PURE__*/ React . createElement ( "tr" , null , /*#__PURE__*/ React . createElement ( "td" , {
2020-01-23 18:39:56 +08:00
colSpan : "2" ,
className : "summary-remove-all"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "span" , {
2020-01-23 18:39:56 +08:00
className : "item-card-name"
2020-04-15 21:17:48 +08:00
} , "Remove all cards" ) , /*#__PURE__*/ React . createElement ( "button" , {
2020-01-23 18:39:56 +08:00
onClick : this . handleOnDeleteAllItems
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
src : "/images/shop/icon-remove.svg"
2020-04-15 21:17:48 +08:00
} ) ) ) ) , mode && /*#__PURE__*/ React . createElement ( "tr" , null , /*#__PURE__*/ React . createElement ( "td" , {
2020-01-23 18:39:56 +08:00
className : "item-card-name"
2020-04-15 21:17:48 +08:00
} , mode . name ) , /*#__PURE__*/ React . createElement ( "td" , {
2020-01-23 18:39:56 +08:00
className : "price"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , null , "" . concat ( currency , " " ) . concat ( formatMoney ( mode . price ) ) , /*#__PURE__*/ React . createElement ( "button" , {
2020-01-23 18:39:56 +08:00
style : {
'opacity' : '0' ,
'cursor' : 'initial'
}
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
src : "/images/shop/icon-remove.svg"
2020-04-15 21:17:48 +08:00
} ) ) ) , /*#__PURE__*/ React . createElement ( "span" , {
2020-01-23 18:39:56 +08:00
style : {
'display' : 'inline-block' ,
'width' : '30px'
}
2020-04-15 21:17:48 +08:00
} , "\xA0" ) ) ) ) , /*#__PURE__*/ React . createElement ( "tbody" , null , summary . map ( function ( item , index ) {
2020-01-23 18:39:56 +08:00
var alert ;
var warning ;
if ( itemsData [ index ] ) {
alert = itemsData [ index ] ;
var warningsKeys = Object . keys ( alert . warnings ) ;
if ( warningsKeys && warningsKeys . length > 0 ) {
warning = alert . warnings [ warningsKeys [ 0 ] ] ;
}
}
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "tr" , {
2020-01-23 18:39:56 +08:00
key : item . id ,
className : "hoverable " . concat ( item . selected ? 'selected' : '' ) ,
2020-04-14 17:54:59 +08:00
onClick : _this9 . handleOnClickSelectItem . bind ( _this9 , index ) ,
onMouseEnter : _this9 . handleOnMouseEnterItem . bind ( _this9 , item . id ) ,
onMouseLeave : _this9 . handleOnMouseLeaveItem
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "td" , {
2020-01-23 18:39:56 +08:00
className : "item-card-name"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , null , "" . concat ( item . name _number , " " ) . concat ( item . name , " " ) . concat ( item . name _codename ) ) ) , /*#__PURE__*/ React . createElement ( "td" , {
2020-01-23 18:39:56 +08:00
className : "price"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , null , "" . concat ( currency , " " ) . concat ( formatMoney ( item . price ) ) , /*#__PURE__*/ React . createElement ( "button" , {
2020-04-14 17:54:59 +08:00
onClick : _this9 . handleOnDeleteItem . bind ( _this9 , index )
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
src : "/images/shop/icon-remove.svg"
2020-04-15 21:17:48 +08:00
} ) ) ) , warning && /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
style : {
'marginLeft' : '10px'
} ,
className : "alert-warning" ,
src : "/images/" . concat ( warning . icon )
2020-04-15 21:17:48 +08:00
} ) , ! warning && /*#__PURE__*/ React . createElement ( "span" , {
2020-01-23 18:39:56 +08:00
style : {
'display' : 'inline-block' ,
'width' : '30px'
}
} , "\xA0" ) ) ) ;
2020-04-15 21:17:48 +08:00
} ) ) , /*#__PURE__*/ React . createElement ( "tfoot" , null , /*#__PURE__*/ React . createElement ( "tr" , null , /*#__PURE__*/ React . createElement ( "td" , {
2020-01-23 18:39:56 +08:00
className : "item-card-name"
2020-04-15 21:17:48 +08:00
} , "Price estimate" ) , /*#__PURE__*/ React . createElement ( "td" , {
2020-01-23 18:39:56 +08:00
className : "price"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "div" , null , summary . length ? "" . concat ( currency , " " ) . concat ( formatMoney ( summary . reduce ( function ( prev , next ) {
2020-01-23 18:39:56 +08:00
return prev + next . price ;
2020-04-15 21:17:48 +08:00
} , 0 ) + mode . price ) ) : "" . concat ( currency , " " ) . concat ( formatMoney ( mode . price ) ) , /*#__PURE__*/ React . createElement ( "button" , {
2020-01-23 18:39:56 +08:00
style : {
'opacity' : '0' ,
'cursor' : 'initial'
}
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
src : "/images/shop/icon-remove.svg" ,
alt : "icon remove"
2020-04-15 21:17:48 +08:00
} ) ) ) , /*#__PURE__*/ React . createElement ( "span" , {
2020-01-23 18:39:56 +08:00
style : {
'display' : 'inline-block' ,
'width' : '30px'
}
} , "\xA0" ) ) ) ) ) ) ;
}
} ] ) ;
return OrderSumary ;
} ( React . PureComponent ) ;
/ * *
* Component that renders the backlog in the aside
* /
2020-04-15 21:17:48 +08:00
var Backlog = /*#__PURE__*/ function ( _React$PureComponent11 ) {
2020-01-23 18:39:56 +08:00
_inherits ( Backlog , _React$PureComponent11 ) ;
2020-04-15 21:17:48 +08:00
var _super11 = _createSuper ( Backlog ) ;
2020-01-23 18:39:56 +08:00
function Backlog ( ) {
_classCallCheck ( this , Backlog ) ;
2020-04-15 21:17:48 +08:00
return _super11 . apply ( this , arguments ) ;
2020-01-23 18:39:56 +08:00
}
_createClass ( Backlog , [ {
key : "render" ,
value : function render ( ) {
2020-04-14 17:54:59 +08:00
var _this$props11 = this . props ,
2023-06-29 11:49:24 +08:00
currency = _this$props11 . currency ,
data = _this$props11 . data ,
items = _this$props11 . items ,
onClickAddItem = _this$props11 . onClickAddItem ,
onClickToggleMobileSideMenu = _this$props11 . onClickToggleMobileSideMenu ,
isMobile = _this$props11 . isMobile ;
var ordered _groups = data . categories . map ( function ( groupItem ) {
return {
name : groupItem . name ,
items : groupItem . itemIds . map ( function ( itemId ) {
return items [ itemId ] ;
} )
} ;
} ) ;
var groups = ordered _groups . map ( function ( group , g _index ) {
return /*#__PURE__*/ React . createElement ( "div" , {
className : "card"
} , /*#__PURE__*/ React . createElement ( "h2" , {
className : "card-header"
} , /*#__PURE__*/ React . createElement ( "button" , {
className : "btn btn-link btn-block text-left " ,
type : "button" ,
"data-toggle" : "collapse" ,
"data-target" : "#collapse" . concat ( g _index ) ,
"aria-expanded" : "true" ,
"aria-controls" : "collapse" . concat ( g _index )
} , group . name ) ) , /*#__PURE__*/ React . createElement ( "div" , {
id : "collapse" . concat ( g _index ) ,
className : "collapse" ,
"aria-labelledby" : "headingOne" ,
"data-parent" : "#accordion_categories"
} , /*#__PURE__*/ React . createElement ( "div" , {
className : "card-body"
} , group . items . map ( function ( item ) {
return /*#__PURE__*/ React . createElement ( ProductItem , {
key : item . id ,
id : item . id ,
name : "" . concat ( item . name _number , " " ) . concat ( item . name ) ,
name _codename : item . name _codename ,
price : item . price ,
currency : currency ,
image : "/images/" . concat ( item . image ) ,
specs : item . specs ,
datasheet _file : item . datasheet _file ,
datasheet _name : item . datasheet _name ,
onClickAddItem : onClickAddItem
} ) ;
} ) ) ) ) ;
2020-01-23 18:39:56 +08:00
} ) ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( Droppable , {
2020-01-23 18:39:56 +08:00
droppableId : data . id ,
isDropDisabled : true
} , function ( provided ) {
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( "div" , _extends ( {
2020-01-23 18:39:56 +08:00
className : "backlog-container" ,
ref : provided . innerRef
2020-04-15 21:17:48 +08:00
} , provided . droppableProps ) , isMobile ? /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
className : "mobileCloseMenu"
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "button" , {
2020-01-23 18:39:56 +08:00
onClick : onClickToggleMobileSideMenu
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( "img" , {
2020-01-23 18:39:56 +08:00
src : "/images/shop/icon-close-white.svg" ,
alt : "add"
2023-06-29 11:49:24 +08:00
} ) ) ) : null , /*#__PURE__*/ React . createElement ( "div" , {
className : "accordion" ,
id : "accordion_categories"
} , groups ) , provided . placeholder && /*#__PURE__*/ React . createElement ( "div" , {
2020-01-23 18:39:56 +08:00
style : {
display : 'none'
}
} , provided . placeholder ) ) ;
} ) ;
}
} ] , [ {
key : "propTypes" ,
get : function get ( ) {
return {
currency : PropTypes . string ,
data : PropTypes . object . isRequired ,
items : PropTypes . object ,
isMobile : PropTypes . bool ,
onClickAddItem : PropTypes . func ,
onClickToggleMobileSideMenu : PropTypes . func
} ;
}
} , {
key : "defaultProps" ,
get : function get ( ) {
return {
items : { }
} ;
}
} ] ) ;
return Backlog ;
} ( React . PureComponent ) ;
/ * *
* Component that render the entire shop
* /
2020-04-15 21:17:48 +08:00
var Shop = /*#__PURE__*/ function ( _React$PureComponent12 ) {
2020-01-23 18:39:56 +08:00
_inherits ( Shop , _React$PureComponent12 ) ;
2020-04-15 21:17:48 +08:00
var _super12 = _createSuper ( Shop ) ;
2020-01-23 18:39:56 +08:00
_createClass ( Shop , null , [ {
key : "propTypes" ,
get : function get ( ) {
return {
data : PropTypes . object . isRequired
} ;
}
} ] ) ;
function Shop ( props ) {
2020-04-14 17:54:59 +08:00
var _this10 ;
2020-01-23 18:39:56 +08:00
_classCallCheck ( this , Shop ) ;
2020-04-15 21:17:48 +08:00
_this10 = _super12 . call ( this , props ) ;
2020-04-14 17:54:59 +08:00
_this10 . state = _this10 . props . data ;
_this10 . handleCrateModeChange = _this10 . handleCrateModeChange . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleOnDragEnd = _this10 . handleOnDragEnd . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleDeleteItem = _this10 . handleDeleteItem . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleDeleteAllItems = _this10 . handleDeleteAllItems . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleMouseEnterItem = _this10 . handleMouseEnterItem . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleMouseLeaveItem = _this10 . handleMouseLeaveItem . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleClickAddItem = _this10 . handleClickAddItem . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . checkAlerts = _this10 . checkAlerts . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleToggleItemProgress = _this10 . handleToggleItemProgress . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleToggleItemWarning = _this10 . handleToggleItemWarning . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleClickSelectItem = _this10 . handleClickSelectItem . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleClickSubmit = _this10 . handleClickSubmit . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleToggleOverlayRemove = _this10 . handleToggleOverlayRemove . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleClickToggleMobileSideMenu = _this10 . handleClickToggleMobileSideMenu . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleClickCloseRFQFeedback = _this10 . handleClickCloseRFQFeedback . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleClickShowOrder = _this10 . handleClickShowOrder . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleClickOpenImport = _this10 . handleClickOpenImport . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . handleLoadCustomConf = _this10 . handleLoadCustomConf . bind ( _assertThisInitialized ( _this10 ) ) ;
_this10 . timer = null ;
return _this10 ;
2020-01-23 18:39:56 +08:00
}
_createClass ( Shop , [ {
key : "componentDidMount" ,
value : function componentDidMount ( ) {
// index 0 is a Kasli, we place it as a default conf on the crate.
2023-06-29 11:49:24 +08:00
var sourceIds = Array . from ( this . state . columns . backlog . categories . map ( function ( groupId ) {
return groupId . itemIds ;
} ) . flat ( ) ) ;
2020-01-23 18:39:56 +08:00
var source = {
droppableId : 'backlog' ,
2023-06-29 11:49:24 +08:00
index : null
2020-01-23 18:39:56 +08:00
} ;
var destination = {
droppableId : 'cart' ,
index : 0
} ;
this . handleOnDragEnd ( {
source : source ,
destination : destination ,
2023-06-29 11:49:24 +08:00
draggableId : sourceIds [ 0 ]
2020-01-23 18:39:56 +08:00
} ) ;
}
} , {
key : "componentDidUpdate" ,
value : function componentDidUpdate ( prevProps , prevState ) {
2020-04-14 17:54:59 +08:00
var _this11 = this ;
2020-01-23 18:39:56 +08:00
/ * *
* We check alerts ( reminder + warning ) only when items inside crate or
* crate mode change .
*
* In the function checkAlerts , we DO NOT want to change items as we will
* trigger again this function ( componentDidUpdate ) and thus ,
* making an infinite loop .
* /
if ( prevState . columns . cart . items !== this . state . columns . cart . items || prevState . currentMode !== this . state . currentMode ) {
this . checkAlerts ( prevState . columns . cart . items , this . state . columns . cart . items ) ;
}
if ( this . state . newCardJustAdded ) {
this . timer = setTimeout ( function ( ) {
2020-04-14 17:54:59 +08:00
_this11 . setState ( {
2020-01-23 18:39:56 +08:00
newCardJustAdded : false
} ) ;
} , 2000 ) ;
}
}
} , {
key : "componentWillUnmount" ,
value : function componentWillUnmount ( ) {
clearTimeout ( this . timer ) ;
}
} , {
key : "handleCrateModeChange" ,
value : function handleCrateModeChange ( mode ) {
this . setState ( {
currentMode : mode
} ) ;
}
} , {
key : "handleDeleteItem" ,
value : function handleDeleteItem ( index ) {
var cloned = Array . from ( this . state . columns . cart . items ) ;
cloned . splice ( index , 1 ) ;
this . setState ( _objectSpread ( { } , this . state , {
columns : _objectSpread ( { } , this . state . columns , {
cart : _objectSpread ( { } , this . state . columns . cart , {
items : cloned
} )
} )
} ) ) ;
}
} , {
key : "handleDeleteAllItems" ,
value : function handleDeleteAllItems ( ) {
this . setState ( _objectSpread ( { } , this . state , {
columns : _objectSpread ( { } , this . state . columns , {
cart : _objectSpread ( { } , this . state . columns . cart , {
items : [ ]
} )
} )
} ) ) ;
}
} , {
key : "handleMouseEnterItem" ,
value : function handleMouseEnterItem ( id ) {
this . setState ( _objectSpread ( { } , this . state , {
currentItemHovered : id
} ) ) ;
}
} , {
key : "handleMouseLeaveItem" ,
value : function handleMouseLeaveItem ( ) {
this . setState ( _objectSpread ( { } , this . state , {
currentItemHovered : null
} ) ) ;
}
} , {
key : "handleClickAddItem" ,
2023-06-29 11:49:24 +08:00
value : function handleClickAddItem ( id , tap ) {
2020-01-23 18:39:56 +08:00
var source = {
droppableId : 'backlog' ,
2023-06-29 11:49:24 +08:00
index : null
2020-01-23 18:39:56 +08:00
} ;
var destination = {
droppableId : 'cart' ,
index : this . state . columns . cart . items . length
} ;
this . handleOnDragEnd ( {
source : source ,
destination : destination ,
2023-06-29 11:49:24 +08:00
draggableId : id
2020-01-23 18:39:56 +08:00
} , tap ) ;
}
} , {
key : "handleToggleItemProgress" ,
value : function handleToggleItemProgress ( index , show ) {
var itemsCloned = Array . from ( this . state . columns . cart . items ) ;
this . setState ( _objectSpread ( { } , this . state , {
columns : _objectSpread ( { } , this . state . columns , {
cart : _objectSpread ( { } , this . state . columns . cart , {
items : itemsCloned . map ( function ( item , i ) {
return _objectSpread ( { } , item , {
showProgress : i === index ? show : false ,
showOverlayRemove : false ,
showWarning : false
} ) ;
} )
} )
} )
} ) ) ;
}
} , {
key : "handleToggleItemWarning" ,
value : function handleToggleItemWarning ( index , show ) {
var itemsCloned = Array . from ( this . state . columns . cart . items ) ;
this . setState ( _objectSpread ( { } , this . state , {
columns : _objectSpread ( { } , this . state . columns , {
cart : _objectSpread ( { } , this . state . columns . cart , {
items : itemsCloned . map ( function ( item , i ) {
return _objectSpread ( { } , item , {
showWarning : i === index ? show : false ,
showProgress : false ,
showOverlayRemove : false
} ) ;
} )
} )
} )
} ) ) ;
}
} , {
key : "handleClickSelectItem" ,
value : function handleClickSelectItem ( index ) {
var itemsCloned = Array . from ( this . state . columns . cart . items ) ;
this . setState ( _objectSpread ( { } , this . state , {
columns : _objectSpread ( { } , this . state . columns , {
cart : _objectSpread ( { } , this . state . columns . cart , {
items : itemsCloned . map ( function ( item , id ) {
return _objectSpread ( { } , item , {
selected : id === index ? true : false
} ) ;
} )
} )
} )
} ) ) ;
}
} , {
key : "handleToggleOverlayRemove" ,
value : function handleToggleOverlayRemove ( index , show ) {
var itemsCloned = Array . from ( this . state . columns . cart . items ) ;
this . setState ( _objectSpread ( { } , this . state , {
columns : _objectSpread ( { } , this . state . columns , {
cart : _objectSpread ( { } , this . state . columns . cart , {
items : itemsCloned . map ( function ( item , id ) {
return _objectSpread ( { } , item , {
showOverlayRemove : id === index ? show : false ,
showProgress : false ,
showWarning : false
} ) ;
} )
} )
} )
} ) ) ;
}
2020-04-14 17:54:59 +08:00
} , {
key : "handleClickShowOrder" ,
value : function handleClickShowOrder ( ) {
var crate = {
items : [ ] ,
type : this . state . currentMode
} ;
var clonedCart = Array . from ( this . state . columns . cart . items ) ;
for ( var i in clonedCart ) {
var item = clonedCart [ i ] ;
crate . items . push ( {
'pn' : item . name _number
} ) ;
}
this . setState ( {
isProcessing : false ,
shouldShowRFQFeedback : true ,
RFQBodyType : 'show' ,
RFQBodyOrder : JSON . stringify ( crate )
} ) ;
}
} , {
key : "handleClickOpenImport" ,
value : function handleClickOpenImport ( ) {
this . setState ( {
isProcessing : false ,
shouldShowRFQFeedback : true ,
RFQBodyType : 'import'
} ) ;
}
} , {
key : "handleLoadCustomConf" ,
value : function handleLoadCustomConf ( customconf ) {
if ( ! customconf ) {
return ;
}
var items = this . props . data . items ;
var self = this ;
var new _items = [ ] ;
this . setState ( _objectSpread ( { } , this . state , {
columns : _objectSpread ( { } , this . state . columns , {
cart : _objectSpread ( { } , this . state . columns . cart , {
items : [ ]
} )
} )
} ) , function ( ) {
customconf . items . map ( function ( item ) {
Object . keys ( items ) . map ( function ( key ) {
if ( item . pn && item . pn === items [ key ] . name _number ) {
new _items . push ( Object . assign ( _objectSpread ( { } , items [ key ] ) , {
id : uuidv4 ( )
} ) ) ;
}
} ) ;
return item ;
} ) ;
this . setState ( _objectSpread ( { } , this . state , {
columns : _objectSpread ( { } , this . state . columns , {
cart : _objectSpread ( { } , this . state . columns . cart , {
items : new _items
} )
} ) ,
currentMode : customconf . type
} ) ) ;
} ) ;
}
2020-01-23 18:39:56 +08:00
} , {
key : "handleClickSubmit" ,
2020-04-14 17:54:59 +08:00
value : function handleClickSubmit ( note , email ) {
var _this12 = this ;
2020-01-23 18:39:56 +08:00
var crate = {
items : [ ] ,
type : this . state . currentMode
} ;
var clonedCart = Array . from ( this . state . columns . cart . items ) ;
for ( var i in clonedCart ) {
var item = clonedCart [ i ] ;
crate . items . push ( {
2020-03-23 12:35:31 +08:00
'pn' : item . name _number
2020-01-23 18:39:56 +08:00
} ) ;
}
2020-04-14 17:54:59 +08:00
var data = this . props . data ;
this . setState ( {
isProcessing : true
} ) ;
axios . post ( data . API _RFQ , {
email : email ,
2020-04-15 21:17:48 +08:00
note : note ,
2020-04-16 10:33:49 +08:00
configuration : JSON . stringify ( crate )
2020-04-14 17:54:59 +08:00
} ) . then ( function ( response ) {
_this12 . setState ( {
isProcessing : false ,
shouldShowRFQFeedback : true ,
RFQBodyType : 'email' ,
isProcessingComplete : true
} ) ;
} ) [ "catch" ] ( function ( err ) {
_this12 . setState ( {
isProcessing : false
} , function ( ) {
alert ( "We cannot receive your request. Try using the export by coping the configuration and send it to us at sales[at]m-labs.hk" ) ;
} ) ;
} ) ;
2020-01-23 18:39:56 +08:00
}
} , {
key : "handleOnDragEnd" ,
value : function handleOnDragEnd ( result , newAdded ) {
var source = result . source ,
2023-06-29 11:49:24 +08:00
destination = result . destination ,
draggableId = result . draggableId ;
2020-01-23 18:39:56 +08:00
if ( ! destination ) {
if ( source . droppableId === 'cart' ) {
this . setState ( _objectSpread ( { } , this . state , {
newCardJustAdded : false ,
columns : _objectSpread ( { } , this . state . columns , _defineProperty ( { } , source . droppableId , _objectSpread ( { } , this . state . columns [ source . droppableId ] , {
items : remove ( this . state . columns [ source . droppableId ] . items , source . index )
} ) ) )
} ) ) ;
}
return ;
}
switch ( source . droppableId ) {
case 'backlog' :
this . setState ( _objectSpread ( { } , this . state , {
newCardJustAdded : newAdded ? true : false ,
columns : _objectSpread ( { } , this . state . columns , _defineProperty ( { } , destination . droppableId , _objectSpread ( { } , this . state . columns [ destination . droppableId ] , {
2023-06-29 11:49:24 +08:00
items : copy ( this . state . items , this . state . columns [ source . droppableId ] , this . state . columns [ destination . droppableId ] , draggableId , destination )
2020-01-23 18:39:56 +08:00
} ) ) )
} ) ) ;
break ;
case destination . droppableId :
this . setState ( _objectSpread ( { } , this . state , {
newCardJustAdded : false ,
columns : _objectSpread ( { } , this . state . columns , _defineProperty ( { } , destination . droppableId , _objectSpread ( { } , this . state . columns [ destination . droppableId ] , {
items : reorder ( this . state . columns [ destination . droppableId ] . items , source . index , destination . index )
} ) ) )
} ) ) ;
break ;
default :
break ;
}
}
} , {
key : "handleClickToggleMobileSideMenu" ,
value : function handleClickToggleMobileSideMenu ( ) {
this . setState ( _objectSpread ( { } , this . state , {
mobileSideMenuShouldOpen : ! this . state . mobileSideMenuShouldOpen
} ) ) ;
}
2020-04-14 17:54:59 +08:00
} , {
key : "handleClickCloseRFQFeedback" ,
value : function handleClickCloseRFQFeedback ( ) {
this . setState ( {
shouldShowRFQFeedback : false
} ) ;
}
2020-01-23 18:39:56 +08:00
} , {
key : "checkAlerts" ,
value : function checkAlerts ( prevItems , newItems ) {
2020-04-14 17:54:59 +08:00
var _this13 = this ;
2020-01-23 18:39:56 +08:00
console . log ( '--- START CHECKING CRATE WARNING ---' ) ;
2020-04-14 17:54:59 +08:00
var _this$state2 = this . state ,
2023-06-29 11:49:24 +08:00
currentMode = _this$state2 . currentMode ,
crateModeSlots = _this$state2 . crateModeSlots ,
crateRules = _this$state2 . crateRules ;
2020-01-23 18:39:56 +08:00
var itemsCloned = Array . from ( newItems ) ;
var itemsData = { } ;
2023-06-29 11:49:24 +08:00
var rules = { } ;
2020-01-23 18:39:56 +08:00
2023-06-29 11:49:24 +08:00
// check number of slot in crate
2020-01-23 18:39:56 +08:00
var nbrOccupied = nbrOccupiedSlotsInCrate ( newItems ) ;
if ( nbrOccupied > crateModeSlots [ currentMode ] ) {
rules [ crateRules . maxSlot . type ] = _objectSpread ( { } , crateRules . maxSlot ) ;
2020-01-27 23:09:29 +08:00
} else if ( crateModeSlots [ currentMode ] === 21 && nbrOccupied <= 10 ) {
rules [ crateRules . compactSlot . type ] = _objectSpread ( { } , crateRules . compactSlot ) ;
2023-06-29 11:49:24 +08:00
}
2020-01-23 18:39:56 +08:00
2023-06-29 11:49:24 +08:00
// check the number of EEM connectors available for all Kasli
2020-01-23 18:39:56 +08:00
var idxK = itemsCloned . reduce ( function ( prev , next , i ) {
2021-03-23 00:40:59 +08:00
if ( next . type === 'kasli' || next . type === 'vhdcicarrier' ) {
2020-01-23 18:39:56 +08:00
prev . push ( i ) ;
}
return prev ;
} , [ ] ) ;
for ( var _i2 = 0 ; _i2 <= idxK . length - 1 ; _i2 ++ ) {
var slots = void 0 ;
var nbUsedSlot = 0 ;
var nbrCurrentClock = 0 ;
var idx = idxK [ _i2 ] ;
if ( _i2 !== idxK . length - 1 ) {
slots = itemsCloned . slice ( idx + 1 , idxK [ _i2 + 1 ] ) ;
} else {
slots = itemsCloned . slice ( idx + 1 ) ;
}
if ( _i2 == 0 ) {
var slots _need _resource = itemsCloned . slice ( 0 , idx ) ;
var idx _need = slots _need _resource . findIndex ( function ( e ) {
return e . rules && e . rules . resources ;
} ) ;
if ( idx _need != - 1 ) {
if ( idx _need in itemsData ) {
if ( 'warnings' in itemsData [ idx _need ] ) {
itemsData [ idx _need ] . warnings . resources = _objectSpread ( { } , itemsCloned [ idx _need ] . rules . resources ) ;
} else {
itemsData [ idx _need ] . warnings = { } ;
itemsData [ idx _need ] . warnings . resources = _objectSpread ( { } , itemsCloned [ idx _need ] . rules . resources ) ;
}
} else {
itemsData [ idx _need ] = _objectSpread ( { } , itemsCloned [ idx _need ] ) ;
itemsData [ idx _need ] . warnings = { } ;
itemsData [ idx _need ] . warnings . resources = _objectSpread ( { } , itemsCloned [ idx _need ] . rules . resources ) ;
}
}
}
nbUsedSlot = slots . filter ( function ( item ) {
return item . type !== 'idc-bnc' ;
} ) . reduce ( function ( prev , next ) {
return prev + next . slotOccupied ;
} , 0 ) ;
nbrCurrentClock = slots . reduce ( function ( prev , next ) {
return next . type === 'clocker' ? prev + next . clockOccupied : prev ;
} , 0 ) ;
if ( idx in itemsData ) {
itemsData [ idx ] . nbrCurrentSlot = nbUsedSlot ;
itemsData [ idx ] . nbrCurrentClock = nbrCurrentClock ;
if ( ! ( 'warnings' in itemsData [ idx ] ) ) {
itemsData [ idx ] . warnings = { } ;
}
} else {
itemsData [ idx ] = _objectSpread ( { } , itemsCloned [ idx ] ) ;
itemsData [ idx ] . nbrCurrentSlot = nbUsedSlot ;
itemsData [ idx ] . nbrCurrentClock = nbrCurrentClock ;
itemsData [ idx ] . warnings = { } ;
}
if ( nbUsedSlot > itemsCloned [ idx ] . nbrSlotMax ) {
if ( itemsCloned [ idx ] . rules . maxSlot . message ) {
rules [ itemsCloned [ idx ] . rules . maxSlot . type ] = _objectSpread ( { } , itemsCloned [ idx ] . rules . maxSlot ) ;
}
itemsData [ idx ] . warnings . maxSlotWarning = _objectSpread ( { } , itemsCloned [ idx ] . rules . maxSlotWarning ) ;
}
if ( nbrCurrentClock > itemsCloned [ idx ] . nbrClockMax ) {
rules [ itemsCloned [ idx ] . rules . maxClock . type ] = _objectSpread ( { } , itemsCloned [ idx ] . rules . maxClock ) ;
itemsData [ idx ] . warnings . maxClockWarning = _objectSpread ( { } , itemsCloned [ idx ] . rules . maxClockWarning ) ;
}
if ( itemsCloned . length > idx + 1 ) {
var ddkali = itemsCloned [ idx + 1 ] ;
2021-03-23 00:40:59 +08:00
if ( ddkali . type === 'kasli' || ddkali . type === 'vhdcicarrier' ) {
2020-01-23 18:39:56 +08:00
rules [ ddkali . rules . follow . type ] = _objectSpread ( { } , ddkali . rules . follow ) ;
}
}
2020-01-27 23:38:44 +08:00
}
if ( idxK . length === 0 ) {
var _slots _need _resource = itemsCloned . slice ( 0 ) ;
var _idx _need = _slots _need _resource . findIndex ( function ( e ) {
return e . rules && e . rules . resources ;
} ) ;
if ( _idx _need != - 1 ) {
if ( _idx _need in itemsData ) {
if ( 'warnings' in itemsData [ _idx _need ] ) {
itemsData [ _idx _need ] . warnings . resources = _objectSpread ( { } , itemsCloned [ _idx _need ] . rules . resources ) ;
} else {
itemsData [ _idx _need ] . warnings = { } ;
itemsData [ _idx _need ] . warnings . resources = _objectSpread ( { } , itemsCloned [ _idx _need ] . rules . resources ) ;
}
} else {
itemsData [ _idx _need ] = _objectSpread ( { } , itemsCloned [ _idx _need ] ) ;
itemsData [ _idx _need ] . warnings = { } ;
itemsData [ _idx _need ] . warnings . resources = _objectSpread ( { } , itemsCloned [ _idx _need ] . rules . resources ) ;
}
}
2023-06-29 11:49:24 +08:00
}
2020-01-23 18:39:56 +08:00
2023-06-29 11:49:24 +08:00
// check number of clock connector available
2020-01-23 18:39:56 +08:00
var idxC = itemsCloned . reduce ( function ( prev , next , i ) {
2021-03-22 18:30:56 +08:00
if ( next . type === 'kasli' || next . type === 'clocker' ) {
2020-01-23 18:39:56 +08:00
prev . push ( i ) ;
}
return prev ;
} , [ ] ) ;
for ( var _i3 = 0 ; _i3 <= idxC . length - 1 ; _i3 ++ ) {
var _slots = void 0 ;
var _nbrCurrentClock = 0 ;
var _idx = idxC [ _i3 ] ;
if ( _i3 !== idxC . length - 1 ) {
_slots = itemsCloned . slice ( _idx + 1 , idxC [ _i3 + 1 ] ) ;
} else {
_slots = itemsCloned . slice ( _idx + 1 ) ;
}
_nbrCurrentClock = _slots . reduce ( function ( prev , next ) {
return prev + next . clockOccupied ;
} , 0 ) ;
if ( _idx in itemsData ) {
if ( itemsData [ _idx ] . nbrCurrentClock ) {
itemsData [ _idx ] . nbrCurrentClock += _nbrCurrentClock ;
} else {
itemsData [ _idx ] . nbrCurrentClock = _nbrCurrentClock ;
}
} else {
itemsData [ _idx ] = _objectSpread ( { } , itemsCloned [ _idx ] ) ;
itemsData [ _idx ] . nbrCurrentClock = _nbrCurrentClock ;
itemsData [ _idx ] . warnings = { } ;
}
if ( _nbrCurrentClock > itemsCloned [ _idx ] . nbrClockMax ) {
rules [ itemsCloned [ _idx ] . rules . maxClock . type ] = _objectSpread ( { } , itemsCloned [ _idx ] . rules . maxClock ) ;
itemsData [ _idx ] . warnings . maxClockWarning = _objectSpread ( { } , itemsCloned [ _idx ] . rules . maxClockWarning ) ;
}
2023-06-29 11:49:24 +08:00
}
2020-01-23 18:39:56 +08:00
2023-06-29 11:49:24 +08:00
// check for number of recommanded EEM connectors
2020-01-23 18:39:56 +08:00
[ 'novo' , 'urukul' , 'koster' ] . map ( function ( _type ) {
if ( itemsCloned . find ( function ( elem ) {
return elem . type === _type ;
} ) ) {
2020-04-14 17:54:59 +08:00
rules [ _this13 . state . items [ _type ] . rules . connectors . type ] = _objectSpread ( { } , _this13 . state . items [ _type ] . rules . connectors ) ;
2020-01-23 18:39:56 +08:00
}
return _type ;
2020-01-31 20:51:25 +08:00
} ) ;
if ( itemsCloned . find ( function ( elem ) {
return elem . type === 'urukul' ;
} ) ) {
if ( this . state . items [ 'urukul' ] . rules . info ) {
rules [ this . state . items [ 'urukul' ] . rules . info . type ] = _objectSpread ( { } , this . state . items [ 'urukul' ] . rules . info ) ;
}
2023-06-29 11:49:24 +08:00
}
2020-01-23 18:39:56 +08:00
2023-06-29 11:49:24 +08:00
// check if IDC-BNC is correctly positionned (after Zotino or HD68)
2020-01-23 18:39:56 +08:00
var idxIDCBNC = itemsCloned . reduce ( function ( prev , next , i ) {
if ( next . type === 'idc-bnc' ) {
prev . push ( i ) ;
}
return prev ;
} , [ ] ) ;
for ( var i = idxIDCBNC . length - 1 ; i >= 0 ; i -- ) {
var ce = idxIDCBNC [ i ] ;
var shouldWarning = false ;
if ( ce == 0 ) {
shouldWarning = true ;
} else if ( ce >= 1 ) {
var pe = idxIDCBNC [ i ] - 1 ;
if ( itemsCloned [ pe ] . type !== 'zotino' && itemsCloned [ pe ] . type !== 'hd68' && itemsCloned [ pe ] . type !== 'idc-bnc' ) {
shouldWarning = true ;
}
}
if ( shouldWarning ) {
itemsData [ ce ] = _objectSpread ( { } , itemsCloned [ ce ] ) ;
itemsData [ ce ] . warnings = { } ;
itemsData [ ce ] . warnings . wrong = _objectSpread ( { } , itemsCloned [ ce ] . rules . wrong ) ;
}
2023-06-29 11:49:24 +08:00
}
2020-01-23 18:39:56 +08:00
2023-06-29 11:49:24 +08:00
// check number of IDC-BNC adapters for a Zotino and HD68-IDC
2020-01-23 18:39:56 +08:00
var idxZH = itemsCloned . reduce ( function ( prev , next , i ) {
if ( next . type === 'zotino' || next . type === 'hd68' ) {
prev . push ( i ) ;
}
return prev ;
} , [ ] ) ;
var _loop = function _loop ( _i4 ) {
var slots = void 0 ;
var nbUsedSlot = 0 ;
var idx = idxZH [ _i4 ] ;
if ( _i4 !== idxZH . length - 1 ) {
slots = itemsCloned . slice ( idx + 1 , idxZH [ _i4 + 1 ] ) ;
} else {
slots = itemsCloned . slice ( idx + 1 ) ;
}
var stopCount = false ;
nbUsedSlot = slots . reduce ( function ( prev , next , ci , ca ) {
if ( ci === 0 && next . type === 'idc-bnc' ) {
return prev + 1 ;
} else if ( ca [ 0 ] . type === 'idc-bnc' && ci > 0 && ca [ ci - 1 ] . type === 'idc-bnc' ) {
if ( next . type !== 'idc-bnc' ) {
stopCount = true ;
}
return prev + ( next . type === 'idc-bnc' && ! stopCount ? 1 : 0 ) ;
}
return prev ;
} , 0 ) ;
if ( idx in itemsData ) {
itemsData [ idx ] . nbrCurrentSlot = nbUsedSlot ;
if ( ! ( 'warnings' in itemsData [ idx ] ) ) {
itemsData [ idx ] . warnings = { } ;
}
} else {
itemsData [ idx ] = _objectSpread ( { } , itemsCloned [ idx ] ) ;
itemsData [ idx ] . nbrCurrentSlot = nbUsedSlot ;
itemsData [ idx ] . warnings = { } ;
}
if ( nbUsedSlot > 0 ) {
if ( itemsCloned [ idx ] . rules . maxSlot . message ) {
rules [ itemsCloned [ idx ] . rules . maxSlot . type ] = _objectSpread ( { } , itemsCloned [ idx ] . rules . maxSlot ) ;
}
}
if ( nbUsedSlot > itemsCloned [ idx ] . nbrSlotMax ) {
itemsData [ idx ] . warnings . maxSlotWarning = _objectSpread ( { } , itemsCloned [ idx ] . rules . maxSlotWarning ) ;
2023-06-29 11:49:24 +08:00
}
2020-01-23 18:39:56 +08:00
2023-06-29 11:49:24 +08:00
// check if HD68-IDC has at least 1 IDC-BNC adapter
2020-01-23 18:39:56 +08:00
if ( itemsCloned [ idx ] . type === 'hd68' ) {
var _shouldWarning = false ;
if ( idx < itemsCloned . length - 1 ) {
if ( itemsCloned [ idx + 1 ] . type !== 'idc-bnc' ) {
_shouldWarning = true ;
}
} else if ( idx === itemsCloned . length - 1 ) {
_shouldWarning = true ;
}
if ( _shouldWarning ) {
if ( idx in itemsData ) {
itemsData [ idx ] . warnings . minAdapter = _objectSpread ( { } , itemsCloned [ idx ] . rules . minAdapter ) ;
} else {
itemsData [ idx ] = _objectSpread ( { } , itemsCloned [ idx ] ) ;
itemsData [ idx ] . warnings = { } ;
itemsData [ idx ] . warnings . minAdapter = _objectSpread ( { } , itemsCloned [ idx ] . rules . minAdapter ) ;
}
}
}
} ;
for ( var _i4 = 0 ; _i4 <= idxZH . length - 1 ; _i4 ++ ) {
_loop ( _i4 ) ;
2023-06-29 11:49:24 +08:00
}
2020-01-23 18:39:56 +08:00
2023-06-29 11:49:24 +08:00
// update state with rules
2020-01-23 18:39:56 +08:00
this . setState ( _objectSpread ( { } , this . state , {
columns : _objectSpread ( { } , this . state . columns , {
cart : _objectSpread ( { } , this . state . columns . cart , {
itemsData : _objectSpread ( { } , itemsData )
} )
} ) ,
rules : _objectSpread ( { } , rules )
} ) ) ;
}
} , {
key : "render" ,
value : function render ( ) {
2020-04-14 17:54:59 +08:00
var _this$state3 = this . state ,
2023-06-29 11:49:24 +08:00
currency = _this$state3 . currency ,
currentItemHovered = _this$state3 . currentItemHovered ,
currentMode = _this$state3 . currentMode ,
crateModeSlots = _this$state3 . crateModeSlots ,
crateModeItems = _this$state3 . crateModeItems ,
items = _this$state3 . items ,
columns = _this$state3 . columns ,
rules = _this$state3 . rules ,
mobileSideMenuShouldOpen = _this$state3 . mobileSideMenuShouldOpen ,
newCardJustAdded = _this$state3 . newCardJustAdded ,
isProcessing = _this$state3 . isProcessing ,
shouldShowRFQFeedback = _this$state3 . shouldShowRFQFeedback ,
RFQBodyType = _this$state3 . RFQBodyType ,
RFQBodyOrder = _this$state3 . RFQBodyOrder ,
isProcessingComplete = _this$state3 . isProcessingComplete ;
2020-01-23 18:39:56 +08:00
var isMobile = window . deviceIsMobile ( ) ;
2020-04-15 21:17:48 +08:00
return /*#__PURE__*/ React . createElement ( DragDropContext , {
2020-01-23 18:39:56 +08:00
onDragEnd : this . handleOnDragEnd
2020-04-15 21:17:48 +08:00
} , /*#__PURE__*/ React . createElement ( Layout , {
2020-04-14 17:54:59 +08:00
showRFQFeedback : shouldShowRFQFeedback ,
RFQBodyType : RFQBodyType ,
RFQBodyOrder : RFQBodyOrder ,
2020-01-23 18:39:56 +08:00
className : "shop" ,
mobileSideMenuShouldOpen : mobileSideMenuShouldOpen ,
isMobile : isMobile ,
newCardJustAdded : newCardJustAdded ,
onClickToggleMobileSideMenu : this . handleClickToggleMobileSideMenu ,
2020-04-14 17:54:59 +08:00
onClickCloseRFQFeedback : this . handleClickCloseRFQFeedback ,
onClickLoadCustomConf : this . handleLoadCustomConf ,
2020-04-20 22:53:32 +08:00
items : items ,
2020-04-15 21:17:48 +08:00
aside : /*#__PURE__*/ React . createElement ( Backlog , {
2020-01-23 18:39:56 +08:00
currency : currency ,
items : items ,
data : columns [ 'backlog' ] ,
onClickAddItem : this . handleClickAddItem ,
onClickToggleMobileSideMenu : this . handleClickToggleMobileSideMenu ,
isMobile : isMobile
} ) ,
2020-04-15 21:17:48 +08:00
main : /*#__PURE__*/ React . createElement ( OrderPanel , {
2020-01-23 18:39:56 +08:00
onClickToggleMobileSideMenu : this . handleClickToggleMobileSideMenu ,
2020-04-14 17:54:59 +08:00
onClickOpenImport : this . handleClickOpenImport ,
2020-01-23 18:39:56 +08:00
isMobile : isMobile ,
title : "Order hardware" ,
description : " Drag and drop the cards you want into the crate below to see how the combination would look like. If you have any issues with this ordering system, or if you need other configurations, email us directly anytime at sales@m-****.hk. The price is estimated and must be confirmed by a quote." ,
2020-04-15 21:17:48 +08:00
crateMode : /*#__PURE__*/ React . createElement ( CrateMode , {
2020-01-23 18:39:56 +08:00
items : crateModeItems ,
mode : currentMode ,
onClickMode : this . handleCrateModeChange
} ) ,
2020-04-15 21:17:48 +08:00
crate : /*#__PURE__*/ React . createElement ( Crate , {
cart : /*#__PURE__*/ React . createElement ( Cart , {
2020-01-23 18:39:56 +08:00
nbrSlots : crateModeSlots [ currentMode ] ,
data : columns [ 'cart' ] ,
isMobile : isMobile ,
itemHovered : currentItemHovered ,
onToggleProgress : this . handleToggleItemProgress ,
onToggleWarning : this . handleToggleItemWarning ,
onToggleOverlayRemove : this . handleToggleOverlayRemove ,
onClickRemoveItem : this . handleDeleteItem
} ) ,
rules : Object . values ( rules ) . filter ( function ( rule ) {
return rule ;
} )
} ) ,
2020-04-15 21:17:48 +08:00
summaryPrice : /*#__PURE__*/ React . createElement ( OrderSumary , {
2020-01-23 18:39:56 +08:00
currency : currency ,
currentMode : currentMode ,
modes : crateModeItems ,
summary : columns [ 'cart' ] . items ,
itemsData : columns . cart . itemsData ,
onMouseEnterItem : this . handleMouseEnterItem ,
onMouseLeaveItem : this . handleMouseLeaveItem ,
onDeleteItem : this . handleDeleteItem ,
onDeleteAllItems : this . handleDeleteAllItems ,
onClickSelectItem : this . handleClickSelectItem
} ) ,
2020-04-15 21:17:48 +08:00
form : /*#__PURE__*/ React . createElement ( OrderForm , {
2020-04-14 17:54:59 +08:00
isProcessingComplete : isProcessingComplete ,
processingComplete : this . handleProcessingComplete ,
isProcessing : isProcessing ,
onClickSubmit : this . handleClickSubmit ,
onClickShow : this . handleClickShowOrder
2020-01-23 18:39:56 +08:00
} )
} )
} ) ) ;
}
} ] ) ;
return Shop ;
} ( React . PureComponent ) ;
2020-04-15 21:17:48 +08:00
ReactDOM . render ( /*#__PURE__*/ React . createElement ( Shop , {
2020-01-23 18:39:56 +08:00
data : data
} ) , document . querySelector ( '#root-shop' ) ) ;