ExceutiveScoreboard.js 36.6 KB
Newer Older
1 2
import React, { Component } from 'react'
import ReactSpeedometer from "react-d3-speedometer"
syadziy's avatar
syadziy committed
3
import { GridList, GridListTile, Checkbox, FormControlLabel, Menu, Typography, Button } from '@material-ui/core'
d.arizona's avatar
d.arizona committed
4

5
import Images from '../../assets/Images'
d.arizona's avatar
d.arizona committed
6
import NumberFormat from 'react-number-format';
d.arizona's avatar
d.arizona committed
7 8
import ReactECharts from 'echarts-for-react';
import api from '../../api';
9 10 11 12 13 14 15 16 17 18 19 20

export default class ExceutiveScoreboard extends Component {
    constructor(props) {
        super(props)
        this.state = {
            listDummy: [
                { judul: "Overall", kpi: 0, rank: 'BS', value: 3.67, status: 'up' },
                { judul: "Financial", kpi: 5, rank: 'BS', value: 3.67, status: 'up' },
                { judul: "Customer Perspective", kpi: 2, rank: 'B', value: 3.05, status: 'down' },
                { judul: "Internal Perspective", kpi: 5, rank: 'C', value: 2.61, status: 'down' },
                { judul: "Financial", kpi: 5, rank: 'B+', value: 3.52, status: 'up' },
            ],
d.arizona's avatar
d.arizona committed
21
            arraySpeedo: [],
d.arizona's avatar
d.arizona committed
22
            data: this.props.data,
d.arizona's avatar
d.arizona committed
23
            newData: [],
d.arizona's avatar
d.arizona committed
24
            dataPayload: this.props.dataPayload,
d.arizona's avatar
d.arizona committed
25
            selectIndex: null,
d.arizona's avatar
d.arizona committed
26 27
            loading: false,
            listKPI: [],
d.arizona's avatar
d.arizona committed
28
            selectedKPI: this.props.selectedKPI,
d.arizona's avatar
d.arizona committed
29 30 31 32
            listDetailKPI: [],
            checkAll: true,
            checkYTD: true,
            checkAB: true,
d.arizona's avatar
d.arizona committed
33
            checkYoy: true,
34
            loading2: false,
d.arizona's avatar
d.arizona committed
35 36
            newDataParent: [],
            deleteKPIList: false
37 38
        }
    }
d.arizona's avatar
d.arizona committed
39 40

    componentDidMount() {
d.arizona's avatar
d.arizona committed
41
        // console.log()
d.arizona's avatar
d.arizona committed
42
        console.log(this.state.dataPayload)
43
        this.setState({ loading: true, loading2: true })
d.arizona's avatar
d.arizona committed
44
        this.olahDataChart()
d.arizona's avatar
d.arizona committed
45
        this.getDetailDashboardCAT()
d.arizona's avatar
d.arizona committed
46 47
    }

d.arizona's avatar
d.arizona committed
48
    olahDataChart() {
d.arizona's avatar
d.arizona committed
49
        let listKPI = []
d.arizona's avatar
d.arizona committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
        let newDataParent = []
        this.state.data.executive_scoreboard.category.map((item, index) => {
            let perfomanceScore = 'K'
            let lastTotal = Number(item.current_value).toFixed(2)
            if (lastTotal >= 1.00 && lastTotal <= 2.00) {
                perfomanceScore = 'K'
            } else if (lastTotal >= 2.01 && lastTotal <= 2.75) {
                perfomanceScore = 'C'
            } else if (lastTotal >= 2.76 && lastTotal <= 3.00) {
                perfomanceScore = 'B-'
            } else if (lastTotal >= 3.01 && lastTotal <= 3.75) {
                perfomanceScore = 'B'
            } else if (lastTotal >= 3.76 && lastTotal <= 4.00) {
                perfomanceScore = 'B+'
            } else if (lastTotal >= 4.01 && lastTotal <= 4.75) {
                perfomanceScore = 'BS'
            } else if (lastTotal >= 4.76 && lastTotal <= 5.00) {
                perfomanceScore = 'IST'
            }
            newDataParent.push({ ...item, current_value: Number(item.current_value).toFixed(2), perfomanceScore })
        })

        console.log(newDataParent)

d.arizona's avatar
d.arizona committed
74 75 76 77
        this.state.data.kpi.category.map((item, index) => {
            if (item.nodes.length > 0) {
                item.nodes.map((items, indexs) => {
                    listKPI.push(items.item_name)
d.arizona's avatar
d.arizona committed
78
                })
d.arizona's avatar
d.arizona committed
79
            }
d.arizona's avatar
d.arizona committed
80
        })
d.arizona's avatar
d.arizona committed
81
        this.setState({ loading: false, listKPI, newDataParent })
d.arizona's avatar
d.arizona committed
82 83 84 85 86 87
    }

    handleValueChild(item) {
        let data = this.state.newData.filter((val) => val.parent != null)
        let indexID = data.findIndex((val) => val.item_name == item.item_name)
        let indexMonthID = data[indexID].month.findIndex((val) => val.name == `month${this.state.dataPayload.month.month_id}`)
d.arizona's avatar
d.arizona committed
88
        return data[indexID].month[indexMonthID].value == null ? 0 : data[indexID].month[indexMonthID].value
d.arizona's avatar
d.arizona committed
89
    }
d.arizona's avatar
d.arizona committed
90

d.arizona's avatar
d.arizona committed
91 92 93 94
    handleValueSpeedo(item) {
        let indexMonthID = item.month.findIndex((val) => val.name == `month${this.state.dataPayload.month.month_id}`)
        return item.month[indexMonthID].value
    }
d.arizona's avatar
d.arizona committed
95

d.arizona's avatar
d.arizona committed
96 97 98 99 100 101 102 103 104 105
    handleListKPI(item) {
        let list = this.state.selectedKPI
        let indexID = list.findIndex((val) => val == item)
        if (indexID == -1) {
            if (list.length < 4) {
                list.push(item)
            }
        } else {
            list.splice(indexID, 1)
        }
d.arizona's avatar
d.arizona committed
106 107 108 109
        // console.log(this.state.deleteKPIList)
        if (list.length > 0) {
            this.setState({ deleteKPIList: false })
        }
d.arizona's avatar
d.arizona committed
110 111
        this.props.setSelectedKPI(list)
        this.getDetailDashboardCAT()
d.arizona's avatar
d.arizona committed
112

d.arizona's avatar
d.arizona committed
113
        // this.setState({ selectedKPI: list }, () => { this.getDetailDashboardCAT() })
d.arizona's avatar
d.arizona committed
114 115 116
    }

