DashboardFinancial.js 61.4 KB
Newer Older
d.arizona's avatar
d.arizona committed
1 2
import * as React from 'react';
import Paper from '@material-ui/core/Paper';
d.arizona's avatar
d.arizona committed
3 4
import { useTheme } from '@nivo/core'
import { Divider, Snackbar, TextField, Typography, withStyles } from '@material-ui/core';
d.arizona's avatar
d.arizona committed
5 6 7 8 9
import MuiAlert from '@material-ui/lab/Alert';
import { Autocomplete } from '@material-ui/lab';
import { titleCase } from '../../library/Utils';
import api from '../../api';
import Constant from '../../library/Constant';
d.arizona's avatar
d.arizona committed
10 11
import { format } from 'date-fns';
import { PropagateLoader } from 'react-spinners';
d.arizona's avatar
d.arizona committed
12
import ReactECharts from 'echarts-for-react';
d.arizona's avatar
d.arizona committed
13 14 15 16 17 18 19 20 21 22

const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);

// make sure parent container have a defined height when using
// responsive component, otherwise height will be 0 and
// no chart will be rendered.
// website examples showcase many properties,
// you'll often use just a few of them.
// const MyResponsiveBar = ({ data /* see data tab */ }) => (
d.arizona's avatar
d.arizona committed
23

d.arizona's avatar
d.arizona committed
24 25 26
// )

export default class DashboardFinancial extends React.Component {
d.arizona's avatar
d.arizona committed
27 28
    constructor(props) {
        super(props);
d.arizona's avatar
d.arizona committed
29

d.arizona's avatar
d.arizona committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
        this.state = {
            listReportType: [
                {
                    name: 'GRAPH - MONTHLY BY INDUSTRY',
                    value: 'mtd'
                }, {
                    name: 'GRAPH - YTD BY INDUSTRY',
                    value: 'ytd'
                }, {
                    name: 'GRAPH - MONTHLY HISTORICAL BY COMPANY',
                    value: 'summary'
                },
            ],
            report: {
                name: 'GRAPH - MONTHLY BY INDUSTRY',
                value: 'mtd'
            },
            listCompany: null,
            company: null,
            listPeriode: null,
            periode: null,
            listMonth: null,
            month: null,
            listBusiness: null,
            businessUnit: null,
            listPeriode2: null,
            periode2: null,
            listMonth2: null,
            month2: null,
            loading: false,
d.arizona's avatar
d.arizona committed
60 61 62 63 64 65
            tpat: null,
            companyRev: [],
            mbRev: [],
            mrRev: [],
            minRev: 0,
            maxRev: 0,
d.arizona's avatar
d.arizona committed
66
            intervalRev: 0,
d.arizona's avatar
d.arizona committed
67 68 69 70 71
            companyTPAT: [],
            mbTPAT: [],
            mrTPAT: [],
            minTPAT: 0,
            maxTPAT: 0,
d.arizona's avatar
d.arizona committed
72
            intervalTPAT: 0,
d.arizona's avatar
d.arizona committed
73 74 75 76 77
            companyEBITDA: [],
            mbEBITDA: [],
            mrEBITDA: [],
            minEBITDA: 0,
            maxEBITDA: 0,
d.arizona's avatar
d.arizona committed
78
            intervalEBITDA: 0,
d.arizona's avatar
d.arizona committed
79 80
            data: [],
            defaultMonth: [],
81 82 83 84 85
            defaultYear: [],
            revOptions: {},
            tpatOptions: {},
            ebitdaOptions: {},
            totalAssetsOptions: {}
d.arizona's avatar
d.arizona committed
86 87
        };
    }
d.arizona's avatar
d.arizona committed
88

d.arizona's avatar
d.arizona committed
89 90
    componentDidMount() {
        console.log(this.props.height)
d.arizona's avatar
d.arizona committed
91
        this.setState({ loading: true })
d.arizona's avatar
d.arizona committed
92 93
        this.getDetailUser()
    }
d.arizona's avatar
d.arizona committed
94

d.arizona's avatar
d.arizona committed
95 96 97 98 99 100 101 102 103 104
    getDetailUser() {
        let userId = localStorage.getItem(Constant.USER)
        api.create().getDetailUser(userId).then((response) => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        this.setState({ userCompany: response.data.data.company }, () => {
                            this.getCompanyActive()
                        })
                    }
d.arizona's avatar
d.arizona committed
105 106 107 108 109 110 111 112 113 114 115 116
                    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
117
                }
d.arizona's avatar
d.arizona committed
118 119
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
120
            }
d.arizona's avatar
d.arizona committed
121
        })
d.arizona's avatar
d.arizona committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
    }

    getCompanyActive() {
        api.create().getPerusahaanActive().then((response) => {
            // console.log(response);
            if (response.data) {
                if (response.data.status === 'success') {
                    let data = response.data.data
                    let comID = this.state.rawData ? this.state.rawData.company_id : 0
                    let companyData = data.map((item) => {
                        return {
                            company_id: item.company_id,
                            company_name: item.company_name,
                        }
                    })

                    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 = {
d.arizona's avatar
d.arizona committed
147
                        options: arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name)),
d.arizona's avatar
d.arizona committed
148 149
                        getOptionLabel: (option) => titleCase(option.company_name),
                    };
d.arizona's avatar
d.arizona committed
150

d.arizona's avatar
d.arizona committed
151 152
                    let index = arrayBaru.findIndex((val) => val.company_id == comID)
                    this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
d.arizona's avatar
d.arizona committed
153
                        this.getAllBusiness()
d.arizona's avatar
d.arizona committed
154 155 156
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
157
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
158 159 160 161 162 163 164 165 166 167 168 169 170
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null })
            }
        })
    }

