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

gas

parent 82626371
...@@ -132,7 +132,7 @@ class HomePage extends Component { ...@@ -132,7 +132,7 @@ class HomePage extends Component {
arrayChild.push({ ...items, current_value: Number(items.current_value).toFixed(2), performanceColor: this.handleBackgroundPerform(Number(items.current_value)) }) arrayChild.push({ ...items, current_value: Number(items.current_value).toFixed(2), performanceColor: this.handleBackgroundPerform(Number(items.current_value)) })
} }
}) })
if (arrayChild.length > 0) { if (arrayChild.length > 0 && String(item.item_business).toLocaleLowerCase() != 'holding') {
data.push({ ...item, category: arrayChild }) data.push({ ...item, category: arrayChild })
} }
}) })
...@@ -913,13 +913,13 @@ class HomePage extends Component { ...@@ -913,13 +913,13 @@ class HomePage extends Component {
rawData: {month: this.state.monthCAT.month_id, periode: this.state.periodeCAT.value, companyId: item.company_id} rawData: {month: this.state.monthCAT.month_id, periode: this.state.periodeCAT.value, companyId: item.company_id}
} }
}}> }}>
<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 }}> <div style={{ padding: 10, backgroundColor: '#fff', height: 350, 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> */} {/* <span style={{ fontSize: '17px', color: this.state.selectIndex === index ? '#fff' : '#7e8085', maxWidth: 100 }}>{item.category_name}</span> */}
<div style={{ fontSize: '17px', width: '100%' }}> <div style={{ fontSize: '17px', width: '100%', height: 25}}>
<Typography style={{ textAlign: 'left', color: '#4b4b4b' }}>{titleCase(String(item.category_name).toLocaleLowerCase())}</Typography> <Typography style={{ textAlign: 'left', color: '#4b4b4b' }}>{item.category_name}</Typography>
</div> </div>
{item.total_kpi != null && {item.total_kpi != null &&
<div style={{ width: '100%', display: 'flex', justifyContent: 'center', marginTop: String(item.category_name).toLocaleLowerCase().includes('internal') ? 0 : 25 }}> <div style={{ width: '100%', display: 'flex', justifyContent: 'center', marginTop: 10 }}>
<span style={{ textAlign: 'center', fontSize: '18px', color: "#fff" }}>{item.total_kpi}</span> <span style={{ textAlign: 'center', fontSize: '18px', color: "#fff" }}>{item.total_kpi}</span>
{/* <span style={{ textAlign: 'center', fontSize: '11px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>KPIs</span> */} {/* <span style={{ textAlign: 'center', fontSize: '11px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>KPIs</span> */}
</div>} </div>}
......
...@@ -39,15 +39,16 @@ export default class DashboardCAT extends Component { ...@@ -39,15 +39,16 @@ export default class DashboardCAT extends Component {
componentDidMount() { componentDidMount() {
console.log(this.props) console.log(this.props)
// localStorage.removeItem(Constant.DATACAT)
this.props.selectIndex('CAT Dashboard') this.props.selectIndex('CAT Dashboard')
let dataStorageCAT = localStorage.getItem(Constant.DATACAT) let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
if (this.props.location.state !== undefined) { if (this.props.location.state !== undefined) {
if (dataStorageCAT != 'datacat' && dataStorageCAT != null) { if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
this.setState({ selectedKPI: JSON.parse(dataStorageCAT).listKPI }, () => { this.setState({ selectedKPI: JSON.parse(dataStorageCAT).listKPI }, () => {
console.log(dataStorageCAT) console.log(dataStorageCAT)
console.log(this.props.location.state.rawData.companyId) // console.log(this.props.location.state.rawData.companyId)
console.log(this.state.selectedKPI) 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.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData}, () => {
this.getDetailUser() this.getDetailUser()
}) })
}) })
...@@ -146,9 +147,19 @@ export default class DashboardCAT extends Component { ...@@ -146,9 +147,19 @@ export default class DashboardCAT extends Component {
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => { this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
let dataStorageCAT = localStorage.getItem(Constant.DATACAT) let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
let userID = localStorage.getItem(Constant.USER)
if (dataStorageCAT != 'datacat' && dataStorageCAT != null) { if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
this.setState({ selectedKPI: JSON.parse(dataStorageCAT).companyId == this.state.company.company_id ? JSON.parse(dataStorageCAT).listKPI : [] }) let arrayStorage = JSON.parse(dataStorageCAT)
console.log(dataStorageCAT) let indexListKPI = arrayStorage.findIndex((val) => val.userID == userID)
let selectedKPI = []
let indexListKPIDetail = -1
if (indexListKPI != -1) {
indexListKPIDetail = arrayStorage[indexListKPI].listKPI.findIndex((val) => val.companyId == this.state.company.company_id)
if (indexListKPIDetail != -1) {
selectedKPI = arrayStorage[indexListKPI].listKPI[indexListKPIDetail].list
}
}
this.setState({ selectedKPI })
} }
this.getLastPeriod() this.getLastPeriod()
}) })
...@@ -312,12 +323,64 @@ export default class DashboardCAT extends Component { ...@@ -312,12 +323,64 @@ export default class DashboardCAT extends Component {
setSelectedKPI(data) { setSelectedKPI(data) {
this.setState({ selectedKPI: data }, () => { this.setState({ selectedKPI: data }, () => {
let payloadData = { let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
userID: localStorage.getItem(Constant.USER), let userID = localStorage.getItem(Constant.USER)
listKPI: this.state.selectedKPI, if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
companyId: this.state.company.company_id let arrayStorage = JSON.parse(dataStorageCAT)
if (arrayStorage.length > 0) {
let indexID = arrayStorage.findIndex((val) => val.userID == userID)
if (indexID == -1) {
let listKPI = []
listKPI.push({
list: this.state.selectedKPI,
companyId: this.state.company.company_id
})
let payloadData = {
userID,
listKPI
}
arrayStorage.push(payloadData)
console.log('1')
console.log(arrayStorage)
} else {
let listKPI = arrayStorage[indexID].listKPI
let indexComp = listKPI.findIndex((val) => val.companyId == this.state.company.company_id)
if (indexComp == -1) {
listKPI.push({
list: this.state.selectedKPI,
companyId: this.state.company.company_id
})
// arrayStorage.push(payloadData)
arrayStorage[indexID].listKPI = listKPI
console.log('2')
console.log(arrayStorage)
} else {
arrayStorage[indexID].listKPI[indexComp].list = this.state.selectedKPI
console.log('3')
console.log(arrayStorage)
}
}
localStorage.setItem(Constant.DATACAT, JSON.stringify(arrayStorage))
console.log(localStorage.getItem(Constant.DATACAT))
}
} else {
let arrayStorage = []
let listKPI = []
listKPI.push({
list: this.state.selectedKPI,
companyId: this.state.company.company_id
})
let payloadData = {
userID: localStorage.getItem(Constant.USER),
listKPI
}
arrayStorage.push(payloadData)
localStorage.setItem(Constant.DATACAT, JSON.stringify(arrayStorage))
console.log('4')
console.log(arrayStorage)
} }
localStorage.setItem(Constant.DATACAT, this.state.selectedKPI.length == 0 ? 'datacat' : JSON.stringify(payloadData))
}) })
} }
...@@ -365,11 +428,19 @@ export default class DashboardCAT extends Component { ...@@ -365,11 +428,19 @@ export default class DashboardCAT extends Component {
id="month" id="month"
onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true }, () => { onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true }, () => {
let dataStorageCAT = localStorage.getItem(Constant.DATACAT) let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
let userID = localStorage.getItem(Constant.USER)
if (dataStorageCAT != 'datacat' && dataStorageCAT != null) { if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
this.setState({ selectedKPI: JSON.parse(dataStorageCAT).companyId == this.state.company.company_id ? JSON.parse(dataStorageCAT).listKPI : [] }) let arrayStorage = JSON.parse(dataStorageCAT)
console.log(dataStorageCAT) let indexListKPI = arrayStorage.findIndex((val) => val.userID == userID)
} else { let selectedKPI = []
this.setState({selectedKPI: []}) let indexListKPIDetail = -1
if (indexListKPI != -1) {
indexListKPIDetail = arrayStorage[indexListKPI].listKPI.findIndex((val) => val.companyId == this.state.company.company_id)
if (indexListKPIDetail != -1) {
selectedKPI = arrayStorage[indexListKPI].listKPI[indexListKPIDetail].list
}
}
this.setState({ selectedKPI })
} }
this.getDasboardCAT() this.getDasboardCAT()
})} })}
......
...@@ -2,6 +2,7 @@ import React, { Component } from 'react' ...@@ -2,6 +2,7 @@ import React, { Component } from 'react'
import { Checkbox, FormControlLabel, Menu, Paper, Typography, Button } from '@material-ui/core' import { Checkbox, FormControlLabel, Menu, Paper, Typography, Button } from '@material-ui/core'
import LineChart from 'react-linechart'; import LineChart from 'react-linechart';
import Images from '../../assets/Images' import Images from '../../assets/Images'
import NumberFormat from 'react-number-format';
export default class StrategiMap extends Component { export default class StrategiMap extends Component {
constructor(props) { constructor(props) {
...@@ -221,7 +222,8 @@ export default class StrategiMap extends Component { ...@@ -221,7 +222,8 @@ export default class StrategiMap extends Component {
</div> </div>
<div style={{ width: '10%', display: 'grid', alignContent: 'center' }}> <div style={{ width: '10%', display: 'grid', alignContent: 'center' }}>
<Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 12 }}>{item.current_value}</Typography> <Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 12 }}><NumberFormat value={item.current_value} displayType={'text'} thousandSeparator={true} /></Typography>
{/* <Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 12 }}>{item.current_value}</Typography> */}
</div> </div>
<div style={{ width: '10%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}> <div style={{ width: '10%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', backgroundColor: item.achievement < -10 ? '#333333' : item.achievement < 0 ? '#333333' : '#333333', height: 70, width: 105, marginRight: 20 }}> <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', backgroundColor: item.achievement < -10 ? '#333333' : item.achievement < 0 ? '#333333' : '#333333', height: 70, width: 105, marginRight: 20 }}>
......
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