DashboardCAT.js 26.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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
        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()
                        })
                    }
                }
            }
        })
    }

    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' }, () => {
                            if (response.data.message.includes("Someone Logged In")) {
                                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
125
                    let comID = this.state.rawData != null ? this.state.rawData.companyId : 0
d.arizona's avatar
d.arizona committed
126
                    // console.log(comID)
d.arizona's avatar
d.arizona committed
127 128 129 130 131
                    let companyData = data.map((item) => {
                        return {
                            company_id: item.company_id,
                            company_name: item.company_name,
                        }
d.arizona's avatar
d.arizona committed
132 133
                    })

d.arizona's avatar
d.arizona committed
134 135 136 137 138 139 140 141 142
                    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
143
                        options: arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name)),
d.arizona's avatar
d.arizona committed
144 145 146
                        getOptionLabel: (option) => titleCase(option.company_name),
                    };
                    let index = arrayBaru.findIndex((val) => val.company_id == comID)
147

d.arizona's avatar
d.arizona committed
148
                    this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
149
                        let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
d.arizona's avatar
d.arizona committed
150
                        let userID = localStorage.getItem(Constant.USER)
151
                        if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
d.arizona's avatar
d.arizona committed
152 153 154 155 156 157 158 159 160 161 162
                            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 })
163
                        }
d.arizona's avatar
d.arizona committed
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
                        this.getLastPeriod()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            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
207
                    let periodeID = this.state.rawData != null ? this.state.rawData.periode : 0
d.arizona's avatar
d.arizona committed
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
                    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
225
                        options: periodeData.sort((a, b) => a.periode - b.periode),
d.arizona's avatar
d.arizona committed
226 227 228
                        getOptionLabel: (option) => option.periode,
                    };
                    let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
d.arizona's avatar
d.arizona committed
229
                    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
230 231 232 233 234
                    // // 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
235
                    console.log(index)
d.arizona's avatar
d.arizona committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
                    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
253
                    let monthID = this.state.rawData != null ? this.state.rawData.month : 0
d.arizona's avatar
d.arizona committed
254 255 256 257 258 259 260 261 262 263
                    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
264
                    let index = data.findIndex((val) => monthID == 0 ? val.month_name == month : val.id == monthID)
d.arizona's avatar
d.arizona committed
265
                    console.log(index);
d.arizona's avatar
d.arizona committed
266 267 268 269 270 271
                    let selectedMonth = []
                    monthData.map((item, indexs) => {
                        if (indexs <= index) {
                            selectedMonth.push(item.month_value)
                        }
                    })
d.arizona's avatar
d.arizona committed
272

d.arizona's avatar
d.arizona committed
273
                    this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index], selectedMonth }, () => {
d.arizona's avatar
d.arizona committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
                        this.getDasboardCAT()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            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
294 295
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
d.arizona's avatar
d.arizona committed
296
            "months": this.state.month.month_id
297
        }
d.arizona's avatar
d.arizona committed
298
        let dataDashboard = []
d.arizona's avatar
d.arizona committed
299 300 301
        api.create().getDashboardCAT(payload).then((res) => {
            if (res.data.status == 'success') {
                console.log(res)
d.arizona's avatar
d.arizona committed
302
                // let resp = res.data.data
d.arizona's avatar
d.arizona committed
303
                this.setState({ dataDashboard: res.data.data }, () => {
d.arizona's avatar
d.arizona committed
304
                    setTimeout(() => {
d.arizona's avatar
d.arizona committed
305
                        this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
306 307
                    }, 400);
                })
d.arizona's avatar
d.arizona committed
308
            }
d.arizona's avatar
d.arizona committed
309 310 311
            // else {
            //     this.setState({loading: false})
            // }
d.arizona's avatar
d.arizona committed
312 313 314 315 316 317
            // conole.log(JSON.stringify(payload))
        })
    }

    closeAlert() {
        this.setState({ alert: false })
318 319 320 321 322 323
    }

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

d.arizona's avatar
d.arizona committed
324
    setSelectedKPI(data) {
d.arizona's avatar
d.arizona committed
325
        this.setState({ selectedKPI: data }, () => {
d.arizona's avatar
d.arizona committed
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 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
            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
383 384
            }
        })
d.arizona's avatar
d.arizona committed
385 386
    }

387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
    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
402 403 404 405 406 407 408 409 410 411 412

        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>
        );
413
        return (
Deni Rinaldi's avatar
Deni Rinaldi committed
414
            <div className='a-s-p-mid no-header'>
d.arizona's avatar
d.arizona committed
415 416 417 418 419 420
                <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
421
                <div className={"main-color"} style={{ padding: 27 }}>
d.arizona's avatar
d.arizona committed
422
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Dashboard CAT Report</Typography>
423
                </div>
d.arizona's avatar
d.arizona committed
424
                <div style={{ padding: 20 }}>
d.arizona's avatar
d.arizona committed
425
                    <div style={{ marginTop: 0, display: 'flex' }}>
d.arizona's avatar
d.arizona committed
426 427 428
                        <Autocomplete
                            {...this.state.listCompany}
                            id="month"
429 430
                            onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true }, () => {
                                let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
d.arizona's avatar
d.arizona committed
431
                                let userID = localStorage.getItem(Constant.USER)
432
                                if (dataStorageCAT != 'datacat' && dataStorageCAT != null) {
d.arizona's avatar
d.arizona committed
433 434 435 436 437 438 439 440 441 442 443
                                    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 })
444
                                }
d.arizona's avatar
d.arizona committed
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
                                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 }} />}
461
                            value={this.state.periode}
d.arizona's avatar
d.arizona committed
462 463 464 465 466
                        />
                        <Autocomplete
                            {...this.state.listMonth}
                            id="month"
                            onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
467 468 469 470 471 472 473
                                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)
                                    }
                                })
474
                                this.setState({ selectedMonth })
d.arizona's avatar
d.arizona committed
475 476 477 478 479 480 481 482
                                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
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
                    {/* <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
517
                </div>
d.arizona's avatar
d.arizona committed
518

d.arizona's avatar
d.arizona committed
519
                {!this.state.loading && <div className="padding-20px" style={{ display: 'flex' }}>
d.arizona's avatar
d.arizona committed
520
                    <Paper style={{ marginTop: 10, minWidth: this.props.open ? this.props.width - 360 : this.props.width - 100 }}>
521
                        <AppBar position="static" style={{ borderTopRightRadius: 10, borderTopLeftRadius: 10 }}>
d.arizona's avatar
d.arizona committed
522
                            <Tabs indicatorColor="primary" value={this.state.tab} onChange={this.selectTab} aria-label="simple tabs example" style={{ backgroundColor: '#354960', borderColor: 'transparent', borderTopRightRadius: 10, borderTopLeftRadius: 10 }}>
523 524 525 526 527
                                <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>
528
                        {this.state.tab === 0 ?
d.arizona's avatar
d.arizona committed
529
                            <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 }} />
530
                            :
531
                            this.state.tab === 1 ?
d.arizona's avatar
d.arizona committed
532
                                <StrategiMap height={this.props.height} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
533
                                :
d.arizona's avatar
d.arizona committed
534
                                <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 }} />
535 536
                        }
                    </Paper>
d.arizona's avatar
d.arizona committed
537
                </div>}
538 539 540 541
            </div>
        )
    }
}