d.arizona's avatar
d.arizona committed
171 172
    getAllBusiness() {
        api.create().getUnitBisnisActive().then((response) => {
d.arizona's avatar
d.arizona committed
173
            // console.log(response);
d.arizona's avatar
d.arizona committed
174 175 176 177 178 179 180 181 182 183 184
            if (response.data) {
                if (response.data.status === 'success') {
                    let data = response.data.data
                    console.log(data)
                    // let comID = this.state.rawData ? this.state.rawData.company_id : 0
                    let businessData = data.map((item) => {
                        return {
                            business_unit_id: item.business_unit_id,
                            business_unit_name: String(item.business_unit_name).toLocaleLowerCase(),
                        }
                    })
d.arizona's avatar
d.arizona committed
185
                    businessData.sort((a, b) => a.business_unit_name.localeCompare(b.business_unit_name))
d.arizona's avatar
d.arizona committed
186 187 188 189 190
                    let defaultProps = {
                        options: businessData,
                        getOptionLabel: (option) => titleCase(option.business_unit_name),
                    };
                    // let index = arrayBaru.findIndex((val) => val.company_id == comID)
d.arizona's avatar
d.arizona committed
191
                    this.setState({ listBusiness: defaultProps, businessUnit: businessData[0] }, () => {
d.arizona's avatar
d.arizona committed
192 193 194 195
                        this.getMonth()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
196
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null })
            }
        })
    }

    getMonth() {
        api.create().getMonthTransaction().then(response => {
            let dateNow = new Date()
            dateNow.setMonth(dateNow.getMonth() - 1);
            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
220
                    let index = data.findIndex((val) => val.month_name == month)
221
                    console.log(index);
d.arizona's avatar
d.arizona committed
222 223 224 225 226 227 228 229 230 231
                    let monthData = []
                    let defaultMonth = []
                    data.map((item, indexs) => {
                        if (indexs <= index + 1) {
                            monthData.push({
                                month_id: item.id,
                                month_value: String(item.month_name).substr(0, 3)
                            })
                        }
                        defaultMonth.push({
d.arizona's avatar
d.arizona committed
232 233
                            month_id: item.id,
                            month_value: String(item.month_name).substr(0, 3)
d.arizona's avatar
d.arizona committed
234
                        })
d.arizona's avatar
d.arizona committed
235 236 237 238 239
                    })
                    let defaultProps = {
                        options: monthData,
                        getOptionLabel: (option) => option.month_value,
                    };
d.arizona's avatar
d.arizona committed
240 241

                    console.log(monthData);
242
                    this.setState({ defaultMonth, listMonth: defaultProps, listMonth2: defaultProps, month: index == -1 ? monthData[0] : monthData[index], month2: index == -1 ? monthData[1] : monthData[index], }, () => {
d.arizona's avatar
d.arizona committed
243 244 245 246 247
                        console.log(this.state.month)
                        this.getPeriode()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
248
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
249 250 251 252 253 254 255 256 257
                            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
258 259 260 261 262 263 264 265 266 267 268 269
            }
        })
    }

    getPeriode() {
        api.create().getPeriodeTransaction().then(response => {
            let currentYear = new Date().getFullYear()
            // console.log(currentYear)
            if (response.data) {
                if (response.data.status === "success") {
                    let data = []
                    response.data.data.map((item) => {
d.arizona's avatar
d.arizona committed
270
                        // if (this.state.isApprover) {
d.arizona's avatar
d.arizona committed
271
                        if (item >= 2000 && item <= (Number(currentYear))) {
d.arizona's avatar
d.arizona committed
272
                            data.push(item)
d.arizona's avatar
d.arizona committed
273
                        }
d.arizona's avatar
d.arizona committed
274
                        // }
d.arizona's avatar
d.arizona committed
275 276 277 278 279 280 281 282 283 284
                    })
                    let periodeData = data.map((item) => {
                        return {
                            periode: item,
                        }
                    })
                    let defaultProps = {
                        options: periodeData,
                        getOptionLabel: (option) => option.periode,
                    };
d.arizona's avatar
d.arizona committed
285 286 287 288 289 290
                    // let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
                    let dateNow = new Date()
                    dateNow.setMonth(dateNow.getMonth() - 1);
                    let yearNow = dateNow.getFullYear()
                    let index = data.sort((a, b) => a - b).findIndex((val) => val == yearNow)
                    console.log(data)
d.arizona's avatar
d.arizona committed
291 292 293
                    // console.log(this.state.latestPeriode)
                    // console.log(periodeData)
                    // console.log(index)
d.arizona's avatar
d.arizona committed
294
                    this.setState({ listPeriode: defaultProps, listPeriode2: { ...defaultProps, options: [periodeData[index]] }, periode: index === -1 ? periodeData[0] : periodeData[index], periode2: periodeData[index] }, () => {
d.arizona's avatar
d.arizona committed
295
                        this.getDashboardFinancial()
d.arizona's avatar
d.arizona committed
296 297 298 299 300 301
                    })
                }
            }
        })
    }

d.arizona's avatar
d.arizona committed
302 303 304 305 306 307 308 309 310 311 312 313 314
    getOption() {
        let option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    crossStyle: {
                        color: '#999'
                    }
                }
            },
            toolbox: {
                feature: {
d.arizona's avatar
d.arizona committed
315 316 317 318
                    dataView: { show: true, readOnly: false },
                    magicType: { show: true, type: ['line', 'bar'] },
                    restore: { show: true },
                    saveAsImage: { show: true }
d.arizona's avatar
d.arizona committed
319 320 321 322 323 324 325 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
                }
            },
            legend: {
                data: ['蒸发量', '降水量', '平均温度']
            },
            xAxis: [
                {
                    type: 'category',
                    data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                    axisPointer: {
                        type: 'shadow'
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    name: '水量',
                    min: 0,
                    max: 250,
                    interval: 50,
                    axisLabel: {
                        formatter: '{value} ml'
                    }
                },
                {
                    type: 'value',
                    name: '温度',
                    min: 0,
                    max: 25,
                    interval: 5,
                    axisLabel: {
                        formatter: '{value} °C'
                    }
                }
            ],
            series: [
                {
                    name: '蒸发量',
                    type: 'bar',
                    data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
                },
                {
                    name: '降水量',
                    type: 'bar',
                    data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
                },
                {
                    name: '平均温度',
                    type: 'line',
                    yAxisIndex: 1,
                    data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
                }
            ]
        };

        return option
    }

