Commit 8ad67663 authored by EKSAD's avatar EKSAD

update create RI

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