Commit 27969e74 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-dev(pc)' into 'master'

validasi value parameter

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