-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
built require admin component and used it on the new newsletter button
- Loading branch information
1 parent
3a2e056
commit 1ce7b33
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
class RequireAdmin extends Component { | ||
render() { | ||
if(this.props.admin) { | ||
return {...this.props.children} | ||
} | ||
return <div></div> | ||
} | ||
} | ||
|
||
function mapStateToProps(state) { | ||
const { admin } = state.auth.user; | ||
return { admin } | ||
} | ||
|
||
RequireAdmin = connect(mapStateToProps)(RequireAdmin); | ||
|
||
export default RequireAdmin; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters