DashboardCAT.js 27.6 KB
Newer Older
1
import React, { Component } from 'react'
d.arizona's avatar
d.arizona committed
2
import { Typography, MenuItem, TextField, AppBar, Paper, Tabs, Tab, Snackbar, withStyles } from '@material-ui/core'
3
import ExceutiveScoreboard from './ExceutiveScoreboard'
Deni Rinaldi's avatar
Deni Rinaldi committed
4
import StrategiMap from './StrategiMap'
Riri Novita's avatar
Riri Novita committed
5
import KPIs from './KPIs'
d.arizona's avatar
d.arizona committed
6 7 8 9 10 11 12 13 14 15
import api from '../../api'
import { Autocomplete } from '@material-ui/lab'
import { PropagateLoader } from 'react-spinners'
import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../library/Constant'
import { titleCase } from '../../library/Utils'
import { format } from 'date-fns';

const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
16 17 18 19 20 21 22

export default class DashboardCAT extends Component {
    constructor(props) {
        super(props)
        this.state = {
            periode: '2020',
            perusahaan: 'TAP Group',
d.arizona's avatar
d.arizona committed
23 24 25 26 27 28 29 30
            tab: 0,
            lastPeriod: '',
            listCompany: null,
            company: null,
            listPeriode: null,
            periode: null,
            listMonth: null,
            month: null,
d.arizona's avatar
d.arizona committed
31
            loading: true,
d.arizona's avatar
d.arizona committed
32 33
            dataDashboard: [],
            selectedKPI: [],
d.arizona's avatar
d.arizona committed
34
            listKPI: [],
d.arizona's avatar
d.arizona committed
35 36
            selectedMonth: [],
            rawData: null
d.arizona's avatar
d.arizona committed
37 38 39 40
        }
    }

    componentDidMount() {
d.arizona's avatar
d.arizona committed
41
        console.log(this.props)
d.arizona's avatar
d.arizona committed
42
        // localStorage.removeItem(Constant.DATACAT)
d.arizona's avatar
d.arizona committed
43 44 45
        this.props.selectIndex('CAT Dashboard')
        let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
        if (this.props.location.state !== undefined) {
46 47 48
            if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
                this.setState({ selectedKPI: JSON.parse(dataStorageCAT).listKPI }, () => {
                    console.log(dataStorageCAT)
d.arizona's avatar
d.arizona committed
49
                    // console.log(this.props.location.state.rawData.companyId)
50
                    console.log(this.state.selectedKPI)
d.arizona's avatar
d.arizona committed
51
                    this.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData}, () => {
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
                        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()
            // })
d.arizona's avatar
d.arizona committed
68 69 70
        } else {
            this.getDetailUser()
        }
d.arizona's avatar
d.arizona committed
71 72 73
    }

    getDetailUser() {
d.arizona's avatar
d.arizona committed
74
        console.log(this.state.rawData)
d.arizona's avatar
d.arizona committed
75 76 77 78 79 80 81 82 83 84
        let userId = localStorage.getItem(Constant.USER)
        api.create().getDetailUser(userId).then((response) => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        this.getRole(response.data.data.role_id)
                        this.setState({ userCompany: response.data.data.company }, () => {
                            this.getCompanyActive()
                        })
                    }
d.arizona's avatar
d.arizona committed
85 86 87 88 89 90 91 92 93 94 95 96
                    else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
97
                }
d.arizona's avatar
d.arizona committed
98 99
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
100
            }
d.arizona's avatar
d.arizona committed
101 102
            //     }
            // }
d.arizona's avatar
d.arizona committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
        })
    }

    getRole(id) {
        api.create().getDetailRole(id).then((response) => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        // this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
                        // // // console.log(response.data.data)
                        if (String(response.data.data.role_name).toLocaleLowerCase() == 'superadmin') {
                            this.setState({ isAdmin: true })
                        }
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
118
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
                                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' })
            }
        })
    }

    getCompanyActive() {
        api.create().getPerusahaanActive().then((response) => {
            console.log(response);
            if (response.data) {
                if (response.data.status === 'success') {
                    let data = response.data.data
d.arizona's avatar
d.arizona committed
141
                    let comID = this.state.rawData != null ? this.state.rawData.companyId : 0
d.arizona's avatar
d.arizona committed
142
                    // console.log(comID)
d.arizona's avatar
d.arizona committed
143 144 145 146 147
                    let companyData = data.map((item) => {
                        return {
                            company_id: item.company_id,
                            company_name: item.company_name,
                        }
d.arizona's avatar
d.arizona committed
148 149
                    })

d.arizona's avatar
d.arizona committed
150 151 152 153 154 155 156 157 158
                    let arrayBaru = []
                    this.state.userCompany.map((item, index) => {
                        let indexID = companyData.findIndex((val) => val.company_id == item)
                        if (indexID !== -1) {
                            arrayBaru.push(companyData[indexID])
                        }
                    })

                    let defaultProps = {
Deni Rinaldi's avatar
Deni Rinaldi committed
159
                        options: arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name)),
d.arizona's avatar
d.arizona committed
160 161 162
                        getOptionLabel: (option) => titleCase(option.company_name),
                    };
                    let index = arrayBaru.findIndex((val) => val.company_id == comID)
163

d.arizona's avatar
d.arizona committed
164
                    this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
165
                        let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
d.arizona's avatar
d.arizona committed
166
                        let userID = localStorage.getItem(Constant.USER)
167
                        if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
d.arizona's avatar
d.arizona committed
168 169 170 171 172 173 174 175 176 177 178
                            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 })
179
                        }
d.arizona's avatar
d.arizona committed
180 181 182 183
                        this.getLastPeriod()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
184
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
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
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null })
            }
        })
    }

    getLastPeriod() {
        console.log(this.state.company)
        api.create().getLastPeriod(this.state.company.company_id).then(response => {
            console.log(response);
            if (response.data.status === "success") {
                this.setState({ lastPeriod: response.data.data.last_periode, latestPeriode: response.data.data.latest_periode }, () => {
                    console.log(this.state.lastPeriod)
                    this.getPeriode()
                })
            }
        })
    }

    getPeriode() {
        api.create().getPeriodeTransaction().then(response => {
            // let dateNow = new Date
            console.log(response)
            // let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy')
            let currentYear = new Date().getFullYear()
            // // // console.log(currentYear)
            if (response.data) {
                if (response.data.status === "success") {
                    let data = []
                    console.log(response.data.data)
                    console.log(this.state.lastPeriod)
d.arizona's avatar
d.arizona committed
223
                    let periodeID = this.state.rawData != null ? this.state.rawData.periode : 0
d.arizona's avatar
d.arizona committed
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
                    response.data.data.map((item) => {
                        if (this.state.isApprover) {
                            if (item >= 2000 && item <= (Number(currentYear) + 1)) {
                                data.push(item)
                            }
                        } else {
                            if ((Number(item) >= 2000) && (Number(item) == this.state.lastPeriod || Number(item) < this.state.lastPeriod)) {
                                data.push(item)
                            }
                        }
                    })
                    let periodeData = data.map((item) => {
                        return {
                            periode: item,
                        }
                    })
                    let defaultProps = {
d.arizona's avatar
d.arizona committed
241
                        options: periodeData.sort((a, b) => a.periode - b.periode),
d.arizona's avatar
d.arizona committed
242 243 244
                        getOptionLabel: (option) => option.periode,
                    };
                    let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
d.arizona's avatar
d.arizona committed
245
                    let index = periodeData.sort((a, b) => a.periode - b.periode).findIndex((val) => periodeID == 0 ? val.periode === periode : val.periode == periodeID)
d.arizona's avatar
d.arizona committed
246 247 248 249 250
                    // // console.log(this.props.location.state.rawData)
                    // console.log(this.state.lastPeriod)
                    console.log(data)
                    console.log(periodeData)
                    console.log(defaultProps)
d.arizona's avatar
d.arizona committed
251
                    console.log(index)
d.arizona's avatar
d.arizona committed
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
                    this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
                        this.getMonth()
                    })
                }
            }
        })
    }

    getMonth() {
        api.create().getMonthTransaction().then(response => {
            let dateNow = new Date
            let month = format(dateNow, 'MMMM')
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
                    console.log(response);
                    let data = response.data.data
d.arizona's avatar
d.arizona committed
269
                    let monthID = this.state.rawData != null ? this.state.rawData.month : 0
d.arizona's avatar
d.arizona committed
270 271 272 273 274 275 276 277 278 279
                    let monthData = data.map((item) => {
                        return {
                            month_id: item.id,
                            month_value: String(item.month_name).substr(0, 3)
                        }
                    })
                    let defaultProps = {
                        options: monthData,
                        getOptionLabel: (option) => option.month_value,
                    };
d.arizona's avatar
d.arizona committed
280
                    let index = data.findIndex((val) => monthID == 0 ? val.month_name == month : val.id == monthID)
d.arizona's avatar
d.arizona committed
281
                    console.log(index);
d.arizona's avatar
d.arizona committed
282 283 284 285 286 287
                    let selectedMonth = []
                    monthData.map((item, indexs) => {
                        if (indexs <= index) {
                            selectedMonth.push(item.month_value)
                        }
                    })
d.arizona's avatar
d.arizona committed
288

d.arizona's avatar
d.arizona committed
289
                    this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index], selectedMonth }, () => {
d.arizona's avatar
d.arizona committed
290 291 292 293
                        this.getDasboardCAT()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
294
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
            }
        })
    }

    getDasboardCAT() {
        let payload = {
d.arizona's avatar
d.arizona committed
310 311
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
d.arizona's avatar
d.arizona committed
312
            "months": this.state.month.month_id
313
        }
d.arizona's avatar
d.arizona committed
314
        let dataDashboard = []
d.arizona's avatar
d.arizona committed
315 316 317
        api.create().getDashboardCAT(payload).then((res) => {
            if (res.data.status == 'success') {
                console.log(res)
d.arizona's avatar
d.arizona committed
318
                // let resp = res.data.data
d.arizona's avatar
d.arizona committed
319
                this.setState({ dataDashboard: res.data.data }, () => {
d.arizona's avatar
d.arizona committed
320
                    setTimeout(() => {
d.arizona's avatar
d.arizona committed
321
                        this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
322 323
                    }, 400);
                })
d.arizona's avatar
d.arizona committed
324
            }
d.arizona's avatar
d.arizona committed
325 326 327
            // else {
            //     this.setState({loading: false})
            // }
d.arizona's avatar
d.arizona committed
328 329 330 331 332 333
            // conole.log(JSON.stringify(payload))
        })
    }

    closeAlert() {
        this.setState({ alert: false })
334 335 336 337 338 339
    }

    selectTab = (event, newEvent) => {
        this.setState({ tab: newEvent })
    }

