Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import React, {Component} from 'react'
  2. import { connect } from 'react-redux'
  3. import { compose } from 'redux'
  4. import { Redirect } from 'react-router-dom'
  5. import { fetchAppliedAd } from '~/actions/globalAction'
  6.  
  7. const CheckPermission = ({Component}) => {
  8. return class HOC extends Component {
  9.  
  10. componentDidMount() {
  11. this.props.fetchAppliedAd()
  12. }
  13.  
  14. render() {
  15. const { appliedAd } = this.props
  16.  
  17. appliedAd &&
  18. !this.props.location.pathname.includes('applied') &&
  19. <Redirect to={`/dashboard/ad/${appliedAd}/applied`} />
  20.  
  21. return <Component {...this.props} />
  22. }
  23. }
  24. }
  25.  
  26. export default compose(
  27. connect(state => state.global, {fetchAppliedAd}),
  28. CheckPermission
  29. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement