Commit 02881d0d authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

update ui create, edit, apprmatrix

parent b8835dc3
...@@ -34,7 +34,10 @@ export default class CreateApprovalMatrix extends Component { ...@@ -34,7 +34,10 @@ export default class CreateApprovalMatrix extends Component {
getUserData() { getUserData() {
api.create().getApprovedByAM().then((response) => { api.create().getApprovedByAM().then((response) => {
if (response.data.status == 'success') { if(response.status == null){
alert(response.problem)
}
else if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let userData = data.map((item) => { let userData = data.map((item) => {
return { return {
...@@ -49,7 +52,7 @@ export default class CreateApprovalMatrix extends Component { ...@@ -49,7 +52,7 @@ export default class CreateApprovalMatrix extends Component {
}; };
this.setState({ approvedBy: defaultProps, userData: response.data.data}) this.setState({ approvedBy: defaultProps, userData: response.data.data})
} else { } else {
alert(response.data.message) alert('Pemberi Persetujuan: ' +response.data.message)
} }
}) })
} }
...@@ -70,7 +73,7 @@ export default class CreateApprovalMatrix extends Component { ...@@ -70,7 +73,7 @@ export default class CreateApprovalMatrix extends Component {
}; };
this.setState({ types: typeProps, typeData: response.data.data }) this.setState({ types: typeProps, typeData: response.data.data })
} else { } else {
alert(response.data.message) alert('Tipe Persetujuan: ' +response.data.message)
} }
}) })
} }
...@@ -92,7 +95,7 @@ export default class CreateApprovalMatrix extends Component { ...@@ -92,7 +95,7 @@ export default class CreateApprovalMatrix extends Component {
}; };
this.setState({ operators: operatorProps, operatorData: response.data.data }) this.setState({ operators: operatorProps, operatorData: response.data.data })
} else { } else {
alert(response.data.message) alert('Operator: ' +response.data.message)
} }
}) })
} }
...@@ -125,10 +128,10 @@ export default class CreateApprovalMatrix extends Component { ...@@ -125,10 +128,10 @@ export default class CreateApprovalMatrix extends Component {
if (R.isEmpty(this.state.endDate)) return alert("Tanggal Berakhir is Required."); if (R.isEmpty(this.state.endDate)) return alert("Tanggal Berakhir is Required.");
console.log('masuk'); console.log('masuk');
let payload = { let payload = {
"approval_type_id": this.state.typeId, "approval_type_id": this.state.typeId.approval_type_id,
"orders": this.state.order, "orders": this.state.order,
"user_id": this.state.userId, "user_id": this.state.userId.user_id,
"operator_type_id": this.state.operatorId, "operator_type_id": this.state.operatorId.operator_type_id,
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate
} }
...@@ -187,20 +190,28 @@ export default class CreateApprovalMatrix extends Component { ...@@ -187,20 +190,28 @@ export default class CreateApprovalMatrix extends Component {
<Autocomplete <Autocomplete
{...this.state.types} {...this.state.types}
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({typeId:newInputValue.approval_type_id})} onChange={(event, newInputValue) => this.setState({typeId:newInputValue})}
disableClearable // disableClearable
renderInput={(params) => <TextField {...params} label="Tipe Persetujuan" />} debug
renderInput={(params) =>
<TextField
{...params}
label="Tipe Persetujuan"
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
/>
}
value={this.state.typeId}
// inputProps={{ // inputProps={{
// style: { // style: {
// fontSize: 11 // fontSize: 11
// } // }
// }} // }}
// InputLabelProps={{
// style: {
// fontSize: 11,
// color: '#7e8085'
// }
// }}
/> />
</div> </div>
</div> </div>
...@@ -232,24 +243,28 @@ export default class CreateApprovalMatrix extends Component { ...@@ -232,24 +243,28 @@ export default class CreateApprovalMatrix extends Component {
<div className="column-2"> <div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete <Autocomplete
// margin="normal"
{...this.state.approvedBy} {...this.state.approvedBy}
id="approvedby" id="approvedby"
onChange={(event, newInputValue) => this.setState({userId:newInputValue.user_id})} onChange={(event, newInputValue) => this.setState({userId:newInputValue})}
disableClearable // disableClearable
renderInput={(params) => <TextField {...params} label="Pemberi Persetujuan" />} debug
// value={this.state.value} renderInput={(params) =>
<TextField {...params}
label="Pemberi Persetujuan"
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
/>}
value={this.state.userId}
// inputProps={{ // inputProps={{
// style: { // style: {
// fontSize: 11 // fontSize: 11
// } // }
// }} // }}
// InputLabelProps={{
// style: {
// fontSize: 11,
// color: '#7e8085'
// }
// }}
// style={{ padding: 0, margin: 0, width: '100%'}} // style={{ padding: 0, margin: 0, width: '100%'}}
/> />
</div> </div>
...@@ -260,23 +275,27 @@ export default class CreateApprovalMatrix extends Component { ...@@ -260,23 +275,27 @@ export default class CreateApprovalMatrix extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete <Autocomplete
{...this.state.operators} {...this.state.operators}
// margin="normal"
id="operator" id="operator"
disableClearable // disableClearable
onChange={(event, newInputValue) => this.setState({operatorId:newInputValue.operator_type_id})} debug
renderInput={(params) => <TextField {...params} label="Operator" />} onChange={(event, newInputValue) => this.setState({operatorId:newInputValue})}
// value={this.state.value} renderInput={(params) =>
<TextField {...params}
label="Operator"
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
/>}
value={this.state.operatorId}
// inputProps={{ // inputProps={{
// style: { // style: {
// fontSize: 11 // fontSize: 11
// } // }
// }} // }}
// InputLabelProps={{
// style: {
// fontSize: 11,
// color: '#7e8085'
// }
// }}
// style={{ padding: 0, margin: 0, width: '100%' }} // style={{ padding: 0, margin: 0, width: '100%' }}
/> />
</div> </div>
......
...@@ -76,7 +76,7 @@ export default class EditApprovalMatrix extends Component { ...@@ -76,7 +76,7 @@ export default class EditApprovalMatrix extends Component {
}; };
this.setState({ approvedBy: defaultProps, userData: response.data.data, getApprovedBy: index == -1 ? userData[0]: userData[index] }) this.setState({ approvedBy: defaultProps, userData: response.data.data, getApprovedBy: index == -1 ? userData[0]: userData[index] })
} else { } else {
alert(response.data.message) alert('Pemberi Persetujuan: ' +response.data.message)
} }
}) })
} }
...@@ -98,7 +98,7 @@ export default class EditApprovalMatrix extends Component { ...@@ -98,7 +98,7 @@ export default class EditApprovalMatrix extends Component {
}; };
this.setState({ operators: operatorProps, operatorData: response.data.data, getOperators: index == -1 ? operatorData[0]: operatorData[index] }) this.setState({ operators: operatorProps, operatorData: response.data.data, getOperators: index == -1 ? operatorData[0]: operatorData[index] })
} else { } else {
alert(response.data.message) alert('Operator: ' +response.data.message)
} }
}) })
} }
...@@ -120,7 +120,7 @@ export default class EditApprovalMatrix extends Component { ...@@ -120,7 +120,7 @@ export default class EditApprovalMatrix extends Component {
}; };
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0]: typeData[index] }) this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0]: typeData[index] })
} else { } else {
alert(response.data.message) alert('Tipe Persetujuan: ' +response.data.message)
} }
}) })
} }
...@@ -144,10 +144,10 @@ export default class EditApprovalMatrix extends Component { ...@@ -144,10 +144,10 @@ export default class EditApprovalMatrix extends Component {
} }
validasi() { validasi() {
if (R.isNil(this.state.getTypeId)) return alert("Tipe Persetujuan is Required."); if (R.isNil(this.state.getTypes)) return alert("Tipe Persetujuan is Required.");
if (R.isEmpty(this.state.order)) return alert("Order is Required."); if (R.isEmpty(this.state.order)) return alert("Order is Required.");
if (R.isNil(this.state.getUserId)) return alert("Pemberi Persetujuan is Required."); if (R.isNil(this.state.getApprovedBy)) return alert("Pemberi Persetujuan is Required.");
if (R.isNil(this.state.getOperatorId)) return alert("Operator is Required."); if (R.isNil(this.state.getOperators)) return alert("Operator is Required.");
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"); 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");
if (R.isEmpty(this.state.startDate)) return alert("Tanggal Mulai is Required."); if (R.isEmpty(this.state.startDate)) return alert("Tanggal Mulai is Required.");
if (R.isEmpty(this.state.endDate)) return alert("Tanggal Berakhir is Required."); if (R.isEmpty(this.state.endDate)) return alert("Tanggal Berakhir is Required.");
...@@ -223,10 +223,20 @@ export default class EditApprovalMatrix extends Component { ...@@ -223,10 +223,20 @@ export default class EditApprovalMatrix extends Component {
<Autocomplete <Autocomplete
{...this.state.types} {...this.state.types}
option option
disableClearable debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({getTypes:newInputValue})} onChange={(event, newInputValue) => this.setState({getTypes:newInputValue})}
renderInput={(params) => <TextField {...params} label="Tipe Persetujuan" />} renderInput={(params) =>
<TextField {...params}
label="Tipe Persetujuan"
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
/>}
value={this.state.getTypes} value={this.state.getTypes}
/> />
</div> </div>
...@@ -261,10 +271,20 @@ export default class EditApprovalMatrix extends Component { ...@@ -261,10 +271,20 @@ export default class EditApprovalMatrix extends Component {
<Autocomplete <Autocomplete
{...this.state.approvedBy} {...this.state.approvedBy}
option option
disableClearable debug
id="approvedby" id="approvedby"
onChange={(event, newInputValue) => this.setState({getApprovedBy: newInputValue})} onChange={(event, newInputValue) => this.setState({getApprovedBy: newInputValue})}
renderInput={(params) => <TextField {...params} label="Pemberi Persetujuan" />} renderInput={(params) =>
<TextField {...params}
label="Pemberi Persetujuan"
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
/>}
value={this.state.getApprovedBy} value={this.state.getApprovedBy}
/> />
</div> </div>
...@@ -279,7 +299,17 @@ export default class EditApprovalMatrix extends Component { ...@@ -279,7 +299,17 @@ export default class EditApprovalMatrix extends Component {
disableClearable disableClearable
id="operator" id="operator"
onChange={(event, newInputValue) => this.setState({getOperators: newInputValue})} onChange={(event, newInputValue) => this.setState({getOperators: newInputValue})}
renderInput={(params) => <TextField {...params} label="Operator" />} renderInput={(params) =>
<TextField {...params}
label="Operator"
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
/>}
value={this.state.getOperators} value={this.state.getOperators}
/> />
</div> </div>
......
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