Commit 163b234e authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'riri' into 'master'

permission role & user role

See merge request !201
parents 8d32f088 26ab9b2a
...@@ -112,7 +112,7 @@ class Login extends Component { ...@@ -112,7 +112,7 @@ class Login extends Component {
} }
this.props.history.push('/home/beranda') this.props.history.push('/home/beranda')
} else { } else {
if (response.data.message == 'Incorrect password.') { if (response.data.message == 'Password is Not Correct') {
this.setState({ errorPassword: true, msgPassword: response.data.message }) this.setState({ errorPassword: true, msgPassword: response.data.message })
} else { } else {
this.setState({ errorEmail: true, msgEmail: response.data.message }) this.setState({ errorEmail: true, msgEmail: response.data.message })
......
...@@ -838,7 +838,7 @@ export default class ReportItems extends Component { ...@@ -838,7 +838,7 @@ export default class ReportItems extends Component {
<img src={Images.download} /> <img src={Images.download} />
</button> </button>
</a> </a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="visualisasi" place="bottom" type="light" effect="solid" />
<a data-tip={'Visualization'} data-for="visualisasi"> <a data-tip={'Visualization'} data-for="visualisasi">
<button <button
style={{ style={{
...@@ -852,7 +852,7 @@ export default class ReportItems extends Component { ...@@ -852,7 +852,7 @@ export default class ReportItems extends Component {
<img src={Images.visualisasi} /> <img src={Images.visualisasi} />
</button> </button>
</a> </a>
<ReactTooltip border={true} id="visualisasi" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="tambah" place="bottom" type="light" effect="solid" />
{this.state.buttonCreate && ( {this.state.buttonCreate && (
<a data-tip={'Add New'} data-for="tambah"> <a data-tip={'Add New'} data-for="tambah">
<button <button
......
...@@ -34,12 +34,16 @@ export default class UserRole extends Component { ...@@ -34,12 +34,16 @@ export default class UserRole extends Component {
buttonError: false, buttonError: false,
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '' messageAlert: '',
buttonCreate: false,
buttonEdit: false,
load: false
} }
} }
componentDidMount() { componentDidMount() {
this.getUser() this.getUser()
this.getPermission()
} }
closeEdit() { closeEdit() {
...@@ -72,6 +76,26 @@ export default class UserRole extends Component { ...@@ -72,6 +76,26 @@ export default class UserRole extends Component {
}) })
} }
getPermission() {
let payload = {
menu: "user"
}
api.create().getPermission(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
buttonCreate: response.data.data.create,
buttonEdit: response.data.data.edit,
load: true
})
} else {
this.setState({ load: true })
}
}
})
}
searchUser() { searchUser() {
let payload = { let payload = {
"keyword": this.state.search "keyword": this.state.search
...@@ -355,6 +379,7 @@ export default class UserRole extends Component { ...@@ -355,6 +379,7 @@ export default class UserRole extends Component {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{/* {tableMeta.rowData[6] === "Active" ? */} {/* {tableMeta.rowData[6] === "Active" ? */}
{this.state.buttonEdit && (
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -366,6 +391,7 @@ export default class UserRole extends Component { ...@@ -366,6 +391,7 @@ export default class UserRole extends Component {
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
)}
{/* : {/* :
null null
} */} } */}
...@@ -450,15 +476,44 @@ export default class UserRole extends Component { ...@@ -450,15 +476,44 @@ export default class UserRole extends Component {
</Alert> </Alert>
</Snackbar> </Snackbar>
{this.state.visibleUser ? <div> {this.state.visibleUser ? <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -118 }}> {this.state.load && (
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - User</label> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -118 }}>
{/* <div style={{ width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - User</label>
<div style={{ width: '50%', backgroundColor: 'white', padding: 10, borderRadius: 7.5 }}> {/* <div style={{ width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}>
<TextField <div style={{ width: '50%', backgroundColor: 'white', padding: 10, borderRadius: 7.5 }}>
id="input-with-icon-textfield" <TextField
name="search" id="input-with-icon-textfield"
name="search"
value={this.state.search}
placeholder={'Search'}
onChange={(e) => {
this.setState({ search: e.target.value }, () => {
if (this.state.search.length > 0) {
this.searchUser()
} else {
this.getUser()
}
});
}}
onKeyDown={(e) => this._handleKeyDown(e)}
style={{ width: '100%', borderBottomWidth: 0, borderBottomColor: 'red' }}
InputProps={{
style: { fontFamily: 'nunito', borderBottomColor: 'white' },
startAdornment: (
<InputAdornment position="start">
<SearchIcon />
</InputAdornment>
),
}}
/>
</div>
</div> */}
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} />
<InputBase
style={{ width: '100%' }}
placeholder="Search"
value={this.state.search} value={this.state.search}
placeholder={'Search'}
onChange={(e) => { onChange={(e) => {
this.setState({ search: e.target.value }, () => { this.setState({ search: e.target.value }, () => {
if (this.state.search.length > 0) { if (this.state.search.length > 0) {
...@@ -468,97 +523,74 @@ export default class UserRole extends Component { ...@@ -468,97 +523,74 @@ export default class UserRole extends Component {
} }
}); });
}} }}
onKeyDown={(e) => this._handleKeyDown(e)} inputProps={{ 'aria-label': 'naked' }}
style={{ width: '100%', borderBottomWidth: 0, borderBottomColor: 'red' }}
InputProps={{
style: { fontFamily: 'nunito', borderBottomColor: 'white' },
startAdornment: (
<InputAdornment position="start">
<SearchIcon />
</InputAdornment>
),
}}
/> />
</div> </div>
</div> */} {/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */}
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}> <div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} /> <a data-tip={'Download Template'} data-for="template">
<InputBase <button
style={{ width: '100%' }} style={{
placeholder="Search" backgroundColor: 'transparent',
value={this.state.search} cursor: 'pointer',
onChange={(e) => { borderColor: 'transparent',
this.setState({ search: e.target.value }, () => { margin: 5
if (this.state.search.length > 0) { }}
this.searchUser() onClick={() => this.downloadFile()}
} else { >
this.getUser() <img src={Images.template} />
} </button>
}); </a>
}} <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
inputProps={{ 'aria-label': 'naked' }} {this.state.buttonCreate && (
/> <a data-tip={'Upload'} data-for="upload">
</div> <button
{/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */} style={{
<div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}> backgroundColor: 'transparent',
<a data-tip={'Download Template'} data-for="template"> cursor: 'pointer',
<button borderColor: 'transparent',
style={{ margin: 5
backgroundColor: 'transparent', }}
cursor: 'pointer', onClick={() => this.setState({ visibleUpload: true })}
borderColor: 'transparent', >
margin: 5 <img src={Images.upload} />
}} </button>
onClick={() => this.downloadFile()} </a>
> )}
<img src={Images.template} /> <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
</button> <a data-tip={'Download'} data-for="download">
</a> <button
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" /> style={{
<a data-tip={'Upload'} data-for="upload"> backgroundColor: 'transparent',
<button cursor: 'pointer',
style={{ borderColor: 'transparent',
backgroundColor: 'transparent', margin: 5
cursor: 'pointer', }}
borderColor: 'transparent', onClick={() => this.downloadDataTables()}
margin: 5 >
}} <img src={Images.download} />
onClick={() => this.setState({ visibleUpload: true })} </button>
> </a>
<img src={Images.upload} /> <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
</button> {this.state.buttonCreate && (
</a> <a data-tip={'Create'} data-for="create">
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" /> <button
<a data-tip={'Download'} data-for="download"> style={{
<button backgroundColor: 'transparent',
style={{ cursor: 'pointer',
backgroundColor: 'transparent', borderColor: 'transparent',
cursor: 'pointer', margin: 5
borderColor: 'transparent', }}
margin: 5 onClick={() => this.setState({ add: true })}
}} >
onClick={() => this.downloadDataTables()} <img src={Images.add} />
> </button>
<img src={Images.download} /> </a>
</button> )}
</a> <ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> </div>
<a data-tip={'Create'} data-for="create">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ add: true })}
>
<img src={Images.add} />
</button>
</a>
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div> </div>
</div> )}
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
......
...@@ -32,12 +32,16 @@ class UserRole extends Component { ...@@ -32,12 +32,16 @@ class UserRole extends Component {
search: '', search: '',
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '' messageAlert: '',
buttonCreate: false,
buttonEdit: false,
load: false
} }
} }
componentDidMount() { componentDidMount() {
this.getRole() this.getRole()
this.getPermission()
} }
closeEdit() { closeEdit() {
...@@ -75,6 +79,26 @@ class UserRole extends Component { ...@@ -75,6 +79,26 @@ class UserRole extends Component {
}) })
} }
getPermission() {
let payload = {
menu: "user role"
}
api.create().getPermission(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
buttonCreate: response.data.data.create,
buttonEdit: response.data.data.edit,
load: true
})
} else {
this.setState({ load: true })
}
}
})
}
searchRole() { searchRole() {
let payload = { let payload = {
"keyword": this.state.search "keyword": this.state.search
...@@ -130,23 +154,25 @@ class UserRole extends Component { ...@@ -130,23 +154,25 @@ class UserRole extends Component {
console.log(tableMeta); console.log(tableMeta);
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<button {this.state.buttonEdit && (
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
}} borderColor: 'transparent',
// onClick={() => console.log(tableMeta.rowData[1])} }}
onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })} // onClick={() => console.log(tableMeta.rowData[1])}
> onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })}
<div style={{ display: 'flex' }}> >
{tableMeta.rowData[2] !== "superadmin" ? <div style={{ display: 'flex' }}>
<img src={Images.editCopy} /> : {tableMeta.rowData[2] !== "superadmin" ?
null <img src={Images.editCopy} /> :
} null
</div > }
</div >
</button> </button>
)}
</div > </div >
); );
} }
...@@ -206,44 +232,49 @@ class UserRole extends Component { ...@@ -206,44 +232,49 @@ class UserRole extends Component {
</Alert> </Alert>
</Snackbar> </Snackbar>
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -118 }}> {this.state.load && (
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Role & Authorization</label>
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -118 }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} /> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Role & Authorization</label>
<InputBase <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
style={{ width: '100%' }} <img src={Images.searchBlack} style={{ marginRight: 10 }} />
placeholder="Search" <InputBase
value={this.state.search} style={{ width: '100%' }}
onChange={(e) => { placeholder="Search"
this.setState({ search: e.target.value }, () => { value={this.state.search}
if (this.state.search.length > 0) { onChange={(e) => {
this.searchRole() this.setState({ search: e.target.value }, () => {
} else { if (this.state.search.length > 0) {
this.getRole() this.searchRole()
} } else {
}); this.getRole()
}} }
inputProps={{ 'aria-label': 'naked' }} });
/>
</div>
{/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */}
<div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}>
<a data-tip={'Create'} data-for="create">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}} }}
onClick={() => this.setState({ add: true })} inputProps={{ 'aria-label': 'naked' }}
> />
<img src={Images.add} /> </div>
</button> {/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */}
</a> <div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}>
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" /> {this.state.buttonCreate && (
<a data-tip={'Create'} data-for="create">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ add: true })}
>
<img src={Images.add} />
</button>
</a>
)}
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div>
</div> </div>
</div> )}
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment