Commit 8ad67663 authored by EKSAD's avatar EKSAD

update create RI

parent 2b7d52e4
...@@ -7,8 +7,6 @@ import { titleCase } from '../../../library/Utils'; ...@@ -7,8 +7,6 @@ import { titleCase } from '../../../library/Utils';
import format from "date-fns/format"; import format from "date-fns/format";
import { DatePicker } from '@material-ui/pickers'; import { DatePicker } from '@material-ui/pickers';
const options = ['WARNING', 'STOPPER'];
export default class CreateReportItems extends Component { export default class CreateReportItems extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -25,8 +23,7 @@ export default class CreateReportItems extends Component { ...@@ -25,8 +23,7 @@ export default class CreateReportItems extends Component {
weight: null, weight: null,
formula: '', formula: '',
realVal: '', realVal: '',
condition: '', condition: null,
value: options[0],
inputValue: '', inputValue: '',
date: new Date(), date: new Date(),
listInputType: null, listInputType: null,
...@@ -37,19 +34,18 @@ export default class CreateReportItems extends Component { ...@@ -37,19 +34,18 @@ export default class CreateReportItems extends Component {
errorDesc: false, errorDesc: false,
errorFormula: false, errorFormula: false,
errorRV: false, errorRV: false,
errorCF: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorOrder: '', msgErrorOrder: '',
msgErrorDesc: '', msgErrorDesc: '',
msgErrorFormula: '', msgErrorFormula: '',
msgErrorRV: '', msgErrorRV: '',
msgErrorCF: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
disabledFormula: true, disabledFormula: true,
disabledCondt: true, disabledCondt: true,
disabledValue: true disabledValue: true,
options: ['WARNING', 'STOPPER']
} }
} }
...@@ -61,6 +57,7 @@ export default class CreateReportItems extends Component { ...@@ -61,6 +57,7 @@ export default class CreateReportItems extends Component {
this.getParent() this.getParent()
} }
handleChange(e, type) { handleChange(e, type) {
let data = this.state let data = this.state
let isDate = type !== ''? true : false let isDate = type !== ''? true : false
...@@ -70,14 +67,12 @@ export default class CreateReportItems extends Component { ...@@ -70,14 +67,12 @@ export default class CreateReportItems extends Component {
errorDesc: false, errorDesc: false,
errorFormula: false, errorFormula: false,
errorRV: false, errorRV: false,
errorCF: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorOrder: '', msgErrorOrder: '',
msgErrorDesc: '', msgErrorDesc: '',
msgErrorFormula: '', msgErrorFormula: '',
msgErrorRV: '', msgErrorRV: '',
msgErrorCF: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
}) })
...@@ -87,14 +82,12 @@ export default class CreateReportItems extends Component { ...@@ -87,14 +82,12 @@ export default class CreateReportItems extends Component {
errorDesc: false, errorDesc: false,
errorFormula: false, errorFormula: false,
errorRV: false, errorRV: false,
errorCF: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorOrder: '', msgErrorOrder: '',
msgErrorDesc: '', msgErrorDesc: '',
msgErrorFormula: '', msgErrorFormula: '',
msgErrorRV: '', msgErrorRV: '',
msgErrorCF: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
}) })
...@@ -104,14 +97,12 @@ export default class CreateReportItems extends Component { ...@@ -104,14 +97,12 @@ export default class CreateReportItems extends Component {
errorDesc: false, errorDesc: false,
errorFormula: false, errorFormula: false,
errorRV: false, errorRV: false,
errorCF: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorOrder: '', msgErrorOrder: '',
msgErrorDesc: '', msgErrorDesc: '',
msgErrorFormula: '', msgErrorFormula: '',
msgErrorRV: '', msgErrorRV: '',
msgErrorCF: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
}) })
...@@ -136,9 +127,7 @@ export default class CreateReportItems extends Component { ...@@ -136,9 +127,7 @@ export default class CreateReportItems extends Component {
else if (this.state.disabledValue === false && R.isEmpty(this.state.realVal)) { else if (this.state.disabledValue === false && R.isEmpty(this.state.realVal)) {
this.setState({errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi'}) this.setState({errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi'})
} }
else if (this.state.disabledCondt === false && R.isEmpty(this.state.condition)) { else if (this.state.disabledCondt === false && R.isEmpty(this.state.condition)) return alert("Kondisi Jika Salah is Required.")
this.setState({errorCF: true, msgErrorCF: 'Nilai Seharusnya Harus Diisi'})
}
else if (R.isNil(this.state.startDate)) { else if (R.isNil(this.state.startDate)) {
this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'}) this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'})
} }
...@@ -169,15 +158,15 @@ export default class CreateReportItems extends Component { ...@@ -169,15 +158,15 @@ export default class CreateReportItems extends Component {
"end_date": this.state.endDate "end_date": this.state.endDate
} }
console.log(payload) console.log(payload)
// api.create().createReportItems(payload).then((response) => { api.create().createReportItems(payload).then((response) => {
// console.log(response) console.log(response)
// if (response.data.status === 'success') { if (response.data.status === 'success') {
// this.props.onClickClose() this.props.onClickClose()
// this.props.refresh() this.props.refresh()
// } else { } else {
// alert(response.data.message) alert(response.data.message)
// } }
// }) })
} }
getInputType() { getInputType() {
...@@ -253,12 +242,13 @@ export default class CreateReportItems extends Component { ...@@ -253,12 +242,13 @@ export default class CreateReportItems extends Component {
let data = response.data.data let data = response.data.data
let parentData = data.map((item) => { let parentData = data.map((item) => {
return { return {
item_report_id: item.item_report_id item_report_id: item.item_report_id,
report_name: item.report_name
} }
}) })
let defaultProps = { let defaultProps = {
options: parentData, options: parentData,
getOptionLabel: (option) => titleCase(option.item_report_id), getOptionLabel: (option) => titleCase(option.report_name),
}; };
this.setState({listParent: defaultProps, parentData: response.data.data}) this.setState({listParent: defaultProps, parentData: response.data.data})
} else { } else {
...@@ -430,14 +420,14 @@ export default class CreateReportItems extends Component { ...@@ -430,14 +420,14 @@ export default class CreateReportItems extends Component {
<div className="margin-top-10px" style={{padding: 10}}> <div className="margin-top-10px" style={{padding: 10}}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="realValue" id="realVal"
label="Nilai Seharusnya" label="Nilai Seharusnya"
name="realValue" name="realVal"
disabled={this.state.disabledValue}
value={this.state.realVal} value={this.state.realVal}
error={this.state.errorRV} error={this.state.errorRV}
helperText={this.state.msgErrorRV} helperText={this.state.msgErrorRV}
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
disabled={this.state.disabledValue}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11, fontSize: 11,
...@@ -655,55 +645,27 @@ export default class CreateReportItems extends Component { ...@@ -655,55 +645,27 @@ export default class CreateReportItems extends Component {
</div> </div>
<div className="margin-top-10px" style={{padding: 10}}> <div className="margin-top-10px" style={{padding: 10}}>
<Autocomplete <Autocomplete
value={this.state.condition}
id="isWrongCondition"
disabled={this.state.disabledCondt}
onChange={(event, newValue) => {
this.setState({value: newValue});
}}
inputValue={this.state.inputValue}
onInputChange={(event, newInputValue) => {
this.setState({inputValue: newInputValue});
}}
id="controllable-states-demo"
options={options}
style={{ width: 300 }}
renderInput={(params) =>
<TextField {...params}
label="Kondisi Jika Salah"
InputLabelProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontWeight: 600, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
{/* <TextField
style={{ width: '100%' }}
value={this.state.condition} value={this.state.condition}
id="isWrongCondition" id="isWrongCondition"
label="Kondisi Jika Salah"
disabled={this.state.disabledCondt} disabled={this.state.disabledCondt}
inputProps={{ onChange={(event, newValue) => {
style: { this.setState({condition: newValue});
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085',
}
}} }}
/> */} options={this.state.options}
renderInput={(params) =>
<TextField {...params}
label="Kondisi Jika Salah"
InputLabelProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontWeight: 600, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<DatePicker <DatePicker
...@@ -754,7 +716,7 @@ export default class CreateReportItems extends Component { ...@@ -754,7 +716,7 @@ export default class CreateReportItems extends Component {
</button> </button>
</div> </div>
<div className="column-2" style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'center'}}> <div className="column-2" style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'center'}}>
<div onClick={() => this.addReportItems()} style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div onClick={() => this.validasi()} style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span> <span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div> </div>
</div> </div>
......
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