Commit c3ca8e19 authored by Deni Rinaldi's avatar Deni Rinaldi

validasi value parameter

parent 39c75b90
......@@ -15,10 +15,10 @@ export default class CreateParameter extends Component {
enableParameter: false,
id: '',
description: '',
value: null,
value: '',
order: null,
minValue: null,
maxValue: null,
minValue: '',
maxValue: '',
startDate: '',
endDate: null,
date: new Date(),
......@@ -82,13 +82,12 @@ export default class CreateParameter extends Component {
let data = response.data.data
this.setState({
tempData: response.data.data,
getSettingGroupID: data.setting_group_id,
getSettingGroupID: response.data.data.setting_group_id,
getCompanyID: data.company_id,
settingType: data.setting_type,
}, () => {
this.getAllGroup()
this.getPerusahaan()
this.getParameterByGroup(data.setting_group_id)
console.log(this.state.tempData)
})
} else {
......@@ -128,7 +127,8 @@ export default class CreateParameter extends Component {
options: typeData,
getOptionLabel: (option) => option.setting_group_name,
};
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] })
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] }, ()=> {
this.getParameterByGroup(this.state.getTypes.setting_group_id)})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
......@@ -267,7 +267,7 @@ export default class CreateParameter extends Component {
getParameterByGroup(id) {
api.create().getParameterByGroup(id).then(response => {
console.log(response);
console.log(id, response);
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
......@@ -432,15 +432,15 @@ export default class CreateParameter extends Component {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty.' })
// } else if (R.isEmpty(this.state.tempData.description)) {
// this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
// } else if (R.isEmpty(this.state.tempData.value)) {
// this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if ((!R.isNil(this.state.tempData.max_value) && R.isNil(this.state.tempData.min_value)) || (!R.isEmpty(this.state.tempData.max_value) && R.isEmpty(this.state.tempData.min_value))) {
} else if (R.isEmpty(this.state.tempData.value) && R.isEmpty(this.state.tempData.min_value) && R.isEmpty(this.state.tempData.max_value)) {
this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if ((!R.isEmpty(this.state.tempData.max_value) && R.isEmpty(this.state.tempData.min_value))) {
this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value Cannot be Empty.' })
} else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Valid From Cannot be Empty.' })
// } else if (R.isNil(this.state.tempData.order)) {
// this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
} else if ((!R.isNil(this.state.tempData.min_value) && R.isNil(this.state.tempData.max_value)) || (!R.isEmpty(this.state.tempData.min_value) && R.isEmpty(this.state.tempData.max_value))) {
} else if ((!R.isEmpty(this.state.tempData.min_value) && R.isEmpty(this.state.tempData.max_value))) {
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value Cannot be Empty.' })
} else if (R.isNil(this.state.tempData.end_date)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'Valid To Cannot be Empty.' })
......@@ -458,15 +458,15 @@ export default class CreateParameter extends Component {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty.' })
// } else if (R.isEmpty(this.state.description)) {
// this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
// } else if (R.isNil(this.state.value)) {
// this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if ((!R.isNil(this.state.maxValue) && R.isNil(this.state.minValue)) || (!R.isNil(this.state.maxValue) && R.isEmpty(this.state.minValue))) {
} else if ((R.isEmpty(this.state.value) && R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) {
this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if ((!R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) {
this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value Cannot be Empty.' })
} else if (R.isNil(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Valid From Cannot be Empty.' })
// } else if (R.isNil(this.state.order)) {
// this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
} else if ((!R.isNil(this.state.minValue) && R.isNil(this.state.maxValue)) || (!R.isNil(this.state.minValue) && R.isEmpty(this.state.maxValue))) {
} else if ((!R.isEmpty(this.state.minValue) && R.isEmpty(this.state.maxValue))) {
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value Cannot be Empty.' })
} else if (R.isNil(this.state.endDate)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'Valid To Cannot be Empty.' })
......@@ -632,8 +632,8 @@ export default class CreateParameter extends Component {
}
// this.handleChange(coba, 'value')}
}
// error={this.state.errorValue}
// helperText={this.state.msgErrorValue}
error={this.state.errorValue}
helperText={this.state.msgErrorValue}
>
</TextField>
</div>
......@@ -990,7 +990,7 @@ export default class CreateParameter extends Component {
style={{ width: '100%' }}
id="value"
label="Value"
value={this.state.value === null ? '' : this.state.value}
value={this.state.value}
inputProps={{
min: 0,
style: {
......@@ -1014,8 +1014,8 @@ export default class CreateParameter extends Component {
}
// this.handleChange(coba, 'value')}
}
// error={this.state.errorValue}
// helperText={this.state.msgErrorValue}
error={this.state.errorValue}
helperText={this.state.msgErrorValue}
>
</TextField>
</div>
......@@ -1024,7 +1024,7 @@ export default class CreateParameter extends Component {
style={{ width: '100%' }}
id="min_value"
label="Min Value"
value={this.state.minValue === null ? '' : this.state.minValue}
value={this.state.minValue}
inputProps={{
min: 0,
style: {
......@@ -1183,7 +1183,7 @@ export default class CreateParameter extends Component {
style={{ width: '100%' }}
id="max_value"
label="Max Value"
value={this.state.maxValue === null ? '' : this.state.maxValue}
value={this.state.maxValue}
inputProps={{
min: 0,
style: {
......
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