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