d.arizona's avatar
d.arizona committed
378
    getDashboardFinancial() {
d.arizona's avatar
d.arizona committed
379
        let payload = {
d.arizona's avatar
d.arizona committed
380 381
            "report_type": this.state.report.value,
            "business_unit_id": this.state.businessUnit.business_unit_id,
d.arizona's avatar
d.arizona committed
382
            "periode": this.state.periode.periode,
d.arizona's avatar
d.arizona committed
383
            "months": this.state.month.month_id
d.arizona's avatar
d.arizona committed
384
        }
d.arizona's avatar
d.arizona committed
385 386
        if (this.state.report.value == 'summary') {
            payload = {
d.arizona's avatar
d.arizona committed
387
                ...payload,
d.arizona's avatar
d.arizona committed
388 389 390 391 392 393 394
                "company_id": this.state.company.company_id,
                "periode_from": this.state.periode.periode,
                "periode_to": this.state.periode2.periode,
                "month_from": this.state.month.month_id,
                "month_to": this.state.month2.month_id
            }
        }
d.arizona's avatar
d.arizona committed
395

d.arizona's avatar
d.arizona committed
396 397
        const handleName = (name) => {
            let newName = ''
d.arizona's avatar
d.arizona committed
398
            if (String(name).includes(':')) {
d.arizona's avatar
d.arizona committed
399 400 401
                let indexTidu = String(name).indexOf(':')
                let indexSpace = String(name).indexOf(' ')
                if (indexTidu > indexSpace) {
d.arizona's avatar
d.arizona committed
402
                    newName = String(name).substr(0, indexSpace)
d.arizona's avatar
d.arizona committed
403
                } else {
d.arizona's avatar
d.arizona committed
404
                    newName = String(name).substr(0, indexTidu)
d.arizona's avatar
d.arizona committed
405 406 407 408 409
                }
            } else {
                // if (String(name).includes('Consolidated')) {
                //     newName = `asd \n baba`
                // } else {
d.arizona's avatar
d.arizona committed
410
                let splitName = String(name).split(' ')
411
                // console.log(splitName)
d.arizona's avatar
d.arizona committed
412
                newName = name
d.arizona's avatar
d.arizona committed
413 414 415 416
                // }
            }
            return newName
        }
d.arizona's avatar
d.arizona committed
417 418 419
        api.create().getDashboardFinancial(payload).then((res) => {
            console.log(res)
            if (res.data) {
d.arizona's avatar
d.arizona committed
420
                let response = res.data.data.ytd != null ? res.data.data.ytd : (res.data.data.mtd != null ? res.data.data.mtd : res.data.data.summary)
d.arizona's avatar
d.arizona committed
421 422 423
                let revenue = []
                let totalAssets = []

d.arizona's avatar
d.arizona committed
424 425 426 427 428
                let companyRev = []
                let mbRev = []
                let mrRev = []
                let maxRev = response.revenue.vertical_pointing[0]
                let minRev = response.revenue.vertical_pointing[1]
d.arizona's avatar
d.arizona committed
429
                let intervalRev = Number(response.revenue.interval)
d.arizona's avatar
d.arizona committed
430 431 432 433 434 435

                let companyTPAT = []
                let mbTPAT = []
                let mrTPAT = []
                let maxTPAT = response.tpat.vertical_pointing[0]
                let minTPAT = response.tpat.vertical_pointing[1]
d.arizona's avatar
d.arizona committed
436
                let intervalTPAT = Number(response.tpat.interval)
d.arizona's avatar
d.arizona committed
437 438 439 440 441 442

                let companyEBITDA = []
                let mbEBITDA = []
                let mrEBITDA = []
                let maxEBITDA = response.ebitda.vertical_pointing[0]
                let minEBITDA = response.ebitda.vertical_pointing[1]
d.arizona's avatar
d.arizona committed
443
                let intervalEBITDA = Number(response.ebitda.interval)
d.arizona's avatar
d.arizona committed
444

445 446 447 448 449 450 451 452 453
                let companyTA = []
                let mbTA = []
                let maxTA = 0
                let minTA = 0
                let intervalTA = 0
                if (response.total_asset != undefined) {
                    intervalTA = Number(response.total_asset.interval)
                    maxTA = response.total_asset.vertical_pointing[0]
                    minTA = response.total_asset.vertical_pointing[1]
d.arizona's avatar
d.arizona committed
454 455
                }

456 457
                let respRev = this.state.report.value == 'summary' ? response.revenue.nodes.sort((a, b) => a.index - b.index) : response.revenue.nodes.sort((a, b) => a.company.localeCompare(b.company))
                respRev.map((item, index) => {
d.arizona's avatar
d.arizona committed
458
                    if (this.state.report.value == 'summary') {
d.arizona's avatar
d.arizona committed
459
                        companyRev.push(item.periode)
460
                        mbRev.push(Number(item.value))
d.arizona's avatar
d.arizona committed
461
                        mrRev.push(Number(item.gp_margin).toFixed(1))
d.arizona's avatar
d.arizona committed
462 463
                    } else {
                        companyRev.push(handleName(item.company))
464 465
                        mbRev.push(Number(item.value_mb))
                        mrRev.push(Number(item.value_mr))
d.arizona's avatar
d.arizona committed
466
                    }
d.arizona's avatar
d.arizona committed
467

d.arizona's avatar
d.arizona committed
468 469
                })

470 471 472 473 474 475 476 477 478 479 480 481 482 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
                let revOptions = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            crossStyle: {
                                color: '#999'
                            }
                        }
                    },
                    toolbox: {
                        feature: {
                            // restore: { show: true },
                            // saveAsImage: { show: true }
                        }
                    },
                    legend: {
                        data: ['MB', 'MR', 'Revenue', 'GP Margin']
                    },
                    grid: {
                        bottom: 125,
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: companyRev,
                            axisPointer: {
                                type: 'shadow'
                            },
                            axisLabel: {
                                interval: 0,
                                rotate: 30,
                                textStyle: {
                                    baseline: "top",
                                    color: "#333",
                                    fontSize: 13,
                                }
                            }
                        }
                    ],
                    yAxis: this.state.report.value != 'summary' ?
                        [
                            {
                                type: 'value',
d.arizona's avatar
d.arizona committed
514
                                name: '(Rp mn)',
515
                                min: minRev,
d.arizona's avatar
d.arizona committed
516 517
                                // max: maxRev,
                                // interval: intervalRev,
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
                                axisLabel: {
                                    interval: 0,
                                    // rotate: 10,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                        // fontWeight: "bold"
                                    }
                                }
                            }
                        ] :
                        [
                            {
                                type: 'value',
d.arizona's avatar
d.arizona committed
533
                                name: '(Rp mn)',
534
                                min: minRev,
d.arizona's avatar
d.arizona committed
535 536
                                // max: maxRev,
                                // interval: intervalRev,
537 538 539 540 541 542 543 544 545 546 547 548 549 550
                                axisLabel: {
                                    interval: 0,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                    }
                                }
                            },
                            {
                                type: 'value',
                                name: '(%)',
                                min: 0,
                                max: 100,
d.arizona's avatar
d.arizona committed
551
                                // interval: 20,
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
                                axisLabel: {
                                    formatter: '{value}%',
                                    interval: 0,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                    }
                                }
                            }
                        ]
                    ,
                    series: this.state.report.value != 'summary' ?
                        [
                            {
                                name: 'MB',
                                type: 'bar',
                                data: mbRev
                            },
                            {
                                name: 'MR',
                                type: 'bar',
                                data: mrRev
                            }
                        ] :
                        [
                            {
                                name: 'Revenue',
                                type: 'bar',
                                data: mbRev
                            },
                            {
                                name: 'GP Margin',
                                type: 'line',
                                yAxisIndex: 1,
                                data: mrRev
                            }
                        ]
                }

                let respTpat = this.state.report.value == 'summary' ? response.tpat.nodes.sort((a, b) => a.index - b.index) : response.tpat.nodes.sort((a, b) => a.company.localeCompare(b.company))
                respTpat.map((item, index) => {
d.arizona's avatar
d.arizona committed
594
                    if (this.state.report.value == 'summary') {
d.arizona's avatar
d.arizona committed
595
                        companyTPAT.push(item.periode)
596
                        mbTPAT.push(Number(item.value))
d.arizona's avatar
d.arizona committed
597
                        mrTPAT.push(Number(item.gp_margin).toFixed(1))
d.arizona's avatar
d.arizona committed
598
                    } else {
d.arizona's avatar
d.arizona committed
599
                        companyTPAT.push(handleName(item.company))
600 601
                        mbTPAT.push(Number(item.value_mb))
                        mrTPAT.push(Number(item.value_mr))
d.arizona's avatar
d.arizona committed
602
                    }
d.arizona's avatar
d.arizona committed
603 604
                })

