Commit ee725aba authored by Riri Novita's avatar Riri Novita

Parameter Setting Currency USD

parent 8083f146
...@@ -184,6 +184,7 @@ const create = (type = "") => { ...@@ -184,6 +184,7 @@ const create = (type = "") => {
const uploadParameter = (body) => api.post('/setting/import_setting', body) const uploadParameter = (body) => api.post('/setting/import_setting', body)
const searchParameter = (body) => api.post('setting/search_setting', body) const searchParameter = (body) => api.post('setting/search_setting', body)
const deleteParameter = (id) => api.post(`setting/delete_setting/${id}`) const deleteParameter = (id) => api.post(`setting/delete_setting/${id}`)
const getDataReport = () => api.get('type_report/get_all_type_report')
// 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')
...@@ -608,6 +609,7 @@ const create = (type = "") => { ...@@ -608,6 +609,7 @@ const create = (type = "") => {
getDetailReportMB, getDetailReportMB,
deleteUnitBisnis, deleteUnitBisnis,
deleteParameter, deleteParameter,
getDataReport,
deletePerusahaan, deletePerusahaan,
deleteReportItems, deleteReportItems,
getCarfmDocumentBySubmenu, getCarfmDocumentBySubmenu,
......
...@@ -38,6 +38,7 @@ export default class CreateParameter extends Component { ...@@ -38,6 +38,7 @@ export default class CreateParameter extends Component {
tempData: null, tempData: null,
errorParameter: false, errorParameter: false,
errorDeskripsi: false, errorDeskripsi: false,
errorReportName: false,
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
...@@ -50,6 +51,7 @@ export default class CreateParameter extends Component { ...@@ -50,6 +51,7 @@ export default class CreateParameter extends Component {
msgErrorGroup: '', msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorReportName: '',
msgErrorValue: '', msgErrorValue: '',
msgErrorMinValue: '', msgErrorMinValue: '',
msgErrorOrder: '', msgErrorOrder: '',
...@@ -76,7 +78,7 @@ export default class CreateParameter extends Component { ...@@ -76,7 +78,7 @@ export default class CreateParameter extends Component {
getDetailParameter() { getDetailParameter() {
api.create().getDetailParameter(this.props.data[0]).then((response) => { api.create().getDetailParameter(this.props.data[0]).then((response) => {
// console.log(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') {
...@@ -86,11 +88,15 @@ export default class CreateParameter extends Component { ...@@ -86,11 +88,15 @@ export default class CreateParameter extends Component {
getSettingGroupID: response.data.data.setting_group_id, getSettingGroupID: response.data.data.setting_group_id,
getCompanyID: data.company_id, getCompanyID: data.company_id,
settingType: data.setting_type, settingType: data.setting_type,
getSettingTypeID: data.setting_type_id getSettingTypeID: data.setting_type_id,
typeReport: data.type_report_name,
getTypeReportID: data.type_report_id,
enableReportName: data.setting_group === "CURRENCY" ? true : false
}, () => { }, () => {
this.getAllGroup() this.getAllGroup()
this.getPerusahaan() this.getPerusahaan()
// console.log(this.state.tempData) this.getReport()
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -129,7 +135,7 @@ export default class CreateParameter extends Component { ...@@ -129,7 +135,7 @@ export default class CreateParameter extends Component {
getOptionLabel: (option) => option.setting_group_name, getOptionLabel: (option) => option.setting_group_name,
}; };
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] }, () => { this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] }, () => {
this.getParameterByGroup(this.state.getTypes.setting_group_id) this.getParameterByGroup(this.state.getTypes.setting_group_id, this.state.getTypes.setting_group_name)
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -191,6 +197,43 @@ export default class CreateParameter extends Component { ...@@ -191,6 +197,43 @@ export default class CreateParameter extends Component {
}) })
} }
getReport() {
api.create().getDataReport().then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let reportData = data.map((item) => {
return {
type_report_id: item.type_report_id,
type_report_name: item.type_report_name
}
})
let index = reportData.findIndex((val) => val.type_report_id == this.state.getTypeReportID)
let reportProps = {
options: reportData,
getOptionLabel: (option) => option.type_report_name,
};
this.setState({ reportName: reportProps, reportData: response.data.data, getReportName: index == -1 ? reportData[0] : reportData[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) {
...@@ -267,11 +310,11 @@ export default class CreateParameter extends Component { ...@@ -267,11 +310,11 @@ export default class CreateParameter extends Component {
}) })
} }
getParameterByGroup(id) { getParameterByGroup(id, name) {
if (id === 13) { if (name === "CURRENCY") {
this.setState({ enableReportName: true}) this.setState({ enableReportName: true })
} else { } else {
this.setState({ enableReportName: false}) this.setState({ enableReportName: false })
} }
api.create().getParameterByGroup(id).then(response => { api.create().getParameterByGroup(id).then(response => {
// console.log(id, response); // console.log(id, response);
...@@ -311,82 +354,68 @@ export default class CreateParameter extends Component { ...@@ -311,82 +354,68 @@ export default class CreateParameter extends Component {
} }
getDataReportName() { getDataReportName() {
let reportData = [ api.create().getDataReport().then((response) => {
{ console.log(response);
"report_id": 12, if (response.data) {
"report_name": "Master Budget" if (response.ok) {
}, if (response.data.status == 'success') {
{ let data = response.data.data
"report_id": 16, let reportData = data.map((item) => {
"report_name": "Monthly Report - Jan" return {
}, type_report_id: item.type_report_id,
{ type_report_name: item.type_report_name
"report_id": 17, }
"report_name": "Monthly Report - Feb" })
}, let reportProps = {
{ options: reportData,
"report_id": 18, getOptionLabel: (option) => option.type_report_name,
"report_name": "Monthly Report - Mar" };
}, this.setState({ reportName: reportProps, reportData: response.data.data })
{ } else {
"report_id": 19, this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
"report_name": "Monthly Report - Apr" if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
}, setTimeout(() => {
{ localStorage.removeItem(Constant.TOKEN)
"report_id": 20, window.location.reload();
"report_name": "Monthly Report - May" }, 1000);
}, }
{ })
"report_id": 21, }
"report_name": "Monthly Report - Jun" } else {
}, this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
{ }
"report_id": 22, } else {
"report_name": "Monthly Report - Jul" this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
},
{
"report_id": 23,
"report_name": "Monthly Report - Aug"
},
{
"report_id": 24,
"report_name": "Monthly Report - Sep"
},
{
"report_id": 25,
"report_name": "Monthly Report - Oct"
},
{
"report_id": 26,
"report_name": "Monthly Report - Nov"
},
{
"report_id": 27,
"report_name": "Monthly Report - Dec"
},
{
"report_id": 13,
"report_name": "Rolling Outlook Q1"
},
{
"report_id": 14,
"report_name": "Rolling Outlook Q2"
},
{
"report_id": 16,
"report_name": "Rolling Outlook Q3"
},
{
"report_id": 11,
"report_name": "Operating Indicator"
} }
})
// let reportData = [
// {
// "type_report_id": 1,
// "report_name": "Master Budget"
// },
// {
// "type_report_id": 2,
// "report_name": "Monthly Report"
// },
// {
// "type_report_id": 3,
// "report_name": "Rolling Outlook"
// },
// {
// "type_report_id": 4,
// "report_name": "Outlook PA"
// },
// {
// "type_report_id": 5,
// "report_name": "Operating Indicator"
// }
// ]
] // let reportProps = {
let reportProps = { // options: reportData.sort((a, b) => a.report_id - b.report_id),
options: reportData.sort((a, b) => a.report_id - b.report_id), // getOptionLabel: (option) => option.report_name,
getOptionLabel: (option) => option.report_name, // };
}; // this.setState({ reportName: reportProps })
this.setState({ reportName: reportProps })
} }
handleChange(e, type) { handleChange(e, type) {
...@@ -397,6 +426,7 @@ export default class CreateParameter extends Component { ...@@ -397,6 +426,7 @@ export default class CreateParameter extends Component {
...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null }, ...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null },
errorParameter: false, errorParameter: false,
errorDeskripsi: false, errorDeskripsi: false,
errorReportName: false,
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
...@@ -409,6 +439,7 @@ export default class CreateParameter extends Component { ...@@ -409,6 +439,7 @@ export default class CreateParameter extends Component {
msgErrorGroup: '', msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorReportName: '',
msgErrorValue: '', msgErrorValue: '',
msgErrorMinValue: '', msgErrorMinValue: '',
msgErrorOrder: '', msgErrorOrder: '',
...@@ -421,6 +452,7 @@ export default class CreateParameter extends Component { ...@@ -421,6 +452,7 @@ export default class CreateParameter extends Component {
...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') }, ...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
errorParameter: false, errorParameter: false,
errorDeskripsi: false, errorDeskripsi: false,
errorReportName: false,
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
...@@ -433,6 +465,7 @@ export default class CreateParameter extends Component { ...@@ -433,6 +465,7 @@ export default class CreateParameter extends Component {
msgErrorGroup: '', msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorReportName: '',
msgErrorValue: '', msgErrorValue: '',
msgErrorMinValue: '', msgErrorMinValue: '',
msgErrorOrder: '', msgErrorOrder: '',
...@@ -446,6 +479,7 @@ export default class CreateParameter extends Component { ...@@ -446,6 +479,7 @@ export default class CreateParameter extends Component {
tempData: { ...this.state.tempData, [e.target.name]: e.target.value }, tempData: { ...this.state.tempData, [e.target.name]: e.target.value },
errorParameter: false, errorParameter: false,
errorDeskripsi: false, errorDeskripsi: false,
errorReportName: false,
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
...@@ -458,6 +492,7 @@ export default class CreateParameter extends Component { ...@@ -458,6 +492,7 @@ export default class CreateParameter extends Component {
msgErrorGroup: '', msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorReportName: '',
msgErrorValue: '', msgErrorValue: '',
msgErrorMinValue: '', msgErrorMinValue: '',
msgErrorOrder: '', msgErrorOrder: '',
...@@ -475,6 +510,7 @@ export default class CreateParameter extends Component { ...@@ -475,6 +510,7 @@ export default class CreateParameter extends Component {
errorValue: false, errorValue: false,
errorMinValue: false, errorMinValue: false,
errorOrder: false, errorOrder: false,
errorReportName: false,
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
...@@ -489,7 +525,8 @@ export default class CreateParameter extends Component { ...@@ -489,7 +525,8 @@ export default class CreateParameter extends Component {
msgErrorOrder: '', msgErrorOrder: '',
msgErrorMaxValue: '', msgErrorMaxValue: '',
msgErrorStartDate: '', msgErrorStartDate: '',
msgErrorEndDate: '' msgErrorEndDate: '',
msgErrorReportName: ''
}) })
} }
...@@ -518,6 +555,8 @@ export default class CreateParameter extends Component { ...@@ -518,6 +555,8 @@ export default class CreateParameter extends Component {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' }) this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
// } 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)) {
this.setState({ errorReportName: true, msgErrorReportName: 'Report Name 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))) {
...@@ -536,6 +575,7 @@ export default class CreateParameter extends Component { ...@@ -536,6 +575,7 @@ export default class CreateParameter extends Component {
} }
validasiCreate() { validasiCreate() {
console.log(this.state.getTypes);
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' })
} else if (R.isNil(this.state.getParameter)) { } else if (R.isNil(this.state.getParameter)) {
...@@ -544,6 +584,8 @@ export default class CreateParameter extends Component { ...@@ -544,6 +584,8 @@ export default class CreateParameter extends Component {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' }) this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
// } 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)) {
this.setState({ errorReportName: true, msgErrorReportName: 'Report Name 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))) {
...@@ -567,6 +609,7 @@ export default class CreateParameter extends Component { ...@@ -567,6 +609,7 @@ export default class CreateParameter extends Component {
"setting_group_id": this.state.getTypes.setting_group_id, "setting_group_id": this.state.getTypes.setting_group_id,
"setting_type_id": this.state.getParameter.setting_type_id, "setting_type_id": this.state.getParameter.setting_type_id,
"company_id": this.state.getPerusahaan.company_id, "company_id": this.state.getPerusahaan.company_id,
"type_report_id": this.state.getReportName.type_report_id,
"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,
...@@ -584,6 +627,7 @@ export default class CreateParameter extends Component { ...@@ -584,6 +627,7 @@ export default class CreateParameter extends Component {
"setting_group_id": this.state.getTypes.setting_group_id, "setting_group_id": this.state.getTypes.setting_group_id,
"setting_type_id": this.state.getParameter.setting_type_id, "setting_type_id": this.state.getParameter.setting_type_id,
"company_id": this.state.getPerusahaan.company_id, "company_id": this.state.getPerusahaan.company_id,
"type_report_id": this.state.getReportName.type_report_id,
"description": this.state.description, "description": this.state.description,
"orders": this.state.order, "orders": this.state.order,
"value": this.state.value, "value": this.state.value,
...@@ -815,7 +859,7 @@ export default class CreateParameter extends Component { ...@@ -815,7 +859,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, getParameter: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id), this.clearMessage())} 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())}
renderInput={(params) => renderInput={(params) =>
<TextField <TextField
{...params} {...params}
...@@ -879,6 +923,28 @@ export default class CreateParameter extends Component { ...@@ -879,6 +923,28 @@ export default class CreateParameter extends Component {
> >
</TextField> </TextField>
</div> </div>
{this.state.enableReportName &&
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.reportName}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getReportName: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Report Name"
// error={this.state.errorPerusahaan}
// helperText={this.state.msgErrorPerusahaan}
/>}
value={this.state.getReportName}
/>
</div>
}
<div style={{ marginTop: '80px', padding: 10, borderRadius: 5 }}> <div style={{ marginTop: '80px', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
...@@ -1198,7 +1264,7 @@ export default class CreateParameter extends Component { ...@@ -1198,7 +1264,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 }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id), this.clearMessage())} 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())}
renderInput={(params) => renderInput={(params) =>
<TextField <TextField
{...params} {...params}
...@@ -1276,8 +1342,8 @@ export default class CreateParameter extends Component { ...@@ -1276,8 +1342,8 @@ export default class CreateParameter extends Component {
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Report Name" label="Report Name"
// error={this.state.errorPerusahaan} error={this.state.errorReportName}
// helperText={this.state.msgErrorPerusahaan} helperText={this.state.msgErrorReportName}
/>} />}
value={this.state.getReportName} value={this.state.getReportName}
/> />
......
...@@ -107,7 +107,7 @@ export default class Parameter extends Component { ...@@ -107,7 +107,7 @@ export default class Parameter extends Component {
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
// console.log(response); console.log(response);
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
return [ return [
...@@ -308,6 +308,7 @@ export default class Parameter extends Component { ...@@ -308,6 +308,7 @@ export default class Parameter extends Component {
else { else {
// let judul = resp.rows[2] // let judul = resp.rows[2]
let isi = resp.rows.slice(3) let isi = resp.rows.slice(3)
console.log(isi);
let payload = [] let payload = []
isi.map((item, index) => { isi.map((item, index) => {
if (item.length > 0) { if (item.length > 0) {
...@@ -316,13 +317,14 @@ export default class Parameter extends Component { ...@@ -316,13 +317,14 @@ export default class Parameter extends Component {
group: item[0] === undefined ? "" : item[0], group: item[0] === undefined ? "" : item[0],
parameter: item[1] === undefined ? "" : item[1], parameter: item[1] === undefined ? "" : item[1],
company: item[2] === undefined ? "" : item[2], company: item[2] === undefined ? "" : item[2],
description: item[3] === undefined ? "" : item[3], type_report: item[3] === undefined ? "" : item[3],
orders: item[4] === undefined ? "" : item[4], description: item[4] === undefined ? "" : item[4],
value: item[5] === undefined ? "" : item[5], orders: item[5] === undefined ? "" : item[5],
min_value: item[6] === undefined ? "" : item[6], value: item[6] === undefined ? "" : item[6],
max_value: item[7] === undefined ? "" : item[7], min_value: item[7] === undefined ? "" : item[7],
start_date: item[8] === undefined ? "" : item[8], max_value: item[8] === undefined ? "" : item[8],
end_date: item[9] === undefined ? "" : item[9], start_date: item[9] === undefined ? "" : item[9],
end_date: item[10] === undefined ? "" : item[10],
}) })
} }
}) })
...@@ -337,7 +339,7 @@ export default class Parameter extends Component { ...@@ -337,7 +339,7 @@ export default class Parameter extends Component {
checkUpload() { checkUpload() {
api.create().checkUploadParameter(this.state.payload).then(response => { api.create().checkUploadParameter(this.state.payload).then(response => {
// console.log(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") {
...@@ -347,6 +349,7 @@ export default class Parameter extends Component { ...@@ -347,6 +349,7 @@ export default class Parameter extends Component {
item.group, item.group,
item.parameter, item.parameter,
item.company, item.company,
item.type_report,
item.description, item.description,
item.orders, item.orders,
item.value, item.value,
...@@ -363,17 +366,18 @@ export default class Parameter extends Component { ...@@ -363,17 +366,18 @@ export default class Parameter extends Component {
name: "Group", name: "Group",
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
console.log(tableMeta);
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('group')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('group'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
...@@ -388,16 +392,16 @@ export default class Parameter extends Component { ...@@ -388,16 +392,16 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('parameter')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('parameter'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
...@@ -412,16 +416,40 @@ export default class Parameter extends Component { ...@@ -412,16 +416,40 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('company')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('company'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
}
</div >
);
}
}
},
{
name: "Type Report",
options: {
customBodyRender: (val, tableMeta) => {
let check = null
if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[12].findIndex((val) => val.field.includes('type_report'))
if (check > -1) {
this.setState({ buttonError: true })
}
}
return (
<div style={{ display: 'flex' }}>
{tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
...@@ -436,16 +464,16 @@ export default class Parameter extends Component { ...@@ -436,16 +464,16 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('description')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('description'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
...@@ -460,16 +488,16 @@ export default class Parameter extends Component { ...@@ -460,16 +488,16 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('order')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('order'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
...@@ -484,16 +512,16 @@ export default class Parameter extends Component { ...@@ -484,16 +512,16 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('value')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('value'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
...@@ -508,16 +536,16 @@ export default class Parameter extends Component { ...@@ -508,16 +536,16 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('min_value')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('min_value'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
...@@ -532,16 +560,16 @@ export default class Parameter extends Component { ...@@ -532,16 +560,16 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('max_value')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('max_value'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
...@@ -556,16 +584,16 @@ export default class Parameter extends Component { ...@@ -556,16 +584,16 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('start_date')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('start_date'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
...@@ -580,16 +608,16 @@ export default class Parameter extends Component { ...@@ -580,16 +608,16 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[11] != null) { if (tableMeta.rowData[12] != null) {
check = tableMeta.rowData[11].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[12].findIndex((val) => val.field.includes('end_date'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[12] != null && check > -1 ?
<LightTooltip title={tableMeta.rowData[11][check].message} arrow> <LightTooltip title={tableMeta.rowData[12][check].message} arrow>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</LightTooltip> : </LightTooltip> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
...@@ -647,7 +675,7 @@ export default class Parameter extends Component { ...@@ -647,7 +675,7 @@ export default class Parameter extends Component {
uploadParameter() { uploadParameter() {
api.create().uploadParameter(this.state.payload).then(response => { api.create().uploadParameter(this.state.payload).then(response => {
// console.log(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") {
......
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