    getDetailDashboardCAT() {
117
        this.setState({ loading2: true })
d.arizona's avatar
d.arizona committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131
        let payload = {
            "company_id": this.state.dataPayload.company.company_id,
            "periode": this.state.dataPayload.periode.periode,
            "months": this.state.dataPayload.month.month_id,
            "checklist": this.state.selectedKPI
        }
        console.log(payload)
        api.create().getDashboardCATDetail(payload).then((res) => {
            if (res.data) {
                let responseArray = res.data.data.executive_scoreboard.category
                // let newArr = []
                // responseArray.map((item,index) => {
                //     if
                // })
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
                let aa = responseArray.filter((val) => this.state.selectedKPI.includes(val.category_name))
                console.log(aa)
                let arrayNew = []
                aa.map((item, index) => {
                    let act = []
                    let mbv = []
                    let yoy = []
                    let minACT = 0
                    let maxACT = 0
                    let minMBV = 0
                    let maxMBV = 0
                    let minYOY = 0
                    let maxYOY = 0
                    item.nodes.map((items, indexs) => {
                        act.push(items.nodes_actual_value)
                        mbv.push(items.nodes_mb_value)
                        yoy.push(items.nodes_yoy_value)

                        if (minACT > items.nodes_actual_value) {
                            minACT = items.nodes_actual_value
                        }
                        if (maxACT < items.nodes_actual_value) {
                            maxACT = items.nodes_actual_value
                        }
                        if (minMBV > items.nodes_mb_value) {
                            minMBV = items.nodes_mb_value
                        }
                        if (maxMBV < items.nodes_mb_value) {
                            maxMBV = items.nodes_mb_value
                        }
                        if (minYOY > items.nodes_yoy_value) {
                            minYOY = items.nodes_yoy_value
                        }
                        if (maxYOY < items.nodes_yoy_value) {
                            maxYOY = items.nodes_yoy_value
                        }
                    })
                    let sortMin = []
                    let sortMax = []
                    if (this.state.checkAll) {
                        sortMin = [minACT, minMBV, minYOY].sort((a, b) => a - b)
                        sortMax = [maxACT, maxMBV, maxYOY].sort((a, b) => b - a)
                    } else if (this.state.checkAB && this.state.checkYTD && !this.state.checkYoy) {
                        sortMin = [minACT, minMBV].sort((a, b) => a - b)
                        sortMax = [maxACT, maxMBV].sort((a, b) => b - a)
                    } else if (this.state.checkAB && !this.state.checkYTD && this.state.checkYoy) {
                        sortMin = [minACT, minYOY].sort((a, b) => a - b)
                        sortMax = [maxACT, maxYOY].sort((a, b) => b - a)
                    } else if (this.state.checkAB && !this.state.checkYTD && !this.state.checkYoy) {
                        sortMin = [minMBV]
                        sortMax = [maxMBV]
                    } else if (!this.state.checkAB && this.state.checkYTD && this.state.checkYoy) {
                        sortMin = [minMBV, minYOY].sort((a, b) => a - b)
                        sortMax = [maxMBV, maxYOY].sort((a, b) => b - a)
                    } else if (!this.state.checkAB && this.state.checkYTD && !this.state.checkYoy) {
                        sortMin = [minMBV]
                        sortMax = [maxMBV]
                    } else if (!this.state.checkAB && !this.state.checkYTD && this.state.checkYoy) {
                        sortMin = [minYOY]
                        sortMax = [maxYOY]
                    }

                    let options = {
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                crossStyle: {
                                    color: '#999'
                                }
                            }
                        },
                        legend: {
                            data:
                                this.state.checkAll ?
                                    ['Actual', 'MB', 'Yoy']
                                    :
                                    (this.state.checkAB && this.state.checkYTD && !this.state.checkYoy ?
                                        ['Actual', 'MB']
                                        :
                                        (this.state.checkAB && !this.state.checkYTD && this.state.checkYoy ?
                                            ['Actual', 'Yoy']
                                            :
                                            (this.state.checkAB && !this.state.checkYTD && !this.state.checkYoy ?
                                                ['Actual']
                                                :
                                                (!this.state.checkAB && this.state.checkYTD && this.state.checkYoy ?
                                                    ['MB', 'Yoy']
                                                    :
                                                    (!this.state.checkAB && this.state.checkYTD && !this.state.checkYoy ?
                                                        ['MB']
                                                        :
                                                        ['Yoy'])))))
                        },
                        grid: {
                            left: 0,
                            bottom: 0
                        },
                        xAxis: {
                            type: 'category',
                            data: this.props.selectedMonth
                        },
                        yAxis: {
                            type: 'value',
                            min: sortMin[0] - 0.5,
                            max: sortMax[0] + 0.5,
                        },
                        series:
                            this.state.checkAll ?
                                [
                                    {
                                        name: 'Actual',
                                        data: act,
                                        type: 'line'
                                    },
                                    {
                                        name: 'MB',
                                        data: mbv,
                                        type: 'line'
                                    },
                                    {
                                        name: 'Yoy',
                                        data: yoy,
                                        type: 'line'
                                    }
                                ]
                                :
                                this.state.checkAB && this.state.checkYTD && !this.state.checkYoy ?
                                    [
                                        {
                                            name: 'Actual',
                                            data: act,
                                            type: 'line'
                                        },
                                        {
                                            name: 'MB',
                                            data: mbv,
                                            type: 'line'
                                        },
                                    ]
                                    :
                                    this.state.checkAB && !this.state.checkYTD && this.state.checkYoy ?
                                        [
                                            {
                                                name: 'Actual',
                                                data: act,
                                                type: 'line'
                                            },
                                            {
                                                name: 'Yoy',
                                                data: yoy,
                                                type: 'line'
                                            }
                                        ]
                                        :
                                        this.state.checkAB && !this.state.checkYTD && !this.state.checkYoy ?
                                            [
                                                {
                                                    name: 'Actual',
                                                    data: act,
                                                    type: 'line'
                                                },
                                            ]
                                            :
                                            !this.state.checkAB && this.state.checkYTD && this.state.checkYoy ?
                                                [
                                                    {
                                                        name: 'MB',
                                                        data: mbv,
                                                        type: 'line'
                                                    },
                                                    {
                                                        name: 'Yoy',
                                                        data: yoy,
                                                        type: 'line'
                                                    }
                                                ]
                                                :
                                                !this.state.checkAB && this.state.checkYTD && !this.state.checkYoy ?
                                                    [
                                                        {
                                                            name: 'MB',
                                                            data: mbv,
                                                            type: 'line'
                                                        },
                                                    ]
                                                    :
                                                    [
                                                        {
                                                            name: 'Yoy',
                                                            data: yoy,
                                                            type: 'line'
                                                        }
                                                    ]

                    }
d.arizona's avatar
d.arizona committed
328
                    arrayNew.push({ ...item, options })
329 330 331 332 333
                })
                console.log(arrayNew)
                console.log(this.state.checkAll)
                this.setState({ listDetailKPI: arrayNew }, () => {
                    setTimeout(() => {
d.arizona's avatar
d.arizona committed
334
                        this.setState({ loading2: false })
335 336 337
                    }, 500);
                })
                // console.log(aa)
d.arizona's avatar
d.arizona committed
338 339 340 341
            }
        })
    }