605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
                let tpatOptions = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            crossStyle: {
                                color: '#999'
                            }
                        }
                    },
                    toolbox: {
                        feature: {
                            // restore: { show: true },
                            // saveAsImage: { show: true }
                        }
                    },
                    legend: {
                        data: ['MB', 'MR', 'TPAT', 'TPAT Margin']
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: companyTPAT,
                            axisPointer: {
                                type: 'shadow'
                            },
                            axisLabel: {
                                interval: 0,
                                rotate: 30,
                                textStyle: {
                                    baseline: "top",
                                    color: "#333",
                                    fontSize: 13,
                                }
                            }
                        }
                    ],
                    yAxis: this.state.report.value != 'summary' ?
                        [
                            {
                                type: 'value',
d.arizona's avatar
d.arizona committed
646
                                name: '(Rp mn)',
647
                                min: minTPAT,
d.arizona's avatar
d.arizona committed
648 649
                                // max: maxTPAT,
                                // interval: intervalTPAT
650 651 652 653 654
                            }
                        ] :
                        [
                            {
                                type: 'value',
d.arizona's avatar
d.arizona committed
655
                                name: '(Rp mn)',
656
                                min: minTPAT,
d.arizona's avatar
d.arizona committed
657 658
                                // max: maxTPAT,
                                // interval: intervalTPAT,
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
                                axisLabel: {
                                    interval: 0,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                    }
                                }
                            },
                            {
                                type: 'value',
                                name: '(%)',
                                min: 0,
                                max: 100,
                                interval: 20,
                                axisLabel: {
                                    formatter: '{value}%',
                                    interval: 0,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                    }
                                }
                            }
                        ]
                    ,
                    grid: {
                        bottom: 125,
                    },
                    series: this.state.report.value != 'summary' ?
                        [
                            {
                                name: 'MB',
                                type: 'bar',
                                data: mbTPAT
                            },
                            {
                                name: 'MR',
                                type: 'bar',
                                data: mrTPAT
                            }
                        ] :
                        [
                            {
                                name: 'TPAT',
                                type: 'bar',
                                data: mbTPAT
                            },
                            {
                                name: 'TPAT Margin',
                                type: 'line',
                                yAxisIndex: 1,
                                data: mrTPAT
                            }
                        ]
                }

                let respEbit = this.state.report.value == 'summary' ? response.ebitda.nodes.sort((a, b) => a.index - b.index) : response.ebitda.nodes.sort((a, b) => a.company.localeCompare(b.company))
                respEbit.map((item, index) => {
d.arizona's avatar
d.arizona committed
719
                    if (this.state.report.value == 'summary') {
d.arizona's avatar
d.arizona committed
720
                        companyEBITDA.push(item.periode)
721
                        mbEBITDA.push(Number(item.value))
d.arizona's avatar
d.arizona committed
722
                        mrEBITDA.push(Number(item.gp_margin).toFixed(1))
d.arizona's avatar
d.arizona committed
723
                    } else {
d.arizona's avatar
d.arizona committed
724
                        companyEBITDA.push(handleName(item.company))
725 726
                        mbEBITDA.push(Number(item.value_mb))
                        mrEBITDA.push(Number(item.value_mr))
d.arizona's avatar
d.arizona committed
727
                    }
d.arizona's avatar
d.arizona committed
728 729
                })

