Commit 8d2805c3 authored by d.arizona's avatar d.arizona

update banyak juga jir, kirain gampang dashboard, jadi pusing aku tuh

parent 1ce45619
......@@ -45,12 +45,13 @@ class HomePage extends Component {
accessMB: false,
accessMR: false,
company: [],
dataDashboardCAT: []
dataDashboardCAT: [],
loading2: false
}
}
componentDidMount() {
this.setState({ loading: true })
this.setState({ loading: true, loading2: true })
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
......@@ -136,7 +137,7 @@ class HomePage extends Component {
}
})
console.log(data)
this.setState({ dataDashboardCAT: data, loading: false })
this.setState({ dataDashboardCAT: data, loading: false, loading2: false })
}
})
}
......@@ -642,7 +643,7 @@ class HomePage extends Component {
<div style={{ padding: 10, backgroundColor: '#fff', borderRadius: 6, paddingBottom: 20, margin: 10, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', width: 250, marginRight: index == items.category.length - 1 ? 25 : 0, marginLeft: index == 0 ? 5 : 25 }}>
{/* <span style={{ fontSize: '17px', color: this.state.selectIndex === index ? '#fff' : '#7e8085', maxWidth: 100 }}>{item.category_name}</span> */}
<div style={{ fontSize: '17px', width: '100%' }}>
<Typography style={{ textAlign: 'left' }}>{titleCase(String(item.category_name).toLocaleLowerCase())}</Typography>
<Typography style={{ textAlign: 'left', color: '#4b4b4b' }}>{titleCase(String(item.category_name).toLocaleLowerCase())}</Typography>
</div>
{item.total_kpi != null &&
<div style={{ width: '100%', display: 'flex', justifyContent: 'center', marginTop: String(item.category_name).toLocaleLowerCase().includes('internal') ? 0 : 25 }}>
......@@ -651,7 +652,7 @@ class HomePage extends Component {
</div>}
<div style={{ display: 'flex', justifyContent: 'center', marginTop: item.total_kpi == null ? 50 : 0 }}>
<div style={{ backgroundColor: item.performanceColor, textAlign: 'center', display: 'flex', justifyContent: 'center', width: 40, height: 21 }}>
<Typography style={{ textAlign: 'center' }}>{item.performance}</Typography>
<Typography style={{ textAlign: 'center', color: '#4b4b4b' }}>{item.performance}</Typography>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'center' }}>
......@@ -915,7 +916,7 @@ class HomePage extends Component {
<div style={{ padding: 10, backgroundColor: '#fff', borderRadius: 6, paddingBottom: 20, margin: 10, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', width: 250, marginRight: index == items.category.length - 1 ? 25 : 0, marginLeft: index == 0 ? 5 : 25 }}>
{/* <span style={{ fontSize: '17px', color: this.state.selectIndex === index ? '#fff' : '#7e8085', maxWidth: 100 }}>{item.category_name}</span> */}
<div style={{ fontSize: '17px', width: '100%' }}>
<Typography style={{ textAlign: 'left' }}>{titleCase(String(item.category_name).toLocaleLowerCase())}</Typography>
<Typography style={{ textAlign: 'left', color: '#4b4b4b' }}>{titleCase(String(item.category_name).toLocaleLowerCase())}</Typography>
</div>
{item.total_kpi != null &&
<div style={{ width: '100%', display: 'flex', justifyContent: 'center', marginTop: String(item.category_name).toLocaleLowerCase().includes('internal') ? 0 : 25 }}>
......@@ -924,7 +925,7 @@ class HomePage extends Component {
</div>}
<div style={{ display: 'flex', justifyContent: 'center', marginTop: item.total_kpi == null ? 50 : 0 }}>
<div style={{ backgroundColor: item.performanceColor, textAlign: 'center', display: 'flex', justifyContent: 'center', width: 40, height: 21 }}>
<Typography style={{ textAlign: 'center' }}>{item.performance}</Typography>
<Typography style={{ textAlign: 'center', color: '#4b4b4b' }}>{item.performance}</Typography>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'center' }}>
......@@ -1081,7 +1082,7 @@ class HomePage extends Component {
/>
</div>
<Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5 }}>
<Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Monthly Report - ${this.state.month.month_value} ${this.state.periodeMR.periode} ${this.state.valueSubmitMR}/${this.state.listSubcoMR.length}`}</Typography>
{!this.state.loading2 && <Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Monthly Report - ${this.state.month.month_value} ${this.state.periodeMR.value} ${this.state.valueSubmitMR}/${this.state.listSubcoMR.length}`}</Typography>}
{this.state.listSubcoMR.map((item, index) => {
return (
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
......
......@@ -41,15 +41,29 @@ export default class DashboardCAT extends Component {
console.log(this.props)
this.props.selectIndex('CAT Dashboard')
let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
console.log(dataStorageCAT)
if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
this.setState({selectedKPI: JSON.parse(dataStorageCAT).listKPI})
console.log(dataStorageCAT)
}
if (this.props.location.state !== undefined) {
this.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData }, () => {
this.getDetailUser()
})
if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
this.setState({ selectedKPI: JSON.parse(dataStorageCAT).listKPI }, () => {
console.log(dataStorageCAT)
console.log(this.props.location.state.rawData.companyId)
console.log(this.state.selectedKPI)
this.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData, selectedKPI: this.state.selectedKPI.length == 0 ? [] : (JSON.parse(dataStorageCAT).companyId == this.props.location.state.rawData.companyId ? JSON.parse(dataStorageCAT).listKPI : []) }, () => {
this.getDetailUser()
})
})
} else {
this.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData }, () => {
this.getDetailUser()
})
}
// console.log(this.state.selectedKPI)
// console.log(dataStorageCAT)
// console.log(this.state.company.company_id)
// this.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData, selectedKPI: this.state.selectedKPI.length == 0? [] : ((dataStorageCAT != 'datacat' && dataStorageCAT != null) ? (dataStorageCAT.companyId == this.state.company.company_id? JSON.parse(dataStorageCAT).listKPI : []) : [])}, () => {
// this.getDetailUser()
// })
} else {
this.getDetailUser()
}
......@@ -129,7 +143,13 @@ export default class DashboardCAT extends Component {
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]) }, () => {
let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
this.setState({ selectedKPI: JSON.parse(dataStorageCAT).companyId == this.state.company.company_id ? JSON.parse(dataStorageCAT).listKPI : [] })
console.log(dataStorageCAT)
}
this.getLastPeriod()
})
} else {
......@@ -294,7 +314,8 @@ export default class DashboardCAT extends Component {
this.setState({ selectedKPI: data }, () => {
let payloadData = {
userID: localStorage.getItem(Constant.USER),
listKPI: this.state.selectedKPI
listKPI: this.state.selectedKPI,
companyId: this.state.company.company_id
}
localStorage.setItem(Constant.DATACAT, this.state.selectedKPI.length == 0 ? 'datacat' : JSON.stringify(payloadData))
})
......@@ -342,7 +363,14 @@ export default class DashboardCAT extends Component {
<Autocomplete
{...this.state.listCompany}
id="month"
onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true, selectedKPI: [] }, () => {
onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true }, () => {
let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
this.setState({ selectedKPI: JSON.parse(dataStorageCAT).companyId == this.state.company.company_id ? JSON.parse(dataStorageCAT).listKPI : [] })
console.log(dataStorageCAT)
} else {
this.setState({selectedKPI: []})
}
this.getDasboardCAT()
})}
disableClearable
......@@ -376,7 +404,7 @@ export default class DashboardCAT extends Component {
selectedMonth.push(item.month_value)
}
})
this.setState({selectedMonth})
this.setState({ selectedMonth })
this.getDasboardCAT()
})}
disableClearable
......
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