Commit 76bf230a authored by muhammad ridwan's avatar muhammad ridwan

Merge branch 'ENV-DEV-CR-CAFRM' into 'ENV-DEPLOYMENT'

Env dev cr cafrm

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