730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
                let ebitdaOptions = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            crossStyle: {
                                color: '#999'
                            }
                        }
                    },
                    toolbox: {
                        feature: {
                            // restore: { show: true },
                            // saveAsImage: { show: true }
                        }
                    },
                    legend: {
                        data: ['MB', 'MR', 'EBITDA', 'EBITDA Margin']
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: companyEBITDA,
                            axisPointer: {
                                type: 'shadow'
                            },
                            axisLabel: {
                                interval: 0,
                                rotate: 30,
                                textStyle: {
                                    baseline: "top",
                                    color: "#333",
                                    fontSize: 13,
                                }
                            }
                        }
                    ],
                    yAxis: this.state.report.value != 'summary' ?
                        [
                            {
                                type: 'value',
d.arizona's avatar
d.arizona committed
771
                                name: '(Rp mn)',
772
                                min: minEBITDA,
d.arizona's avatar
d.arizona committed
773 774
                                // max: maxEBITDA,
                                // interval: intervalEBITDA,
775 776 777 778 779 780 781 782 783 784 785 786 787
                                axisLabel: {
                                    interval: 0,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                    }
                                }
                            }
                        ] :
                        [
                            {
                                type: 'value',
d.arizona's avatar
d.arizona committed
788
                                name: '(Rp mn)',
789
                                min: minEBITDA,
d.arizona's avatar
d.arizona committed
790 791
                                // max: maxEBITDA,
                                // interval: intervalEBITDA,
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849
                                axisLabel: {
                                    interval: 0,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                    }
                                }
                            },
                            {
                                type: 'value',
                                name: '(%)',
                                min: 0,
                                max: 100,
                                interval: 20,
                                axisLabel: {
                                    formatter: '{value}%',
                                    interval: 0,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                    }
                                }
                            }
                        ]
                    ,
                    grid: {
                        bottom: 125,
                    },
                    series: this.state.report.value != 'summary' ?
                        [
                            {
                                name: 'MB',
                                type: 'bar',
                                data: mbEBITDA
                            },
                            {
                                name: 'MR',
                                type: 'bar',
                                data: mrEBITDA
                            }
                        ] :
                        [
                            {
                                name: 'EBITDA',
                                type: 'bar',
                                data: mbEBITDA
                            },
                            {
                                name: 'EBITDA Margin',
                                type: 'line',
                                yAxisIndex: 1,
                                data: mrEBITDA
                            }
                        ]
                }

d.arizona's avatar
d.arizona committed
850
                if (this.state.report.value == 'summary') {
851 852 853
                    response.total_asset.nodes.sort((a, b) => a.index - b.index).map((item, index) => {
                        companyTA.push(item.periode)
                        mbTA.push(item.value)
d.arizona's avatar
d.arizona committed
854
                    })
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899

                    let totalAssetsOptions = {
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                crossStyle: {
                                    color: '#999'
                                }
                            }
                        },
                        toolbox: {
                            feature: {
                                // restore: { show: true },
                                // saveAsImage: { show: true }
                            }
                        },
                        legend: {
                            data: ['MB']
                        },
                        grid: {
                            bottom: 125,
                        },
                        xAxis: [
                            {
                                type: 'category',
                                data: companyTA,
                                axisPointer: {
                                    type: 'shadow'
                                },
                                axisLabel: {
                                    interval: 0,
                                    rotate: 30,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 13,
                                    }
                                }
                            }
                        ],
                        yAxis:
                            [
                                {
                                    type: 'value',
d.arizona's avatar
d.arizona committed
900
                                    name: '(Rp mn)',
901
                                    min: minTA,
d.arizona's avatar
d.arizona committed
902 903
                                    // max: maxTA,
                                    // interval: intervalTA
904 905 906 907 908 909 910 911 912 913 914 915 916 917
                                }
                            ]
                        ,
                        series:
                            [
                                {
                                    name: 'MB',
                                    type: 'bar',
                                    data: mbTA
                                }
                            ]
                    }

                    this.setState({ totalAssetsOptions })
