Commit ce2c31cc authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'GGMAC' into 'master'

gas

See merge request !1248
parents 132edc7b 8c7b235e
......@@ -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)) })
}
})
if (arrayChild.length > 0) {
if (arrayChild.length > 0 && String(item.item_business).toLocaleLowerCase() != 'holding') {
data.push({ ...item, category: arrayChild })
}
})
......@@ -913,13 +913,13 @@ class HomePage extends Component {
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> */}
<div style={{ fontSize: '17px', width: '100%' }}>
<Typography style={{ textAlign: 'left', color: '#4b4b4b' }}>{titleCase(String(item.category_name).toLocaleLowerCase())}</Typography>
<div style={{ fontSize: '17px', width: '100%', height: 25}}>
<Typography style={{ textAlign: 'left', color: '#4b4b4b' }}>{item.category_name}</Typography>
</div>
{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: '11px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>KPIs</span> */}
</div>}
......
......@@ -39,15 +39,16 @@ export default class DashboardCAT extends Component {
componentDidMount() {
console.log(this.props)
// localStorage.removeItem(Constant.DATACAT)
this.props.selectIndex('CAT Dashboard')
let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
if (this.props.location.state !== undefined) {
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.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.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData}, () => {
this.getDetailUser()
})
})
......@@ -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]) }, () => {
let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
let userID = localStorage.getItem(Constant.USER)
if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
this.setState({ selectedKPI: JSON.parse(dataStorageCAT).companyId == this.state.company.company_id ? JSON.parse(dataStorageCAT).listKPI : [] })
console.log(dataStorageCAT)
let arrayStorage = JSON.parse(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()
})
......@@ -312,12 +323,64 @@ export default class DashboardCAT extends Component {
setSelectedKPI(data) {
this.setState({ selectedKPI: data }, () => {
let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
let userID = localStorage.getItem(Constant.USER)
if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
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: localStorage.getItem(Constant.USER),
listKPI: this.state.selectedKPI,
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 {
id="month"
onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true }, () => {
let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
let userID = localStorage.getItem(Constant.USER)
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: []})
let arrayStorage = JSON.parse(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.getDasboardCAT()
})}
......
......@@ -2,6 +2,7 @@ import React, { Component } from 'react'
import { Checkbox, FormControlLabel, Menu, Paper, Typography, Button } from '@material-ui/core'
import LineChart from 'react-linechart';
import Images from '../../assets/Images'
import NumberFormat from 'react-number-format';
export default class StrategiMap extends Component {
constructor(props) {
......@@ -221,7 +222,8 @@ export default class StrategiMap extends Component {
</div>
<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 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 }}>
......
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