Commit 5a6a3fce authored by Rifka Kurnia's avatar Rifka Kurnia

Merge branch 'rifka' into 'master'

list md cat

See merge request !1217
parents b2cdb131 d9ebeac5
...@@ -32,16 +32,6 @@ export default class CreateMasterDataCAT extends Component { ...@@ -32,16 +32,6 @@ export default class CreateMasterDataCAT extends Component {
} }
componentDidMount() { componentDidMount() {
this.getInputType()
this.getPerusahaan()
this.getReportType()
// this.getParent()
let date = format(new Date, 'yyyy-MM-dd')
// console.log(date);
this.setState({
startDate: date,
endDate: date
})
this.getPeriode() this.getPeriode()
this.getDetailUser() this.getDetailUser()
} }
...@@ -176,9 +166,10 @@ export default class CreateMasterDataCAT extends Component { ...@@ -176,9 +166,10 @@ export default class CreateMasterDataCAT extends Component {
dataSource[indexID].weight = e.target.value dataSource[indexID].weight = e.target.value
this.setState({getParent: dataSource}, () => { this.setState({getParent: dataSource}, () => {
console.log(this.state.getParent); console.log(this.state.getParent);
this.clearMessage()
}) })
} }
console.log(e.target.value) // console.log(e.target.value)
} }
handleReportName(item) { handleReportName(item) {
...@@ -224,265 +215,10 @@ export default class CreateMasterDataCAT extends Component { ...@@ -224,265 +215,10 @@ export default class CreateMasterDataCAT extends Component {
this.props.createReportItems(payload) this.props.createReportItems(payload)
} }
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),
};
this.setState({ listKPI: defaultProps, inputKPI: 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);
}
})
// 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),
};
this.setState({ listMaxAch: defaultProps, inputMaxAch: 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);
}
})
// 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' })
}
})
}
getInputType() {
api.create().getInputType().then((response) => {
// console.log(response.data)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputData = data.map((item) => {
return {
type_item_report_id: item.type_item_report_id,
type_item_report_name: item.type_item_report_name
}
})
let defaultProps = {
options: inputData,
getOptionLabel: (option) => titleCase(option.type_item_report_name),
};
this.setState({ listInputType: defaultProps, inputData: 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);
}
})
// 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' })
}
})
}
getPerusahaan() {
api.create().getPerusahaanActive().then((response) => {
// console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let companyData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
}
})
companyData.push({
company_id: 0,
company_name: 'Default'
})
let typeProps = {
options: companyData.sort((a, b) => a.company_id - b.company_id),
getOptionLabel: (option) => option.company_name,
};
this.setState({ listCompany: typeProps, companyData: 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);
}
})
// 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' })
}
})
}
getReportType() {
api.create().getReportType().then((response) => {
// console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let reportTypeData = data.map((item) => {
return {
report_id: item.report_id,
report_name: item.report_name,
}
})
let defaultProps = {
options: reportTypeData,
getOptionLabel: (option) => titleCase(option.report_name),
};
this.setState({ listReportType: defaultProps, reportTypeData: response.data.data })
} else {
// alert(response.data.message)
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' })
}
})
}
getParent() {
if (this.state.reportType !== null && this.state.company !== null) {
let payload = {
"report_id": this.state.reportType.report_id,
"company_id": this.state.company.company_id
}
api.create().getReportParent(payload).then((response) => {
// console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let parentData = data.map((item) => {
return {
item_report_id: item.item_report_id,
description: item.description
}
})
let defaultProps = {
options: parentData,
getOptionLabel: (option) => titleCase(option.description),
};
this.setState({ listParent: defaultProps, parentData: 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);
}
})
// 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' })
}
})
}
}
handleDate(item) {
let value = format(item, 'dd MMMM yyyy')
return value
}
clearMessage() { clearMessage() {
this.setState({ this.setState({
errorFormula: false, msgErrorFormula: '', errorFormula: false, msgErrorFormula: '',
errorTipeData: false, errorWeight: false, msgErrorWeight: ''
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
errorRV: false, msgErrorRV: '',
errorJenisLaporan: false, msgErrorJenisLaporan: '',
errorPerusahaan: false, msgErrorPerusahaan: ''
}) })
} }
...@@ -523,19 +259,6 @@ export default class CreateMasterDataCAT extends Component { ...@@ -523,19 +259,6 @@ export default class CreateMasterDataCAT extends Component {
<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={{ padding: 10, borderRadius: 5 }} >
{/* <Autocomplete
{...this.state.listCompany}
id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue, kpiDisable: false, maxAchDisable: false }, () => {
this.getParent()
this.clearMessage()
this.getKPIType()
this.getMaxAch()
})}
debug
value={this.state.company}
/> */}
<Autocomplete <Autocomplete
{...this.state.listCompany} {...this.state.listCompany}
id="company" id="company"
...@@ -545,7 +268,6 @@ export default class CreateMasterDataCAT extends Component { ...@@ -545,7 +268,6 @@ export default class CreateMasterDataCAT extends Component {
})} })}
disableClearable disableClearable
style={{ width: 250 }} style={{ width: 250 }}
// renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
label="Company Name" label="Company Name"
...@@ -569,10 +291,6 @@ export default class CreateMasterDataCAT extends Component { ...@@ -569,10 +291,6 @@ export default class CreateMasterDataCAT extends Component {
<Autocomplete <Autocomplete
{...this.state.listPeriode} {...this.state.listPeriode}
id="year" id="year"
// onChange={(event, newInputValue) => this.setState({ reportType: newInputValue, kpiDisable: true, maxAchDisable: true }, () => {
// newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ kpiTypeValue: null, maxAchValue: null, formulaYTDValue: null }, () => this.clearMessage())
// : this.clearMessage();
// })}
onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true, previewTable: false }, () => { onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true, previewTable: false }, () => {
this.getParentIR() this.getParentIR()
})} })}
...@@ -667,11 +385,7 @@ export default class CreateMasterDataCAT extends Component { ...@@ -667,11 +385,7 @@ export default class CreateMasterDataCAT extends Component {
name="itemReportName1" name="itemReportName1"
label="Item Report Name" label="Item Report Name"
disabled disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={this.handleReportName(item.description)} value={this.handleReportName(item.description)}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
inputProps={{ inputProps={{
min: 0, min: 0,
style: { style: {
......
...@@ -177,9 +177,9 @@ export default class EditMasterDataCAT extends Component { ...@@ -177,9 +177,9 @@ export default class EditMasterDataCAT extends Component {
dataSource[indexID].weight = e.target.value dataSource[indexID].weight = e.target.value
this.setState({getParent: dataSource}, () => { this.setState({getParent: dataSource}, () => {
console.log(this.state.getParent); console.log(this.state.getParent);
this.clearMessage()
}) })
} }
console.log(e.target.value)
} }
handleReportName(item) { handleReportName(item) {
...@@ -334,6 +334,13 @@ export default class EditMasterDataCAT extends Component { ...@@ -334,6 +334,13 @@ export default class EditMasterDataCAT extends Component {
}) })
} }
clearMessage() {
this.setState({
errorFormula: false, msgErrorFormula: '',
errorWeight: false, msgErrorWeight: ''
})
}
closeAlert() { closeAlert() {
this.setState({ alert: false }) this.setState({ alert: false })
} }
......
...@@ -604,7 +604,7 @@ export default class MasterDataCAT extends Component { ...@@ -604,7 +604,7 @@ export default class MasterDataCAT extends Component {
return [ return [
index, index,
item.item_report_id, item.item_report_id,
item.report_name, item.item_report_name,
item.company_name, item.company_name,
item.report_name, item.report_name,
item.weight, item.weight,
...@@ -877,60 +877,60 @@ export default class MasterDataCAT extends Component { ...@@ -877,60 +877,60 @@ export default class MasterDataCAT extends Component {
} }
}, },
{ {
name: "Item Report Name", name: "Report Name",
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{tableMeta.rowData[4]}</span>
</div > </div >
); );
} }
} }
}, },
{ {
name: "Company Name", name: "Item Report Name",
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{tableMeta.rowData[2]}</span>
</div > </div >
); );
} }
} }
}, },
{ {
name: "Report Name", name: "Year",
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{tableMeta.rowData[6]}</span>
</div > </div >
); );
} }
} }
}, },
{ {
name: "Weight", name: "Company Name",
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{tableMeta.rowData[3]}</span>
</div > </div >
); );
} }
} }
}, },
{ {
name: "Year", name: "Weight",
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{tableMeta.rowData[5]}</span>
</div > </div >
); );
} }
...@@ -942,7 +942,7 @@ export default class MasterDataCAT extends Component { ...@@ -942,7 +942,7 @@ export default class MasterDataCAT extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[7] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{tableMeta.rowData[7]}</span>
</div > </div >
); );
} }
...@@ -955,13 +955,6 @@ export default class MasterDataCAT extends Component { ...@@ -955,13 +955,6 @@ export default class MasterDataCAT extends Component {
} }
} }
] ]
const data = [
["", "1", "KPI", "TIA", "1", "Financial Perspective", "0", "-", "35%", "Formula", "Aktif"],
["", "2", "KPI", "TIA", "2", "Trading Profit", "1", "Rp Bio", "35%", "Formula", "Aktif"],
["", "3", "KPI", "TIA", "3", "Revenue", "1", "Rp Bio", "0%", "Formula", "Aktif"],
["", "4", "KPI", "TIA", "4", "EBITDA", "1", "Rp Bio", "0%", "Formula", "Non Aktif"],
["", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"],
]
const loadingComponent = ( const loadingComponent = (
<div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}> <div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
<PropagateLoader <PropagateLoader
......
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