d.arizona's avatar
d.arizona committed
918
                }
919 920 921 922 923 924


                this.setState({ revOptions, tpatOptions, ebitdaOptions }, () => {
                    setTimeout(() => {
                        this.setState({ loading: false })
                    }, 300);
d.arizona's avatar
d.arizona committed
925
                })
d.arizona's avatar
d.arizona committed
926 927 928
            }
        })
    }
d.arizona's avatar
d.arizona committed
929

d.arizona's avatar
d.arizona committed
930 931 932 933 934 935 936 937 938 939 940 941 942 943
    render() {
        const { data: chartData } = this.state;
        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>
        );
        const CustomTick = tick => {
            const theme = useTheme()
d.arizona's avatar
d.arizona committed
944

d.arizona's avatar
d.arizona committed
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
            return (
                <g transform={`translate(${tick.x},${tick.y + 22})`}>
                    {/* <rect x={-14} y={-6} rx={3} ry={3} width={28} height={24} fill="rgba(0, 0, 0, .05)" />
                    <rect x={-12} y={-12} rx={2} ry={2} width={24} height={24} fill="rgb(232, 193, 160)" />
                    <line stroke="rgb(232, 193, 160)" strokeWidth={1.5} y1={-22} y2={-12} /> */}
                    <text
                        lengthAdjust
                        fontSizeAdjust
                        textAnchor="middle"
                        dominantBaseline="middle"
                        style={{
                            ...theme.axis.ticks.text,
                            fill: '#333',
                            fontSize: 11,
                            // textAlign: 'justify',
                        }}
                    >
                        {tick.value}
                    </text>
                </g>
            )
        }
        return (
            <div style={{ flex: 1, backgroundColor: '#f8f8f8' }} ref={this.myRef}>
969
                {/* {this.state.loading && loadingComponent} */}
d.arizona's avatar
d.arizona committed
970 971 972 973 974 975 976 977 978 979 980 981 982
                <div>
                    <div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                        <Typography style={{ fontSize: '16px', color: 'white' }}>Dashboard Financial</Typography>
                    </div>
                    <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                        <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                            {this.state.messageAlert}
                        </Alert>
                    </Snackbar>
                    <div style={{ padding: 20, width: '100%' }}>
                        <Paper style={{ paddingTop: 10, minHeight: this.props.height, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>FINANCIAL SUMMARY OF TRIPUTRA GROUP</Typography>
d.arizona's avatar
d.arizona committed
983
                            </div>
d.arizona's avatar
d.arizona committed
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
                            <div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
                                <div style={{ marginTop: 15 }}>
                                    <Autocomplete
                                        options={this.state.listReportType}
                                        getOptionLabel={(option) => titleCase(option.name)}
                                        id="typereport"
                                        onChange={(event, newInputValue) => this.setState({ report: newInputValue, loading: true, previewTable: false }, () => {
                                            this.getDashboardFinancial()
                                        })}
                                        disableClearable
                                        style={{ width: 250 }}
                                        renderInput={(params) => <TextField {...params} label="Report Type" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.report}
                                    />
                                </div>
d.arizona's avatar
d.arizona committed
999
                                <div style={{ display: 'flex', marginTop: 10 }}>
d.arizona's avatar
d.arizona committed
1000 1001 1002 1003
                                    <Autocomplete
                                        {...this.state.listMonth}
                                        id="month"
                                        onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
                                            let indexMonth1 = this.state.listMonth.options.findIndex((val) => val.month_value == newInputValue.month_value)
                                            let listMonth2 = []
                                            this.state.listMonth.options.map((item, index) => {
                                                if (index >= indexMonth1) {
                                                    listMonth2.push(item)
                                                }
                                            })
                                            this.setState({ listMonth2: Number(this.state.periode.periode) < Number(this.state.periode2.periode) ? this.state.listMonth2 : { ...this.state.listMonth2, options: listMonth2, month2: listMonth2[0] } }, () => {
                                                this.setState({ month2: Number(this.state.periode.periode) < Number(this.state.periode2.periode) ? this.state.month2 : this.state.listMonth2.options[0] })
                                            })
d.arizona's avatar
d.arizona committed
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024
                                            this.getDashboardFinancial()
                                        })}
                                        disableClearable
                                        style={{ minWidth: 250, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.month}
                                    />
                                    <Autocomplete
                                        {...this.state.listPeriode}
                                        id="periode"
                                        onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
                                            let indexPeriode1 = this.state.listPeriode.options.findIndex((val) => val.periode == newInputValue.periode)
                                            let listPeriode2 = []
                                            let listMonth = []
                                            let listMonth2 = this.state.listMonth2.options
                                            let dateNow = new Date()
                                            let dateNow2 = new Date()
                                            let yearNow = dateNow.getFullYear()
                                            dateNow2.setMonth(dateNow2.getMonth() - 1);
                                            let month = format(dateNow2, 'MMMM')
                                            this.state.listPeriode.options.map((item, index) => {
                                                if (index >= indexPeriode1) {
                                                    listPeriode2.push(item)
                                                }
                                            })

                                            let data = this.state.defaultMonth
                                            let index = data.findIndex((val) => val.month_value == String(month).substr(0, 3))
                                            let monthData = []
                                            let monthData2 = []

                                            if (Number(newInputValue.periode) < Number(yearNow)) {
                                                listMonth = this.state.defaultMonth
                                                data.map((item, indexs) => {
                                                    if (indexs <= index + 1) {
                                                        monthData2.push({
                                                            month_id: item.month_id,
                                                            month_value: String(item.month_value).substr(0, 3)
                                                        })
                                                    }
                                                })
                                                listMonth2 = monthData2
                                            } else {
                                                data.map((item, indexs) => {
                                                    if (indexs <= index + 1) {
                                                        monthData.push({
                                                            month_id: item.month_id,
                                                            month_value: String(item.month_value).substr(0, 3)
                                                        })
                                                    }
                                                })
                                                listMonth = monthData
                                            }
                                            this.setState({ listPeriode2: { ...this.state.listPeriode2, options: listPeriode2, periode2: listPeriode2[0], } }, () => {
                                                this.setState({
                                                    periode2: Number(this.state.periode.periode) < Number(this.state.periode2.periode) ? this.state.periode2 : this.state.listPeriode2.options[0],
                                                    listMonth: { ...this.state.listMonth, options: listMonth },
                                                    listMonth2: { ...this.state.listMonth2, options: listMonth2 },
                                                    month: Number(newInputValue.periode) < Number(this.state.periode.periode) ? this.state.month : listMonth[0]
                                                }, () => {
                                                    this.getDashboardFinancial()
                                                })
                                            })
d.arizona's avatar
d.arizona committed
1077 1078 1079 1080 1081 1082
                                        })}
                                        disableClearable
                                        style={{ width: 250 }}
                                        renderInput={(params) => <TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.periode}
                                    />
