Commit 9be36deb authored by Riri Novita's avatar Riri Novita

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

update parameter

See merge request !1908
parents 750b9205 bdcec7ae
......@@ -616,6 +616,7 @@ export default class CreateParameter extends Component {
"description": this.state.tempData.description,
"orders": this.state.tempData.order,
// "value": this.state.tempData.value,
// convert IDR to IDR mn
"value": this.state.enableReportName ? this.state.tempData.value.includes(".") || arrayChar.length == 2 ? this.state.tempData.value : Number((this.state.tempData.value)/1000).toFixed(1) : this.state.tempData.value ,
"max_value": this.state.tempData.max_value,
"min_value": this.state.tempData.min_value,
......@@ -637,7 +638,8 @@ export default class CreateParameter extends Component {
"reference_id": this.state.getReportName == null ? null : this.state.getReportName.setting_type_id,
"description": this.state.description,
"orders": this.state.order,
"value": this.state.value.includes(".") && arrayChar.length == 2 ? this.state.value : Number((this.state.value)/1000).toFixed(1) ,
// convert IDR to IDR mn
"value": this.state.enableReportName ? this.state.value.includes(".") || arrayChar.length == 2 ? this.state.value : Number((this.state.value)/1000).toFixed(1) : this.state.value ,
"max_value": this.state.maxValue,
"min_value": this.state.minValue,
"start_date": this.state.startDate,
......@@ -830,7 +832,8 @@ export default class CreateParameter extends Component {
style={{ width: '100%' }}
id="value"
label= {"Value"}
value={this.state.tempData === null ? '' : this.state.tempData.value}
// get data IDR by IDR mn
value={this.state.tempData === null ? '' : this.state.tempData.setting_group === "CURRENCY" ? Number(this.state.tempData.value )*1000 : this.state.tempData.value}
inputProps={{
min: 0,
style: {
......@@ -1266,7 +1269,7 @@ export default class CreateParameter extends Component {
<TextField
style={{ width: '100%' }}
id="value"
label= {this.state.enableReportName ? "Value IDR mn" : "Value"}
label= {"Value"}
value={this.state.value}
inputProps={{
min: 0,
......
......@@ -62,7 +62,7 @@ export default class Parameter extends Component {
this.getSizeUpload()
}
getSizeUpload(){
getSizeUpload() {
let body = {
group: 'MAX_FILE_SIZE',
company_id: 0,
......@@ -104,6 +104,7 @@ export default class Parameter extends Component {
getAllParameter() {
this.setState({ loading: true })
api.create().getAllParameter().then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
......@@ -118,7 +119,7 @@ export default class Parameter extends Component {
item.company_name,
item.description,
item.order,
item.value,
item.setting_group === "CURRENCY" ? Number(item.value) * 1000 : item.value, // convert IDR mn to IDR
item.min_value,
item.max_value,
item.status
......@@ -332,6 +333,7 @@ export default class Parameter extends Component {
let body = {
setting: payload
}
console.log(body);
// console.log(resp.rows[1]);
this.setState({ payload: body, buttonError: false, judul: resp.rows[1] === undefined ? "" : resp.rows[1][0] })
}
......@@ -675,8 +677,19 @@ export default class Parameter extends Component {
}
uploadParameter() {
console.log(this.state.payload);
api.create().uploadParameter(this.state.payload).then(response => {
let payload = this.state.payload
let arr = []
for (let index = 0; index < payload.setting.length; index++) {
let item = payload.setting[index]
arr.push({
...item,
value: item?.group === 'CURRENCY' ? Number(item?.value)/1000 : item?.value
})
}
payload = {
setting: arr
}
api.create().uploadParameter(payload).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
......
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