Commit 5bd11c52 authored by Riri Novita's avatar Riri Novita

Merge branch 'ENV-DEV' into 'ENV-STAGING'

Update Parameter

See merge request !2069
parents 82b1f8fd cfb3808c
...@@ -190,6 +190,7 @@ const create = (type = "") => { ...@@ -190,6 +190,7 @@ const create = (type = "") => {
const deleteParameter = (id) => api.post(`setting/delete_setting/${id}`) const deleteParameter = (id) => api.post(`setting/delete_setting/${id}`)
const getDataReport = () => api.get('setting_type/get_all_setting_type_by_report_submit_period_group') const getDataReport = () => api.get('setting_type/get_all_setting_type_by_report_submit_period_group')
const getFormatValue = () => api.get('setting_type/get_all_setting_type_by_money_format_group') const getFormatValue = () => api.get('setting_type/get_all_setting_type_by_money_format_group')
const getThreshold = () => api.get('/setting_type/get_all_setting_type_by_threshold_control')
// MASTER DATA - CAT // MASTER DATA - CAT
const getAllMasterDataCat = () => api.get('item_report_company/get_all_item_report_company') const getAllMasterDataCat = () => api.get('item_report_company/get_all_item_report_company')
...@@ -651,6 +652,7 @@ const create = (type = "") => { ...@@ -651,6 +652,7 @@ const create = (type = "") => {
deleteParameter, deleteParameter,
getDataReport, getDataReport,
getFormatValue, getFormatValue,
getThreshold,
deletePerusahaan, deletePerusahaan,
getDataCurrency, getDataCurrency,
deleteReportItems, deleteReportItems,
......
...@@ -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().getThreshold().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().getThreshold().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
...@@ -530,6 +615,8 @@ export default class CreateParameter extends Component { ...@@ -530,6 +615,8 @@ export default class CreateParameter extends Component {
errorEndDate: false, errorEndDate: false,
errorGroup: false, errorGroup: false,
errorPerusahaan: false, errorPerusahaan: false,
errorThresholdCurrency: false,
msgErrorThresholdCurrency: '',
msgErrorPerusahaan: '', msgErrorPerusahaan: '',
msgErrorGroup: '', msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
...@@ -558,6 +645,8 @@ export default class CreateParameter extends Component { ...@@ -558,6 +645,8 @@ export default class CreateParameter extends Component {
errorEndDate: false, errorEndDate: false,
errorGroup: false, errorGroup: false,
errorPerusahaan: false, errorPerusahaan: false,
errorThresholdCurrency: false,
msgErrorThresholdCurrency: '',
msgErrorPerusahaan: '', msgErrorPerusahaan: '',
msgErrorGroup: '', msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
...@@ -587,6 +676,8 @@ export default class CreateParameter extends Component { ...@@ -587,6 +676,8 @@ export default class CreateParameter extends Component {
errorEndDate: false, errorEndDate: false,
errorGroup: false, errorGroup: false,
errorPerusahaan: false, errorPerusahaan: false,
errorThresholdCurrency: false,
msgErrorThresholdCurrency: '',
msgErrorPerusahaan: '', msgErrorPerusahaan: '',
msgErrorGroup: '', msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
...@@ -617,6 +708,8 @@ export default class CreateParameter extends Component { ...@@ -617,6 +708,8 @@ export default class CreateParameter extends Component {
errorEndDate: false, errorEndDate: false,
errorGroup: false, errorGroup: false,
errorPerusahaan: false, errorPerusahaan: false,
errorThresholdCurrency: false,
msgErrorThresholdCurrency: '',
msgErrorPerusahaan: '', msgErrorPerusahaan: '',
msgErrorGroup: '', msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
...@@ -683,18 +776,17 @@ export default class CreateParameter extends Component { ...@@ -683,18 +776,17 @@ 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 {
...@@ -702,7 +794,7 @@ export default class CreateParameter extends Component { ...@@ -702,7 +794,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({
...@@ -711,43 +803,43 @@ export default class CreateParameter extends Component { ...@@ -711,43 +803,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()
} }
} }
...@@ -760,7 +852,7 @@ export default class CreateParameter extends Component { ...@@ -760,7 +852,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) {
...@@ -772,7 +864,7 @@ export default class CreateParameter extends Component { ...@@ -772,7 +864,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) {
...@@ -786,10 +878,10 @@ export default class CreateParameter extends Component { ...@@ -786,10 +878,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) {
...@@ -803,7 +895,7 @@ export default class CreateParameter extends Component { ...@@ -803,7 +895,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) {
...@@ -814,27 +906,27 @@ export default class CreateParameter extends Component { ...@@ -814,27 +906,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()
} }
} }
...@@ -859,7 +951,7 @@ export default class CreateParameter extends Component { ...@@ -859,7 +951,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) {
...@@ -873,13 +965,13 @@ export default class CreateParameter extends Component { ...@@ -873,13 +965,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()
} }
} }
...@@ -890,10 +982,10 @@ export default class CreateParameter extends Component { ...@@ -890,10 +982,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()
} }
} }
...@@ -901,11 +993,11 @@ export default class CreateParameter extends Component { ...@@ -901,11 +993,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()
} }
} }
...@@ -914,11 +1006,11 @@ export default class CreateParameter extends Component { ...@@ -914,11 +1006,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' })
} }
} }
...@@ -927,12 +1019,12 @@ export default class CreateParameter extends Component { ...@@ -927,12 +1019,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 {
...@@ -1030,16 +1122,76 @@ export default class CreateParameter extends Component { ...@@ -1030,16 +1122,76 @@ 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)) {
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 {
if (this.state.getPerusahaan.company_name == "Default") {
if (R.isNil(this.state.getParameter)) {
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
}
} else {
switch (this.state.getParameter.setting_type_name) {
case "MASTER_BUDGET":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
case "MONTHLY_REPORT":
obj = {
minMaxRegex: (/^(?:\d{1,2}|(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}))$/),
minLength: 11, maxLength: 11
}
break
case "OUTLOOK_Q1":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
case "OUTLOOK_Q2":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
case "OUTLOOK_Q3":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
case "OUTLOOK_PA":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
default:
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
}
}
} else {
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
}
}
}
break break
case "THRESHOLD_CONTROL": case "THRESHOLD_CONTROL":
obj = { minMaxRegex: (/^-?\d+\.?\d+$/), minLength: this.state.minValue.length, maxLength: this.state.maxValue.length } obj = { minMaxRegex: (/-?\d+(\.?\d+)?$/), minLength: this.state.minValue.length, maxLength: this.state.maxValue.length }
break break
default: default:
obj = { regexValue: null, minLength: 11, maxLength: 11 } obj = { regexValue: null, minLength: 11, maxLength: 11 }
...@@ -1048,31 +1200,52 @@ export default class CreateParameter extends Component { ...@@ -1048,31 +1200,52 @@ 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;
} }
validasiCurrencyTC(){
console.log(this.state.getThresholdCurrency)
console.log(this.state.errorThresholdCurrency)
console.log(this.state.msgErrorThresholdCurrency)
if (R.isNil(this.state.getThresholdCurrency)){
this.setState({ errorThresholdCurrency: true, msgErrorThresholdCurrency: 'Currency Cannot be Empty' })
}
}
async validasiMaxValue() { async validasiMaxValue() {
let data = await this.validasiValueData() let data = await this.validasiValueData()
let minMaxValidasi = await this.validasiMinMaxValue() let minMaxValidasi = await this.validasiMinMaxValue()
if (R.isEmpty(data.maxValue)) { if (R.isEmpty(data.maxValue)) {
this.validasiMaxResponse() this.validasiMaxResponse()
this.validasiCurrencyTC()
} else { } else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) { if (R.isNil(this.state.getTypes)){
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0,1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
this.validasiCurrencyTC()
} else {
this.validasiMaxResponse()
this.validasiCurrencyTC()
}
}else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.maxValue.substring(0,1) != "0" : true ) && data.maxValue.length <= minMaxValidasi.maxLength) {
this.validasiCurrencyTC()
} else { } else {
this.validasiMaxResponse() this.validasiMaxResponse()
this.validasiCurrencyTC()
}
} }
} }
} }
validasiFormatData() { validasiFormatData() {
if (R.isNil(this.state.getFormatData)){ if (R.isNil(this.state.getFormatData)) {
this.validasiFormatResponse() this.validasiFormatResponse()
this.validasiMaxValue() this.validasiMaxValue()
} else { } else {
...@@ -1087,64 +1260,73 @@ export default class CreateParameter extends Component { ...@@ -1087,64 +1260,73 @@ export default class CreateParameter extends Component {
this.validasiMinResponse() this.validasiMinResponse()
this.validasiFormatData() this.validasiFormatData()
} else { } else {
if (R.isNil(this.state.getTypes)){
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()
this.validasiFormatData() this.validasiFormatData()
} }
}else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.minValue.substring(0,1) != "0" : true ) && data.minValue.length <= minMaxValidasi.minLength){
this.validasiFormatData()
} else {
this.validasiMinResponse()
this.validasiFormatData()
}
}
} }
} }
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()
} }
} }
...@@ -1248,9 +1430,9 @@ export default class CreateParameter extends Component { ...@@ -1248,9 +1430,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
}) })
...@@ -1315,7 +1497,7 @@ export default class CreateParameter extends Component { ...@@ -1315,7 +1497,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}
...@@ -1519,6 +1701,27 @@ export default class CreateParameter extends Component { ...@@ -1519,6 +1701,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 ?
...@@ -1804,7 +2007,7 @@ export default class CreateParameter extends Component { ...@@ -1804,7 +2007,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}
...@@ -1967,7 +2170,8 @@ export default class CreateParameter extends Component { ...@@ -1967,7 +2170,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}
...@@ -2001,6 +2205,26 @@ export default class CreateParameter extends Component { ...@@ -2001,6 +2205,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