Commit 14e0c78a authored by muhammad ridwan's avatar muhammad ridwan

Merge branch 'env/ridwan' into 'ENV-DEV-CR-CAFRM'

bug fixing v6

See merge request !1590
parents 3c445104 549f7718
......@@ -20,15 +20,15 @@ export default class CarfmDocument extends Component {
alert: false,
listData: [],
id: 0,
btncreate: false,
btnview: false,
load: false,
name: '',
userCompActive: [],
isHasAccessDocument: true,
submenu_id : 0,
submenu_name: "",
menu_title: ""
menu_title: "",
loading: true,
finishLoad: false,
}
}
......@@ -37,8 +37,12 @@ export default class CarfmDocument extends Component {
// this.getPermission()
await this.getMenuName();
await this.getPermission(this.state.submenu_name)
await this.getDataCarfm();
await this.getDetailUser();
await this.setState({
finishLoad: true
})
}
......@@ -77,25 +81,20 @@ export default class CarfmDocument extends Component {
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({
isHasAccessDocument: dataList.length == 0 ? false : true,
isHasAccessDocument: true,
listData: dataList,
loadTable: true,
refresh: create == undefined ? '' : create
}, () => {
this.getPermission(this.state.submenu_name)
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
......@@ -117,13 +116,17 @@ export default class CarfmDocument extends Component {
}
await api.create().getPermission(payload).then(response => {
if (response.data) {
console.log(`status get permission ${response.data.status}`);
if (response.data.status === "success") {
this.setState({
btncreate: response.data.data.create,
btnview: response.data.data.view,
btndownload: response.data.data.download,
load: true
load: true,
})
this.setState({
}, console.log(`btnview ${this.state.btnview}, btncreate ${this.state.btncreate}, btndownload ${this.state.btnview}`), console.log(response.data.data))
console.log("btn create " + this.state.btncreate);
} else {
this.setState({
......@@ -142,7 +145,7 @@ export default class CarfmDocument extends Component {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company, visibleTrue: false }, () => {
this.setState({ userCompany: response.data.data.company, visibleTrue: false, loading: false }, () => {
this.getCompanyActive()
console.log(this.state.userCompany);
})
......@@ -155,7 +158,7 @@ export default class CarfmDocument extends Component {
async getCompanyActive() {
await api.create().getPerusahaanActive().then((response) => {
console.log("getcompanyactive start");
console.log(response);
console.log(response.data.data);
console.log("getcompanyactive stop");
if (response.data) {
if (response.data.status === 'success') {
......@@ -163,8 +166,7 @@ export default class CarfmDocument extends Component {
let compActive = []
let userCompActive = []
this.state.userCompany.map((item, index) => {
let indeks = data.findIndex((val) => val.company_id == item)
if (indeks !== -1 && String(data[indeks].status).toLocaleLowerCase() == 'active'){
if (index !== -1 && String(data[index].status).toLocaleLowerCase() == 'active'){
userCompActive.push(item)
}
})
......@@ -179,7 +181,8 @@ export default class CarfmDocument extends Component {
this.setState({ btnadd: false})
}
this.setState({ userCompActive, visibleTrue: true })
// console.log(userCompActive)
console.log("usercompactive")
console.log(userCompActive)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', visibleTrue: true }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
......@@ -276,10 +279,11 @@ export default class CarfmDocument extends Component {
{this.state.loading && loadingComponent}
<Paper style={{padding: 20}}>
{this.state.btnview && this.state.finishLoad && (
<Paper style={{padding: 20}}>
<div style={{display: 'flex', justifyContent: 'flex-end'}}>
{console.log("renderbtn" + this.state.btncreate)}
{(this.state.btncreate) && <span>
<a data-tip={'Add'} data-for="add">
<div style={{display: 'grid', justifyContent: 'flex-end'}}>
......@@ -299,24 +303,24 @@ export default class CarfmDocument extends Component {
<div style={{display: 'flex'}}>
{this.state.visibleTrue && (<TableDocument
data={this.state.listData}
refresh={this.state.refresh}
load={true}
userCompActive={this.state.userCompActive}
handleLoading={this.handleLoading.bind(this)}
name={this.state.name}
submenu_id={this.state.submenu_id}
btndownload = {this.state.btndownload}
/>)}
{this.state.visibleTrue && (
<TableDocument
data={this.state.listData}
refresh={this.state.refresh}
load={true}
userCompActive={this.state.userCompActive}
handleLoading={this.handleLoading.bind(this)}
name={this.state.name}
submenu_id={this.state.submenu_id}
btndownload = {this.state.btndownload}
/>
)}
</div>
</Paper>
)}
{!this.state.isHasAccessDocument && (
{!this.state.btnview && this.state.finishLoad && (
<Paper style={{ padding: 20 }}>
<label>You Don't Have Any Access in Document Management</label>
</Paper>
......
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