DashboardFinancial.js 61.4 KB
Newer Older
d.arizona's avatar
d.arizona committed
1 2 3
import * as React from 'react';
import Paper from '@material-ui/core/Paper';
import { ResponsiveBar } from '@nivo/bar'
d.arizona's avatar
d.arizona committed
4 5
import { useTheme } from '@nivo/core'
import { Divider, Snackbar, TextField, Typography, withStyles } from '@material-ui/core';
d.arizona's avatar
d.arizona committed
6 7 8 9 10
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
11 12
import { format } from 'date-fns';
import { PropagateLoader } from 'react-spinners';
d.arizona's avatar
d.arizona committed
13
import ReactECharts from 'echarts-for-react';
d.arizona's avatar
d.arizona committed
14
import { FormatListNumberedRtlOutlined } from '@material-ui/icons';
d.arizona's avatar
d.arizona committed
15 16 17 18 19 20 21 22 23 24

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
25

d.arizona's avatar
d.arizona committed
26 27 28
// )

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

d.arizona's avatar
d.arizona committed
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 60 61
        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
62 63 64 65 66 67
            tpat: null,
            companyRev: [],
            mbRev: [],
            mrRev: [],
            minRev: 0,
            maxRev: 0,
d.arizona's avatar
d.arizona committed
68
            intervalRev: 0,
d.arizona's avatar
d.arizona committed
69 70 71 72 73
            companyTPAT: [],
            mbTPAT: [],
            mrTPAT: [],
            minTPAT: 0,
            maxTPAT: 0,
d.arizona's avatar
d.arizona committed
74
            intervalTPAT: 0,
d.arizona's avatar
d.arizona committed
75 76 77 78 79
            companyEBITDA: [],
            mbEBITDA: [],
            mrEBITDA: [],
            minEBITDA: 0,
            maxEBITDA: 0,
d.arizona's avatar
d.arizona committed
80
            intervalEBITDA: 0,
d.arizona's avatar
d.arizona committed
81 82
            data: [],
            defaultMonth: [],
83 84 85 86 87
            defaultYear: [],
            revOptions: {},
            tpatOptions: {},
            ebitdaOptions: {},
            totalAssetsOptions: {}
d.arizona's avatar
d.arizona committed
88 89
        };
    }
d.arizona's avatar
d.arizona committed
90

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

d.arizona's avatar
d.arizona committed
97 98 99 100 101 102 103 104 105 106
    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
107 108 109 110 111 112 113 114 115 116 117 118
                    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
119
                }
d.arizona's avatar
d.arizona committed
120 121
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
122
            }
d.arizona's avatar
d.arizona committed
123
        })
d.arizona's avatar
d.arizona committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
    }

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

d.arizona's avatar
d.arizona committed
153 154
                    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
155
                        this.getAllBusiness()
d.arizona's avatar
d.arizona committed
156 157 158
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
159
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
160 161 162 163 164 165 166 167 168 169 170 171 172
                            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
173 174
    getAllBusiness() {
        api.create().getUnitBisnisActive().then((response) => {
d.arizona's avatar
d.arizona committed
175
            // console.log(response);
d.arizona's avatar
d.arizona committed
176 177 178 179 180 181 182 183 184 185 186
            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
187
                    businessData.sort((a, b) => a.business_unit_name.localeCompare(b.business_unit_name))
d.arizona's avatar
d.arizona committed
188 189 190 191 192
                    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
193
                    this.setState({ listBusiness: defaultProps, businessUnit: businessData[0] }, () => {
d.arizona's avatar
d.arizona committed
194 195 196 197
                        this.getMonth()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
198
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
                            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
222 223 224 225 226 227 228 229 230 231 232
                    let index = data.findIndex((val) => val.month_name == month)
                    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
233 234
                            month_id: item.id,
                            month_value: String(item.month_name).substr(0, 3)
d.arizona's avatar
d.arizona committed
235
                        })
d.arizona's avatar
d.arizona committed
236 237 238 239 240
                    })
                    let defaultProps = {
                        options: monthData,
                        getOptionLabel: (option) => option.month_value,
                    };
d.arizona's avatar
d.arizona committed
241 242 243

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

    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
271
                        // if (this.state.isApprover) {
d.arizona's avatar
d.arizona committed
272
                        if (item >= 2000 && item <= (Number(currentYear))) {
d.arizona's avatar
d.arizona committed
273
                            data.push(item)
d.arizona's avatar
d.arizona committed
274
                        }
d.arizona's avatar
d.arizona committed
275
                        // }
d.arizona's avatar
d.arizona committed
276 277 278 279 280 281 282 283 284 285
                    })
                    let periodeData = data.map((item) => {
                        return {
                            periode: item,
                        }
                    })
                    let defaultProps = {
                        options: periodeData,
                        getOptionLabel: (option) => option.periode,
                    };
d.arizona's avatar
d.arizona committed
286 287 288 289 290 291
                    // 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
292 293 294
                    // console.log(this.state.latestPeriode)
                    // console.log(periodeData)
                    // console.log(index)
d.arizona's avatar
d.arizona committed
295
                    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
