import { connect } from 'react-redux' ; import { ImageViewer } from '../pages/image' ; import { updateImageBrightnessAction , updateImageContrastAction } from '@piximi/store' ; import { Dispatch } from 'redux' ; import { Classifier , Image } from '@piximi/types' ; type State = { classifier : Classifier ; } ; const mapStateToProps = ( state ) => { return { images : state . classifier . images } ; } ; const mapDispatchToProps = ( dispatch ) => { return { saveEdits : ( identifier , brightness , contrast ) => { const brightnessPayload = { identifier : identifier , brightness : brightness } ; const brightnessAction = updateImageBrightnessAction ( brightnessPayload ) ; dispatch ( brightnessAction ) ; const contrastPayload = { identifier : identifier , contrast : contrast } ; const contrastAction = updateImageContrastAction ( contrastPayload ) ; dispatch ( contrastAction ) ; } , saveEditsGlobally : ( images , brightness , contrast ) => { for ( let image of images ) { const brightnessPayload = { identifier : image . identifier , brightness : brightness } ; const brightnessAction = updateImageBrightnessAction ( brightnessPayload ) ; dispatch ( brightnessAction ) ; const contrastPayload = { identifier : image . identifier , contrast : contrast } ; const contrastAction = updateImageContrastAction ( contrastPayload ) ; dispatch ( contrastAction ) ; } } } ; } ; const ConnectedImageViewer = connect ( mapStateToProps , mapDispatchToProps ) ( ImageViewer ) ; export default ConnectedImageViewer ;