Commit 84e6bd54 authored by syadziy's avatar syadziy

update doc management

parent f5b4e102
...@@ -30,16 +30,17 @@ export default class DocumentManagement extends Component { ...@@ -30,16 +30,17 @@ export default class DocumentManagement extends Component {
btndelete: false, btndelete: false,
load: false, load: false,
name: '', name: '',
userCompActive: [] userCompActive: [],
isHasAccessDocument: false,
} }
} }
getPermission() { getPermission(subMenu) {
let payload = { let payload = {
menu: "document management" menu: subMenu
} }
api.create().getPermission(payload).then(response => { api.create().getPermission(payload).then(response => {
// console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ this.setState({
...@@ -60,28 +61,44 @@ export default class DocumentManagement extends Component { ...@@ -60,28 +61,44 @@ export default class DocumentManagement extends Component {
} }
selectTab = (event, newEvent) => { selectTab = (event, newEvent) => {
this.setState({ tab: newEvent }) this.setState({ tab: newEvent }, () => {
console.log(this.state.tab) console.log(this.state.tab)
this.getPermission(this.state.listData[this.state.tab].value.toLocaleLowerCase())
})
} }
componentDidMount() { componentDidMount() {
this.getDataDocument() this.getDataDocument()
this.getPermission() // this.getPermission()
this.getDetailUser() this.getDetailUser()
} }
getDataDocument(id, name) { getDataDocument(id, name) {
api.create().getDocumentCategory().then(response => { api.create().getDocumentCategory().then(response => {
// console.log(response); console.log(response);
if (response) { if (response) {
if (response.data.status === "success") { if (response.data.status === "success") {
let dataList = []
response.data.data.map((item, index) => {
// if (item.value == "Manual Book TIA 4.0sss") {
dataList.push(item)
// }
})
if (dataList.length == 0) {
this.setState({ isHasAccessDocument: dataList.length == 0 ? false : true })
} else {
this.setState({ this.setState({
listData: response.data.data, isHasAccessDocument: dataList.length == 0 ? false : true,
id: id === undefined ? response.data.data[0].setting_id : id, listData: dataList,
name: name === undefined ? response.data.data[0].value : name, id: id === undefined ? dataList[0].setting_id : id,
name: name === undefined ? dataList[0].value : name,
loadTable: true, loadTable: true,
refresh: id === undefined ? '' : 'create' refresh: id === undefined ? '' : 'create'
}, () => {
this.getPermission(dataList[0].value)
}) })
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) { if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
...@@ -255,7 +272,7 @@ export default class DocumentManagement extends Component { ...@@ -255,7 +272,7 @@ export default class DocumentManagement extends Component {
<Typography style={{ fontSize: '16px', color: 'white' }}>Document Management</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Document Management</Typography>
</div> </div>
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
{this.state.loading && loadingComponent} {this.state.loading && loadingComponent && this.state.isHasAccessDocument}
<Paper style={{ padding: 20 }}> <Paper style={{ padding: 20 }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}> <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
{(this.state.btncreate) && <span> {(this.state.btncreate) && <span>
...@@ -308,6 +325,11 @@ export default class DocumentManagement extends Component { ...@@ -308,6 +325,11 @@ export default class DocumentManagement extends Component {
</div> </div>
</Paper> </Paper>
{!this.state.isHasAccessDocument && (
<Paper style={{ padding: 20 }}>
<label>You Don't Have Any Access in Document Management</label>
</Paper>
)}
</div> </div>
{this.state.konfirmasi && ( {this.state.konfirmasi && (
<PopUpKonfirmasi <PopUpKonfirmasi
......
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