296
                        this.getDashboardFinancial()
d.arizona's avatar
d.arizona committed
297 298 299 300 301 302
                    })
                }
            }
        })
    }

d.arizona's avatar
d.arizona committed
303 304 305 306 307 308 309 310 311 312 313 314 315
    getOption() {
        let option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    crossStyle: {
                        color: '#999'
                    }
                }
            },
            toolbox: {
                feature: {
d.arizona's avatar
d.arizona committed
316 317 318 319
                    dataView: { show: true, readOnly: false },
                    magicType: { show: true, type: ['line', 'bar'] },
                    restore: { show: true },
                    saveAsImage: { show: true }
d.arizona's avatar
d.arizona committed
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 378
                }
            },
            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
379
    getDashboardFinancial() {
d.arizona's avatar
d.arizona committed
380
        let payload = {
d.arizona's avatar
d.arizona committed
381 382
            "report_type": this.state.report.value,
            "business_unit_id": this.state.businessUnit.business_unit_id,
d.arizona's avatar
d.arizona committed
383
            "periode": this.state.periode.periode,
d.arizona's avatar
d.arizona committed
384
            "months": this.state.month.month_id
d.arizona's avatar
d.arizona committed
385
        }
d.arizona's avatar
d.arizona committed
386 387
        if (this.state.report.value == 'summary') {
            payload = {
d.arizona's avatar
d.arizona committed
388
                ...payload,
d.arizona's avatar
d.arizona committed
389 390 391 392 393 394 395
                "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
396

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

d.arizona's avatar
d.arizona committed
425 426 427 428 429
                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
430
                let intervalRev = Number(response.revenue.interval)
d.arizona's avatar
d.arizona committed
431 432 433 434 435 436

                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
437
                let intervalTPAT = Number(response.tpat.interval)
d.arizona's avatar
d.arizona committed
438 439 440 441 442 443

                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
444
                let intervalEBITDA = Number(response.ebitda.interval)
d.arizona's avatar
d.arizona committed
445

446 447 448 449 450 451 452 453 454
                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
455 456
                }

457 458
                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
459
                    if (this.state.report.value == 'summary') {
d.arizona's avatar
d.arizona committed
460
                        companyRev.push(item.periode)
461
                        mbRev.push(Number(item.value))
d.arizona's avatar
d.arizona committed
462
                        mrRev.push(Number(item.gp_margin).toFixed(1))
d.arizona's avatar
d.arizona committed
463 464
                    } else {
                        companyRev.push(handleName(item.company))
465 466
                        mbRev.push(Number(item.value_mb))
                        mrRev.push(Number(item.value_mr))
d.arizona's avatar
d.arizona committed
467
                    }
d.arizona's avatar
d.arizona committed
468

d.arizona's avatar
d.arizona committed
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 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 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 594
                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',
                                name: '(Rp bn)',
                                min: minRev,
                                max: maxRev,
                                interval: intervalRev,
                                axisLabel: {
                                    interval: 0,
                                    // rotate: 10,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                        // fontWeight: "bold"
                                    }
                                }
                            }
                        ] :
                        [
                            {
                                type: 'value',
                                name: '(Rp bn)',
                                min: minRev,
                                max: maxRev,
                                interval: intervalRev,
                                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,
                                    }
                                }
                            }
                        ]
                    ,
                    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
595
                    if (this.state.report.value == 'summary') {
d.arizona's avatar
d.arizona committed
596
                        companyTPAT.push(item.periode)
597
                        mbTPAT.push(Number(item.value))
d.arizona's avatar
d.arizona committed
598
                        mrTPAT.push(Number(item.gp_margin).toFixed(1))
d.arizona's avatar
d.arizona committed
599
                    } else {
d.arizona's avatar
d.arizona committed
600
                        companyTPAT.push(handleName(item.company))
601 602
                        mbTPAT.push(Number(item.value_mb))
                        mrTPAT.push(Number(item.value_mr))
d.arizona's avatar
d.arizona committed
603
                    }
d.arizona's avatar
d.arizona committed
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 646 647 648 649 650 651 652 653 654 655 656 657 658 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 719
                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',
                                name: '(Rp bn)',
                                min: minTPAT,
                                max: maxTPAT,
                                interval: intervalTPAT
                            }
                        ] :
                        [
                            {
                                type: 'value',
                                name: '(Rp bn)',
                                min: minTPAT,
                                max: maxTPAT,
                                interval: intervalTPAT,
                                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
720
                    if (this.state.report.value == 'summary') {
d.arizona's avatar
d.arizona committed
721
                        companyEBITDA.push(item.periode)
722
                        mbEBITDA.push(Number(item.value))
d.arizona's avatar
d.arizona committed
723
                        mrEBITDA.push(Number(item.gp_margin).toFixed(1))
d.arizona's avatar
d.arizona committed
724
                    } else {
d.arizona's avatar
d.arizona committed
725
                        companyEBITDA.push(handleName(item.company))
726 727
                        mbEBITDA.push(Number(item.value_mb))
                        mrEBITDA.push(Number(item.value_mr))
d.arizona's avatar
d.arizona committed
728
                    }
d.arizona's avatar
d.arizona committed
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 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 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 850
                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',
                                name: '(Rp bn)',
                                min: minEBITDA,
                                max: maxEBITDA,
                                interval: intervalEBITDA,
                                axisLabel: {
                                    interval: 0,
                                    textStyle: {
                                        baseline: "top",
                                        color: "#333",
                                        fontSize: 12,
                                    }
                                }
                            }
                        ] :
                        [
                            {
                                type: 'value',
                                name: '(Rp bn)',
                                min: minEBITDA,
                                max: maxEBITDA,
                                interval: intervalEBITDA,
                                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
851
                if (this.state.report.value == 'summary') {
852 853 854
                    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
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 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918

                    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',
                                    name: '(Rp bn)',
                                    min: minTA,
                                    max: maxTA,
                                    interval: intervalTA
                                }
                            ]
                        ,
                        series:
                            [
                                {
                                    name: 'MB',
                                    type: 'bar',
                                    data: mbTA
                                }
                            ]
                    }

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


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

