Commit 3799d451 authored by faisalhamdi's avatar faisalhamdi

update action company

parent 4c88492d
...@@ -48,9 +48,8 @@ export default class CreatePerusahaan extends Component { ...@@ -48,9 +48,8 @@ export default class CreatePerusahaan extends Component {
this.getParentCompany() this.getParentCompany()
this.getAllUnitBisnis() this.getAllUnitBisnis()
if(this.props.type === 'edit') { if(this.props.type === 'edit') {
let data = this.props.data this.getDetailPerusahaan()
this.getDetailPerusahaan(data.company_id,) // console.log(this.props.data);
console.log(this.props.data);
} else { } else {
let date = format(new Date, 'yyyy-MM-dd') let date = format(new Date, 'yyyy-MM-dd')
// console.log(date); // console.log(date);
...@@ -61,8 +60,8 @@ export default class CreatePerusahaan extends Component { ...@@ -61,8 +60,8 @@ export default class CreatePerusahaan extends Component {
} }
} }
getDetailPerusahaan(id) { getDetailPerusahaan() {
api.create().getDetailPerusahaan(id).then(response => { api.create().getDetailPerusahaan(this.props.data[1]).then(response => {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response); console.log(response);
this.setState({ this.setState({
...@@ -218,14 +217,14 @@ export default class CreatePerusahaan extends Component { ...@@ -218,14 +217,14 @@ export default class CreatePerusahaan extends Component {
this.setState({ errorED: true, msgErrorED: 'End Date tidak boleh kosong' }) this.setState({ errorED: true, msgErrorED: 'End Date tidak boleh kosong' })
} else if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) { } else if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) {
return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai") return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai")
} else if (R.isEmpty(this.state.totalReport)) { // } else if (R.isEmpty(this.state.totalReport)) {
this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' }) // this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' })
} else { } else {
let payload = { let payload = {
"company_name": this.state.company, "company_name": this.state.company,
"parent": this.state.getPerusahaan.company_id, "parent": this.state.getPerusahaan.company_id,
"business_unit_id": this.state.getTypes.business_unit_id, "business_unit_id": this.state.getTypes.business_unit_id,
"total_report": this.state.totalReport, // "total_report": this.state.totalReport,
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate
} }
...@@ -343,7 +342,7 @@ export default class CreatePerusahaan extends Component { ...@@ -343,7 +342,7 @@ export default class CreatePerusahaan extends Component {
</div> </div>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography> <Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.updated == - null ? "" : this.props.data.updated}</Typography> <Typography style={{ fontSize: 11 }}>: {this.state.updated}</Typography>
</div> </div>
</div> </div>
</div> </div>
...@@ -652,7 +651,7 @@ export default class CreatePerusahaan extends Component { ...@@ -652,7 +651,7 @@ export default class CreatePerusahaan extends Component {
style={{ padding: 0, margin: 0, width: '100%' }} style={{ padding: 0, margin: 0, width: '100%' }}
/> />
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> {/* <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="report" id="report"
...@@ -674,7 +673,7 @@ export default class CreatePerusahaan extends Component { ...@@ -674,7 +673,7 @@ export default class CreatePerusahaan extends Component {
onChange={(e) => this.setState({ totalReport: e.target.value }, () => this.clearError())} onChange={(e) => this.setState({ totalReport: e.target.value }, () => this.clearError())}
> >
</TextField> </TextField>
</div> </div> */}
</div> </div>
</div> </div>
......
...@@ -238,7 +238,7 @@ export default class Perusahaan extends Component { ...@@ -238,7 +238,7 @@ export default class Perusahaan extends Component {
console.log(response) console.log(response)
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.sort((a, b) => a.company_id - b.company_id).map((item, index) => {
return [index, item.company_id, item.company_name, item.parent_name, item.business_unit_name, item.total_report, item.status] return [index, item.company_id, item.company_name, item.parent_name, item.business_unit_name, item.total_report, item.status]
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
...@@ -248,15 +248,15 @@ export default class Perusahaan extends Component { ...@@ -248,15 +248,15 @@ export default class Perusahaan extends Component {
}) })
} }
openPopUp(index, type) { openPopUp(rowData, type) {
if (type === 'edit') { if (type === 'edit') {
this.setState({ this.setState({
selectIndex: index, rowData: rowData,
visibleEdit: true visibleEdit: true
}) })
} else { } else {
this.setState({ this.setState({
data: this.state.listData[index], rowData: rowData,
visibleCreate: true visibleCreate: true
}) })
} }
...@@ -268,7 +268,7 @@ export default class Perusahaan extends Component { ...@@ -268,7 +268,7 @@ export default class Perusahaan extends Component {
"keyword": e "keyword": e
} }
api.create().searchPerusahaan(body).then(response => { api.create().searchPerusahaan(body).then(response => {
console.log(response.data); // console.log(response.data);
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
...@@ -357,7 +357,7 @@ export default class Perusahaan extends Component { ...@@ -357,7 +357,7 @@ export default class Perusahaan extends Component {
borderColor: 'transparent' borderColor: 'transparent'
}} }}
// onClick={() => this.setState({ visibleEdit: true, data: tableMeta.rowData })} // onClick={() => this.setState({ visibleEdit: true, data: tableMeta.rowData })}
onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')} onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
...@@ -585,7 +585,7 @@ export default class Perusahaan extends Component { ...@@ -585,7 +585,7 @@ export default class Perusahaan extends Component {
<CreatePerusahaan <CreatePerusahaan
type={"edit"} type={"edit"}
onClickClose={() => this.setState({ visibleEdit: false })} onClickClose={() => this.setState({ visibleEdit: false })}
data={this.state.listData[this.state.selectIndex]} data={this.state.rowData}
updatePerusahaan={this.updatePerusahaan.bind(this)} updatePerusahaan={this.updatePerusahaan.bind(this)}
/> />
)} )}
......
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