Commit f3ba480d authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

rapiin validasi

parent ad779c59
......@@ -232,41 +232,53 @@ export default class CreateManagementDoc extends Component {
validasi() {
if (String(this.props.name).includes('Manual Book TIA')){
if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
} else if (R.isNil(this.state.getDocument)) {
this.setState({ errorDocument: true, msgErrorDocument: 'Category Cannot be Empty' })
} else if (R.isNil(this.state.file)) {
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
} else {
if (R.isNil(this.state.periode)) {
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
} else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
}
const formData = new FormData();
formData.append("file", this.state.file);
formData.append("companyId", this.state.getPerusahaan.company_id);
formData.append("settingId", this.state.getDocument.document_category_id);
formData.append("description", this.state.description);
formData.append("extension", this.state.fileType);
formData.append("documentPeriode", null);
formData.append("documentMonth", null);
this.setState({ formData }, ()=> {
this.props.createDocument(this.state.formData, this.props.setting_id)
})
}
} else {
if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
} else if (R.isNil(this.state.getDocument)) {
this.setState({ errorDocument: true, msgErrorDocument: 'Category Cannot be Empty' })
} else if (R.isNil(this.state.periode)) {
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
} else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
}
else if (R.isNil(this.state.file)) {
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
} else {
console.log("save")
const formData = new FormData();
formData.append("file", this.state.file);
formData.append("companyId", this.state.getPerusahaan.company_id);
formData.append("settingId", this.state.getDocument.document_category_id);
formData.append("description", this.state.description);
formData.append("extension", this.state.fileType);
if(String(this.props.name).includes('Manual Book TIA')){
formData.append("documentPeriode", null);
formData.append("documentMonth", null);
} else {
formData.append("documentPeriode", this.state.periode.periode);
formData.append("documentMonth", this.state.monthId.month_id);
}
this.setState({ formData }, ()=> {
this.props.createDocument(this.state.formData, this.props.setting_id)
})
}
}
}
deleteFile(e){
this.setState({ file: null})
......
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