Commit 0292a49a authored by Riri Novita's avatar Riri Novita

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into riri

parents f2318dea 62961a4a
......@@ -186,7 +186,10 @@ const create = (type = "") => {
const deleteParameter = (id) => api.post(`setting/delete_setting/${id}`)
// MASTER DATA - CAT
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 saveMasterDataCat = (body) => api.post('item_report_company/create_item_report_company', body)
const deleteMasterDataCat = (idCompany, years) => api.post(`item_report_company/delete_item_report_company/${idCompany}/${years}`)
//Transaction
const getReportTypeBody = (body) => api.post('transaction/master_budget/get_all_report', body)
......@@ -687,7 +690,10 @@ const create = (type = "") => {
getHierarkiCronJobMRRatio,
getRollingOutlookID,
getRollingOutlookBS,
getParentItemReport
getAllMasterDataCat,
getParentItemReport,
saveMasterDataCat,
deleteMasterDataCat
}
}
......
......@@ -16,65 +16,17 @@ export default class CreateMasterDataCAT extends Component {
constructor(props) {
super(props)
this.state = {
InputType: null,
company: null,
parent: null,
reportType: null,
startDate: null,
endDate: null,
order: '',
description: '',
uom: '',
weight: '',
formula: '',
formulasum: '',
realVal: '',
condition: null,
date: new Date(),
listInputType: null,
listCompany: null,
listReportType: null,
listParent: null,
listKPI: null,
listMaxAch: null,
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
errorJenisLaporan: false,
errorPerusahaan: false,
msgErrorJenisLaporan: '',
msgErrorPerusahaan: '',
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '',
msgErrorED: '',
disabledFormula: true,
disabledFormulaSum: true,
disabledCondt: true,
disabledValue: true,
options: ['WARNING', 'STOPPER'],
alert: false,
tipeAlert: '',
messageAlert: '',
kpiType: ['HIG', 'HIB'],
maxAch: ['50%', '100%', 'Unlimited'],
formulaYtd: ['SUM', 'AVG', 'LAST'],
kpiTypeValue: null,
maxAchValue: null,
formulaYTDValue: null,
kpiDisable: true,
maxAchDisable: true,
listPeriode: null,
// periode: null,
errorWeight: false,
msgErrorWeight: '',
getParent: []
}
}
......@@ -91,6 +43,70 @@ export default class CreateMasterDataCAT extends Component {
endDate: date
})
this.getPeriode()
this.getDetailUser()
}
getDetailUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanyActive()
})
}
}
}
})
}
getCompanyActive() {
api.create().getPerusahaanActive().then((response) => {
// console.log(response);
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let comID = this.state.rawData ? this.state.rawData.company_id : 0
let companyData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name,
}
})
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 })
}
})
}
getPeriode() {
......@@ -145,23 +161,14 @@ export default class CreateMasterDataCAT extends Component {
if (response.data) {
if (response.data.status === "success") {
this.setState({ getParent: response.data.data.filter((val) => String(val.type_item_report_name).toLocaleLowerCase() != 'break')})
// response.data.data.map((item) => {
// console.log(item.description)
// this.setState({
// itemReport1: String(item.description).toLocaleLowerCase().includes("financial").tolocal ? item.description : null
// })
// })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
console.log(this.state.itemReport1)
})
}
handleChange(e, item) {
// let data = this.state
// let isDate = type !== '' ? true : false
let dataSource = this.state.getParent
let indexID = dataSource.findIndex((val) => val.item_report_id == item.item_report_id)
// console.log(indexID)
......@@ -171,125 +178,49 @@ export default class CreateMasterDataCAT extends Component {
console.log(this.state.getParent);
})
}
// if (isDate && type === 'start_date') {
// this.setState({
// ...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
// errorOrder: false,
// errorDesc: false,
// errorFormula: false,
// errorRV: false,
// errorStartDate: false,
// errorEndDate: false,
// errorTipeData: false,
// errorCondition: false,
// msgErrorTipeData: '',
// msgErrorCondition: '',
// msgErrorOrder: '',
// msgErrorDesc: '',
// msgErrorFormula: '',
// msgErrorRV: '',
// msgErrorSD: '',
// msgErrorED: '',
// })
// } else if (isDate && type === 'end_date') {
// this.setState({
// ...data, endDate: format(e, 'yyyy-MM-dd'),
// errorOrder: false,
// errorDesc: false,
// errorFormula: false,
// errorRV: false,
// errorStartDate: false,
// errorEndDate: false,
// errorTipeData: false,
// errorCondition: false,
// msgErrorTipeData: '',
// msgErrorCondition: '',
// msgErrorOrder: '',
// msgErrorDesc: '',
// msgErrorFormula: '',
// msgErrorRV: '',
// msgErrorSD: '',
// msgErrorED: '',
// })
// } else {
// this.setState({
// ...data, [e.target.name]: e.target.value,
// errorOrder: false,
// errorDesc: false,
// errorFormula: false,
// errorRV: false,
// errorStartDate: false,
// errorEndDate: false,
// errorTipeData: false,
// errorCondition: false,
// msgErrorTipeData: '',
// msgErrorCondition: '',
// msgErrorOrder: '',
// msgErrorDesc: '',
// msgErrorFormula: '',
// msgErrorRV: '',
// msgErrorSD: '',
// msgErrorED: '',
// })
// }
console.log(e.target.value)
}
validasi() {
// alert('coba ya')
if (R.isNil(this.state.reportType)) {
this.setState({ errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty' })
} else if (R.isNil(this.state.company)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty' })
} else if (R.isEmpty(this.state.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty' })
}
else if (R.isEmpty(this.state.description)) {
this.setState({ errorDesc: true, msgErrorDesc: 'Description Cannot be Empty' })
}
else if (R.isNil(this.state.InputType)) {
this.setState({ errorTipeData: true, msgErrorTipeData: 'Data Type Cannot be Empty' })
}
else if (this.state.disabledFormula === false && R.isEmpty(this.state.formula)) {
this.setState({ errorFormula: true, msgErrorFormula: 'Formula Cannot be Empty' })
}
else if (this.state.disabledValue === false && R.isEmpty(this.state.realVal)) {
this.setState({ errorRV: true, msgErrorRV: 'True Value Cannot be Empty' })
}
else if (this.state.disabledCondt === false && R.isEmpty(this.state.condition)) {
this.setState({ errorCondition: true, msgErrorCondition: 'False Condition Cannot be Empty' })
handleReportName(item) {
let indexString = String(item).indexOf('-')
let gantiNama = String(item).substr(0, indexString)
return gantiNama
}
else if (R.isNil(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty' })
}
else if (R.isNil(this.state.endDate)) {
this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty' })
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()
this.addReportItems(getData)
}
}
addReportItems() {
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 = {
"report_id": this.state.reportType.report_id,
"company_id": this.state.company.company_id,
"description": this.state.description,
"orders": this.state.order,
"parent": this.state.parent === null ? null : this.state.parent.item_report_id,
"type_report_id": this.state.InputType.type_item_report_id,
"formula": this.state.formula,
"uom": this.state.uom,
"weight": this.state.weight,
"condition_if_wrong": this.state.condition,
"condition_it_should_be": this.state.realVal,
"type_kpi": this.state.kpiTypeValue ? this.state.kpiTypeValue.value : null,
"max_ach": this.state.maxAchValue ? this.state.maxAchValue.value : null,
"formula_ytd": this.state.formulaYTDValue,
"start_date": this.state.startDate,
"end_date": this.state.endDate
}
// console.log(payload)
"years": this.state.periode.periode,
"detail": simpan
}
console.log(payload)
this.props.createReportItems(payload)
}
......@@ -592,7 +523,7 @@ export default class CreateMasterDataCAT extends Component {
<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 }} >
<Autocomplete
{/* <Autocomplete
{...this.state.listCompany}
id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue, kpiDisable: false, maxAchDisable: false }, () => {
......@@ -602,6 +533,19 @@ export default class CreateMasterDataCAT extends Component {
this.getMaxAch()
})}
debug
value={this.state.company}
/> */}
<Autocomplete
{...this.state.listCompany}
id="company"
disabled={this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true, previewTable: false }, () => {
this.getReportType()
})}
disableClearable
style={{ width: 250 }}
// renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
renderInput={(params) =>
<TextField {...params}
label="Company Name"
......@@ -649,21 +593,6 @@ export default class CreateMasterDataCAT extends Component {
/>}
value={this.state.periode}
/>
{/* <Autocomplete
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true, previewTable: false }, () => {
// this.getSubmission()
this.getDataTable()
})}
disabled={this.state.intent === 'Home' ? true : false}
disableClearable
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }}
/>}
value={this.state.periode}
/> */}
</div>
</div>
</div>
......@@ -708,11 +637,7 @@ export default class CreateMasterDataCAT extends Component {
name="reportName1"
label="Report Name"
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={item.report_name}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
inputProps={{
min: 0,
style: {
......@@ -744,7 +669,7 @@ export default class CreateMasterDataCAT extends Component {
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={item.description}
value={this.handleReportName(item.description)}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
inputProps={{
......@@ -773,6 +698,8 @@ export default class CreateMasterDataCAT extends Component {
name="weight1"
label="Weight"
value={item.weight}
error={this.state.errorWeight}
helperText={this.state.msgErrorWeight}
onChange={(e) => this.handleChange(e, item)}
inputProps={{
style: {
......@@ -796,373 +723,6 @@ export default class CreateMasterDataCAT extends Component {
)
})}
{/* <div style={{ borderBottom: 'solid 1px #c4c4c4', margin: 20, marginBottom: 10 }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', padding: 10, fontWeight: 'bold' }}>Item Report - 2</Typography>
</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={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={'-'}
id="ID"
label="ID"
disabled
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, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="orders"
name="order"
label="Report Name"
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={'CAT'}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
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="itemReportName2"
name="itemReportName2"
label="Item Report Name"
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={'item report name'}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
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 className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="weight2"
name="weight2"
label="Weight"
value={this.state.weight}
onChange={(e) => this.handleChange(e, '')}
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 style={{ borderBottom: 'solid 1px #c4c4c4', margin: 20, marginBottom: 10 }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', padding: 10, fontWeight: 'bold' }}>Item Report - 3</Typography>
</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={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={'-'}
id="ID"
label="ID"
disabled
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, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="orders"
name="order"
label="Report Name"
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={'CAT'}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
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="itemReportName3"
name="itemReportName3"
label="Item Report Name"
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={'item report name'}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
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 className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="weight3"
name="weight3"
label="Weight"
value={this.state.weight}
onChange={(e) => this.handleChange(e, '')}
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 style={{ borderBottom: 'solid 1px #c4c4c4', margin: 20, marginBottom: 10 }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', padding: 10, fontWeight: 'bold' }}>Item Report - 4</Typography>
</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={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={'-'}
id="ID"
label="ID"
disabled
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, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="orders"
name="order"
label="Report Name"
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={'CAT'}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
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="itemReportName4"
name="itemReportName4"
label="Item Report Name"
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={'item report name'}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
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 className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="weight4"
name="weight4"
label="Weight"
value={this.state.weight}
onChange={(e) => this.handleChange(e, '')}
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={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
......@@ -1193,11 +753,9 @@ export default class CreateMasterDataCAT extends Component {
<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>
{/* <Typography style={{ fontSize: 11 }}>: </Typography> */}
</div>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '13%' }}>Updated By :</Typography>
{/* <Typography style={{ fontSize: 11 }}>: </Typography> */}
</div>
</div>
</div>
......@@ -1216,7 +774,7 @@ export default class CreateMasterDataCAT extends Component {
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.validasi()}
onClick={() => this.validasi(this.state.getParent)}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Save</span>
......
......@@ -594,8 +594,8 @@ export default class MasterDataCAT extends Component {
getData() {
this.setState({ loading: true })
api.create().getReportItems().then((response) => {
// console.log(response)
api.create().getAllMasterDataCat().then((response) => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
......@@ -606,22 +606,19 @@ export default class MasterDataCAT extends Component {
item.item_report_id,
item.report_name,
item.company_name,
item.order,
item.description,
item.parent !== null ? `${item.parent} - ${item.parent_name}` : "" ,
item.uom,
item.report_name,
item.weight,
item.type_item_report_name,
item.kpi_type,
item.max_ach,
item.formula_ytd,
item.status]
item.years,
item.status,
item.item_report_company_id
]
})
this.setState({ dataTable: listData, listData: response.data.data }, () => {
setTimeout(() => {
this.setState({ loading: false })
}, 2000);
})
console.log(this.state.dataTable)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
......@@ -642,9 +639,11 @@ export default class MasterDataCAT extends Component {
}
deleteReport(payload) {
// console.log(payload);
let id = String(payload[1])
api.create().deleteReportItems(id).then(response => {
console.log(payload);
let idCompany = payload[8]
let years = payload[6]
api.create().deleteMasterDataCat(idCompany, years).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
......@@ -678,7 +677,7 @@ export default class MasterDataCAT extends Component {
} else if (type === 'delete') {
this.setState({
rowData: index,
reportNameDelete: "[" + String(index[2]) + " - " + String(index[3]) + " - " + String(index[5]) + "]",
reportNameDelete: "[" + String(index[3]) + " - " + String(index[6]) + "] ",
visibleDelete: true
})
} else {
......@@ -724,7 +723,7 @@ export default class MasterDataCAT extends Component {
createReportItems = (payload) => {
this.setState({ add: false })
api.create().createReportItems(payload).then(response => {
api.create().saveMasterDataCat(payload).then(response => {
// console.log(response);
if (response.data) {
if (response.ok) {
......@@ -896,7 +895,7 @@ export default class MasterDataCAT extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[13] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
......@@ -908,7 +907,7 @@ export default class MasterDataCAT extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[13] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
......@@ -920,7 +919,7 @@ export default class MasterDataCAT extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[13] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
......@@ -932,7 +931,7 @@ export default class MasterDataCAT extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[13] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
......@@ -944,7 +943,7 @@ export default class MasterDataCAT extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[13] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
......@@ -956,7 +955,7 @@ export default class MasterDataCAT extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[13] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
......@@ -968,11 +967,17 @@ export default class MasterDataCAT extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[13] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "company id",
options: {
display: false
}
}
]
const data = [
......@@ -1018,7 +1023,7 @@ export default class MasterDataCAT extends Component {
/>
</div> */}
<div style={{ width: '50%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Download Template'} data-for="template">
{/* <a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
......@@ -1031,8 +1036,8 @@ export default class MasterDataCAT extends Component {
<img src={Images.template} />
</button>
</a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
{this.state.buttonCreate && (
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" /> */}
{/* {this.state.buttonCreate && (
<a data-tip={'Upload'} data-for="upload">
<button
style={{
......@@ -1047,7 +1052,7 @@ export default class MasterDataCAT extends Component {
</button>
</a>
)}
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" /> */}
<a data-tip={'Download'} data-for="download">
<button
style={{
......@@ -1062,7 +1067,7 @@ export default class MasterDataCAT extends Component {
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<a data-tip={'Visualization'} data-for="visualisasi">
{/* <a data-tip={'Visualization'} data-for="visualisasi">
<button
style={{
backgroundColor: 'transparent',
......@@ -1075,7 +1080,7 @@ export default class MasterDataCAT extends Component {
<img src={Images.visualisasi} />
</button>
</a>
<ReactTooltip border={true} id="visualisasi" place="bottom" type="light" effect="solid" />
<ReactTooltip border={true} id="visualisasi" place="bottom" type="light" effect="solid" /> */}
{this.state.buttonCreate && (
<a data-tip={'Add New'} data-for="tambah">
<button
......
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