Commit 91b63baf authored by Riri Novita's avatar Riri Novita

setting full aount

parent da0ebf69
...@@ -14,6 +14,7 @@ export default class CreateParameter extends Component { ...@@ -14,6 +14,7 @@ export default class CreateParameter extends Component {
this.state = { this.state = {
enableParameter: false, enableParameter: false,
enableReportName: false, enableReportName: false,
enableFormat: false,
id: '', id: '',
description: '', description: '',
value: '', value: '',
...@@ -29,7 +30,9 @@ export default class CreateParameter extends Component { ...@@ -29,7 +30,9 @@ export default class CreateParameter extends Component {
getTypes: null, getTypes: null,
perusahaan: null, perusahaan: null,
reportName: null, reportName: null,
formatCurrency: null,
getReportName: null, getReportName: null,
getFormatData: null,
getPerusahaan: null, getPerusahaan: null,
parameter: null, parameter: null,
getParameter: null, getParameter: null,
...@@ -40,6 +43,7 @@ export default class CreateParameter extends Component { ...@@ -40,6 +43,7 @@ export default class CreateParameter extends Component {
errorParameter: false, errorParameter: false,
errorDeskripsi: false, errorDeskripsi: false,
errorReportName: false, errorReportName: false,
errorFormatValue: false,
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
...@@ -53,6 +57,7 @@ export default class CreateParameter extends Component { ...@@ -53,6 +57,7 @@ export default class CreateParameter extends Component {
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorReportName: '', msgErrorReportName: '',
msgErrorFormatValue: '',
msgErrorValue: '', msgErrorValue: '',
msgErrorMinValue: '', msgErrorMinValue: '',
msgErrorOrder: '', msgErrorOrder: '',
...@@ -74,6 +79,7 @@ export default class CreateParameter extends Component { ...@@ -74,6 +79,7 @@ export default class CreateParameter extends Component {
this.getDataGroup() this.getDataGroup()
this.getDataPerusahaan() this.getDataPerusahaan()
this.getDataReportName() this.getDataReportName()
this.getDataFormat()
} }
} }
...@@ -93,12 +99,14 @@ export default class CreateParameter extends Component { ...@@ -93,12 +99,14 @@ export default class CreateParameter extends Component {
typeReport: data.setting_type_name, typeReport: data.setting_type_name,
getTypeReportID: data.setting_type_id, getTypeReportID: data.setting_type_id,
enableReportName: data.setting_group === "CURRENCY" ? true : false, enableReportName: data.setting_group === "CURRENCY" ? true : false,
tesValue: response.data.data.setting_group === "CURRENCY" ? Number(response.data.data.value)*1000 : response.data.data.value enableFormat: data.setting_group === "CURRENCY_MONEY_FORMAT" ? true : false,
tesValue: response.data.data.setting_group === "CURRENCY" ? Number(response.data.data.value) * 1000 : response.data.data.value
}, () => { }, () => {
this.getAllGroup() this.getAllGroup()
this.getPerusahaan() this.getPerusahaan()
this.getReport() this.getReport()
this.getFormat()
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -236,6 +244,44 @@ export default class CreateParameter extends Component { ...@@ -236,6 +244,44 @@ export default class CreateParameter extends Component {
}) })
} }
getFormat() {
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 formatData = data.map((item) => {
return {
setting_type_id: item.setting_type_id,
setting_type_name: item.setting_type_name
}
})
let index = formatData.findIndex((val) => val.setting_type_id == this.state.tempData.reference_id)
let formatProps = {
options: formatData,
getOptionLabel: (option) => option.setting_type_name,
};
this.setState({ formatCurrency: formatProps, formatData: response.data.data, getFormatData: index == -1 ? formatData[0] : formatData[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) {
...@@ -314,9 +360,11 @@ export default class CreateParameter extends Component { ...@@ -314,9 +360,11 @@ export default class CreateParameter extends Component {
getParameterByGroup(id, name) { getParameterByGroup(id, name) {
if (name === "CURRENCY") { if (name === "CURRENCY") {
this.setState({ enableReportName: true }) this.setState({ enableReportName: true, enableFormat : false})
} else if (name === "CURRENCY_MONEY_FORMAT") {
this.setState({ enableFormat: true, enableReportName : false })
} else { } else {
this.setState({ enableReportName: false }) this.setState({ enableReportName: false, enableFormat: false })
} }
api.create().getParameterByGroup(id).then(response => { api.create().getParameterByGroup(id).then(response => {
// console.log(id, response); // console.log(id, response);
...@@ -420,6 +468,43 @@ export default class CreateParameter extends Component { ...@@ -420,6 +468,43 @@ export default class CreateParameter extends Component {
// this.setState({ reportName: reportProps }) // this.setState({ reportName: reportProps })
} }
getDataFormat() {
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 formatData = data.map((item) => {
return {
setting_type_id: item.setting_type_id,
setting_type_name: item.setting_type_name
}
})
let formatProps = {
options: formatData,
getOptionLabel: (option) => option.setting_type_name,
};
this.setState({ formatCurrency: formatProps, formatData: 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
...@@ -429,6 +514,7 @@ export default class CreateParameter extends Component { ...@@ -429,6 +514,7 @@ export default class CreateParameter extends Component {
errorParameter: false, errorParameter: false,
errorDeskripsi: false, errorDeskripsi: false,
errorReportName: false, errorReportName: false,
errorFormatValue: false,
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
...@@ -442,6 +528,7 @@ export default class CreateParameter extends Component { ...@@ -442,6 +528,7 @@ export default class CreateParameter extends Component {
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorReportName: '', msgErrorReportName: '',
msgErrorFormatValue: '',
msgErrorValue: '', msgErrorValue: '',
msgErrorMinValue: '', msgErrorMinValue: '',
msgErrorOrder: '', msgErrorOrder: '',
...@@ -455,6 +542,7 @@ export default class CreateParameter extends Component { ...@@ -455,6 +542,7 @@ export default class CreateParameter extends Component {
errorParameter: false, errorParameter: false,
errorDeskripsi: false, errorDeskripsi: false,
errorReportName: false, errorReportName: false,
errorFormatValue: false,
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
...@@ -468,6 +556,7 @@ export default class CreateParameter extends Component { ...@@ -468,6 +556,7 @@ export default class CreateParameter extends Component {
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorReportName: '', msgErrorReportName: '',
msgErrorFormatValue: '',
msgErrorValue: '', msgErrorValue: '',
msgErrorMinValue: '', msgErrorMinValue: '',
msgErrorOrder: '', msgErrorOrder: '',
...@@ -482,6 +571,7 @@ export default class CreateParameter extends Component { ...@@ -482,6 +571,7 @@ export default class CreateParameter extends Component {
errorParameter: false, errorParameter: false,
errorDeskripsi: false, errorDeskripsi: false,
errorReportName: false, errorReportName: false,
errorFormatValue: false,
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
...@@ -495,6 +585,7 @@ export default class CreateParameter extends Component { ...@@ -495,6 +585,7 @@ export default class CreateParameter extends Component {
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorReportName: '', msgErrorReportName: '',
msgErrorFormatValue: '',
msgErrorValue: '', msgErrorValue: '',
msgErrorMinValue: '', msgErrorMinValue: '',
msgErrorOrder: '', msgErrorOrder: '',
...@@ -513,6 +604,7 @@ export default class CreateParameter extends Component { ...@@ -513,6 +604,7 @@ export default class CreateParameter extends Component {
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
errorReportName: false, errorReportName: false,
errorFormatValue: false,
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
...@@ -528,7 +620,8 @@ export default class CreateParameter extends Component { ...@@ -528,7 +620,8 @@ export default class CreateParameter extends Component {
msgErrorMaxValue: '', msgErrorMaxValue: '',
msgErrorStartDate: '', msgErrorStartDate: '',
msgErrorEndDate: '', msgErrorEndDate: '',
msgErrorReportName: '' msgErrorReportName: '',
msgErrorFormatValue: '',
}) })
} }
...@@ -558,7 +651,9 @@ export default class CreateParameter extends Component { ...@@ -558,7 +651,9 @@ export default class CreateParameter extends Component {
// } 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 (this.state.getTypes.setting_group_name === "CURRENCY" && R.isNil(this.state.getReportName)) { } else if (this.state.getTypes.setting_group_name === "CURRENCY" && R.isNil(this.state.getReportName)) {
this.setState({ errorReportName: true, msgErrorReportName: 'Report Cannot be Empty' }) this.setState({ errorReportName: true, msgErrorReportName: 'Type Report Cannot be Empty' })
} else if (this.state.getTypes.setting_group_name === "CURRENCY_MONEY_FORMAT" && R.isNil(this.state.getFormatData)) {
this.setState({ errorFormatValue: true, msgErrorFormatValue: 'Format Cannot be Empty' })
} else if (R.isEmpty(this.state.tempData.value) && R.isEmpty(this.state.tempData.min_value) && R.isEmpty(this.state.tempData.max_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 Cannot be Empty' }) this.setState({ errorValue: true, msgErrorValue: 'Value Cannot be Empty' })
} else if ((!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))) {
...@@ -587,7 +682,9 @@ export default class CreateParameter extends Component { ...@@ -587,7 +682,9 @@ export default class CreateParameter extends Component {
// } 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 (this.state.getTypes.setting_group_name === "CURRENCY" && R.isNil(this.state.getReportName)) { } else if (this.state.getTypes.setting_group_name === "CURRENCY" && R.isNil(this.state.getReportName)) {
this.setState({ errorReportName: true, msgErrorReportName: 'Report Cannot be Empty' }) this.setState({ errorReportName: true, msgErrorReportName: 'Type Report Cannot be Empty' })
} else if (this.state.getTypes.setting_group_name === "CURRENCY_MONEY_FORMAT" && R.isNil(this.state.getFormatData)) {
this.setState({ errorFormatValue: true, msgErrorFormatValue: 'Format Cannot be Empty' })
} else if ((R.isEmpty(this.state.value) && R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) { } else if ((R.isEmpty(this.state.value) && R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) {
this.setState({ errorValue: true, msgErrorValue: 'Value Cannot be Empty' }) this.setState({ errorValue: true, msgErrorValue: 'Value Cannot be Empty' })
} else if ((!R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) { } else if ((!R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) {
...@@ -640,7 +737,7 @@ export default class CreateParameter extends Component { ...@@ -640,7 +737,7 @@ export default class CreateParameter extends Component {
"orders": this.state.order, "orders": this.state.order,
"value": this.state.value, "value": this.state.value,
// convert IDR to IDR mn // convert IDR to IDR mn
"value": this.state.enableReportName ? this.state.value.includes(".") || arrayChar.length == 2 ? this.state.value : this.state.value/1000 : this.state.value , "value": this.state.enableReportName ? this.state.value.includes(".") || arrayChar.length == 2 ? this.state.value : this.state.value / 1000 : 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,
...@@ -706,7 +803,7 @@ export default class CreateParameter extends Component { ...@@ -706,7 +803,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, 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, 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}
...@@ -832,9 +929,9 @@ export default class CreateParameter extends Component { ...@@ -832,9 +929,9 @@ export default class CreateParameter extends Component {
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="value" id="value"
label= {"Value"} label={"Value"}
// get data IDR by IDR mn // 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} 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: {
...@@ -852,7 +949,7 @@ export default class CreateParameter extends Component { ...@@ -852,7 +949,7 @@ export default class CreateParameter extends Component {
this.setState({ this.setState({
tempData: { tempData: {
...this.state.tempData, ...this.state.tempData,
value: this.state.tempData.setting_group === "CURRENCY" ? e.target.value/1000 : e.target.value value: this.state.tempData.setting_group === "CURRENCY" ? e.target.value / 1000 : e.target.value
} }
}) })
this.clearMessage() this.clearMessage()
...@@ -884,8 +981,50 @@ export default class CreateParameter extends Component { ...@@ -884,8 +981,50 @@ export default class CreateParameter extends Component {
/>} />}
value={this.state.getReportName} value={this.state.getReportName}
/> />
</div> : null </div>
:
this.state.enableFormat == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.formatCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getFormatData: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Format"
error={this.state.errorFormatValue}
helperText={this.state.msgErrorFormatValue}
/>}
value={this.state.getFormatData}
/>
</div>
:
null
} }
{/* {this.state.enableFormat == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.formatCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getFormatData: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Format"
error={this.state.errorFormatValue}
helperText={this.state.msgErrorFormatValue}
/>}
value={this.state.getFormatData}
/>
</div> : null
} */}
</div> </div>
</div> </div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ padding: '5px 20px' }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ padding: '5px 20px' }}>
...@@ -1145,7 +1284,7 @@ export default class CreateParameter extends Component { ...@@ -1145,7 +1284,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, 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, 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}
...@@ -1270,7 +1409,7 @@ export default class CreateParameter extends Component { ...@@ -1270,7 +1409,7 @@ export default class CreateParameter extends Component {
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="value" id="value"
label= {"Value"} label={"Value"}
value={this.state.value} value={this.state.value}
inputProps={{ inputProps={{
min: 0, min: 0,
...@@ -1301,7 +1440,7 @@ export default class CreateParameter extends Component { ...@@ -1301,7 +1440,7 @@ export default class CreateParameter extends Component {
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
{this.state.enableReportName && {this.state.enableReportName == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}> <div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete <Autocomplete
{...this.state.reportName} {...this.state.reportName}
...@@ -1320,7 +1459,30 @@ export default class CreateParameter extends Component { ...@@ -1320,7 +1459,30 @@ export default class CreateParameter extends Component {
value={this.state.getReportName} value={this.state.getReportName}
/> />
</div> </div>
:
this.state.enableFormat == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.formatCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getFormatData: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Format"
error={this.state.errorFormatValue}
helperText={this.state.msgErrorFormatValue}
/>}
value={this.state.getFormatData}
/>
</div>
:
null
} }
</div> </div>
</div> </div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ padding: '5px 20px' }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ padding: '5px 20px' }}>
......
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