import React, { Dispatch } from 'react'
import { connect } from 'react-redux'
import { AnyAction } from 'redux'
import appSlice from '../App.slice'
import { InitError } from '../components/InitError/InitError'

interface Props {
  onTryAgainPress: () => void
}

const InitErrorScreen: React.FunctionComponent<Props> = ({ onTryAgainPress }) => (
  <InitError onTryAgainPress={onTryAgainPress} />
)

const mapDispatchToProps = (dispatch: Dispatch<AnyAction>) => ({
  onTryAgainPress: () => dispatch(appSlice.actions.initApp()),
})

export default connect(null, mapDispatchToProps)(InitErrorScreen)