d.arizona's avatar
d.arizona committed
931 932 933 934 935 936 937 938 939 940 941 942 943 944
    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
945

d.arizona's avatar
d.arizona committed
946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969
            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}>
970
                {/* {this.state.loading && loadingComponent} */}
d.arizona's avatar
d.arizona committed
971 972 973 974 975 976 977 978 979 980 981 982 983
                <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
984
                            </div>
d.arizona's avatar
d.arizona committed
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999
                            <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
1000
                                <div style={{ display: 'flex', marginTop: 10 }}>
d.arizona's avatar
d.arizona committed
1001 1002 1003 1004
                                    <Autocomplete
                                        {...this.state.listMonth}
                                        id="month"
                                        onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
                                            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
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
                                            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
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 1077
                                            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
1078 1079 1080 1081 1082 1083
                                        })}
                                        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
1084
                                    {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
1085
                                    {this.state.report.value == 'summary' && <Autocomplete
d.arizona's avatar
d.arizona committed
1086
                                        {...this.state.listMonth2}
d.arizona's avatar
d.arizona committed
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096
                                        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
1097
                                        {...this.state.listPeriode2}
d.arizona's avatar
d.arizona committed
1098 1099
                                        id="periode"
                                        onChange={(event, newInputValue) => this.setState({ periode2: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118
                                            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
1119
                                                    this.setState({ month2: listMonth2[0], listMonth2: { ...this.state.listMonth2, options: listMonth2 } }, () => {
d.arizona's avatar
d.arizona committed
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143
                                                        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
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 1197
                                        })}
                                        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
1198
                            </div>
d.arizona's avatar
d.arizona committed
1199 1200
                            <Divider style={{ marginTop: 15 }} />
                            <div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
d.arizona's avatar
d.arizona committed
1201
                                <div>
d.arizona's avatar
d.arizona committed
1202
                                    <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
1203 1204 1205 1206
                                    {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
1207 1208
                                <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>}
1209 1210
                                    {<ReactECharts
                                        showLoading={this.state.loading}
d.arizona's avatar
d.arizona committed
1211
                                        style={{ height: 500, width: '100%', marginTop: 20 }}
1212
                                        option={this.state.revOptions}
d.arizona's avatar
d.arizona committed
1213 1214 1215
                                    />}
                                </div>

d.arizona's avatar
d.arizona committed
1216 1217
                                <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>}
1218 1219
                                    {<ReactECharts
                                        showLoading={this.state.loading}
d.arizona's avatar
d.arizona committed
1220
                                        style={{ height: 500, width: '100%', marginTop: 20 }}
1221
                                        option={this.state.tpatOptions}
d.arizona's avatar
d.arizona committed
1222 1223 1224
                                    />}
                                </div>

d.arizona's avatar
d.arizona committed
1225 1226
                                <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>}
1227 1228 1229
                                    {<ReactECharts
                                        lazyUpdate={true}
                                        showLoading={this.state.loading}
d.arizona's avatar
d.arizona committed
1230
                                        style={{ height: 500, width: '100%', marginTop: 20 }}
1231
                                        option={this.state.ebitdaOptions}
d.arizona's avatar
d.arizona committed
1232 1233 1234
                                    />}
                                </div>

d.arizona's avatar
d.arizona committed
1235
                                {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
1236
                                    <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`Total Assets - ${this.state.company.company_name}`}</Typography>
1237
                                    {<ReactECharts
d.arizona's avatar
d.arizona committed
1238
                                        style={{ height: 500, width: '100%', marginTop: 20 }}
1239 1240
                                        showLoading={this.state.loading}
                                        option={this.state.totalAssetsOptions}
d.arizona's avatar
d.arizona committed
1241 1242
                                    />}
                                </div>}
d.arizona's avatar
d.arizona committed
1243 1244 1245
                            </div>
                        </Paper>
                    </div>
d.arizona's avatar
d.arizona committed
1246 1247
                </div>
            </div>
d.arizona's avatar
d.arizona committed
1248 1249
        );
    }
d.arizona's avatar
d.arizona committed
1250
}