Commit 79bfb438 authored by faisalhamdi's avatar faisalhamdi

editMasterDataCat

parent cc3294c7
...@@ -189,6 +189,7 @@ const create = (type = "") => { ...@@ -189,6 +189,7 @@ const create = (type = "") => {
const getAllMasterDataCat = () => api.get('item_report_company/get_all_item_report_company') const getAllMasterDataCat = () => api.get('item_report_company/get_all_item_report_company')
const getParentItemReport = (body) => api.post('item_report/get_parent_item_report_default', body) const getParentItemReport = (body) => api.post('item_report/get_parent_item_report_default', body)
const saveMasterDataCat = (body) => api.post('item_report_company/create_item_report_company', body) const saveMasterDataCat = (body) => api.post('item_report_company/create_item_report_company', body)
// const getDetailMasterDataCat = (id) => api.get(`item_report_company/create_item_report_company/${id}`)
//Transaction //Transaction
const getReportTypeBody = (body) => api.post('transaction/master_budget/get_all_report', body) const getReportTypeBody = (body) => api.post('transaction/master_budget/get_all_report', body)
...@@ -691,7 +692,8 @@ const create = (type = "") => { ...@@ -691,7 +692,8 @@ const create = (type = "") => {
getRollingOutlookBS, getRollingOutlookBS,
getAllMasterDataCat, getAllMasterDataCat,
getParentItemReport, getParentItemReport,
saveMasterDataCat saveMasterDataCat,
// getDetailMasterDataCat
} }
} }
......
...@@ -16,214 +16,216 @@ export default class EditMasterDataCAT extends Component { ...@@ -16,214 +16,216 @@ export default class EditMasterDataCAT extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
tempData: null,
InputType: null,
company: null, company: null,
parent: null, parent: null,
reportType: null, reportType: null,
startDate: null, weight: '',
endDate: null,
order: null,
description: '',
uom: '',
weight: "",
formula: '',
realVal: '',
condition: null,
date: new Date(),
listInputType: null,
listCompany: null,
listReportType: null,
listParent: null,
listKPI: null,
listMaxAch: null,
MaxAchValue: null,
KPIValue: null,
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorJenisLaporan: false,
errorPerusahaan: false,
msgErrorJenisLaporan: '',
msgErrorPerusahaan: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
errorTipeData: false,
msgErrorTipeData: '',
errorCondition: false,
msgErrorCondition: '',
msgErrorRV: '',
msgErrorSD: '',
msgErrorED: '',
disabledFormula: true,
disabledCondt: true,
disabledValue: true,
options: ['WARNING', 'STOPPER'],
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '', messageAlert: '',
kpiType: ['HIG', 'HIB'], listPeriode: null,
maxAch: ['50%', '100%', 'Unlimited'], errorWeight: false,
formulaYtd: ['SUM', 'AVG', 'LAST'], msgErrorWeight: '',
kpiTypeValue: null, getParent: []
maxAchValue: null,
formulaYTDValue: null
} }
} }
componentDidMount() { componentDidMount() {
this.getDetailReportItems(); this.getInputType()
this.getPerusahaan()
this.getReportType()
let date = format(new Date, 'yyyy-MM-dd')
this.setState({
startDate: date,
endDate: date
})
this.getPeriode()
this.getDetailUser()
this.getDetailMasterDataCat()
} }
handleChange(e, type) { getDetailUser() {
let data = this.state let userId = localStorage.getItem(Constant.USER)
let isDate = type !== '' ? true : false api.create().getDetailUser(userId).then((response) => {
if (isDate && type === 'start_date') { if (response.data) {
this.setState({ if (response.ok) {
...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null }, if (response.data.status === 'success') {
errorOrder: false, this.setState({ userCompany: response.data.data.company }, () => {
errorDesc: false, this.getCompanyActive()
errorFormula: false, })
errorRV: false, }
errorStartDate: false, }
errorEndDate: false, }
msgErrorOrder: '', })
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '',
msgErrorED: '',
})
} else if (isDate && type === 'end_date') {
this.setState({
...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '',
msgErrorED: '',
})
} else {
this.setState({
...data, tempData: { ...this.state.tempData, [e.target.name]: e.target.value },
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '',
msgErrorED: '',
})
}
} }
validasi() { getCompanyActive() {
// alert('coba ya') api.create().getPerusahaanActive().then((response) => {
if (R.isNil(this.state.reportType)) { // console.log(response);
this.setState({ errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty' }) if (response.data) {
} else if (R.isNil(this.state.company)) { if (response.data.status === 'success') {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty' }) let data = response.data.data
} else if (R.isEmpty(this.state.tempData.order)) { let comID = this.state.rawData ? this.state.rawData.company_id : 0
this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty' }) let companyData = data.map((item) => {
} else if (R.isEmpty(this.state.tempData.description)) { return {
this.setState({ errorDesc: true, msgErrorDesc: 'Description Cannot be Empty' }) company_id: item.company_id,
} else if (R.isNil(this.state.InputType)) { company_name: item.company_name,
this.setState({ errorTipeData: true, msgErrorTipeData: 'Data Type Cannot be Empty' }) }
} else if ((this.state.InputType.type_item_report_name === 'Formula' && R.isEmpty(this.state.tempData.formula)) || (this.state.InputType.type_item_report_name === 'Validation' && R.isEmpty(this.state.tempData.formula))) { })
this.setState({ errorFormula: true, msgErrorFormula: 'Formula Cannot be Empty' })
} else if (this.state.InputType.type_item_report_name === 'Validation' && R.isEmpty(this.state.tempData.condition_it_should_be)) {
this.setState({ errorRV: true, msgErrorRV: 'True Value Cannot be Empty' })
} else if (this.state.InputType.type_item_report_name === 'Validation' && R.isNil(this.state.tempData.condition_if_wrong)) {
this.setState({ errorCondition: true, msgErrorCondition: 'False Condition Cannot be Empty' })
} else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty' })
} else if (R.isNil(this.state.tempData.end_date)) {
this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty' })
} else {
this.updateReportItems()
}
let arrayBaru = []
this.state.userCompany.map((item, index) => {
let indexID = companyData.findIndex((val) => val.company_id == item)
if (indexID !== -1) {
arrayBaru.push(companyData[indexID])
}
})
if (arrayBaru.length > 0) {
arrayBaru = arrayBaru.sort((a,b) => a.company_name.localeCompare(b.company_name))
}
let defaultProps = {
options: arrayBaru,
getOptionLabel: (option) => titleCase(option.company_name),
};
let index = arrayBaru.findIndex((val) => val.company_id == comID)
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null })
}
})
} }
updateReportItems() { getPeriode() {
// alert('test') api.create().getPeriodeTransaction().then(response => {
let payload = { let currentYear = new Date().getFullYear()
"item_report_id": this.state.tempData.item_report_id, console.log(currentYear)
"report_id": this.state.reportType == null ? this.state.tempData.report_id : this.state.reportType.report_id, console.log(response)
"company_id": this.state.company == null ? this.state.tempData.company_id : this.state.company.company_id, if (response.data) {
"description": this.state.tempData.description, if (response.data.status === "success") {
"orders": this.state.tempData.order, let data = []
"parent": this.state.parent == null ? null : this.state.parent.item_report_id, response.data.data.map((item) => {
"type_report_id": this.state.InputType == null ? this.state.tempData.type_item_report_id : this.state.InputType.type_item_report_id, // if (this.state.isApprover) {
"formula": this.state.tempData.formula, if (item >= 2000 && item <= (Number(currentYear) + 1)) {
"uom": this.state.tempData.uom, data.push(item)
"weight": this.state.tempData.weight == null ? "" : this.state.tempData.weight, }
"condition_if_wrong": this.state.tempData.condition_if_wrong, // } else {
"condition_it_should_be": this.state.tempData.condition_it_should_be, // if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
"type_kpi": this.state.tempData.kpi_type, // data.push(item)
"max_ach": this.state.tempData.max_ach, // }
"formula_ytd": this.state.tempData.formula_ytd, // }
"start_date": this.state.tempData.start_date, })
"end_date": this.state.tempData.end_date let periodeData = data.map((item) => {
} return {
// console.log(payload) periode: item,
this.props.updateReportItems(payload) }
})
let defaultProps = {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
// let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
let periode = String(Number(currentYear))
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
// console.log(data)
// console.log(this.state.latestPeriode)
// console.log(periodeData)
console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index], loading: false })
}
}
})
} }
getDetailReportItems() { getParentIR() {
api.create().getDetailReportItems(this.props.data[1]).then((response) => { let payload = {
"report_id": 3,
"years": this.state.periode.periode
}
api.create().getParentItemReport(payload).then(response => {
console.log(payload)
console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.data.status === "success") {
if (response.data.status === 'success') { this.setState({ getParent: response.data.data.filter((val) => String(val.type_item_report_name).toLocaleLowerCase() != 'break')})
let data = response.data.data
this.setState({
tempData: response.data.data,
getCompanyID: data.company_id
}, () => this.getInputType(),
this.getPerusahaan(),
this.getReportType())
// console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
} }
}) })
} }
handleChange(e, item) {
let dataSource = this.state.getParent
let indexID = dataSource.findIndex((val) => val.item_report_id == item.item_report_id)
// console.log(indexID)
if (indexID != -1) {
dataSource[indexID].weight = e.target.value
this.setState({getParent: dataSource}, () => {
console.log(this.state.getParent);
})
}
console.log(e.target.value)
}
handleReportName(item) {
let indexString = String(item).indexOf('-')
let gantiNama = String(item).substr(0, indexString)
return gantiNama
}
validasi(getData) {
console.log(getData)
let jumlah = 0
getData.map((item) => {
jumlah += Number(item.weight)
})
console.log(jumlah)
if ( jumlah > 100/100 ) {
this.setState({ errorWeight: true, msgErrorWeight: 'Weight more than 100 %' })
} else if (jumlah < 100/100) {
this.setState({ errorWeight: true, msgErrorWeight: 'Weight less than 100 %' })
}
else {
this.addReportItems(getData)
}
}
addReportItems(getData) {
// alert("test")
let simpan = []
getData.map((item) => {
simpan.push({
"report_id": item.report_id,
"item_report_id": item.item_report_id,
"weight": item.weight
})
})
console.log(simpan)
let payload = {
"company_id": this.state.company.company_id,
"years": this.state.periode.periode,
"detail": simpan
}
console.log(payload)
this.props.createReportItems(payload)
}
getInputType() { getInputType() {
api.create().getInputType().then((response) => { api.create().getInputType().then((response) => {
// console.log(response) // console.log(response.data)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
...@@ -238,9 +240,7 @@ export default class EditMasterDataCAT extends Component { ...@@ -238,9 +240,7 @@ export default class EditMasterDataCAT extends Component {
options: inputData, options: inputData,
getOptionLabel: (option) => titleCase(option.type_item_report_name), getOptionLabel: (option) => titleCase(option.type_item_report_name),
}; };
this.setState({ listInputType: defaultProps, inputData: response.data.data })
let index = inputData.findIndex((val) => val.type_item_report_id === this.state.tempData.type_item_report_id)
this.setState({ listInputType: defaultProps, InputType: index === -1 ? null : inputData[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -250,6 +250,7 @@ export default class EditMasterDataCAT extends Component { ...@@ -250,6 +250,7 @@ export default class EditMasterDataCAT extends Component {
}, 1000); }, 1000);
} }
}) })
// alert(response.data.message)
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -277,100 +278,11 @@ export default class EditMasterDataCAT extends Component { ...@@ -277,100 +278,11 @@ export default class EditMasterDataCAT extends Component {
company_id: 0, company_id: 0,
company_name: 'Default' company_name: 'Default'
}) })
let index = companyData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.getCompanyID) let typeProps = {
let defaultProps = { options: companyData.sort((a, b) => a.company_id - b.company_id),
options: companyData,
getOptionLabel: (option) => option.company_name, getOptionLabel: (option) => option.company_name,
}; };
// let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id) this.setState({ listCompany: typeProps, companyData: response.data.data })
this.setState({ listCompany: defaultProps, companyData: response.data.data, company: index === -1 ? null : companyData[index], msgErrorPerusahaan: index === -1 ? 'Company has been Inactive.' : "", errorPerusahaan: index === -1 ? true : false }, () => {
this.getParent()
this.getKPIType()
this.getMaxAch()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
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' })
}
})
}
getKPIType() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'KPI_TYPE'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputKPI = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputKPI,
getOptionLabel: (option) => titleCase(option.value),
};
let index = inputKPI.findIndex((val) => val.value === this.state.tempData.kpi_type)
this.setState({ listKPI: defaultProps, inputKPI: response.data.data, KPIValue: index === -1 ? null : inputKPI[index]})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getMaxAch() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'MAX_ACHIEVEMENT'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputMaxAch = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputMaxAch,
getOptionLabel: (option) => titleCase(option.value),
};
let index = inputMaxAch.findIndex((val) => val.value === this.state.tempData.max_ach)
this.setState({ listMaxAch: defaultProps, inputMaxAch: response.data.data, MaxAchValue: index === -1 ? null : inputMaxAch[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -408,10 +320,9 @@ export default class EditMasterDataCAT extends Component { ...@@ -408,10 +320,9 @@ export default class EditMasterDataCAT extends Component {
options: reportTypeData, options: reportTypeData,
getOptionLabel: (option) => titleCase(option.report_name), getOptionLabel: (option) => titleCase(option.report_name),
}; };
this.setState({ listReportType: defaultProps, reportTypeData: response.data.data })
let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id)
this.setState({ listReportType: defaultProps, reportType: index === -1 ? null : reportTypeData[index] }, () => this.getParent())
} else { } else {
// alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => { setTimeout(() => {
...@@ -432,7 +343,6 @@ export default class EditMasterDataCAT extends Component { ...@@ -432,7 +343,6 @@ export default class EditMasterDataCAT extends Component {
getParent() { getParent() {
if (this.state.reportType !== null && this.state.company !== null) { if (this.state.reportType !== null && this.state.company !== null) {
// console.log(this.state.tempData.item_report_id)
let payload = { let payload = {
"report_id": this.state.reportType.report_id, "report_id": this.state.reportType.report_id,
"company_id": this.state.company.company_id "company_id": this.state.company.company_id
...@@ -443,27 +353,17 @@ export default class EditMasterDataCAT extends Component { ...@@ -443,27 +353,17 @@ export default class EditMasterDataCAT extends Component {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let currentIndex = null let parentData = data.map((item) => {
let parentData = data.map((item, index) => { return {
if (this.state.tempData.item_report_id !== item.item_report_id) { item_report_id: item.item_report_id,
return { description: item.description
item_report_id: item.item_report_id,
description: item.description
}
} else {
currentIndex = index
} }
}) })
if (currentIndex !== null) {
parentData.splice(currentIndex, 1)
}
// console.log(parentData)
let defaultProps = { let defaultProps = {
options: parentData, options: parentData,
getOptionLabel: (option) => titleCase(option.description), getOptionLabel: (option) => titleCase(option.description),
}; };
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent) this.setState({ listParent: defaultProps, parentData: response.data.data })
this.setState({ listParent: defaultProps, parent: index == -1 ? null : parentData[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -473,6 +373,7 @@ export default class EditMasterDataCAT extends Component { ...@@ -473,6 +373,7 @@ export default class EditMasterDataCAT extends Component {
}, 1000); }, 1000);
} }
}) })
// alert(response.data.message)
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -484,14 +385,41 @@ export default class EditMasterDataCAT extends Component { ...@@ -484,14 +385,41 @@ export default class EditMasterDataCAT extends Component {
} }
} }
clearMessage() { handleDate(item) {
this.setState({ let value = format(item, 'dd MMMM yyyy')
errorFormula: false, msgErrorFormula: '', return value
errorTipeData: false, msgErrorTipeData: '', }
errorCondition: false, msgErrorCondition: '',
errorRV: false, msgErrorRV: '', getDetailMasterDataCat() {
errorJenisLaporan: false, msgErrorJenisLaporan: '', api.create().getDetailReportItems(this.props.data[1]).then((response) => {
errorPerusahaan: false, msgErrorPerusahaan: '' console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
this.setState({
tempData: response.data.data,
getCompanyID: data.company_id
}, () => this.getInputType(),
this.getPerusahaan(),
this.getReportType())
// console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
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' })
}
}) })
} }
...@@ -503,572 +431,275 @@ export default class EditMasterDataCAT extends Component { ...@@ -503,572 +431,275 @@ export default class EditMasterDataCAT extends Component {
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8, maxHeight: 600 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="popup-title"> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Edit Data</span> <div className="popup-title">
</div> <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Create Data</span>
</div> </div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close} />
</button>
</div>
</div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={this.state.tempData === null ? '' : this.state.tempData.item_report_id}
id="ID"
label="ID"
disabled
onChange={(e) => null}
inputProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif'
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10 }}>
<Autocomplete
{...this.state.listReportType}
id="reportType"
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () =>
newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ tempData: { ...this.state.tempData, kpi_type: null, max_ach: null, formula_ytd: null } }, () => this.getParent(), this.clearMessage())
: this.getParent(), this.clearMessage()
)}
debug
renderInput={(params) =>
<TextField {...params}
label="Report Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
error={this.state.errorJenisLaporan}
helperText={this.state.msgErrorJenisLaporan}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.reportType}
/>
</div>
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10 }} >
<Autocomplete
{...this.state.listCompany}
id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => this.getParent(), this.clearMessage())}
debug
renderInput={(params) =>
<TextField {...params}
label="Company Name"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
error={this.state.errorPerusahaan}
helperText={this.state.msgErrorPerusahaan}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.company}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="order"
label="Order"
name="order"
type="number"
value={this.state.tempData === null ? '' : this.state.tempData.order}
error={this.state.errorOrder}
helperText={this.state.msgErrorOrder}
onChange={(e) => this.handleChange(e, '')}
inputProps={{
min: 0,
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif'
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
>
</TextField>
</div>
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="description"
label="Description"
name="description"
error={this.state.errorDesc}
helperText={this.state.msgErrorDesc}
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.description}
inputProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif'
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
>
</TextField>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10 }} >
<Autocomplete
{...this.state.listParent}
id="parentId"
onChange={(event, newInputValue) => this.setState({ parent: newInputValue })}
disabled={this.state.reportType == null || this.state.company == null}
debug
renderInput={(params) =>
<TextField {...params}
label="Parent ID"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.parent}
/>
</div>
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="uom"
label="UOM"
name="uom"
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.uom}
inputProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif'
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
>
</TextField>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="weight"
label="Weight"
name="weight"
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.weight}
inputProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif'
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
>
</TextField>
</div>
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10 }}>
<Autocomplete
{...this.state.listInputType}
id="inputType"
onChange={(event, newInputValue) =>
this.setState({
InputType: newInputValue,
tempData: { ...this.state.tempData, formula: '', condition_it_should_be: '', condition_if_wrong: '' },
},
() => console.log(this.state.InputType), this.clearMessage())}
debug
renderInput={(params) =>
<TextField {...params}
label="Data Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
error={this.state.errorTipeData}
helperText={this.state.msgErrorTipeData}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.InputType}
/>
</div> </div>
</div> <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<div className="column-2"> <button
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> type="button"
<TextField className="btn btn-circle btn-white"
style={{ width: '100%' }} onClick={() => this.props.onClickClose()}
id="formula"
label="Formula"
disabled={this.state.InputType == null ? true : (this.state.InputType.type_item_report_name === 'Formula' || this.state.InputType.type_item_report_name === 'Validation' || this.state.InputType.type_item_report_name === 'Formula - Summary' ? false : true)}
name="formula"
error={this.state.errorFormula}
helperText={this.state.msgErrorFormula}
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.formula}
inputProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif'
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
> >
</TextField> <img src={Images.close} />
</button>
</div> </div>
</div> </div>
</div> </div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div style={{ maxHeight: 500, overflow: 'scroll' }}>
<div className="column-1"> <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<div className="margin-top-10px" style={{ padding: 10 }}> <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
<TextField {this.state.messageAlert}
style={{ width: '100%' }} </Alert>
id="condition_it_should_be" </Snackbar>
label="True Value"
error={this.state.errorRV} <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
helperText={this.state.msgErrorRV} <div className="column-1">
disabled={this.state.InputType == null ? true : (this.state.InputType.type_item_report_name === 'Validation' ? false : true)} <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }} >
name="condition_it_should_be" <Autocomplete
onChange={(e) => this.handleChange(e, '')} {...this.state.listCompany}
value={this.state.tempData === null ? '' : this.state.tempData.condition_it_should_be} id="company"
inputProps={{ disabled={this.state.intent === 'Home' ? true : false}
style: { onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true, previewTable: false }, () => {
fontSize: 11, this.getReportType()
fontFamily: 'Nunito Sans, sans-serif' })}
} disableClearable
}} style={{ width: 250 }}
InputLabelProps={{ renderInput={(params) =>
style: { <TextField {...params}
fontSize: 11, label="Company Name"
fontFamily: 'Nunito Sans, sans-serif', InputLabelProps={{
color: '#7e8085' style: {
} fontSize: 11,
}} fontFamily: 'Nunito Sans, sans-serif',
/> color: '#7e8085'
}
}}
error={this.state.errorPerusahaan}
helperText={this.state.msgErrorPerusahaan}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.company}
/>
</div>
</div> </div>
</div> <div className="column-2">
<div className="column-2"> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div className="margin-top-10px" style={{ padding: 10 }}> <Autocomplete
<Autocomplete {...this.state.listPeriode}
value={this.state.tempData === null ? "" : this.state.tempData.condition_if_wrong} id="year"
id="isWrongCondition" onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true, previewTable: false }, () => {
disabled={this.state.InputType == null ? true : (this.state.InputType.type_item_report_name === 'Validation' ? false : true)} this.getParentIR()
onChange={(event, newValue) => { })}
this.setState({ tempData: { ...this.state.tempData, condition_if_wrong: newValue } }, () => this.clearMessage()); debug
}} renderInput={(params) =>
options={this.state.options} <TextField {...params}
renderInput={(params) => label="Year"
<TextField {...params} InputLabelProps={{
label="False Condition" style: {
InputLabelProps={{ fontSize: 11,
style: { fontFamily: 'Nunito Sans, sans-serif',
fontSize: 11, color: '#7e8085'
fontFamily: 'Nunito Sans, sans-serif', }
color: '#7e8085' }}
} error={this.state.errorJenisLaporan}
}} helperText={this.state.msgErrorJenisLaporan}
error={this.state.errorCondition} InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
helperText={this.state.msgErrorCondition} />}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} value={this.state.periode}
/>} />
/> </div>
</div> </div>
</div> </div>
</div>
{this.state.reportType !== null && ( {this.state.getParent.map((item, index) => {
this.state.reportType.report_name === 'CAT' && ( return (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div>
<div className="column-1"> <div style={{ borderBottom: 'solid 1px #c4c4c4', margin: 20, marginBottom: 10 }} >
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <Typography style={{ fontSize: '12px', color: '#4b4b4b', padding: 10, fontWeight: 'bold' }}>{`Item Report - ${index + 1}`}</Typography>
<Autocomplete </div>
{...this.state.listKPI}
value={this.state.KPIValue} <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
id="kpiType" <div className="column-1">
onChange={(event, newValue) => { <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
this.setState({ tempData: { ...this.state.tempData, kpi_type: newValue.value }, KPIValue: newValue }, () => this.clearMessage()); <TextField
}} style={{ width: '100%' }}
renderInput={(params) => value={item.item_report_id}
<TextField {...params} id="ID"
label="KPI Type" label="ID"
disabled
inputProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
}
}}
InputLabelProps={{ InputLabelProps={{
style: { style: {
fontSize: 11, fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif', fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085' color: '#7e8085',
}
}}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="reportName1"
name="reportName1"
label="Report Name"
disabled
value={item.report_name}
inputProps={{
min: 0,
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
} }
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listMaxAch}
value={this.state.MaxAchValue}
id="maxAch"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, max_ach: newValue.value }, MaxAchValue: newValue }, () => this.clearMessage());
}}
renderInput={(params) =>
<TextField {...params}
label="Max Achievement"
InputLabelProps={{ InputLabelProps={{
style: { style: {
fontSize: 11, fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif', fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085' color: '#7e8085',
} }
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} >
/>} </TextField>
/> </div>
</div>
</div> </div>
</div>
</div>
))}
{this.state.reportType !== null && ( <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
this.state.reportType.report_name === 'CAT' && ( <div className="column-1">
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div className="column-1"> <TextField
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> style={{ width: '100%' }}
<Autocomplete id="itemReportName1"
value={this.state.tempData === null ? "" : this.state.tempData.formula_ytd} name="itemReportName1"
id="kpiType" label="Item Report Name"
onChange={(event, newValue) => { disabled
this.setState({ tempData: { ...this.state.tempData, formula_ytd: newValue } }, () => this.clearMessage()); // onChange={(e) => this.handleChange(e, null)}
}} // value={this.state.order}
options={this.state.formulaYtd} value={this.handleReportName(item.description)}
renderInput={(params) => // error={this.state.errorOrder}
<TextField {...params} // helperText={this.state.msgErrorOrder}
label="Formula YTD" inputProps={{
min: 0,
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
}
}}
InputLabelProps={{ InputLabelProps={{
style: { style: {
fontSize: 11, fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif', fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085' color: '#7e8085',
} }
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} >
/>} </TextField>
/> </div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="weight1"
name="weight1"
label="Weight"
value={item.weight}
error={this.state.errorWeight}
helperText={this.state.msgErrorWeight}
onChange={(e) => this.handleChange(e, item)}
inputProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085',
}
}}
>
</TextField>
</div>
</div>
</div> </div>
</div> </div>
</div> )
))} })}
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<DatePicker <TextField
margin="normal" style={{ width: '100%' }}
id="startDate" defaultValue={"active"}
label="Valid From" id="status"
format="dd-MM-yyyy" label="Status"
value={this.state.tempData === null ? null : this.state.tempData.start_date} disabled
error={this.state.errorStartDate} inputProps={{
helperText={this.state.msgErrorSD} style: {
onChange={(e) => this.handleChange(e, 'start_date')} fontSize: 11,
KeyboardButtonProps={{ fontFamily: 'Nunito Sans, sans-serif',
'aria-label': 'change date', }
}} }}
inputProps={{ InputLabelProps={{
style: { style: {
fontSize: 11, fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif', fontFamily: 'Nunito Sans, sans-serif',
} color: '#7e8085',
}} }
InputLabelProps={{ }}
style: { />
fontSize: 11, </div>
color: '#7e8085',
fontFamily: 'Nunito Sans, sans-serif',
}
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div> </div>
</div> </div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<DatePicker
margin="normal"
id="endDate"
label="Valid To"
format="dd-MM-yyyy"
value={this.state.tempData === null ? null : this.state.tempData.end_date}
error={this.state.errorEndDate}
helperText={this.state.msgErrorED}
minDate={this.state.tempData === null ? null : this.state.tempData.start_date}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085',
fontFamily: 'Nunito Sans, sans-serif',
}
}}
style={{ padding: 0, margin: 0, width: '100%' }} <div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30 }}>
/> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '13%' }}>Created By :</Typography>
</div> </div>
</div> <div style={{ display: 'flex' }}>
</div> <Typography style={{ fontSize: 11, width: '13%' }}>Updated By :</Typography>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={this.state.tempData === null ? '' : this.state.tempData.status}
id="status"
label="Status"
disabled
inputProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif'
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
/>
</div> </div>
</div> </div>
</div> </div>
<div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30 }}> <div>
<div style={{ display: 'flex' }}> <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography> <div className="column-1" style={{ alignSelf: 'center' }}>
<Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.created}</Typography> <button
</div> type="button"
<div style={{ display: 'flex' }}> onClick={() => this.props.onClickClose()}
<Typography style={{ fontSize: 11, width: '12%' }}>Updated By</Typography> >
<Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.updated}</Typography> <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
</div> <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div> </div>
</button>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}> </div>
<div className="column-1" style={{ alignSelf: 'center' }}> <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button <button
type="button" type="button"
onClick={() => this.props.onClickClose()} onClick={() => this.validasi(this.state.getParent)}
> >
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span> <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
</div> </div>
</button> </button>
</div> </div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button onClick={() => this.validasi()}>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Save</span>
</div>
</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -775,32 +775,32 @@ export default class MasterDataCAT extends Component { ...@@ -775,32 +775,32 @@ export default class MasterDataCAT extends Component {
} }
} }
updateReportItems = (payload) => { // updateReportItems = (payload) => {
this.setState({ edit: false }) // this.setState({ edit: false })
api.create().updateReportItems(payload).then(response => { // api.create().updateReportItems(payload).then(response => {
if (response.data) { // if (response.data) {
if (response.ok) { // if (response.ok) {
if (response.data.status == 'success') { // if (response.data.status == 'success') {
this.getData() // this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) // this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { // } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { // this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { // if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => { // setTimeout(() => {
localStorage.removeItem(Constant.TOKEN) // localStorage.removeItem(Constant.TOKEN)
window.location.reload(); // window.location.reload();
}, 1000); // }, 1000);
} // }
}) // })
} // }
} else { // } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) // this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} // }
} else { // } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) // this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} // }
}) // })
} // }
uploadReportItems() { uploadReportItems() {
api.create().uploadReportItems(this.state.payload).then(response => { api.create().uploadReportItems(this.state.payload).then(response => {
...@@ -1163,7 +1163,7 @@ export default class MasterDataCAT extends Component { ...@@ -1163,7 +1163,7 @@ export default class MasterDataCAT extends Component {
onClickClose={() => this.setState({ edit: false })} onClickClose={() => this.setState({ edit: false })}
data={this.state.rowData} data={this.state.rowData}
refresh={this.getData.bind(this)} refresh={this.getData.bind(this)}
updateReportItems={this.updateReportItems.bind(this)} updateReportItems={this.createReportItems.bind(this)}
/> />
)} )}
{this.state.popupError && ( {this.state.popupError && (
......
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