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