import { Features } from '@features/features' ; import { action , observable } from 'mobx' ; import toast from 'react-hot-toast' ; import Store from './store' ; type setWorkflow = ( ( workflow : string [ ] ) => string [ ] ) | string [ ] ; class WorkflowStore extends Store { constructor ( ) { super ( ) ; this . init ( ) ; } @ action init = ( ) => { this . workflow = [ ] ; this . currentFeature = '' ; this . modalState = false ; this . editFeature = null ; } ; @ observable workflow : string [ ] = [ ] ; @ observable currentFeature = '' ; @ observable modalState = false ; @ observable editFeature : keyof Features | null = null ; @ action updateWorkflow = ( newKey ) => { toast . success ( 'Added new feature' ) ; this . workflow . push ( newKey ) ; } ; @ action setWorkflow = ( input ) => { if ( typeof input === 'function' ) { this . workflow = input ( this . workflow ) ; } else { this . workflow = input ; } } ; @ action updateCurrentFeature = ( feature ) => { this . currentFeature = feature ; } ; @ action updateModalState = ( state ) => { this . editFeature = null ; this . modalState = state ; } ; @ action setModalState = ( input ) => { if ( typeof input === 'boolean' ) { this . modalState = input ; } else { this . modalState = input ( this . modalState ) ; } } ; @ action updateEditFeature = ( featureKey ) => { this . editFeature = featureKey ; this . modalState = true ; } ; } export default new WorkflowStore ( ) ;