Commit 41028645 authored by a.bairuha's avatar a.bairuha

update

parent 07bc1c51
...@@ -7,6 +7,7 @@ import Autocomplete from '@material-ui/lab/Autocomplete'; ...@@ -7,6 +7,7 @@ import Autocomplete from '@material-ui/lab/Autocomplete';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import api from '../../../api'; import api from '../../../api';
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import Constant from '../../../library/Constant';
const Alert = withStyles({ const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); })((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -71,23 +72,34 @@ export default class CreatePerusahaan extends Component { ...@@ -71,23 +72,34 @@ export default class CreatePerusahaan extends Component {
api.create().getDetailPerusahaan(this.props.data[1]).then(response => { api.create().getDetailPerusahaan(this.props.data[1]).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.ok) {
this.setState({ if (response.data.status === "success") {
businessID: response.data.data.business_unit_id, this.setState({
companyID: response.data.data.company_id, businessID: response.data.data.business_unit_id,
status: response.data.data.status, companyID: response.data.data.company_id,
company: response.data.data.company_name, status: response.data.data.status,
parentID: response.data.data.parent, company: response.data.data.company_name,
parent: response.data.data.parent_name, parentID: response.data.data.parent,
startDate: response.data.data.start_date, parent: response.data.data.parent_name,
endDate: response.data.data.end_date, startDate: response.data.data.start_date,
totalReport: response.data.data.total_report, endDate: response.data.data.end_date,
created: response.data.data.created, totalReport: response.data.data.total_report,
updated: response.data.data.updated === null ? "" : response.data.data.updated created: response.data.data.created,
}, () => this.getAllUnitBisnis(), this.getCompanyActive()) updated: response.data.data.updated === null ? "" : response.data.data.updated
}, () => this.getAllUnitBisnis(), this.getCompanyActive())
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
...@@ -103,23 +115,34 @@ export default class CreatePerusahaan extends Component { ...@@ -103,23 +115,34 @@ export default class CreatePerusahaan extends Component {
api.create().getPerusahaanActive(payload).then(response => { api.create().getPerusahaanActive(payload).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status == 'success') { if (response.ok) {
let data = response.data.data if (response.data.status == 'success') {
let perusahaanData = data.map((item) => { let data = response.data.data
return { let perusahaanData = data.map((item) => {
company_id: item.company_id, return {
company_name: item.company_name company_id: item.company_id,
} company_name: item.company_name
}) }
let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.parentID) })
let typeProps = { let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.parentID)
options: perusahaanData, let typeProps = {
getOptionLabel: (option) => option.company_name, options: perusahaanData,
}; getOptionLabel: (option) => option.company_name,
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index] }) };
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
...@@ -130,25 +153,36 @@ export default class CreatePerusahaan extends Component { ...@@ -130,25 +153,36 @@ export default class CreatePerusahaan extends Component {
getAllUnitBisnis() { getAllUnitBisnis() {
api.create().getUnitBisnisActive().then(response => { api.create().getUnitBisnisActive().then(response => {
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.ok) {
let data = response.data.data if (response.data.status === 'success') {
let typeData = data.map((item) => { let data = response.data.data
return { let typeData = data.map((item) => {
business_unit_id: item.business_unit_id, return {
business_unit_name: item.business_unit_name business_unit_id: item.business_unit_id,
} business_unit_name: item.business_unit_name
}) }
// console.log(typeData) })
let index = typeData.findIndex((val) => val.business_unit_id == this.state.businessID) // console.log(typeData)
console.log(index) let index = typeData.findIndex((val) => val.business_unit_id == this.state.businessID)
let typeProps = { console.log(index)
options: typeData, let typeProps = {
getOptionLabel: (option) => option.business_unit_name, options: typeData,
}; getOptionLabel: (option) => option.business_unit_name,
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index] }) };
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
......
...@@ -7,6 +7,7 @@ import Nestable from 'react-nestable/dist/Nestable'; ...@@ -7,6 +7,7 @@ import Nestable from 'react-nestable/dist/Nestable';
import AddIcon from '@material-ui/icons/Add'; import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove'; import RemoveIcon from '@material-ui/icons/Remove';
import api from '../../../api'; import api from '../../../api';
import Constant from '../../../library/Constant';
const Alert = withStyles({ const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); })((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -55,11 +56,22 @@ export default class VisualPerusahaan extends Component { ...@@ -55,11 +56,22 @@ export default class VisualPerusahaan extends Component {
api.create().getPerusahaanHierarki().then((response) => { api.create().getPerusahaanHierarki().then((response) => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status == 'success') { if (response.ok) {
this.setState({ items: response.data.data }) if (response.data.status == 'success') {
console.log(response.data.data) this.setState({ items: response.data.data })
console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -89,8 +101,26 @@ export default class VisualPerusahaan extends Component { ...@@ -89,8 +101,26 @@ export default class VisualPerusahaan extends Component {
"company": this.state.items "company": this.state.items
} }
api.create().saveVisualisasiPerusahaan(payload).then((response) => { api.create().saveVisualisasiPerusahaan(payload).then((response) => {
// if (response.data.status == 'ucces') { if (response.data) {
this.props.onClickClose() if (response.ok) {
if (response.data.status == 'success') {
this.props.onClickClose()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
// } else { // } else {
// alert(response.data.message) // alert(response.data.message)
// } // }
......
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