Commit a9dbf53e authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'faisal' into 'master'

update kumpeni

See merge request !277
parents 5b5d61a0 a3b1109e
...@@ -143,7 +143,11 @@ export default class CreatePerusahaan extends Component { ...@@ -143,7 +143,11 @@ export default class CreatePerusahaan extends Component {
options: perusahaanData, options: perusahaanData,
getOptionLabel: (option) => option.company_name, getOptionLabel: (option) => option.company_name,
}; };
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index], msgErrorPC: index === -1 ? 'Company has been Inactive' : "", errorPC: index === -1 ? true : false }) if (this.props.type === 'edit') {
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index], msgErrorPC: index === -1 ? 'Company has been Inactive' : "", errorPC: index === -1 ? true : false })
} else {
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index] })
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -182,8 +186,12 @@ export default class CreatePerusahaan extends Component { ...@@ -182,8 +186,12 @@ export default class CreatePerusahaan extends Component {
let typeProps = { let typeProps = {
options: typeData, options: typeData,
getOptionLabel: (option) => option.business_unit_name, getOptionLabel: (option) => option.business_unit_name,
}; };
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index], msgErrorUB: index === -1 ? 'Business Unit has been Inactive' : "", errorUB: index === -1 ? true : false }) if (this.props.type === 'edit') {
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index], msgErrorUB: index === -1 ? 'Business Unit has been Inactive' : "", errorUB: index === -1 ? true : false })
} else {
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index] })
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
......
...@@ -439,6 +439,33 @@ export default class Perusahaan extends Component { ...@@ -439,6 +439,33 @@ export default class Perusahaan extends Component {
}) })
} }
updateHierarchy = (payload) => {
this.setState({ visibleVisual: false, visiblePerusahaan: true })
api.create().saveVisualisasiPerusahaan(payload).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
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' })
}
})
}
downloadFile = async () => { downloadFile = async () => {
let res = await fetch( let res = await fetch(
"https://tia.eksad.com/tia-reporting-dev/public/attachment/download_file?fileName=CompanyTemplate&&fileType=xlsx" "https://tia.eksad.com/tia-reporting-dev/public/attachment/download_file?fileName=CompanyTemplate&&fileType=xlsx"
...@@ -737,9 +764,9 @@ export default class Perusahaan extends Component { ...@@ -737,9 +764,9 @@ export default class Perusahaan extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => null} onClick={() => this.setState({ visibleVisual: true, visiblePerusahaan: false })}
> >
<img src={Images.visualisasi} onClick={() => this.setState({ visibleVisual: true, visiblePerusahaan: false })} /> <img src={Images.visualisasi} />
</button> </button>
</a> </a>
<ReactTooltip border={true} id="visual" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="visual" place="bottom" type="light" effect="solid" />
...@@ -783,6 +810,7 @@ export default class Perusahaan extends Component { ...@@ -783,6 +810,7 @@ export default class Perusahaan extends Component {
buttonEdit={this.state.edit} buttonEdit={this.state.edit}
onClickClose={() => this.setState({ visibleVisual: false, visiblePerusahaan: true })} onClickClose={() => this.setState({ visibleVisual: false, visiblePerusahaan: true })}
height={this.props.height} height={this.props.height}
updateHierarchy={this.updateHierarchy.bind(this)}
/> />
: :
<div> <div>
......
...@@ -100,7 +100,9 @@ export default class VisualPerusahaan extends Component { ...@@ -100,7 +100,9 @@ export default class VisualPerusahaan extends Component {
let payload = { let payload = {
"company": this.state.items "company": this.state.items
} }
api.create().saveVisualisasiPerusahaan(payload).then((response) => { this.props.updateHierarchy(payload)
/* api.create().saveVisualisasiPerusahaan(payload).then((response) => {
// console.log(response.data)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
...@@ -129,7 +131,7 @@ export default class VisualPerusahaan extends Component { ...@@ -129,7 +131,7 @@ export default class VisualPerusahaan extends Component {
// } else { // } else {
// alert(response.data.message) // alert(response.data.message)
// } // }
}) }) */
} }
renderItem = ({ item, collapseIcon }) => { renderItem = ({ item, collapseIcon }) => {
......
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