redux-security
Version:
45 lines (34 loc) • 1.11 kB
JavaScript
import React, { PropTypes} from 'react'
import { warning, write } from 'redux-journal'
import Snackbar from 'material-ui/Snackbar'
import { types } from '../actions'
import { SERVICE, TAGS } from '../config'
import { select } from '../select'
const tags = `${TAGS}.react.snackbar.login`
class AuthSnackbarLogin extends React.Component {
constructor(props, context) {
super(props, context)
const { serviceName = SERVICE } = props
this.state = { serviceName, value: false }
}
componentWillReceiveProps = (nextProps) => {
const auth = select(nextProps.auth)
if (auth.status() == types.LOGIN_REQUEST) this.setState({ value: true })
}
onRequestClose = () => this.setState({ value: false })
render() {
return (
<Snackbar
open={ this.state.value }
message='LOGIN'
autoHideDuration={ 2000 }
onRequestClose={ this.onRequestClose }
/>
)
}
}
AuthSnackbarLogin.propTypes = {
auth: PropTypes.object.isRequired,
serviceName: PropTypes.string
}
export default AuthSnackbarLogin