d.arizona's avatar
d.arizona committed
1083
                                    {this.state.report.value == 'summary' && <Typography style={{ fontSize: '16px', color: 'black', alignSelf: 'center', marginLeft: 25, marginRight: 25, paddingTop: 25 }}>To</Typography>}
d.arizona's avatar
d.arizona committed
1084
                                    {this.state.report.value == 'summary' && <Autocomplete
d.arizona's avatar
d.arizona committed
1085
                                        {...this.state.listMonth2}
d.arizona's avatar
d.arizona committed
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095
                                        id="month"
                                        onChange={(event, newInputValue) => this.setState({ month2: newInputValue, loading: true }, () => {
                                            this.getDashboardFinancial()
                                        })}
                                        disableClearable
                                        style={{ minWidth: 250, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.month2}
                                    />}
                                    {this.state.report.value == 'summary' && <Autocomplete
d.arizona's avatar
d.arizona committed
1096
                                        {...this.state.listPeriode2}
d.arizona's avatar
d.arizona committed
1097 1098
                                        id="periode"
                                        onChange={(event, newInputValue) => this.setState({ periode2: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117
                                            let dateNow = new Date()
                                            let yearNow = dateNow.getFullYear()
                                            let data = this.state.defaultMonth
                                            let monthData2 = []
                                            let dateNow2 = new Date()
                                            dateNow2.setMonth(dateNow2.getMonth() - 1);
                                            let month = format(dateNow2, 'MMMM')
                                            if (Number(this.state.periode2.periode) < Number(yearNow)) {
                                                if (Number(this.state.periode2.periode) == Number(this.state.periode.periode)) {
                                                    let index = data.findIndex((val) => val.month_value == this.state.month.month_value)
                                                    data.map((item, indexs) => {
                                                        if (indexs >= index) {
                                                            monthData2.push({
                                                                month_id: item.month_id,
                                                                month_value: String(item.month_value).substr(0, 3)
                                                            })
                                                        }
                                                    })
                                                    let listMonth2 = monthData2
1118
                                                    this.setState({ month2: listMonth2[0], listMonth2: { ...this.state.listMonth2, options: listMonth2 } }, () => {
d.arizona's avatar
d.arizona committed
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142
                                                        this.getDashboardFinancial()
                                                    })
                                                } else {
                                                    this.setState({ listMonth2: { ...this.state.listMonth2, options: this.state.defaultMonth } }, () => {
                                                        this.getDashboardFinancial()
                                                    })
                                                }
                                            } else {
                                                let index = data.findIndex((val) => val.month_value == String(month).substr(0, 3))
                                                data.map((item, indexs) => {
                                                    if (indexs <= index + 1) {
                                                        monthData2.push({
                                                            month_id: item.month_id,
                                                            month_value: String(item.month_value).substr(0, 3)
                                                        })
                                                    }
                                                })
                                                let listMonth2 = monthData2
                                                this.setState({ listMonth2: { ...this.state.listMonth2, options: listMonth2 } }, () => {
                                                    this.setState({ month2: this.state.listMonth2.options[0] }, () => {
                                                        this.getDashboardFinancial()
                                                    })
                                                })
                                            }
d.arizona's avatar
d.arizona committed
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196
                                        })}
                                        disableClearable
                                        style={{ width: 250 }}
                                        renderInput={(params) => <TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.periode2}
                                    />}
                                </div>
                                {/* {this.state.report.value == 'summary' && <div style={{ display: 'flex', marginTop: 10}}>
                                    
                                </div>} */}
                                {this.state.report.value != 'summary' && <div style={{ marginTop: 10 }}>
                                    <Autocomplete
                                        {...this.state.listBusiness}
                                        id="company"
                                        disabled={this.state.intent === 'Home' ? true : false}
                                        onChange={(event, newInputValue) => this.setState({ businessUnit: newInputValue, loading: true, previewTable: false }, () => {
                                            this.getDashboardFinancial()
                                        })}
                                        disableClearable
                                        style={{ width: 250 }}
                                        renderInput={(params) => <TextField {...params} label="Business Unit" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.businessUnit}
                                    />
                                </div>}
                                {this.state.report.value == 'summary' && <div style={{ marginTop: 10 }}>
                                    <Autocomplete
                                        {...this.state.listCompany}
                                        id="company"
                                        disabled={this.state.intent === 'Home' ? true : false}
                                        onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true, previewTable: false }, () => {
                                            this.getDashboardFinancial()
                                        })}
                                        disableClearable
                                        style={{ width: 250 }}
                                        renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.company}
                                    />
                                </div>}
                                {/* <div style={{ marginTop: 15 }}>
                                    <Autocomplete
                                        {...this.state.listPeriode}
                                        id="periode"
                                        onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true, previewTable: false }, () => {
                                            this.getReportType()
                                        })}
                                        disabled={this.state.intent === 'Home' ? true : false}
                                        disableClearable
                                        style={{ width: 250 }}
                                        renderInput={(params) =>
                                            <TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }}
                                            />}
                                        value={this.state.periode}
                                    />
                                </div> */}
