Commit 1415023b authored by d.arizona's avatar d.arizona

astaga

parent 8edbff14
import React, { Component } from 'react';
import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, withStyles, makeStyles } from '@material-ui/core';
import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, withStyles, makeStyles, Snackbar } from '@material-ui/core';
import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
import api from '../../api';
......@@ -11,7 +11,7 @@ import ReactTooltip from 'react-tooltip';
import Tooltip from '@material-ui/core/Tooltip';
import { titleCase } from '../../library/Utils';
import Constant from '../../library/Constant';
import { Autocomplete } from '@material-ui/lab';
import { Alert, Autocomplete } from '@material-ui/lab';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
......@@ -60,7 +60,7 @@ export default class CorporateAnnualTarget extends Component {
kpiTypeList: [],
maxAchList: [],
visibleCAT: true,
buttonError: false,
buttonError: true,
// formulaYTDList: null,,
dataDelete: []
}
......@@ -384,6 +384,63 @@ export default class CorporateAnnualTarget extends Component {
})
}
handleValidate() {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
// console.log(i[9] == null? "" : i[9].value)
data.push({
"item_report_id": i[1],
"item_name": i[1] !== ""? null : String(i[6]),
"parent": i[1] !== ""? null : i[2],
"weight": String(i[7]),
"uom": String(i[8]),
"kpi_type": i[9] == null? "" : i[9].value,
"max_ach": i[10] == null? "" : i[10].value,
"formula": i[11] == null? "" : i[11].value,
"total_actual_before": String(i[12]),
"january": String(i[13]),
"february": String(i[14]),
"march": String(i[15]),
"april": String(i[16]),
"may": String(i[17]),
"june": String(i[18]),
"july": String(i[19]),
"august": String(i[20]),
"september": String(i[21]),
"october": String(i[22]),
"november": String(i[23]),
"december": String(i[24]),
"total_current_year": String(i[25]),
"total_next_year": String(i[26]),
"total_more_year": String(i[27]),
"strategic": String(i[28]),
"pic": String(i[29])
})
})
console.log(JSON.stringify(data))
let payload = {
"submission_id": this.props.submissionID,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": "submitted",
"cat": data
}
api.create().validateSubmitReport(payload).then((response) => {
console.log(response)
if (response.data.data.result) {
this.setState({ loading: false, buttonError: false, editable: true })
} else {
this.setState({ loading: false, buttonError: true, editable: true })
}
})
}
closeAlert() {
this.setState({ alert: false })
}
backToMasterBudget(type) {
let data = []
console.log(this.state.dataTable)
......@@ -461,6 +518,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
getKPIType() {
let body = {
group: 'CAT',
......@@ -1718,6 +1776,11 @@ export default class CorporateAnnualTarget extends Component {
<Typography style={{ fontSize: '16px', color: 'white' }}>Pengajuan Budget Tahunan</Typography>
</div>
{/* {this.state.loading && loadingComponent} */}
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleCAT? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
......@@ -1804,7 +1867,7 @@ export default class CorporateAnnualTarget extends Component {
cursor: 'pointer',
borderColor: 'transparent',
}}
onClick={() => this.props.onClickClose()}
onClick={() => this.backToMasterBudget('draft')}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
......@@ -1845,7 +1908,7 @@ export default class CorporateAnnualTarget extends Component {
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: false, editable: true })
this.handleValidate()
}, 100);
})
}}
......@@ -1856,8 +1919,10 @@ export default class CorporateAnnualTarget extends Component {
</button>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.backToMasterBudget('submitted')}
// disabled={this.state.buttonError}
onClick={() => this.state.buttonError?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
: this.backToMasterBudget('submitted')}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
......
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