Commit 06d229aa authored by Riri Novita's avatar Riri Novita

Merge branch 'dev/riri' into 'ENV-DEV'

Update Parameter Threshold

See merge request !2063
parents 2d79f5b9 8eccd40a
...@@ -16,6 +16,7 @@ export default class CreateParameter extends Component { ...@@ -16,6 +16,7 @@ export default class CreateParameter extends Component {
enableParameter: false, enableParameter: false,
enableReportName: false, enableReportName: false,
enableFormat: false, enableFormat: false,
enableThreshold: false,
id: '', id: '',
description: '', description: '',
value: '', value: '',
...@@ -32,8 +33,10 @@ export default class CreateParameter extends Component { ...@@ -32,8 +33,10 @@ export default class CreateParameter extends Component {
perusahaan: null, perusahaan: null,
reportName: null, reportName: null,
formatCurrency: null, formatCurrency: null,
thresholdCurrency: null,
getReportName: null, getReportName: null,
getFormatData: null, getFormatData: null,
getThresholdCurrency: null,
getPerusahaan: null, getPerusahaan: null,
parameter: null, parameter: null,
getParameter: null, getParameter: null,
...@@ -45,6 +48,7 @@ export default class CreateParameter extends Component { ...@@ -45,6 +48,7 @@ export default class CreateParameter extends Component {
errorDeskripsi: false, errorDeskripsi: false,
errorReportName: false, errorReportName: false,
errorFormatValue: false, errorFormatValue: false,
errorThresholdCurrency: false,
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
...@@ -59,6 +63,7 @@ export default class CreateParameter extends Component { ...@@ -59,6 +63,7 @@ export default class CreateParameter extends Component {
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorReportName: '', msgErrorReportName: '',
msgErrorFormatValue: '', msgErrorFormatValue: '',
msgErrorThresholdCurrency: '',
msgErrorValue: '', msgErrorValue: '',
msgErrorMinValue: '', msgErrorMinValue: '',
msgErrorOrder: '', msgErrorOrder: '',
...@@ -87,6 +92,7 @@ export default class CreateParameter extends Component { ...@@ -87,6 +92,7 @@ export default class CreateParameter extends Component {
this.getDataPerusahaan() this.getDataPerusahaan()
this.getDataReportName() this.getDataReportName()
this.getDataFormat() this.getDataFormat()
this.getDataCurrencyThreshold()
} }
} }
...@@ -107,6 +113,7 @@ export default class CreateParameter extends Component { ...@@ -107,6 +113,7 @@ export default class CreateParameter extends Component {
getTypeReportID: data.setting_type_id, getTypeReportID: data.setting_type_id,
enableReportName: data.setting_group === "CURRENCY" ? true : false, enableReportName: data.setting_group === "CURRENCY" ? true : false,
enableFormat: data.setting_group === "CURRENCY_MONEY_FORMAT" ? true : false, enableFormat: data.setting_group === "CURRENCY_MONEY_FORMAT" ? true : false,
enableThreshold: data.setting_group === "THRESHOLD_CONTROL" ? true : false,
tesValue: response.data.data.setting_group === "CURRENCY" ? Number(response.data.data.value) * 1000 : response.data.data.value tesValue: response.data.data.setting_group === "CURRENCY" ? Number(response.data.data.value) * 1000 : response.data.data.value
}, () => { }, () => {
...@@ -114,6 +121,7 @@ export default class CreateParameter extends Component { ...@@ -114,6 +121,7 @@ export default class CreateParameter extends Component {
this.getPerusahaan() this.getPerusahaan()
this.getReport() this.getReport()
this.getFormat() this.getFormat()
this.getCurrencyByThreshold()
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -289,6 +297,44 @@ export default class CreateParameter extends Component { ...@@ -289,6 +297,44 @@ export default class CreateParameter extends Component {
}) })
} }
getCurrencyByThreshold() {
api.create().getFormatValue().then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let currencyData = data.map((item) => {
return {
setting_type_id: item.setting_type_id,
setting_type_name: item.setting_type_name
}
})
let index = currencyData.findIndex((val) => val.setting_type_id == this.state.tempData.reference_id)
let currencyProps = {
options: currencyData,
getOptionLabel: (option) => option.setting_type_name,
};
this.setState({ thresholdCurrency: currencyProps, currencyData: response.data.data, getThresholdCurrency: index == -1 ? currencyData[0] : currencyData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
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' })
}
})
}
getDataGroup() { getDataGroup() {
api.create().getAllGroup().then((response) => { api.create().getAllGroup().then((response) => {
if (response.data) { if (response.data) {
...@@ -367,11 +413,13 @@ export default class CreateParameter extends Component { ...@@ -367,11 +413,13 @@ export default class CreateParameter extends Component {
getParameterByGroup(id, name) { getParameterByGroup(id, name) {
if (name === "CURRENCY") { if (name === "CURRENCY") {
this.setState({ enableReportName: true, enableFormat: false }) this.setState({ enableReportName: true, enableFormat: false, enableThreshold: false })
} else if (name === "CURRENCY_MONEY_FORMAT") { } else if (name === "CURRENCY_MONEY_FORMAT") {
this.setState({ enableFormat: true, enableReportName: false }) this.setState({ enableFormat: true, enableReportName: false, enableThreshold: false })
} else if (name === "THRESHOLD_CONTROL") {
this.setState({ enableThreshold: true, enableFormat: false, enableReportName: false })
} else { } else {
this.setState({ enableReportName: false, enableFormat: false }) this.setState({ enableReportName: false, enableFormat: false, enableThreshold: false })
} }
api.create().getParameterByGroup(id).then(response => { api.create().getParameterByGroup(id).then(response => {
// console.log(id, response); // console.log(id, response);
...@@ -512,6 +560,43 @@ export default class CreateParameter extends Component { ...@@ -512,6 +560,43 @@ export default class CreateParameter extends Component {
}) })
} }
getDataCurrencyThreshold() {
api.create().getFormatValue().then((response) => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let currencyData = data.map((item) => {
return {
setting_type_id: item.setting_type_id,
setting_type_name: item.setting_type_name
}
})
let currencyProps = {
options: currencyData,
getOptionLabel: (option) => option.setting_type_name,
};
this.setState({ thresholdCurrency: currencyProps, currencyData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
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' })
}
})
}
handleChange(e, type) { handleChange(e, type) {
let data = this.state let data = this.state
let isDate = type !== '' ? true : false let isDate = type !== '' ? true : false
...@@ -686,14 +771,14 @@ export default class CreateParameter extends Component { ...@@ -686,14 +771,14 @@ export default class CreateParameter extends Component {
async validasiValueResponse() { async validasiValueResponse() {
let data = await this.validasiValueData() let data = await this.validasiValueData()
if (R.isNil(this.state.getTypes)) { if (R.isNil(this.state.getTypes)) {
}else { } else {
if (this.state.getTypes.setting_group_name == "REPORT_SUBMIT_PERIOD") { if (this.state.getTypes.setting_group_name == "REPORT_SUBMIT_PERIOD") {
if (R.isEmpty(data.value)) { if (R.isEmpty(data.value)) {
if (R.isNil(this.state.getPerusahaan)){ if (R.isNil(this.state.getPerusahaan)) {
}else { } else {
if (this.state.getPerusahaan.company_name == "Default"){ if (this.state.getPerusahaan.company_name == "Default") {
}else { } else {
this.setState({errorValue: true, msgErrorValue: 'Value Cannot be Empty'}) this.setState({ errorValue: true, msgErrorValue: 'Value Cannot be Empty' })
} }
} }
} else { } else {
...@@ -701,7 +786,7 @@ export default class CreateParameter extends Component { ...@@ -701,7 +786,7 @@ export default class CreateParameter extends Component {
} else { } else {
switch (this.state.getParameter.setting_type_name) { switch (this.state.getParameter.setting_type_name) {
case "MASTER_BUDGET": case "MASTER_BUDGET":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023'}) this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023' })
break break
case "MONTHLY_REPORT": case "MONTHLY_REPORT":
this.setState({ this.setState({
...@@ -710,43 +795,43 @@ export default class CreateParameter extends Component { ...@@ -710,43 +795,43 @@ export default class CreateParameter extends Component {
}) })
break break
case "OUTLOOK_Q1": case "OUTLOOK_Q1":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : Q1 2023'}) this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : Q1 2023' })
break break
case "OUTLOOK_Q2": case "OUTLOOK_Q2":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : Q2 2023'}) this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : Q2 2023' })
break break
case "OUTLOOK_Q3": case "OUTLOOK_Q3":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : Q3 2023'}) this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : Q3 2023' })
break break
case "OUTLOOK_PA": case "OUTLOOK_PA":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023'}) this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023' })
break break
default: default:
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023'}) this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023' })
} }
} }
} }
} else if (this.state.getTypes.setting_group_name == "CURRENCY") { } else if (this.state.getTypes.setting_group_name == "CURRENCY") {
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : 15000'}) this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 15000' })
} }
} }
} }
async validasiCreateEdit(){ async validasiCreateEdit() {
let data = await this.validasiValueData() let data = await this.validasiValueData()
let response = await this.validasiRegexValue() let response = await this.validasiRegexValue()
let minMaxValidasi = await this.validasiMinMaxValue() let minMaxValidasi = await this.validasiMinMaxValue()
console.log("Masuk ke menu creat : " + R.isNil(this.state.getFormatData)) console.log("Masuk ke menu creat : " + R.isNil(this.state.getFormatData))
if (this.props.type === "edit"){ if (this.props.type === "edit") {
if (R.isNil(this.state.getTypes)) { if (R.isNil(this.state.getTypes)) {
} else { } else {
if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT") { if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT") {
if (R.isNil(this.state.getParameter)){ if (R.isNil(this.state.getParameter)) {
}else { } else {
if (R.isNil(this.state.getPerusahaan)){ if (R.isNil(this.state.getPerusahaan)) {
}else { } else {
if (R.isNil(this.state.getFormatData)){ if (R.isNil(this.state.getFormatData)) {
}else { } else {
this.updateParameterCurrebcyMoneyFormat() this.updateParameterCurrebcyMoneyFormat()
} }
} }
...@@ -759,7 +844,7 @@ export default class CreateParameter extends Component { ...@@ -759,7 +844,7 @@ export default class CreateParameter extends Component {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) { if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) { if (R.isEmpty(data.minValue)) {
} else { } else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength) { if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) { if (R.isEmpty(data.maxValue)) {
} else { } else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) { if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
...@@ -771,7 +856,7 @@ export default class CreateParameter extends Component { ...@@ -771,7 +856,7 @@ export default class CreateParameter extends Component {
} }
} }
} }
} else if (this.state.getTypes.setting_group_name == "THRESHOLD_VARIANCE" || this.state.getTypes.setting_group_name == "THRESHOLD_CONTROL" ) { } else if (this.state.getTypes.setting_group_name == "THRESHOLD_VARIANCE" || this.state.getTypes.setting_group_name == "THRESHOLD_CONTROL") {
if (R.isEmpty(data.minValue)) { if (R.isEmpty(data.minValue)) {
} else { } else {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) { if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
...@@ -785,10 +870,10 @@ export default class CreateParameter extends Component { ...@@ -785,10 +870,10 @@ export default class CreateParameter extends Component {
} }
} else if (this.state.getTypes.setting_group_name == "REPORT_SUBMIT_PERIOD") { } else if (this.state.getTypes.setting_group_name == "REPORT_SUBMIT_PERIOD") {
if (R.isEmpty(data.value)) { if (R.isEmpty(data.value)) {
if (this.state.getPerusahaan.company_name == "Default"){ if (this.state.getPerusahaan.company_name == "Default") {
if (R.isEmpty(data.minValue)) { if (R.isEmpty(data.minValue)) {
} else { } else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength){ if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) { if (R.isEmpty(data.maxValue)) {
} else { } else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) { if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
...@@ -802,7 +887,7 @@ export default class CreateParameter extends Component { ...@@ -802,7 +887,7 @@ export default class CreateParameter extends Component {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) { if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) { if (R.isEmpty(data.minValue)) {
} else { } else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength){ if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) { if (R.isEmpty(data.maxValue)) {
} else { } else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) { if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
...@@ -813,27 +898,27 @@ export default class CreateParameter extends Component { ...@@ -813,27 +898,27 @@ export default class CreateParameter extends Component {
} }
} }
} }
}else { } else {
if (R.isNil(this.state.getParameter)){ if (R.isNil(this.state.getParameter)) {
}else { } else {
if (R.isNil(this.state.getPerusahaan)){ if (R.isNil(this.state.getPerusahaan)) {
}else { } else {
this.updateParameter() this.updateParameter()
} }
} }
} }
} }
}else { } else {
if (R.isNil(this.state.getTypes)) { if (R.isNil(this.state.getTypes)) {
} else { } else {
if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT") { if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT") {
if (R.isNil(this.state.getParameter)){ if (R.isNil(this.state.getParameter)) {
}else { } else {
if (R.isNil(this.state.getPerusahaan)){ if (R.isNil(this.state.getPerusahaan)) {
}else { } else {
console.log() console.log()
if (R.isNil(this.state.getFormatData)){ if (R.isNil(this.state.getFormatData)) {
}else { } else {
this.createParameterCurrebcyMoneyFormat() this.createParameterCurrebcyMoneyFormat()
} }
} }
...@@ -858,7 +943,7 @@ export default class CreateParameter extends Component { ...@@ -858,7 +943,7 @@ export default class CreateParameter extends Component {
} }
} }
} }
} else if (this.state.getTypes.setting_group_name == "THRESHOLD_VARIANCE" || this.state.getTypes.setting_group_name == "THRESHOLD_CONTROL" ) { } else if (this.state.getTypes.setting_group_name == "THRESHOLD_VARIANCE" || this.state.getTypes.setting_group_name == "THRESHOLD_CONTROL") {
if (R.isEmpty(data.minValue)) { if (R.isEmpty(data.minValue)) {
} else { } else {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) { if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
...@@ -872,13 +957,13 @@ export default class CreateParameter extends Component { ...@@ -872,13 +957,13 @@ export default class CreateParameter extends Component {
} }
} else if (this.state.getTypes.setting_group_name == "REPORT_SUBMIT_PERIOD") { } else if (this.state.getTypes.setting_group_name == "REPORT_SUBMIT_PERIOD") {
if (R.isEmpty(data.value)) { if (R.isEmpty(data.value)) {
if (this.state.getPerusahaan.company_name == "Default"){ if (this.state.getPerusahaan.company_name == "Default") {
if (R.isEmpty(data.minValue)) { if (R.isEmpty(data.minValue)) {
} else { } else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength) { if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) { if (R.isEmpty(data.maxValue)) {
} else { } else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0,1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) { if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
this.createParameter() this.createParameter()
} }
} }
...@@ -889,10 +974,10 @@ export default class CreateParameter extends Component { ...@@ -889,10 +974,10 @@ export default class CreateParameter extends Component {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) { if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) { if (R.isEmpty(data.minValue)) {
} else { } else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength) { if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) { if (R.isEmpty(data.maxValue)) {
} else { } else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0,1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) { if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
this.createParameter() this.createParameter()
} }
} }
...@@ -900,11 +985,11 @@ export default class CreateParameter extends Component { ...@@ -900,11 +985,11 @@ export default class CreateParameter extends Component {
} }
} }
} }
}else { } else {
if (R.isNil(this.state.getParameter)){ if (R.isNil(this.state.getParameter)) {
}else { } else {
if (R.isNil(this.state.getPerusahaan)){ if (R.isNil(this.state.getPerusahaan)) {
}else { } else {
this.createParameter() this.createParameter()
} }
} }
...@@ -913,11 +998,11 @@ export default class CreateParameter extends Component { ...@@ -913,11 +998,11 @@ export default class CreateParameter extends Component {
} }
} }
validasiFormatResponse(){ validasiFormatResponse() {
if (R.isNil(this.state.getTypes)){ if (R.isNil(this.state.getTypes)) {
}else { } else {
if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT"){ if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT") {
if (R.isNil(this.state.getFormatData)){ if (R.isNil(this.state.getFormatData)) {
this.setState({ errorFormatValue: true, msgErrorFormatValue: 'Format Cannot be Empty' }) this.setState({ errorFormatValue: true, msgErrorFormatValue: 'Format Cannot be Empty' })
} }
} }
...@@ -926,12 +1011,12 @@ export default class CreateParameter extends Component { ...@@ -926,12 +1011,12 @@ export default class CreateParameter extends Component {
validasiRegexValue() { validasiRegexValue() {
let obj = null let obj = null
if (R.isNil(this.state.getTypes)){ if (R.isNil(this.state.getTypes)) {
obj = { regexValue: "", valueLength: "" } obj = { regexValue: "", valueLength: "" }
}else { } else {
if (this.state.getTypes.setting_group_name === "CURRENCY"){ if (this.state.getTypes.setting_group_name === "CURRENCY") {
obj = { regexValue: (/\d+(\.\d+)?/), valueLength: 20 } obj = { regexValue: (/\d+(\.\d+)?/), valueLength: 20 }
} else if (this.state.getTypes.setting_group_name === "REPORT_SUBMIT_PERIOD"){ } else if (this.state.getTypes.setting_group_name === "REPORT_SUBMIT_PERIOD") {
if (R.isNil(this.state.getParameter)) { if (R.isNil(this.state.getParameter)) {
obj = { regexValue: (/\b\d{4}\b/), valueLength: 4 } obj = { regexValue: (/\b\d{4}\b/), valueLength: 4 }
} else { } else {
...@@ -1029,16 +1114,16 @@ export default class CreateParameter extends Component { ...@@ -1029,16 +1114,16 @@ export default class CreateParameter extends Component {
} else { } else {
switch (this.state.getTypes.setting_group_name) { switch (this.state.getTypes.setting_group_name) {
case "CURRENCY": case "CURRENCY":
obj = { minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/), minLength: 11, maxLength: 11, regexValue: (/^\d+$/)} obj = { minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/), minLength: 11, maxLength: 11, regexValue: (/^\d+$/) }
break break
case "REPORT_SUBMIT_PERIOD": case "REPORT_SUBMIT_PERIOD":
if (R.isNil(this.state.getPerusahaan)){ if (R.isNil(this.state.getPerusahaan)) {
obj = { obj = {
minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/), minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/),
minLength: 11, maxLength: 11 minLength: 11, maxLength: 11
} }
}else { } else {
if (this.state.getPerusahaan.company_name == "Default"){ if (this.state.getPerusahaan.company_name == "Default") {
if (R.isNil(this.state.getParameter)) { if (R.isNil(this.state.getParameter)) {
obj = { obj = {
minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/), minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/),
...@@ -1089,7 +1174,7 @@ export default class CreateParameter extends Component { ...@@ -1089,7 +1174,7 @@ export default class CreateParameter extends Component {
} }
} }
} }
}else { } else {
obj = { obj = {
minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/), minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/),
minLength: 11, maxLength: 11 minLength: 11, maxLength: 11
...@@ -1107,12 +1192,12 @@ export default class CreateParameter extends Component { ...@@ -1107,12 +1192,12 @@ export default class CreateParameter extends Component {
return obj; return obj;
} }
validasiValueData(){ validasiValueData() {
let obj = null let obj = null
if (this.props.type === "edit"){ if (this.props.type === "edit") {
obj = {value: this.state.tempData.value.toString(), minValue: this.state.tempData.min_value, maxValue: this.state.tempData.max_value, endDate: this.state.tempData.end_date, startDate: this.state.tempData.start_date} obj = { value: this.state.tempData.value.toString(), minValue: this.state.tempData.min_value, maxValue: this.state.tempData.max_value, endDate: this.state.tempData.end_date, startDate: this.state.tempData.start_date }
}else { } else {
obj = {value: this.state.value, minValue: this.state.minValue, maxValue: this.state.maxValue, endDate: this.state.endDate, startDate: this.state.startDate} obj = { value: this.state.value, minValue: this.state.minValue, maxValue: this.state.maxValue, endDate: this.state.endDate, startDate: this.state.startDate }
} }
return obj; return obj;
} }
...@@ -1131,7 +1216,7 @@ export default class CreateParameter extends Component { ...@@ -1131,7 +1216,7 @@ export default class CreateParameter extends Component {
} }
validasiFormatData() { validasiFormatData() {
if (R.isNil(this.state.getFormatData)){ if (R.isNil(this.state.getFormatData)) {
this.validasiFormatResponse() this.validasiFormatResponse()
this.validasiMaxValue() this.validasiMaxValue()
} else { } else {
...@@ -1146,7 +1231,7 @@ export default class CreateParameter extends Component { ...@@ -1146,7 +1231,7 @@ export default class CreateParameter extends Component {
this.validasiMinResponse() this.validasiMinResponse()
this.validasiFormatData() this.validasiFormatData()
} else { } else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength){ if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
this.validasiFormatData() this.validasiFormatData()
} else { } else {
this.validasiMinResponse() this.validasiMinResponse()
...@@ -1155,55 +1240,55 @@ export default class CreateParameter extends Component { ...@@ -1155,55 +1240,55 @@ export default class CreateParameter extends Component {
} }
} }
async validasiValue (){ async validasiValue() {
let data = await this.validasiValueData() let data = await this.validasiValueData()
let response = await this.validasiRegexValue() let response = await this.validasiRegexValue()
if (R.isEmpty(data.value)){ if (R.isEmpty(data.value)) {
this.validasiValueResponse() this.validasiValueResponse()
this.validsiMinValue() this.validsiMinValue()
}else { } else {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength){ if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
this.validsiMinValue() this.validsiMinValue()
}else { } else {
this.validasiValueResponse() this.validasiValueResponse()
this.validsiMinValue() this.validsiMinValue()
} }
} }
} }
validasiReportName(){ validasiReportName() {
if (R.isNil(this.state.getReportName)){ if (R.isNil(this.state.getReportName)) {
this.setState({ errorReportName: true, msgErrorReportName: 'Report Cannot be Empty' }) this.setState({ errorReportName: true, msgErrorReportName: 'Report Cannot be Empty' })
this.validasiValue() this.validasiValue()
}else { } else {
this.validasiValue() this.validasiValue()
} }
} }
validasiPerusahaan(){ validasiPerusahaan() {
if (R.isNil(this.state.getPerusahaan)){ if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' }) this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
this.validasiReportName() this.validasiReportName()
}else { } else {
this.validasiReportName() this.validasiReportName()
this.validasiCreateEdit() this.validasiCreateEdit()
} }
} }
validasiParameter(){ validasiParameter() {
if(R.isNil(this.state.getParameter)){ if (R.isNil(this.state.getParameter)) {
this.setState({ errorParameter: true, msgErrorParameter: 'Parameter Cannot be Empty' }) this.setState({ errorParameter: true, msgErrorParameter: 'Parameter Cannot be Empty' })
this.validasiPerusahaan() this.validasiPerusahaan()
}else { } else {
this.validasiPerusahaan() this.validasiPerusahaan()
} }
} }
validasiGroup(){ validasiGroup() {
if (R.isNil(this.state.getTypes)) { if (R.isNil(this.state.getTypes)) {
this.setState({ errorGroup: true, msgErrorGroup: 'Group Cannot be Empty' }) this.setState({ errorGroup: true, msgErrorGroup: 'Group Cannot be Empty' })
this.validasiParameter() this.validasiParameter()
}else { } else {
this.validasiParameter() this.validasiParameter()
} }
} }
...@@ -1307,9 +1392,9 @@ export default class CreateParameter extends Component { ...@@ -1307,9 +1392,9 @@ export default class CreateParameter extends Component {
} }
openPopUp() { openPopUp() {
if (!R.isNil(this.state.getTypes)){ if (!R.isNil(this.state.getTypes)) {
if (this.state.getTypes.setting_group_name == "CURRENCY"){ if (this.state.getTypes.setting_group_name == "CURRENCY") {
if (!R.isNil(this.state.getReportName)){ if (!R.isNil(this.state.getReportName)) {
this.setState({ this.setState({
visiblePopupInformation: true visiblePopupInformation: true
}) })
...@@ -1374,7 +1459,7 @@ export default class CreateParameter extends Component { ...@@ -1374,7 +1459,7 @@ export default class CreateParameter extends Component {
{...this.state.types} {...this.state.types}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, enableReportName: false, enableFormat: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())} onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, enableReportName: false, enableFormat: false, enableThreshold: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())}
renderInput={(params) => renderInput={(params) =>
<TextField <TextField
{...params} {...params}
...@@ -1578,6 +1663,27 @@ export default class CreateParameter extends Component { ...@@ -1578,6 +1663,27 @@ export default class CreateParameter extends Component {
/> />
</div> </div>
: :
this.state.enableThreshold == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.thresholdCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getThresholdCurrency: newInputValue }, () =>
this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Currency"
error={this.state.errorThresholdCurrency}
helperText={this.state.msgErrorThresholdCurrency}
/>}
value={this.state.getThresholdCurrency}
/>
</div>
:
null null
} }
{/* {this.state.enableFormat == true ? {/* {this.state.enableFormat == true ?
...@@ -1863,7 +1969,7 @@ export default class CreateParameter extends Component { ...@@ -1863,7 +1969,7 @@ export default class CreateParameter extends Component {
{...this.state.types} {...this.state.types}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, enableReportName: false, enableFormat: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())} onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, enableReportName: false, enableFormat: false, enableThreshold: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())}
renderInput={(params) => renderInput={(params) =>
<TextField <TextField
{...params} {...params}
...@@ -2026,7 +2132,8 @@ export default class CreateParameter extends Component { ...@@ -2026,7 +2132,8 @@ export default class CreateParameter extends Component {
id="report" id="report"
onChange={(event, newInputValue) => this.setState({ getReportName: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ getReportName: newInputValue }, () => {
this.clearMessage() this.clearMessage()
this.openPopUp()})} this.openPopUp()
})}
renderInput={(params) => renderInput={(params) =>
<TextField <TextField
{...params} {...params}
...@@ -2060,6 +2167,26 @@ export default class CreateParameter extends Component { ...@@ -2060,6 +2167,26 @@ export default class CreateParameter extends Component {
/> />
</div> </div>
: :
this.state.enableThreshold == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.thresholdCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getThresholdCurrency: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Currency"
error={this.state.errorThresholdCurrency}
helperText={this.state.msgErrorThresholdCurrency}
/>}
value={this.state.getThresholdCurrency}
/>
</div>
:
null null
} }
......
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