Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, {Component} from 'react'
- import { connect } from 'react-redux'
- import { compose } from 'redux'
- import { Redirect } from 'react-router-dom'
- import { fetchAppliedAd } from '~/actions/globalAction'
- const CheckPermission = ({Component}) => {
- return class HOC extends Component {
- componentDidMount() {
- this.props.fetchAppliedAd()
- }
- render() {
- const { appliedAd } = this.props
- appliedAd &&
- !this.props.location.pathname.includes('applied') &&
- <Redirect to={`/dashboard/ad/${appliedAd}/applied`} />
- return <Component {...this.props} />
- }
- }
- }
- export default compose(
- connect(state => state.global, {fetchAppliedAd}),
- CheckPermission
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement