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

rapiin validasi

parent ad779c59
...@@ -232,40 +232,52 @@ export default class CreateManagementDoc extends Component { ...@@ -232,40 +232,52 @@ export default class CreateManagementDoc extends Component {
validasi() { validasi() {
if (String(this.props.name).includes('Manual Book TIA')){ 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 {
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 { } else {
if (R.isNil(this.state.periode)) { 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' }) this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
} else if (R.isNil(this.state.monthId)) { } else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' }) this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
} }
} else if (R.isNil(this.state.file)) {
if (R.isNil(this.state.getPerusahaan)) { this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
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 {
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 { } else {
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", this.state.periode.periode); formData.append("documentPeriode", this.state.periode.periode);
formData.append("documentMonth", this.state.monthId.month_id); formData.append("documentMonth", this.state.monthId.month_id);
this.setState({ formData }, ()=> {
this.props.createDocument(this.state.formData, this.props.setting_id)
})
} }
this.setState({ formData }, ()=> { }
this.props.createDocument(this.state.formData, this.props.setting_id)
})
}
} }
deleteFile(e){ deleteFile(e){
......
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