d.arizona's avatar
d.arizona committed
340
    setSelectedKPI(data) {
d.arizona's avatar
d.arizona committed
341
        this.setState({ selectedKPI: data }, () => {
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 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
            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,
                            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)
d.arizona's avatar
d.arizona committed
399 400
            }
        })
d.arizona's avatar
d.arizona committed
401 402
    }

403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
    render() {
        const perusahaan = [
            { value: 'TAP Group', label: 'TAP Group' },
            { value: '2019', label: '2019' },
            { value: '2018', label: '2018' },
            { value: '2017', label: '2017' },
            { value: '2016', label: '2016' },
        ]
        const periode = [
            { value: '2020', label: '2020' },
            { value: '2019', label: '2019' },
            { value: '2018', label: '2018' },
            { value: '2017', label: '2017' },
            { value: '2016', label: '2016' },
        ]
d.arizona's avatar
d.arizona committed
418 419 420 421 422 423 424 425 426 427 428

        const loadingComponent = (
            <div style={{ position: 'fixed', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );
429
        return (
Deni Rinaldi's avatar
Deni Rinaldi committed
430
            <div className='a-s-p-mid no-header'>
d.arizona's avatar
d.arizona committed
431 432 433 434 435 436
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
                {this.state.loading && loadingComponent}
Deni Rinaldi's avatar
Deni Rinaldi committed
437
                <div className={"main-color"} style={{ padding: 27 }}>
d.arizona's avatar
d.arizona committed
438
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Dashboard CAT Report</Typography>
439
                </div>
d.arizona's avatar
d.arizona committed
440
                <div style={{ padding: 20 }}>
d.arizona's avatar
d.arizona committed
441
                    <div style={{ marginTop: 0, display: 'flex' }}>
d.arizona's avatar
d.arizona committed
442 443 444
                        <Autocomplete
                            {...this.state.listCompany}
                            id="month"
445 446
                            onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true }, () => {
                                let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
d.arizona's avatar
d.arizona committed
447
                                let userID = localStorage.getItem(Constant.USER)
448
                                if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
d.arizona's avatar
d.arizona committed
449 450 451 452 453 454 455 456 457 458 459
                                    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 })
460
                                }
d.arizona's avatar
d.arizona committed
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
                                this.getDasboardCAT()
                            })}
                            disableClearable
                            style={{ maxWidth: 250, marginRight: 20 }}
                            renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
                            value={this.state.company}
                        />
                        <Autocomplete
                            {...this.state.listPeriode}
                            id="month"
                            onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true }, () => {
                                this.getDasboardCAT()
                            })}
                            disableClearable
                            style={{ maxWidth: 250, marginRight: 20 }}
                            renderInput={(params) => <TextField {...params} label="Periode" margin="normal" style={{ marginTop: 7 }} />}