d.arizona's avatar
d.arizona committed
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
    handleBackgroundPerform(total) {
        let color = 'white'
        if (total >= 1.00 && total <= 2.00) {
            color = 'red'
        } else if (total >= 2.01 && total <= 2.75) {
            color = 'yellow'
        } else if (total >= 2.76 && total <= 3.00) {
            color = 'lightgreen'
        } else if (total >= 3.01 && total <= 3.75) {
            color = 'yellowgreen'
        } else if (total >= 3.76 && total <= 4.00) {
            color = 'forestgreen'
        } else if (total >= 4.01 && total <= 4.75) {
            color = 'deepskyblue'
        } else if (total >= 4.76 && total <= 5.00) {
            color = 'dodgerblue'
        }
        return color
    }

362 363
    render() {
        let { selectIndex } = this.state
d.arizona's avatar
d.arizona committed
364
        let yuk = [1, 2, 3]
Deni Rinaldi's avatar
Deni Rinaldi committed
365 366 367 368
        const data = [
            {
                color: "steelblue",
                points: [
d.arizona's avatar
d.arizona committed
369 370
                    { x: 1, y: 4.1 },
                    { x: 2, y: 0 },
Deni Rinaldi's avatar
Deni Rinaldi committed
371
                    { x: 3, y: 3 },
d.arizona's avatar
d.arizona committed
372 373
                    { x: 4, y: 0 },
                    { x: 5, y: -2 },
Deni Rinaldi's avatar
Deni Rinaldi committed
374 375 376 377 378
                    { x: 6, y: 5 },
                    { x: 7, y: 4 },
                ]
            }
        ];
379

d.arizona's avatar
d.arizona committed
380 381 382 383 384 385 386
        const newTitleCase = (val) => {
            let value = val
            return value.split(' ')
                .map(w => w[0].toUpperCase() + w.substr(1).toLowerCase())
                .join(' ')
        }

387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
        const optionzzz = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    crossStyle: {
                        color: '#999'
                    }
                }
            },
            grid: {
                left: 0,
                bottom: 0
            },
            xAxis: {
                type: 'category',
                data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            },
            yAxis: {
                type: 'value'
            },
            series: [{
                data: [150, 230, 224, 218, 135, 147, 260],
                type: 'line'
            }]
        };

