File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,14 +77,17 @@ export class DefaultApiConfiguration implements ApiConfiguration {
7777 return stateMachine ;
7878 }
7979
80+
8081 private findStateByCode ( stateMachine : StateMachine , stateCode : number ) : State {
81- const statesArray = stateMachine . states [ 0 ] ?. State ;
82+ const stateContainer = stateMachine . states [ 0 ] ;
83+ const statesArray = Array . isArray ( stateContainer ?. State )
84+ ? stateContainer . State
85+ : stateContainer ?. State
86+ ? [ stateContainer . State ]
87+ : [ ] ;
8288
83- if ( ! statesArray ) {
84- throw new Error ( `State '${ stateCode } ' not found` ) ;
85- }
89+ const result = statesArray . find ( state => Number ( state . id ) === stateCode ) ;
8690
87- const result = statesArray . find ( state => Number ( state . attributes . id ) === stateCode ) ;
8891 if ( ! result ) {
8992 throw new Error ( `State '${ stateCode } ' not found` ) ;
9093 }
You can’t perform that action at this time.
0 commit comments