477
                            value={this.state.periode}
d.arizona's avatar
d.arizona committed
478 479 480 481 482
                        />
                        <Autocomplete
                            {...this.state.listMonth}
                            id="month"
                            onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
483 484 485 486 487 488 489
                                let index = this.state.listMonth.options.findIndex((val) => val.month_id == this.state.month.month_id)
                                let selectedMonth = []
                                this.state.listMonth.options.map((item, indexs) => {
                                    if (indexs <= index) {
                                        selectedMonth.push(item.month_value)
                                    }
                                })
490
                                this.setState({ selectedMonth })
d.arizona's avatar
d.arizona committed
491 492 493 494 495 496 497 498
                                this.getDasboardCAT()
                            })}
                            disableClearable
                            style={{ maxWidth: 250, marginRight: 20 }}
                            renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
                            value={this.state.month}
                        />
                    </div>
d.arizona's avatar
d.arizona committed
499 500 501 502 503 504 505 506 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
                    {/* <div style={{ marginTop: 20 }}>
                        <Autocomplete
                            {...this.state.listPeriode}
                            id="month"
                            onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true }, () => {
                                this.getDasboardCAT()
                            })}
                            disableClearable
                            style={{ maxWidth: 250, marginRight: 20 }}
                            renderInput={(params) => <TextField {...params} label="Periode" margin="normal" style={{ marginTop: 7 }} />}
                            value={this.state.periode}
                        />
                    </div> */}
                    {/* <div style={{ marginTop: 20 }}>
                        <Autocomplete
                            {...this.state.listMonth}
                            id="month"
                            onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
                                let index = this.state.listMonth.options.findIndex((val) => val.month_id == this.state.month.month_id)
                                let selectedMonth = []
                                this.state.listMonth.options.map((item, indexs) => {
                                    if (indexs <= index) {
                                        selectedMonth.push(item.month_value)
                                    }
                                })
                                this.setState({ selectedMonth })
                                this.getDasboardCAT()
                            })}
                            disableClearable
                            style={{ maxWidth: 250, marginRight: 20 }}
                            renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
                            value={this.state.month}
                        />
                    </div> */}
d.arizona's avatar
d.arizona committed
533
                </div>
d.arizona's avatar
d.arizona committed
534

d.arizona's avatar
d.arizona committed
535
                {!this.state.loading && <div className="padding-20px" style={{ display: 'flex' }}>
d.arizona's avatar
d.arizona committed
536
                    <Paper style={{ marginTop: 10, minWidth: this.props.open ? this.props.width - 360 : this.props.width - 100 }}>
537
                        <AppBar position="static" style={{ borderTopRightRadius: 10, borderTopLeftRadius: 10 }}>
d.arizona's avatar
d.arizona committed
538
                            <Tabs indicatorColor="primary" value={this.state.tab} onChange={this.selectTab} aria-label="simple tabs example" style={{ backgroundColor: '#354960', borderColor: 'transparent', borderTopRightRadius: 10, borderTopLeftRadius: 10 }}>
539 540 541 542 543
                                <Tab label="Executive Scoreboard" style={{ color: '#fff', fontSize: 11 }} />
                                <Tab label="Strategy Map" style={{ color: '#fff', fontSize: 11 }} />
                                <Tab label="KPIs" style={{ color: '#fff', fontSize: 11 }} />
                            </Tabs>
                        </AppBar>
544
                        {this.state.tab === 0 ?
d.arizona's avatar
d.arizona committed
545
                            <ExceutiveScoreboard selectedKPI={this.state.selectedKPI} selectedMonth={this.state.selectedMonth} setSelectedKPI={this.setSelectedKPI.bind(this)} height={this.props.height} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
546
                            :
547
                            this.state.tab === 1 ?
d.arizona's avatar
d.arizona committed
548
                                <StrategiMap height={this.props.height} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
549
                                :
d.arizona's avatar
d.arizona committed
550
                                <KPIs height={this.props.height} selectedMonth={this.state.selectedMonth} width={this.props.open ? this.props.width - 360 : this.props.width - 100} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
551 552
                        }
                    </Paper>
d.arizona's avatar
d.arizona committed
553
                </div>}
554 555 556 557
            </div>
        )
    }
}