414
        return (
d.arizona's avatar
d.arizona committed
415 416
            <div style={{ padding: 20, width: '100%' }}>
                <div style={{ display: 'flex', width: '100%', flex: 'wrap' }}>
d.arizona's avatar
d.arizona committed
417
                    {!this.state.loading && this.state.newDataParent.map((item, index) => {
418
                        return (
d.arizona's avatar
d.arizona committed
419
                            <div style={{ padding: 10, backgroundColor: this.state.selectIndex === index ? '#6885a6' : '#fff', borderRadius: 6, paddingBottom: 20, marginTop: 10, marginBottom: 10, marginLeft: index == 0 ? 0 : 25, marginRight: index == this.state.newDataParent.length - 1 ? 0 : 25, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', width: 250 }}>
d.arizona's avatar
d.arizona committed
420 421
                                {/* <span style={{ fontSize: '17px', color: this.state.selectIndex === index ? '#fff' : '#7e8085', maxWidth: 100 }}>{item.category_name}</span> */}
                                <div style={{ fontSize: '17px', width: '100%' }}>
d.arizona's avatar
d.arizona committed
422
                                    <Typography style={{ textAlign: 'left' }}>{newTitleCase(String(item.category_name).toLocaleLowerCase())}</Typography>
d.arizona's avatar
d.arizona committed
423 424 425 426 427 428 429
                                </div>
                                {item.total_kpi != null &&
                                    <div style={{ width: '100%', display: 'flex', justifyContent: 'center', marginTop: String(item.category_name).toLocaleLowerCase().includes('internal') ? 0 : 25 }}>
                                        <span style={{ textAlign: 'center', fontSize: '18px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>{item.total_kpi}</span>
                                        {/* <span style={{ textAlign: 'center', fontSize: '11px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>KPIs</span> */}
                                    </div>}
                                <div style={{ display: 'flex', justifyContent: 'center', marginTop: String(item.category_name).toLocaleLowerCase() == 'overall' ? 50 : 0 }}>
d.arizona's avatar
d.arizona committed
430
                                    <div style={{ backgroundColor: this.handleBackgroundPerform(Number(item.current_value).toFixed(2)), textAlign: 'center', display: 'flex', justifyContent: 'center', width: 40, height: 21 }}>
d.arizona's avatar
d.arizona committed
431
                                        <Typography style={{ textAlign: 'center' }}>{item.performance}</Typography>
432 433
                                    </div>
                                </div>
d.arizona's avatar
d.arizona committed
434 435 436 437
                                <div style={{ display: 'flex', justifyContent: 'center' }}>
                                    <ReactSpeedometer
                                        maxSegmentLabels={0}
                                        segmentColors={[
d.arizona's avatar
d.arizona committed
438
                                            this.handleBackgroundPerform(Number(item.current_value).toFixed(2)),
d.arizona's avatar
d.arizona committed
439 440 441
                                            "#d8d8d8"
                                        ]}
                                        needleColor={this.state.selectIndex === index ? "#fff" : '#4b4b4b'}
d.arizona's avatar
d.arizona committed
442 443
                                        value={Number(item.current_value).toFixed(2)}
                                        valueFormat={'.2f'}
d.arizona's avatar
d.arizona committed
444 445
                                        minValue={Number(item.low)}
                                        maxValue={Number(item.high)}
d.arizona's avatar
d.arizona committed
446
                                        customSegmentStops={[0, Number(item.current_value).toFixed(2), 5]}
d.arizona's avatar
d.arizona committed
447 448 449 450 451 452
                                        width={200}
                                        height={140}
                                        ringWidth={25}
                                        textColor={selectIndex === index ? "#fff" : '#4b4b4b'}
                                    />
                                </div>
453
                                <div style={{ backgroundColor: 'transparent', display: 'flex', marginTop: 20, placeContent: 'center' }}>
d.arizona's avatar
d.arizona committed
454 455 456 457 458 459 460 461 462 463 464
                                    {item.is_higher == '-' ?
                                        <div style={{ textAlign: '-webkit-center' }}>
                                            <Typography style={{ fontSize: 16, color: '#4b4b4b' }}> - </Typography>
                                        </div>
                                        :
                                        <div style={{ textAlign: '-webkit-center' }}>
                                            {item.is_higher == 'true' ?
                                                <img src={Images.up} /> : <img src={Images.down} />}
                                            <Typography style={{ fontSize: 16, color: '#4b4b4b' }}>vs Last Month</Typography>
                                        </div>
                                    }
465 466 467
                                </div>
                            </div>
                        )
d.arizona's avatar
d.arizona committed
468
                    })}
469
                </div>
d.arizona's avatar
d.arizona committed
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
                <div style={{ display: 'flex', marginTop: 15 }}>
                    <div>
                        <Button aria-controls="simple-menu" aria-haspopup="true" onClick={(e) => this.setState({ openMenuKPI: e.currentTarget })}>
                            KPI List
                        </Button>
                        <Menu
                            id="simple-menu"
                            anchorEl={this.state.openMenuKPI}
                            keepMounted
                            open={Boolean(this.state.openMenuKPI)}
                            onClose={() => this.setState({ openMenuKPI: false })}
                        >
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', borderBottom: 'solid 3px #979696' }}>
                                    <FormControlLabel
                                        control={
                                            <Checkbox
                                                checked={this.state.deleteKPIList}
                                                onChange={() => {
                                                    this.setState({
                                                        deleteKPIList: !this.state.deleteKPIList
                                                    }, () => {
d.arizona's avatar
d.arizona committed
492
                                                        this.props.setSelectedKPI(this.state.deleteKPIList ? [] : this.state.selectedKPI)
d.arizona's avatar
d.arizona committed
493 494 495
                                                        this.setState({ selectedKPI: this.state.deleteKPIList ? [] : this.state.selectedKPI }, () => {
                                                            this.getDetailDashboardCAT()
                                                        })
d.arizona's avatar
d.arizona committed
496 497 498 499 500 501
                                                    })
                                                }}
                                                name="checkedB"
                                                color="primary"
                                            />
                                        }
d.arizona's avatar
d.arizona committed
502
                                        label={"Tidak Pilih Semua"}
d.arizona's avatar
d.arizona committed
503 504 505
                                    />
                                </div>
                                <div style={{ display: 'grid' }}>
d.arizona's avatar
d.arizona committed
506
                                    <Typography style={{ fontSize: 11, color: 'red', fontStyle: 'italic', marginTop: 5 }}>* Hanya dapat memilih 4 item KPI </Typography>
d.arizona's avatar
d.arizona committed
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
                                    {this.state.listKPI.map((item, index) => {
                                        return (
                                            <FormControlLabel
                                                control={
                                                    <Checkbox
                                                        checked={this.state.selectedKPI.includes(item)}
                                                        onChange={() => {
                                                            this.handleListKPI(item)
                                                        }}
                                                        name="checkedB"
                                                        color="primary"
                                                    />
                                                }
                                                label={item}
                                            />
                                        )
                                    })}
                                </div>
                            </div>
                        </Menu>
                    </div>
                    <div>
                        <Button aria-controls="simple-menu" aria-haspopup="true" onClick={(e) => this.setState({ openMenu: e.currentTarget })}>
                            Filter
                        </Button>
                        <Menu
                            id="simple-menu"
                            anchorEl={this.state.openMenu}
                            keepMounted
                            open={Boolean(this.state.openMenu)}
                            onClose={() => this.setState({ openMenu: false })}
                        >
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', borderBottom: 'solid 3px #979696' }}>
                                    <FormControlLabel
                                        control={
                                            <Checkbox
                                                checked={this.state.checkAll}
                                                onChange={() => {
                                                    this.setState({
                                                        checkAll: true,
                                                        checkYTD: true,
                                                        checkAB: true,
                                                        checkYoy: true
551
                                                    }, () => { this.getDetailDashboardCAT() })
d.arizona's avatar
d.arizona committed
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
                                                }}
                                                name="checkedB"
                                                color="primary"
                                            />
                                        }
                                        style={{ marginRight: 20 }}
                                        label={"Pilih Semua"}
                                    />
                                    <FormControlLabel
                                        control={
                                            <Checkbox
                                                checked={!this.state.checkAll && !this.state.checkYoy && !this.state.checkAB && !this.state.checkYTD}
                                                onChange={() => {
                                                    this.setState({
                                                        checkAll: false,
                                                        checkYTD: false,
                                                        checkAB: false,
                                                        checkYoy: false
570
                                                    }, () => { this.getDetailDashboardCAT() })
d.arizona's avatar
d.arizona committed
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
                                                }}
                                                name="checkedB"
                                                color="primary"
                                            />
                                        }
                                        label={"Hapus Semua"}
                                    />
                                </div>
                                <div style={{ display: 'grid' }}>
                                    <FormControlLabel
                                        control={
                                            <Checkbox
                                                checked={this.state.checkYTD}
                                                onChange={() => {
                                                    this.setState({
                                                        checkYTD: !this.state.checkYTD
                                                    }, () => {
588
                                                        this.setState({ checkAll: this.state.checkYoy && this.state.checkAB && this.state.checkYTD }, () => { this.getDetailDashboardCAT() })
d.arizona's avatar
d.arizona committed
589 590 591 592 593 594 595 596 597 598 599 600 601 602
                                                    })
                                                }}
                                                name="checkedB"
                                                color="primary"
                                            />
                                        }
                                        label={"Tren YTD"}
                                    />
                                    <FormControlLabel
                                        control={
                                            <Checkbox
                                                checked={this.state.checkAB}
                                                onChange={() => {
                                                    this.setState({ checkAB: !this.state.checkAB }, () => {
603
                                                        this.setState({ checkAll: this.state.checkYoy && this.state.checkAB && this.state.checkYTD }, () => { this.getDetailDashboardCAT() })
d.arizona's avatar
d.arizona committed
604 605 606 607 608 609 610 611 612 613 614 615 616 617
                                                    })
                                                }}
                                                name="checkedB"
                                                color="primary"
                                            />
                                        }
                                        label={"Actual vs Budget"}
                                    />
                                    <FormControlLabel
                                        control={
                                            <Checkbox
                                                checked={this.state.checkYoy}
                                                onChange={() => {
                                                    this.setState({ checkYoy: !this.state.checkYoy }, () => {
618
                                                        this.setState({ checkAll: this.state.checkYoy && this.state.checkAB && this.state.checkYTD }, () => { this.getDetailDashboardCAT() })
d.arizona's avatar
d.arizona committed
619 620 621 622 623 624 625 626
                                                    })
                                                }}
                                                name="checkedB"
                                                color="primary"
                                            />
                                        }
                                        label={"Yoy"}
                                    />
d.arizona's avatar
d.arizona committed
627 628
                                </div>
                            </div>
d.arizona's avatar
d.arizona committed
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
                        </Menu>
                    </div>
                </div>

                <div style={{ padding: 10, marginTop: 10, display: 'flex', width: '100%' }}>

                    {/* <div style={{ maxWidth: 566, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', padding: 20, marginLeft: 5, marginTop: 5, marginRight: 5, display: 'inline-grid' }}>
                        <div>
                            <span style={{ fontSize: 17 }}>{'kuntul'}</span>
                            <Typography style={{ fontSize: 24, fontWeight: 'bold' }}><NumberFormat value={123345} displayType={'text'} thousandSeparator={true} prefix={'Rp. '} /></Typography>
                            <Typography style={{ fontSize: 16, fontWeight: 'bold' }}>In IDR mn</Typography>
                        </div>
                        <div style={{ marginTop: -50 }}>
                            <LineChart
                                width={400}
                                height={250}
                                data={data}
                                // yMin={0}
                                // yMax={10}
                                hideXAxis={true}
                                hideYAxis={true}
                                hideXLabel={true}
                                hideYLabel={true}
                            />
                        </div>
                    </div> */}
655
                    <GridList cellHeight={500} cols={2}>
d.arizona's avatar
d.arizona committed
656
                        {this.state.listDetailKPI.map((item, index) => {
d.arizona's avatar
d.arizona committed
657
                            return (
658 659
                                <GridListTile key={item} cols={this.state.listDetailKPI.length == 1 ? 2 : 1} style={{ marginBottom: 10 }}>
                                    {!this.state.loading2 && <div style={{ width: 600, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', padding: 20, marginLeft: 15, marginTop: index > 1 ? 20 : 5, marginRight: 5, display: 'inline-grid' }}>
d.arizona's avatar
d.arizona committed
660 661
                                        <div>
                                            <span style={{ fontSize: 17 }}>{item.category_name}</span>
662 663
                                            <Typography style={{ fontSize: 24, fontWeight: 'bold' }}><NumberFormat value={item.current_value} displayType={'text'} thousandSeparator={true} /></Typography>
                                            <Typography style={{ fontSize: 16, fontWeight: 'bold' }}>{item.uom}</Typography>
d.arizona's avatar
d.arizona committed
664 665
                                        </div>
                                        <div style={{}}>
666 667 668 669 670 671
                                            {(this.state.checkAB || this.state.checkYTD || this.state.checkYoy) && !this.state.loading && <ReactECharts
                                                showLoading={this.state.loading2}
                                                lazyUpdate
                                                style={{ height: 350, width: '100%', marginTop: 20 }}
                                                option={item.options}
                                            />}
d.arizona's avatar
d.arizona committed
672
                                        </div>
673
                                    </div>}
d.arizona's avatar
d.arizona committed
674 675 676 677 678
                                </GridListTile>
                            )
                        }
                        )}
                    </GridList>
d.arizona's avatar
d.arizona committed
679
                </div>
d.arizona's avatar
d.arizona committed
680

d.arizona's avatar
d.arizona committed
681
                {/* <div style={{ width: 566, height: 233, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', padding: 20, justifyContent: 'space-between', display: 'grid', margin: 10 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
                        <div>
                            <span style={{ fontSize: 17 }}>YTD Revenue</span>
                            <Typography style={{ fontSize: 24, fontWeight: 'bold' }}>1,016,489.78</Typography>
                            <Typography style={{ fontSize: 16, fontWeight: 'bold' }}>In IDR mn</Typography>
                        </div>
                        <LineChart
                            width={400}
                            height={50}
                            data={data}
                            yMin={0}
                            yMax={10}
                            hideXAxis={true}
                            hideYAxis={true}
                            hideXLabel={true}
                            hideYLabel={true}
                        />
d.arizona's avatar
d.arizona committed
698
                    </div> */}
d.arizona's avatar
d.arizona committed
699
            </div>
700 701 702
        )
    }
}