Commit e216e637 authored by Deni Rinaldi's avatar Deni Rinaldi

updateBalancesitttt & upload size

parent 24f6eb8f
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input } from '@material-ui/core'; import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, Tooltip, withStyles } from '@material-ui/core';
import MUIDataTable from 'mui-datatables'; import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import api from '../../api'; import api from '../../api';
...@@ -11,6 +11,15 @@ import ReactTooltip from 'react-tooltip'; ...@@ -11,6 +11,15 @@ import ReactTooltip from 'react-tooltip';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
const LightTooltip = withStyles((theme) => ({
tooltip: {
backgroundColor: theme.palette.common.white,
color: 'rgba(0, 0, 0, 0.87)',
boxShadow: theme.shadows[1],
fontSize: 11,
},
}))(Tooltip);
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3()); const getMuiTheme = () => createMuiTheme(ct.customTable3());
...@@ -34,7 +43,8 @@ export default class BalanceSheet extends Component { ...@@ -34,7 +43,8 @@ export default class BalanceSheet extends Component {
dataTable: [], dataTable: [],
visibleBalanceSheet: true, visibleBalanceSheet: true,
disabledSave: true, disabledSave: true,
editable: false editable: false,
buttonError: false
} }
this.handleValue = this.handleValue.bind(this) this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -128,7 +138,7 @@ export default class BalanceSheet extends Component { ...@@ -128,7 +138,7 @@ export default class BalanceSheet extends Component {
} }
} }
}) })
this.setState({ dataTable, loading: false }) this.setState({ dataTable, loading: false, buttonError: true })
}) })
} }
...@@ -222,27 +232,28 @@ export default class BalanceSheet extends Component { ...@@ -222,27 +232,28 @@ export default class BalanceSheet extends Component {
let isi = resp.rows.slice(3) let isi = resp.rows.slice(3)
console.log(isi); console.log(isi);
let payload = [] let payload = []
let reg = /^\d+$/;
isi.map((i, index) => { isi.map((i, index) => {
if (i.length > 0) { if (i.length > 0) {
payload.push({ payload.push({
item_report_id: i[0] === undefined ? "" : String(i[0]).trim(), item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
item_report: i[1] === undefined ? "" : String(i[1]).trim(), item_report: i[1] === undefined ? "" : String(i[1]).trim(),
total_actual_before: i[2] === undefined ? "" : String(i[2]).trim(), total_actual_before: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
january: i[3] === undefined ? "" : String(i[3]).trim(), january: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
february: i[4] === undefined ? "" : String(i[4]).trim(), february: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
march: i[5] === undefined ? "" : String(i[5]).trim(), march: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
april: i[6] === undefined ? "" : String(i[6]).trim(), april: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
may: i[7] === undefined ? "" : String(i[7]).trim(), may: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
june: i[8] === undefined ? "" : String(i[8]).trim(), june: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
july: i[9] === undefined ? "" : String(i[9]).trim(), july: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
august: i[10] === undefined ? "" : String(i[10]).trim(), august: i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
september: i[11] === undefined ? "" : String(i[11]).trim(), september: i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
october: i[12] === undefined ? "" : String(i[12]).trim(), october: i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
november: i[13] === undefined ? "" : String(i[13]).trim(), november: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
december: i[14] === undefined ? "" : String(i[14]).trim(), december: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
total_current_year: i[15] === undefined ? "" : String(i[15]).trim(), total_current_year: i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
total_next_year: i[16] === undefined ? "" : String(i[16]).trim(), total_next_year: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
total_more_year: i[16] === undefined ? "" : String(i[17]).trim() total_more_year: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()
}) })
} }
}) })
...@@ -252,15 +263,15 @@ export default class BalanceSheet extends Component { ...@@ -252,15 +263,15 @@ export default class BalanceSheet extends Component {
report_id: this.props.report_id, report_id: this.props.report_id,
balance_sheet: payload balance_sheet: payload
} }
// console.log(JSON.stringify(body)) console.log(body)
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] }) this.setState({ payload: body, judul: resp.rows[1][0] })
} }
}); });
} }
checkUpload() { checkUpload() {
api.create().checkUploadMB(this.state.payload).then(response => { api.create().checkUploadMB(this.state.payload).then(response => {
console.log(JSON.stringify(this.state.payload)); // console.log(JSON.stringify(this.state.payload));
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
...@@ -292,20 +303,16 @@ export default class BalanceSheet extends Component { ...@@ -292,20 +303,16 @@ export default class BalanceSheet extends Component {
item.error item.error
] ]
}) })
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }) this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
if (this.state.dataTable[22].length > 0) {
this.setState({ buttonError: true, errorPreview: true })
}
})
} }
} }
}) })
} }
checkError(tableMeta) {
if (tableMeta.rowData[22]) {
if (tableMeta.rowData[22][0] === 'item') {
this.setState({ buttonError: true })
}
}
}
uploadBalanceSheet() { uploadBalanceSheet() {
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
...@@ -477,26 +484,11 @@ export default class BalanceSheet extends Component { ...@@ -477,26 +484,11 @@ export default class BalanceSheet extends Component {
<div style={{ width: 300 }}> <div style={{ width: 300 }}>
{tableMeta.rowData[22] ? {tableMeta.rowData[22] ?
tableMeta.rowData[22].length > 0 ? tableMeta.rowData[22].length > 0 ?
tableMeta.rowData[22][0].field === 'item' ? <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
tableMeta.rowData[4] == 0 ? <LightTooltip title={"Report Items Not Registered"} arrow>
<a data-tip={tableMeta.rowData[22][0].message} data-for="account"> <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
<span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span> </LightTooltip>
{this.checkError(tableMeta)} </div>
</a>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
{this.checkError(tableMeta)}
</a>
</div>
:
tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
: :
tableMeta.rowData[4] == 0 ? tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span> <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
...@@ -512,7 +504,6 @@ export default class BalanceSheet extends Component { ...@@ -512,7 +504,6 @@ export default class BalanceSheet extends Component {
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span> <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div> </div>
} }
<ReactTooltip border={true} id="account" place="bottom" type="light" effect="solid" />
</div> </div>
) )
} }
...@@ -598,7 +589,7 @@ export default class BalanceSheet extends Component { ...@@ -598,7 +589,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -629,7 +620,6 @@ export default class BalanceSheet extends Component { ...@@ -629,7 +620,6 @@ export default class BalanceSheet extends Component {
placeholder="" placeholder=""
value={value} value={value}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
console.log(dataTable2) console.log(dataTable2)
}} }}
...@@ -685,7 +675,7 @@ export default class BalanceSheet extends Component { ...@@ -685,7 +675,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -772,7 +762,7 @@ export default class BalanceSheet extends Component { ...@@ -772,7 +762,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -859,7 +849,7 @@ export default class BalanceSheet extends Component { ...@@ -859,7 +849,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -946,7 +936,7 @@ export default class BalanceSheet extends Component { ...@@ -946,7 +936,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1033,7 +1023,7 @@ export default class BalanceSheet extends Component { ...@@ -1033,7 +1023,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1120,7 +1110,7 @@ export default class BalanceSheet extends Component { ...@@ -1120,7 +1110,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1207,7 +1197,7 @@ export default class BalanceSheet extends Component { ...@@ -1207,7 +1197,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1294,7 +1284,7 @@ export default class BalanceSheet extends Component { ...@@ -1294,7 +1284,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1381,7 +1371,7 @@ export default class BalanceSheet extends Component { ...@@ -1381,7 +1371,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1468,7 +1458,7 @@ export default class BalanceSheet extends Component { ...@@ -1468,7 +1458,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1555,7 +1545,7 @@ export default class BalanceSheet extends Component { ...@@ -1555,7 +1545,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1642,7 +1632,7 @@ export default class BalanceSheet extends Component { ...@@ -1642,7 +1632,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1729,7 +1719,7 @@ export default class BalanceSheet extends Component { ...@@ -1729,7 +1719,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1816,7 +1806,7 @@ export default class BalanceSheet extends Component { ...@@ -1816,7 +1806,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1903,7 +1893,7 @@ export default class BalanceSheet extends Component { ...@@ -1903,7 +1893,7 @@ export default class BalanceSheet extends Component {
// /> // />
null null
: :
<span>validasi</span> null
} }
</div> </div>
) )
...@@ -1944,7 +1934,7 @@ export default class BalanceSheet extends Component { ...@@ -1944,7 +1934,7 @@ export default class BalanceSheet extends Component {
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div> <div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode}</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
...@@ -2047,40 +2037,40 @@ export default class BalanceSheet extends Component { ...@@ -2047,40 +2037,40 @@ export default class BalanceSheet extends Component {
</div> </div>
</button> </button>
<button <button
className="button"
type="button" type="button"
disabled={this.state.disabledSave}
onClick={() => this.backToMasterBudget('submitted')}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.disabledSave === true ? 'default' : 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
marginRight: 20 marginRight: 20
}} }}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: false, editable: true })
}, 100);
})
}}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div> </div>
</button> </button>
<button <button
className="button"
type="button" type="button"
disabled={this.state.buttonError}
onClick={() => this.backToMasterBudget('submitted')}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none' outline: 'none',
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, disabledSave: false, editable: true })
}, 100);
})
}} }}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div> </div>
</button> </button>
</div> </div>
...@@ -2117,33 +2107,20 @@ export default class BalanceSheet extends Component { ...@@ -2117,33 +2107,20 @@ export default class BalanceSheet extends Component {
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div> </div>
</button> </button>
<button
type="button"
disabled={this.state.buttonError == true ? true : false}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadBalanceSheet()
}, 100);
})}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
<button <button
className="button" className="button"
type="button" type="button"
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none' outline: 'none',
marginRight: 20
}} }}
onClick={() => { onClick={() => {
this.setState({ loading: true }, () => { this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false }) this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
}, 100); }, 100);
}) })
}} }}
...@@ -2152,6 +2129,19 @@ export default class BalanceSheet extends Component { ...@@ -2152,6 +2129,19 @@ export default class BalanceSheet extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div> </div>
</button> </button>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadBalanceSheet()
}, 100);
})}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
</div> </div>
</div> </div>
</Paper>} </Paper>}
......
...@@ -50,7 +50,8 @@ export default class Parameter extends Component { ...@@ -50,7 +50,8 @@ export default class Parameter extends Component {
delete: false, delete: false,
load: false, load: false,
judul: '', judul: '',
loading: false loading: false,
sizeUpload: "1"
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -58,6 +59,25 @@ export default class Parameter extends Component { ...@@ -58,6 +59,25 @@ export default class Parameter extends Component {
componentDidMount() { componentDidMount() {
this.getAllParameter() this.getAllParameter()
this.getPermission() this.getPermission()
this.getSizeUpload()
}
getSizeUpload(){
let body = {
group: 'MAX_FILE_SIZE',
company_id: 0,
type: 'MAX_FILE_SIZE'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({
sizeUpload: response.data.data[0].value
})
}
}
})
} }
getPermission() { getPermission() {
...@@ -1047,6 +1067,7 @@ export default class Parameter extends Component { ...@@ -1047,6 +1067,7 @@ export default class Parameter extends Component {
type={this.state.uploadStatus} type={this.state.uploadStatus}
percentage={this.state.percentage} percentage={this.state.percentage}
result={this.state.result} result={this.state.result}
sizeUpload={Number(this.state.sizeUpload)}
acceptedFiles={["xlsx"]} acceptedFiles={["xlsx"]}
onHandle={(dt) => { onHandle={(dt) => {
this.fileHandler(dt) this.fileHandler(dt)
......
...@@ -62,7 +62,8 @@ export default class UnitBisnis extends Component { ...@@ -62,7 +62,8 @@ export default class UnitBisnis extends Component {
rowData: [], rowData: [],
unitBisnisName: '', unitBisnisName: '',
// visibleLoad: true, // visibleLoad: true,
loading: false loading: false,
sizeUpload: "1"
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -225,6 +226,25 @@ export default class UnitBisnis extends Component { ...@@ -225,6 +226,25 @@ export default class UnitBisnis extends Component {
componentDidMount() { componentDidMount() {
this.getData() this.getData()
this.getPermission() this.getPermission()
this.getSizeUpload()
}
getSizeUpload(){
let body = {
group: 'MAX_FILE_SIZE',
company_id: 0,
type: 'MAX_FILE_SIZE'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({
sizeUpload: response.data.data[0].value
})
}
}
})
} }
getPermission() { getPermission() {
...@@ -771,6 +791,7 @@ export default class UnitBisnis extends Component { ...@@ -771,6 +791,7 @@ export default class UnitBisnis extends Component {
type={this.state.uploadStatus} type={this.state.uploadStatus}
percentage={this.state.percentage} percentage={this.state.percentage}
result={this.state.result} result={this.state.result}
sizeUpload={Number(this.state.sizeUpload)}
acceptedFiles={["xlsx"]} acceptedFiles={["xlsx"]}
onHandle={(dt) => { onHandle={(dt) => {
this.fileHandler(dt) this.fileHandler(dt)
......
...@@ -34,6 +34,8 @@ export default class CreateReportItems extends Component { ...@@ -34,6 +34,8 @@ export default class CreateReportItems extends Component {
listCompany: null, listCompany: null,
listReportType: null, listReportType: null,
listParent: null, listParent: null,
listKPI: null,
listMaxAch: null,
errorOrder: false, errorOrder: false,
errorDesc: false, errorDesc: false,
errorFormula: false, errorFormula: false,
...@@ -66,7 +68,9 @@ export default class CreateReportItems extends Component { ...@@ -66,7 +68,9 @@ export default class CreateReportItems extends Component {
formulaYtd: ['SUM', 'AVG', 'MIN', 'MAX'], formulaYtd: ['SUM', 'AVG', 'MIN', 'MAX'],
kpiTypeValue: null, kpiTypeValue: null,
maxAchValue: null, maxAchValue: null,
formulaYTDValue: null formulaYTDValue: null,
kpiDisable: true,
maxAchDisable: true
} }
} }
...@@ -153,9 +157,9 @@ export default class CreateReportItems extends Component { ...@@ -153,9 +157,9 @@ export default class CreateReportItems extends Component {
validasi() { validasi() {
// alert('coba ya') // alert('coba ya')
if (R.isNil(this.state.reportType)) { if (R.isNil(this.state.reportType)) {
this.setState({errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty'}) this.setState({ errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty' })
} else if (R.isNil(this.state.company)){ } else if (R.isNil(this.state.company)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty'}) this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty' })
} else if (R.isEmpty(this.state.order)) { } else if (R.isEmpty(this.state.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty' }) this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty' })
} }
...@@ -199,8 +203,8 @@ export default class CreateReportItems extends Component { ...@@ -199,8 +203,8 @@ export default class CreateReportItems extends Component {
"weight": this.state.weight, "weight": this.state.weight,
"condition_if_wrong": this.state.condition, "condition_if_wrong": this.state.condition,
"condition_it_should_be": this.state.realVal, "condition_it_should_be": this.state.realVal,
"type_kpi": this.state.kpiTypeValue, "type_kpi": this.state.kpiTypeValue.value,
"max_ach": this.state.maxAchValue, "max_ach": this.state.maxAchValue.value,
"formula_ytd": this.state.formulaYTDValue, "formula_ytd": this.state.formulaYTDValue,
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate
...@@ -209,10 +213,92 @@ export default class CreateReportItems extends Component { ...@@ -209,10 +213,92 @@ export default class CreateReportItems extends Component {
this.props.createReportItems(payload) this.props.createReportItems(payload)
} }
getKPIType() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'KPI_TYPE'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputKPI = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputKPI,
getOptionLabel: (option) => titleCase(option.value),
};
this.setState({ listKPI: defaultProps, inputKPI: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getMaxAch() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'MAX_ACHIEVEMENT'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputMaxAch = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputMaxAch,
getOptionLabel: (option) => titleCase(option.value),
};
this.setState({ listMaxAch: defaultProps, inputMaxAch: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getInputType() { getInputType() {
api.create().getInputType().then((response) => { api.create().getInputType().then((response) => {
// console.log(response.data) // console.log(response.data)
if(response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
...@@ -450,8 +536,8 @@ export default class CreateReportItems extends Component { ...@@ -450,8 +536,8 @@ export default class CreateReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listReportType} {...this.state.listReportType}
id="reportType" id="reportType"
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ reportType: newInputValue, kpiDisable: true, maxAchDisable: true }, () => {
newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ kpiTypeValue: null, maxAchValue: null, formulaYTDValue: null }, () => this.clearMessage()) newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ kpiTypeValue: null, maxAchValue: null, formulaYTDValue: null }, () => this.clearMessage())
: this.clearMessage(); : this.clearMessage();
})} })}
debug debug
...@@ -481,7 +567,12 @@ export default class CreateReportItems extends Component { ...@@ -481,7 +567,12 @@ export default class CreateReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listCompany} {...this.state.listCompany}
id="company" id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => this.getParent(), this.clearMessage())} onChange={(event, newInputValue) => this.setState({ company: newInputValue, kpiDisable: false, maxAchDisable: false }, () => {
this.getParent()
this.clearMessage()
this.getKPIType()
this.getMaxAch()
})}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
...@@ -790,88 +881,90 @@ export default class CreateReportItems extends Component { ...@@ -790,88 +881,90 @@ export default class CreateReportItems extends Component {
</div> </div>
{this.state.reportType !== null && ( {this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && ( this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete <Autocomplete
value={this.state.kpiTypeValue} {...this.state.listKPI}
id="kpiType" value={this.state.kpiTypeValue}
onChange={(event, newValue) => { id="kpiType"
this.setState({ kpiTypeValue: newValue }, () => this.clearMessage()); onChange={(event, newValue) => {
}} this.setState({ kpiTypeValue: newValue }, () => this.clearMessage());
options={this.state.kpiType}
renderInput={(params) =>
<TextField {...params}
label="KPI Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} disabled={this.state.kpiDisable}
/>} renderInput={(params) =>
/> <TextField {...params}
</div> label="KPI Type"
</div> InputLabelProps={{
<div className="column-2"> style: {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> fontSize: 11,
<Autocomplete fontFamily: 'Nunito Sans, sans-serif',
value={this.state.maxAchValue} color: '#7e8085'
id="maxAch" }
onChange={(event, newValue) => { }}
this.setState({ maxAchValue: newValue }, () => this.clearMessage()); InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
}} />}
options={this.state.maxAch} />
renderInput={(params) => </div>
<TextField {...params} </div>
label="Max Achievement" <div className="column-2">
InputLabelProps={{ <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
style: { <Autocomplete
fontSize: 11, {...this.state.listMaxAch}
fontFamily: 'Nunito Sans, sans-serif', value={this.state.maxAchValue}
color: '#7e8085' id="maxAch"
} onChange={(event, newValue) => {
this.setState({ maxAchValue: newValue }, () => this.clearMessage());
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} disabled={this.state.maxAchDisable}
/>} renderInput={(params) =>
/> <TextField {...params}
label="Max Achievement"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div> </div>
</div> ))}
</div>
))}
{this.state.reportType !== null && ( {this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && ( this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete <Autocomplete
value={this.state.formulaYTDValue} value={this.state.formulaYTDValue}
id="formulaYTD" id="formulaYTD"
onChange={(event, newValue) => { onChange={(event, newValue) => {
this.setState({ formulaYTDValue: newValue }, () => this.clearMessage()); this.setState({ formulaYTDValue: newValue }, () => this.clearMessage());
}}
options={this.state.formulaYtd}
renderInput={(params) =>
<TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} options={this.state.formulaYtd}
/>} renderInput={(params) =>
/> <TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div> </div>
</div> ))}
</div>
))}
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
...@@ -968,7 +1061,7 @@ export default class CreateReportItems extends Component { ...@@ -968,7 +1061,7 @@ export default class CreateReportItems extends Component {
</div> </div>
</div> </div>
<div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30}}> <div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30 }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '13%' }}>Created By :</Typography> <Typography style={{ fontSize: 11, width: '13%' }}>Created By :</Typography>
{/* <Typography style={{ fontSize: 11 }}>: </Typography> */} {/* <Typography style={{ fontSize: 11 }}>: </Typography> */}
......
...@@ -36,6 +36,10 @@ export default class EditReportItems extends Component { ...@@ -36,6 +36,10 @@ export default class EditReportItems extends Component {
listCompany: null, listCompany: null,
listReportType: null, listReportType: null,
listParent: null, listParent: null,
listKPI: null,
listMaxAch: null,
MaxAchValue: null,
KPIValue: null,
errorOrder: false, errorOrder: false,
errorDesc: false, errorDesc: false,
errorFormula: false, errorFormula: false,
...@@ -134,10 +138,10 @@ export default class EditReportItems extends Component { ...@@ -134,10 +138,10 @@ export default class EditReportItems extends Component {
validasi() { validasi() {
// alert('coba ya') // alert('coba ya')
if (R.isNil(this.state.reportType)){ if (R.isNil(this.state.reportType)) {
this.setState({errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty'}) this.setState({ errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty' })
} else if (R.isNil(this.state.company)){ } else if (R.isNil(this.state.company)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty'}) this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty' })
} else if (R.isEmpty(this.state.tempData.order)) { } else if (R.isEmpty(this.state.tempData.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty' }) this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty' })
} else if (R.isEmpty(this.state.tempData.description)) { } else if (R.isEmpty(this.state.tempData.description)) {
...@@ -191,13 +195,13 @@ export default class EditReportItems extends Component { ...@@ -191,13 +195,13 @@ export default class EditReportItems extends Component {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
this.setState({ this.setState({
tempData: response.data.data, tempData: response.data.data,
getCompanyID: data.company_id getCompanyID: data.company_id
}, () => this.getInputType(), }, () => this.getInputType(),
this.getPerusahaan(), this.getPerusahaan(),
this.getReportType(),) this.getReportType())
console.log(response.data.data) console.log(response.data.data)
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -279,7 +283,94 @@ export default class EditReportItems extends Component { ...@@ -279,7 +283,94 @@ export default class EditReportItems extends Component {
getOptionLabel: (option) => option.company_name, getOptionLabel: (option) => option.company_name,
}; };
// let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id) // let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id)
this.setState({ listCompany: defaultProps, companyData: response.data.data, company: index === -1 ? null : companyData[index], msgErrorPerusahaan: index === -1 ? 'Company has been Inactive.' : "", errorPerusahaan: index === -1 ? true : false }, () => this.getParent()) this.setState({ listCompany: defaultProps, companyData: response.data.data, company: index === -1 ? null : companyData[index], msgErrorPerusahaan: index === -1 ? 'Company has been Inactive.' : "", errorPerusahaan: index === -1 ? true : false }, () => {
this.getParent()
this.getKPIType()
this.getMaxAch()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getKPIType() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'KPI_TYPE'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputKPI = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputKPI,
getOptionLabel: (option) => titleCase(option.value),
};
let index = inputKPI.findIndex((val) => val.value === this.state.tempData.kpi_type)
this.setState({ listKPI: defaultProps, inputKPI: response.data.data, KPIValue: index === -1 ? null : inputKPI[index]})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getMaxAch() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'MAX_ACHIEVEMENT'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputMaxAch = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputMaxAch,
getOptionLabel: (option) => titleCase(option.value),
};
let index = inputMaxAch.findIndex((val) => val.value === this.state.tempData.max_ach)
this.setState({ listMaxAch: defaultProps, inputMaxAch: response.data.data, MaxAchValue: index === -1 ? null : inputMaxAch[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -289,6 +380,7 @@ export default class EditReportItems extends Component { ...@@ -289,6 +380,7 @@ export default class EditReportItems extends Component {
}, 1000); }, 1000);
} }
}) })
// alert(response.data.message)
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -465,9 +557,9 @@ export default class EditReportItems extends Component { ...@@ -465,9 +557,9 @@ export default class EditReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listReportType} {...this.state.listReportType}
id="reportType" id="reportType"
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () => onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () =>
newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ tempData: { ...this.state.tempData, kpi_type: null, max_ach: null, formula_ytd: null } }, () => this.getParent(), this.clearMessage()) newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ tempData: { ...this.state.tempData, kpi_type: null, max_ach: null, formula_ytd: null } }, () => this.getParent(), this.clearMessage())
: this.getParent(), this.clearMessage() : this.getParent(), this.clearMessage()
)} )}
debug debug
renderInput={(params) => renderInput={(params) =>
...@@ -774,88 +866,88 @@ export default class EditReportItems extends Component { ...@@ -774,88 +866,88 @@ export default class EditReportItems extends Component {
</div> </div>
{this.state.reportType !== null && ( {this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && ( this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete <Autocomplete
value={this.state.tempData === null ? "" : this.state.tempData.kpi_type} {...this.state.listKPI}
id="kpiType" value={this.state.KPIValue}
onChange={(event, newValue) => { id="kpiType"
this.setState({ tempData: { ...this.state.tempData, kpi_type: newValue } }, () => this.clearMessage()); onChange={(event, newValue) => {
}} this.setState({ tempData: { ...this.state.tempData, kpi_type: newValue.value }, KPIValue: newValue }, () => this.clearMessage());
options={this.state.kpiType}
renderInput={(params) =>
<TextField {...params}
label="KPI Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} renderInput={(params) =>
/>} <TextField {...params}
/> label="KPI Type"
</div> InputLabelProps={{
</div> style: {
<div className="column-2"> fontSize: 11,
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> fontFamily: 'Nunito Sans, sans-serif',
<Autocomplete color: '#7e8085'
value={this.state.tempData === null ? "" : this.state.tempData.max_ach} }
id="maxAch" }}
onChange={(event, newValue) => { InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
this.setState({ tempData: { ...this.state.tempData, max_ach: newValue } }, () => this.clearMessage()); />}
}} />
options={this.state.maxAch} </div>
renderInput={(params) => </div>
<TextField {...params} <div className="column-2">
label="Max Achievement" <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
InputLabelProps={{ <Autocomplete
style: { {...this.state.listMaxAch}
fontSize: 11, value={this.state.MaxAchValue}
fontFamily: 'Nunito Sans, sans-serif', id="maxAch"
color: '#7e8085' onChange={(event, newValue) => {
} this.setState({ tempData: { ...this.state.tempData, max_ach: newValue.value }, MaxAchValue: newValue }, () => this.clearMessage());
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} renderInput={(params) =>
/>} <TextField {...params}
/> label="Max Achievement"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div> </div>
</div> ))}
</div>
))}
{this.state.reportType !== null && ( {this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && ( this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete <Autocomplete
value={this.state.tempData === null ? "" : this.state.tempData.formula_ytd} value={this.state.tempData === null ? "" : this.state.tempData.formula_ytd}
id="kpiType" id="kpiType"
onChange={(event, newValue) => { onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, formula_ytd: newValue } }, () => this.clearMessage()); this.setState({ tempData: { ...this.state.tempData, formula_ytd: newValue } }, () => this.clearMessage());
}}
options={this.state.formulaYtd}
renderInput={(params) =>
<TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} options={this.state.formulaYtd}
/>} renderInput={(params) =>
/> <TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div> </div>
</div> ))}
</div>
))}
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
...@@ -949,7 +1041,7 @@ export default class EditReportItems extends Component { ...@@ -949,7 +1041,7 @@ export default class EditReportItems extends Component {
</div> </div>
</div> </div>
</div> </div>
<div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30}}> <div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30 }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography> <Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.created}</Typography> <Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.created}</Typography>
......
...@@ -25,7 +25,8 @@ class Upload extends Component { ...@@ -25,7 +25,8 @@ class Upload extends Component {
percentage: '0', percentage: '0',
completed: '0', completed: '0',
alert: false, alert: false,
alertMessage: '' alertMessage: '',
sizeUpload: this.props.sizeUpload === undefined ? 0 : this.props.sizeUpload
} }
} }
...@@ -146,7 +147,7 @@ class Upload extends Component { ...@@ -146,7 +147,7 @@ class Upload extends Component {
// alert('File Tidak Boleh Lebih Dari 1MB') // alert('File Tidak Boleh Lebih Dari 1MB')
} }
} else { } else {
if (this.state.sizeFile < 1000) { if (this.state.sizeFile < this.state.sizeUpload * 1000) {
this.props.onUpload() this.props.onUpload()
} else { } else {
this.setState({ alertMessage: 'The file is too large. Allowed maximum size is 1MB', alert: true }) this.setState({ alertMessage: 'The file is too large. Allowed maximum size is 1MB', alert: true })
......
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