d.arizona's avatar
d.arizona committed
1197
                            </div>
d.arizona's avatar
d.arizona committed
1198 1199
                            <Divider style={{ marginTop: 15 }} />
                            <div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
d.arizona's avatar
d.arizona committed
1200
                                <div>
d.arizona's avatar
d.arizona committed
1201
                                    <Typography style={{ fontSize: '16px', color: 'black' }}>{this.state.report.value == 'mtd' ? 'Graph MTD by Industry' : this.state.report.value == 'ytd' ? 'Graph YTD by Industry' : 'Graph Monthly Historical by Company'}</Typography>
d.arizona's avatar
d.arizona committed
1202 1203 1204 1205
                                    {this.state.month != null && this.state.periode != null && <Typography style={{ fontSize: '16px', color: 'black' }}>Period : {String(this.state.month.month_value).toLocaleUpperCase()} {this.state.periode.periode}</Typography>}
                                    <Typography style={{ fontSize: '16px', color: 'black' }}>in IDR mn</Typography>
                                </div>

d.arizona's avatar
d.arizona committed
1206 1207
                                <div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 25, paddingBottom: 50 }}>
                                    {this.state.businessUnit != null && <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`Revenue ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? String(this.state.report.value).toLocaleUpperCase() : ''} - ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? titleCase(this.state.businessUnit.business_unit_name) : this.state.company.company_name}`}</Typography>}
1208 1209
                                    {<ReactECharts
                                        showLoading={this.state.loading}
d.arizona's avatar
d.arizona committed
1210
                                        style={{ height: 500, width: '100%', marginTop: 20 }}
1211
                                        option={this.state.revOptions}
d.arizona's avatar
d.arizona committed
1212 1213 1214
                                    />}
                                </div>

d.arizona's avatar
d.arizona committed
1215 1216
                                <div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 50, paddingBottom: 50 }}>
                                    {this.state.businessUnit != null && <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`TPAT ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? String(this.state.report.value).toLocaleUpperCase() : ''} - ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? titleCase(this.state.businessUnit.business_unit_name) : this.state.company.company_name}`}</Typography>}
1217 1218
                                    {<ReactECharts
                                        showLoading={this.state.loading}
d.arizona's avatar
d.arizona committed
1219
                                        style={{ height: 500, width: '100%', marginTop: 20 }}
1220
                                        option={this.state.tpatOptions}
d.arizona's avatar
d.arizona committed
1221 1222 1223
                                    />}
                                </div>

d.arizona's avatar
d.arizona committed
1224 1225
                                <div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 50, paddingBottom: 50 }}>
                                    {this.state.businessUnit != null && <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`EBITDA ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? String(this.state.report.value).toLocaleUpperCase() : ''} - ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? titleCase(this.state.businessUnit.business_unit_name) : this.state.company.company_name}`}</Typography>}
1226 1227 1228
                                    {<ReactECharts
                                        lazyUpdate={true}
                                        showLoading={this.state.loading}
d.arizona's avatar
d.arizona committed
1229
                                        style={{ height: 500, width: '100%', marginTop: 20 }}
1230
                                        option={this.state.ebitdaOptions}
d.arizona's avatar
d.arizona committed
1231 1232 1233
                                    />}
                                </div>

d.arizona's avatar
d.arizona committed
1234
                                {this.state.report.value == 'summary' && <div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 50, paddingBottom: 50 }}>
d.arizona's avatar
d.arizona committed
1235
                                    <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`Total Assets - ${this.state.company.company_name}`}</Typography>
1236
                                    {<ReactECharts
d.arizona's avatar
d.arizona committed
1237
                                        style={{ height: 500, width: '100%', marginTop: 20 }}
1238 1239
                                        showLoading={this.state.loading}
                                        option={this.state.totalAssetsOptions}
d.arizona's avatar
d.arizona committed
1240 1241
                                    />}
                                </div>}
d.arizona's avatar
d.arizona committed
1242 1243 1244
                            </div>
                        </Paper>
                    </div>
d.arizona's avatar
d.arizona committed
1245 1246
                </div>
            </div>
d.arizona's avatar
d.arizona committed
1247 1248
        );
    }
d.arizona's avatar
d.arizona committed
1249
}