HomePage.js 90.8 KB
Newer Older
Deni Rinaldi's avatar
Deni Rinaldi committed
1
import React, { Component } from 'react';
d.arizona's avatar
d.arizona committed
2
import { Typography, MuiThemeProvider, createMuiTheme, Paper, TextField } from '@material-ui/core';
Deni Rinaldi's avatar
Deni Rinaldi committed
3
import MUIDataTable from "mui-datatables";
syadziy's avatar
syadziy committed
4
import Images from '../../assets/Images';
Deni Rinaldi's avatar
Deni Rinaldi committed
5
import DonutChart from 'react-d3-donut';
syadziy's avatar
syadziy committed
6 7
import Constant from '../../library/Constant';
import api from '../../api';
d.arizona's avatar
d.arizona committed
8
import { Link } from 'react-router-dom';
d.arizona's avatar
d.arizona committed
9
import { PropagateLoader } from 'react-spinners';
syadziy's avatar
syadziy committed
10
import { titleCase } from '../../library/Utils';
d.arizona's avatar
d.arizona committed
11
import { format } from 'date-fns';
d.arizona's avatar
d.arizona committed
12
import Autocomplete from '@material-ui/lab/Autocomplete';
d.arizona's avatar
d.arizona committed
13
import ReactSpeedometer from 'react-d3-speedometer';
Deni Rinaldi's avatar
Deni Rinaldi committed
14

syadziy's avatar
syadziy committed
15
var ct = require("../../library/CustomTable");
Deni Rinaldi's avatar
Deni Rinaldi committed
16 17
const getMuiTheme = () => createMuiTheme(ct.customTable());

Deni Rinaldi's avatar
Deni Rinaldi committed
18
class HomePage extends Component {
d.arizona's avatar
d.arizona committed
19 20 21
    constructor(props) {
        super(props)
        this.state = {
d.arizona's avatar
d.arizona committed
22
            userData: null,
Deni Rinaldi's avatar
Deni Rinaldi committed
23 24 25 26 27 28
            listDashboard: [],
            listMasterBudget: [
                { nama: 'Triputra Agro Persada', status: 'complete' },
                { nama: 'Puninar Infinite Raya', status: 'complete' },
                { nama: 'Dharma Group', status: 'overdue' },
                { nama: 'Daya Group', status: 'open' },
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
29
            ],
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
30
            isApprover: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
31
            listSubcoMB: [],
rifkaki's avatar
rifkaki committed
32
            listSubcoMR: [],
r.kurnia's avatar
r.kurnia committed
33 34
            listSubcoRO: [],
            listSubcoOL: [],
Deni Rinaldi's avatar
Deni Rinaldi committed
35
            valueSubmit: 0,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
36
            listdmb: [],
Deni Rinaldi's avatar
Deni Rinaldi committed
37
            dataTableMB: [],
d.arizona's avatar
d.arizona committed
38 39
            listPeriodeMB: null,
            listPeriodeMR: null,
r.kurnia's avatar
r.kurnia committed
40 41
            listPeriodeRO: null,
            listPeriodeOL: null,
d.arizona's avatar
d.arizona committed
42 43 44
            listMonth: null,
            periodeMB: null,
            periodeMR: null,
r.kurnia's avatar
r.kurnia committed
45 46
            periodeRO: null,
            periodeOL: null,
d.arizona's avatar
d.arizona committed
47
            month: null,
d.arizona's avatar
d.arizona committed
48 49
            monthCAT: null,
            periodeCAT: null,
rifkaki's avatar
rifkaki committed
50 51 52
            loading: false,
            accessMB: false,
            accessMR: false,
r.kurnia's avatar
r.kurnia committed
53 54
            accessRO: false,
            accessOL: false,
d.arizona's avatar
d.arizona committed
55
            company: [],
56
            dataDashboardCAT: [],
d.arizona's avatar
d.arizona committed
57
            loading2: false,
d.arizona's avatar
d.arizona committed
58
            loading3: false,
r.kurnia's avatar
r.kurnia committed
59 60 61 62 63 64 65
            parameterPerfom: [],
            quarterList: [
                { value: 'q1', name: 'Q1' },
                { value: 'q2', name: 'Q2' },
                { value: 'q3', name: 'Q3' },
            ],
            quarter: null
d.arizona's avatar
d.arizona committed
66 67 68 69
        }
    }

    componentDidMount() {
d.arizona's avatar
d.arizona committed
70
        this.setState({ loading: true, loading2: true, loading3: true })
d.arizona's avatar
d.arizona committed
71 72
        let userId = localStorage.getItem(Constant.USER)
        api.create().getDetailUser(userId).then((response) => {
qorri_di's avatar
qorri_di committed
73
            console.log(response);
d.arizona's avatar
d.arizona committed
74
            if (response.data) {
d.arizona's avatar
d.arizona committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
                if (response.ok) {
                    if (response.data.status === 'success') {
                        this.setState({ userData: response.data.data })
                        // console.log(response.data.data)
                    } 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
91
                }
d.arizona's avatar
d.arizona committed
92 93
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
94 95
            }
        })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
96 97 98 99 100 101 102 103 104
        // api.create().checkApprover().then(response => {
        //     console.log(response);
        //     if (response.data.data.is_approver === true) {
        //         this.setState({ isApprover: true }, () =>
        //             this.getDashboard())
        //     } else {
        //         this.setState({ isApprover: false })
        //     }
        // })
rifkaki's avatar
rifkaki committed
105 106
        this.getPermissionMB()
        this.getPermissionMR()
r.kurnia's avatar
r.kurnia committed
107 108
        this.getPermissionRO()
        this.getPermissionOL()
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
109
        this.getApprMat()
d.arizona's avatar
d.arizona committed
110 111
        // this.getListUserSubco()
        this.getMonth()
d.arizona's avatar
d.arizona committed
112 113
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
114
    componentDidUpdate() {
d.arizona's avatar
d.arizona committed
115
        window.onpopstate = e => {
Deni Rinaldi's avatar
Deni Rinaldi committed
116 117
            //your code...
            this.props.selectIndex('Home')
d.arizona's avatar
d.arizona committed
118 119 120
        }
    }

d.arizona's avatar
d.arizona committed
121 122 123 124
    getPeriode() {
        let currentYear = new Date().getFullYear()
        let MB = []
        let MR = []
r.kurnia's avatar
r.kurnia committed
125 126
        let ROut = []
        let OL = []
d.arizona's avatar
d.arizona committed
127 128 129
        for (var i = 2000; i <= currentYear; i++) {
            MB.push({ name: String(i), value: i })
            MR.push({ name: String(i), value: i })
r.kurnia's avatar
r.kurnia committed
130 131
            ROut.push({ name: String(i), value: i })
            OL.push({ name: String(i), value: i })
d.arizona's avatar
d.arizona committed
132
            if (i == currentYear) {
d.arizona's avatar
d.arizona committed
133
                MB.push({ name: String(i + 1), value: i + 1 })
d.arizona's avatar
d.arizona committed
134 135 136 137 138 139 140 141 142 143 144 145
            }
        }

        let defaultPropsMB = {
            options: MB,
            getOptionLabel: (option) => option.name,
        };

        let defaultPropsMR = {
            options: MR,
            getOptionLabel: (option) => option.name,
        };
r.kurnia's avatar
r.kurnia committed
146 147 148 149 150 151 152 153 154 155

        let defaultPropsRO = {
            options: ROut,
            getOptionLabel: (option) => option.name,
        };

        let defaultPropsOL = {
            options: OL,
            getOptionLabel: (option) => option.name,
        };
d.arizona's avatar
d.arizona committed
156 157 158 159 160
        // console.log(MR[MR.length - 1])
        let dateNow = new Date()
        dateNow.setMonth(dateNow.getMonth() - 1);
        let yearNow = dateNow.getFullYear()
        let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
r.kurnia's avatar
r.kurnia committed
161 162
        let indexMonthRO = ROut.findIndex((val) => val.value == yearNow)
        let indexMonthOL = OL.findIndex((val) => val.value == yearNow)
d.arizona's avatar
d.arizona committed
163

r.kurnia's avatar
r.kurnia committed
164 165 166 167 168
        let defaultPropsQuarter = {
            options: this.state.quarterList,
            getOptionLabel: (option) => option.name
        }

qorri_di's avatar
qorri_di committed
169 170 171 172 173 174 175 176 177 178 179 180
        this.setState({ listPeriodeMB: defaultPropsMB, 
                        periodeMB: MB[MB.length - 1], 
                        listPeriodeMR: defaultPropsMR, 
                        periodeMR: MR[indexMonthMR], 
                        listPeriodeRO: defaultPropsRO, 
                        periodeRO: ROut[indexMonthRO],
                        listQuarter: defaultPropsQuarter, 
                        quarter: this.state.quarterList[0],
                        listPeriodeOL: defaultPropsOL, 
                        periodeOL: OL[indexMonthOL],
                        listPeriodeCAT: defaultPropsMB, 
                        periodeCAT: MB[indexMonthMR] }, () => {
d.arizona's avatar
d.arizona committed
181
            this.getParameterGroupPerfom()
d.arizona's avatar
d.arizona committed
182 183 184 185 186 187 188
        })
    }

    getDashboardCAT() {
        console.log(this.state.company)
        api.create().getListChildDashboardCAT(this.state.periodeCAT.value, this.state.monthCAT.month_id).then((res) => {
            if (res.data) {
d.arizona's avatar
d.arizona committed
189
                // console.log(res)
d.arizona's avatar
d.arizona committed
190 191 192 193 194 195
                let response = res.data.data.business_unit
                let data = []
                response.map((item, index) => {
                    let arrayChild = []
                    item.category.map((items, indexs) => {
                        if (this.state.company.includes(items.company_id)) {
d.arizona's avatar
d.arizona committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
                            let indexPerform = this.state.parameterPerfom.findIndex((val) => val.company_id == items.company_id)
                            let listPerfomanceDefault = []
                            if (indexPerform == -1) {
                                listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
                            } else {
                                listPerfomanceDefault = this.state.parameterPerfom.filter((val) => val.company_id == items.company_id)
                            }
                            let performanceScore = ''
                            let perfomanceScoreColor = '#fff'
                            if (listPerfomanceDefault.length > 0) {
                                listPerfomanceDefault.map((item, index) => {
                                    // console.log(Number(lastTotal))
                                    // console.log(Number(item.min_value))
                                    // console.log(Number(item.max_value))
                                    if (Number(items.current_value).toFixed(2) >= Number(item.min_value) && Number(items.current_value).toFixed(2) <= Number(item.max_value)) {
                                        // console.log('masuk')
                                        performanceScore = item.description
                                        perfomanceScoreColor = item.value
                                    }
                                })
                            }
d.arizona's avatar
d.arizona committed
217
                            arrayChild.push({ ...items, current_value: Number(items.current_value).toFixed(2), performanceColor: perfomanceScoreColor, performanceScore })
d.arizona's avatar
d.arizona committed
218 219
                        }
                    })
d.arizona's avatar
d.arizona committed
220
                    if (arrayChild.length > 0 && String(item.item_business).toLocaleLowerCase() != 'holding') {
d.arizona's avatar
d.arizona committed
221 222 223
                        data.push({ ...item, category: arrayChild })
                    }
                })
d.arizona's avatar
d.arizona committed
224
                // console.log(this.state.parameterPerfom)
d.arizona's avatar
d.arizona committed
225
                console.log(data)
d.arizona's avatar
d.arizona committed
226 227 228 229 230
                this.setState({ dataDashboardCAT: data, loading: false, loading2: false }, () => {
                    setTimeout(() => {
                        this.setState({loading3: false})
                    }, 1000);
                })
d.arizona's avatar
d.arizona committed
231
            }
d.arizona's avatar
d.arizona committed
232 233 234 235 236
        })
    }

    getMonth() {
        api.create().getMonthTransaction().then(response => {
d.arizona's avatar
d.arizona committed
237 238
            let dateNow = new Date()
            dateNow.setMonth(dateNow.getMonth() - 1);
d.arizona's avatar
d.arizona committed
239
            let month = format(dateNow, 'MMMM')
d.arizona's avatar
d.arizona committed
240
            // console.log(month);
d.arizona's avatar
d.arizona committed
241 242 243 244 245 246 247 248 249 250 251 252 253 254
            if (response.data) {
                if (response.data.status === "success") {
                    // console.log(response);
                    let data = response.data.data
                    let monthData = data.map((item) => {
                        return {
                            month_id: item.id,
                            month_value: String(item.month_name).substr(0, 3)
                        }
                    })
                    let defaultProps = {
                        options: monthData,
                        getOptionLabel: (option) => option.month_value,
                    };
Riri Novita's avatar
Riri Novita committed
255
                    let index = data.findIndex((val) => val.month_name == month)
d.arizona's avatar
d.arizona committed
256 257
                    // console.log(month)
                    // console.log(index)
d.arizona's avatar
d.arizona committed
258
                    this.setState({ listMonth: defaultProps, listMonthCAT: defaultProps, monthCAT: monthData[index], month: index == -1 ? monthData[0] : monthData[index] }, () => {
d.arizona's avatar
d.arizona committed
259 260 261 262 263 264 265 266 267
                        // if (this.state.isApprover === true) {
                        //     if (this.state.submittedOnly) {
                        //         console.log('masuk cuk')
                        //         this.getPeriode()
                        //     } else {
                        //         this.getLastPeriod()
                        //     }
                        this.getPeriode()
                        // } else {
d.arizona's avatar
d.arizona committed
268 269
                        // this.getLastPeriod()
                        // this.getPeriode()
d.arizona's avatar
d.arizona committed
270 271 272 273
                        // }
                    })
                } else {
                    // this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
274
                    //     if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
275 276 277 278 279 280 281 282 283 284 285 286 287
                    //         setTimeout(() => {
                    //             localStorage.removeItem(Constant.TOKEN)
                    //             window.location.reload();
                    //         }, 1000);
                    //     }
                    // })
                }
            } else {
                // this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
            }
        })
    }

rifkaki's avatar
rifkaki committed
288 289 290 291 292
    getPermissionMB() {
        let payload = {
            menu: "Master Budget & CAT"
        }
        api.create().getPermission(payload).then(response => {
d.arizona's avatar
d.arizona committed
293
            // console.log(response)
rifkaki's avatar
rifkaki committed
294 295 296 297 298 299
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        btnCreateMB: response.data.data.create,
                        btnEditMB: response.data.data.edit,
                        load: true
d.arizona's avatar
d.arizona committed
300 301
                    }, () => {
                        if (this.state.btnCreateMB === true && this.state.btnEditMB === true) {
rifkaki's avatar
rifkaki committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
                            this.setState({ accessMB: true })
                        }
                    })
                } else {
                    this.setState({
                        load: true
                    })
                }
            } else {
                this.setState({ load: true })
            }
        })
    }

    getPermissionMR() {
        let payload = {
            menu: "monthly report"
        }
        api.create().getPermission(payload).then(response => {
d.arizona's avatar
d.arizona committed
321
            // console.log(response)
rifkaki's avatar
rifkaki committed
322 323 324 325 326 327
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        btnCreateMR: response.data.data.create,
                        btnEditMR: response.data.data.edit,
                        load: true
d.arizona's avatar
d.arizona committed
328 329
                    }, () => {
                        if (this.state.btnCreateMR === true && this.state.btnEditMR === true) {
rifkaki's avatar
rifkaki committed
330 331 332 333 334 335 336 337 338 339 340 341 342
                            this.setState({ accessMR: true })
                        }
                    })
                } else {
                    this.setState({
                        load: true
                    })
                }
            } else {
                this.setState({ load: true })
            }
        })
    }
d.arizona's avatar
d.arizona committed
343

r.kurnia's avatar
r.kurnia committed
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
    getPermissionRO() {
        let payload = {
            menu: "rolling outlook & cat revision"
        }
        api.create().getPermission(payload).then(response => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        btnCreateRO: response.data.data.create,
                        btnEditRO: response.data.data.edit,
                        load: true
                    }, () => {
                        if (this.state.btnCreateRO === true && this.state.btnEditRO === true) {
                            this.setState({ accessRO: true })
                        }
                    })
                } else {
                    this.setState({
                        load: true
                    })
                }
            } else {
                this.setState({ load: true })
            }
        })
    }

    getPermissionOL() {
        let payload = {
            menu: "outlook performance appraisal"
        }
        api.create().getPermission(payload).then(response => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        btnCreateOL: response.data.data.create,
                        btnEditOL: response.data.data.edit,
                        load: true
                    }, () => {
                        if (this.state.btnCreateOL === true && this.state.btnEditOL === true) {
                            this.setState({ accessOL: true })
                        }
                    })
                } else {
                    this.setState({
                        load: true
                    })
                }
            } else {
                this.setState({ load: true })
            }
        })
    }

d.arizona's avatar
d.arizona committed
400 401 402 403 404 405 406 407 408 409 410
    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({ tempData: response.data.data, company: response.data.data.company }, () =>
                            this.getDashboardCAT())
                        // console.log(response.data.data)
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
411
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

d.arizona's avatar
d.arizona committed
428 429 430 431 432 433 434 435 436 437 438 439 440 441
    getListUserSubcoMB() {
        // console.log(this.state.month.month_id)
        // console.log(this.state.periodeMR.value)
        api.create().getListUserSubcoMB(this.state.periodeMB.value).then((response) => {
            // console.log(response)
            let valueSubmit = 0
            let dataMB = []
            if (response.data) {
                if (response.data.status === "success") {
                    response.data.data.map((item, index) => {
                        if (item.is_submit === true) {
                            valueSubmit += 1
                        }
                        dataMB.push(item)
d.arizona's avatar
d.arizona committed
442

d.arizona's avatar
d.arizona committed
443 444 445 446 447 448 449 450
                    })
                    this.setState({
                        listSubcoMB: dataMB,
                        valueSubmit,
                        loading: false
                    })
                }
            } else {
d.arizona's avatar
d.arizona committed
451
                this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
452 453 454 455 456 457 458 459 460 461
            }
        })
    }

    getListUserSubcoMR() {
        // console.log(this.state.month.month_id)
        // console.log(this.state.periodeMR.value)
        api.create().getListUserSubcoMR(this.state.month.month_id, this.state.periodeMR.value).then((response) => {
            let valueSubmitMR = 0
            let dataMR = []
d.arizona's avatar
d.arizona committed
462
            console.log(response)
d.arizona's avatar
d.arizona committed
463 464 465
            if (response.data) {
                if (response.data.status === "success") {
                    response.data.data.map((item, index) => {
d.arizona's avatar
d.arizona committed
466
                        if (item.is_submit === true) {
d.arizona's avatar
d.arizona committed
467 468 469 470 471 472 473 474 475 476 477
                            valueSubmitMR += 1
                        }
                        dataMR.push(item)
                    })
                    this.setState({
                        listSubcoMR: dataMR,
                        valueSubmitMR,
                        loading: false
                    })
                }
            } else {
d.arizona's avatar
d.arizona committed
478
                this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
479 480 481
            }
        })
    }
rifkaki's avatar
rifkaki committed
482

r.kurnia's avatar
r.kurnia committed
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
    getListUserSubcoRO() {
        // console.log(this.state.month.month_id)
        // console.log(this.state.periodeMR.value)
        api.create().getListUserSubcoRO(this.state.periodeRO.value, this.state.quarter.value).then((response) => {
            let valueSubmitRO = 0
            let dataRO = []
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    response.data.data.map((item, index) => {
                        if (item.is_submit === true) {
                            valueSubmitRO += 1
                        }
                        dataRO.push(item)
                    })
                    this.setState({
                        listSubcoRO: dataRO,
                        valueSubmitRO,
                        loading: false
                    })
                }
            } else {
                this.setState({ loading: false })
            }
        })
    }

    getListUserSubcoOL() {
        // console.log(this.state.month.month_id)
        // console.log(this.state.periodeOL.value)
        api.create().getListUserSubcoOL(this.state.periodeOL.value).then((response) => {
            let valueSubmitOL = 0
            let dataOL = []
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    response.data.data.map((item, index) => {
                        if (item.is_submit === true) {
                            valueSubmitOL += 1
                        }
                        dataOL.push(item)
                    })
                    this.setState({
                        listSubcoOL: dataOL,
                        valueSubmitOL,
                        loading: false
                    })
                }
            } else {
                this.setState({ loading: false })
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
537 538
    getListUserSubco() {
        api.create().getDashboardUser().then(response => {
d.arizona's avatar
d.arizona committed
539
            // console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
540
            let valueSubmit = 0
rifkaki's avatar
rifkaki committed
541 542 543
            let valueSubmitMR = 0
            let dataMB = []
            let dataMR = []
Deni Rinaldi's avatar
Deni Rinaldi committed
544 545 546
            if (response.data) {
                if (response.data.status === "success") {
                    response.data.data.map((item, index) => {
rifkaki's avatar
rifkaki committed
547
                        if (item.is_submit === true && item.type === "master_budget") {
Deni Rinaldi's avatar
Deni Rinaldi committed
548
                            valueSubmit += 1
rifkaki's avatar
rifkaki committed
549 550 551 552
                        } else if (item.is_submit === true && item.type === "monthly_report") {
                            valueSubmitMR += 1
                        }

d.arizona's avatar
d.arizona committed
553
                        if (item.type === "master_budget") {
rifkaki's avatar
rifkaki committed
554 555 556
                            dataMB.push(item)
                        } else {
                            dataMR.push(item)
Deni Rinaldi's avatar
Deni Rinaldi committed
557 558 559
                        }
                    })
                    this.setState({
rifkaki's avatar
rifkaki committed
560 561
                        listSubcoMB: dataMB,
                        listSubcoMR: dataMR,
Deni Rinaldi's avatar
Deni Rinaldi committed
562
                        valueSubmit,
rifkaki's avatar
rifkaki committed
563
                        valueSubmitMR,
Deni Rinaldi's avatar
Deni Rinaldi committed
564
                        loading: false
Deni Rinaldi's avatar
Deni Rinaldi committed
565 566 567
                    })
                }
            }
d.arizona's avatar
d.arizona committed
568 569
            // console.log(this.state.listSubcoMB)
            // console.log(this.state.listSubcoMR)
Deni Rinaldi's avatar
Deni Rinaldi committed
570 571 572
        })
    }

d.arizona's avatar
d.arizona committed
573 574
    getDashboard() {
        let listDashboard = []
d.arizona's avatar
d.arizona committed
575
        let rawData = []
d.arizona's avatar
d.arizona committed
576
        api.create().getDashboard().then((response) => {
d.arizona's avatar
d.arizona committed
577
            console.log(response);
r.kurnia's avatar
r.kurnia committed
578 579 580 581
            console.log(this.state.isApproverMB);
            console.log(this.state.isApproverMR);
            console.log(this.state.isApproverRO);
            console.log(this.state.isApproverOL);
d.arizona's avatar
d.arizona committed
582 583
            if (String(response.data.status).toLocaleLowerCase() == 'success') {
                let data = response.data.data
Deni Rinaldi's avatar
Deni Rinaldi committed
584
                data.map((item, index) => {
d.arizona's avatar
d.arizona committed
585
                    let statusConvert = item.status == 'approval_review' ? 'Waiting For Review' : item.status == 'approval_proccess' ? 'Waiting For Approval' : titleCase(item.status)
r.kurnia's avatar
r.kurnia committed
586
                    if (this.state.isApproverMB && this.state.isApproverMR && this.state.isApproverRO && this.state.isApproverOL) {
d.arizona's avatar
d.arizona committed
587
                        if (String(item.type_report).toLocaleLowerCase().includes("master")) {
rifkaki's avatar
rifkaki committed
588 589
                            listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} - ${item.periode}`, item.revision, item.status, statusConvert])
                            rawData.push(item)
d.arizona's avatar
d.arizona committed
590
                        } else if (String(item.type_report).toLocaleLowerCase().includes("monthly")) {
rifkaki's avatar
rifkaki committed
591 592
                            listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
                            rawData.push(item)
r.kurnia's avatar
r.kurnia committed
593
                        } else if (String(item.type_report).toLocaleLowerCase().includes("rolling")) {
r.kurnia's avatar
r.kurnia committed
594 595
                            listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
                            rawData.push(item)
r.kurnia's avatar
r.kurnia committed
596
                        } else if (String(item.type_report).toLocaleLowerCase().includes("pa")) {
rifkaki's avatar
rifkaki committed
597
                            listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
rifkaki's avatar
rifkaki committed
598
                            rawData.push(item)
qorri_di's avatar
qorri_di committed
599
                        } 
r.kurnia's avatar
r.kurnia committed
600 601 602 603 604 605
                    } else {
                        if (this.state.isApproverMB) {
                            if (String(item.type_report).toLocaleLowerCase().includes("master")) {
                                listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} - ${item.periode}`, item.revision, item.status, statusConvert])
                                rawData.push(item)
                            }
qorri_di's avatar
qorri_di committed
606
                        } 
r.kurnia's avatar
r.kurnia committed
607 608 609 610 611
                        if (this.state.isApproverMR) {
                            if (String(item.type_report).toLocaleLowerCase().includes("monthly")) {
                                listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
                                rawData.push(item)
                            }
qorri_di's avatar
qorri_di committed
612
                        } 
r.kurnia's avatar
r.kurnia committed
613 614 615 616 617
                        if (this.state.isApproverRO) {
                            if (String(item.type_report).toLocaleLowerCase().includes("rolling")) {
                                listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
                                rawData.push(item)
                            }
rifkaki's avatar
rifkaki committed
618
                        }
r.kurnia's avatar
r.kurnia committed
619 620 621 622 623
                        if (this.state.isApproverOL) {
                            if (String(item.type_report).toLocaleLowerCase().includes("pa")) {
                                listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
                                rawData.push(item)
                            }
r.kurnia's avatar
r.kurnia committed
624
                        }
rifkaki's avatar
rifkaki committed
625
                    }
d.arizona's avatar
d.arizona committed
626
                })
d.arizona's avatar
d.arizona committed
627
                this.setState({ listDashboard, rawData })
d.arizona's avatar
d.arizona committed
628 629
            }
        })
d.arizona's avatar
d.arizona committed
630 631
    }

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
632
    getApprMat() {
d.arizona's avatar
d.arizona committed
633
        this.setState({ loading: true })
rifkaki's avatar
rifkaki committed
634 635
        let isApproverMR = false
        let isApproverMB = false
r.kurnia's avatar
r.kurnia committed
636 637
        let isApproverRO = false
        let isApproverOL = false
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
638
        api.create().getAM().then((response) => {
r.kurnia's avatar
r.kurnia committed
639
            console.log(response);
r.kurnia's avatar
r.kurnia committed
640
            let actAMActive = []
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
641
            let actAM = response.data.data.map((item, index) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
642
                if (String(item.status).toLocaleLowerCase() == 'active') {
r.kurnia's avatar
r.kurnia committed
643
                    actAMActive.push(item)
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
644 645 646 647
                    return item
                }
            })
            let userId = localStorage.getItem(Constant.USER)
d.arizona's avatar
d.arizona committed
648
            // console.log(userId);
r.kurnia's avatar
r.kurnia committed
649
            let indexId = actAMActive.findIndex((val) => val.user_id == userId)
rifkaki's avatar
rifkaki committed
650
            actAMActive.map((item, index) => {
d.arizona's avatar
d.arizona committed
651
                if (item.approval_type_name === "MONTHLY_REPORT") {
rifkaki's avatar
rifkaki committed
652
                    isApproverMR = true
d.arizona's avatar
d.arizona committed
653
                } else if (item.approval_type_name === "MASTER_BUDGET") {
rifkaki's avatar
rifkaki committed
654
                    isApproverMB = true
r.kurnia's avatar
r.kurnia committed
655 656 657 658
                } else if (item.approval_type_name === "ROLLING_OUTLOOK") {
                    isApproverRO = true
                } else if (item.approval_type_name === "OUTLOOK_PA") {
                    isApproverOL = true
rifkaki's avatar
rifkaki committed
659 660 661
                }
            })

Deni Rinaldi's avatar
Deni Rinaldi committed
662
            if (indexId === -1) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
663
                this.setState({ isApprover: false })
d.arizona's avatar
d.arizona committed
664 665
                this.getMonth()
                // this.getListUserSubco()
rifkaki's avatar
rifkaki committed
666
            }
r.kurnia's avatar
r.kurnia committed
667
            this.setState({ isApproverMB, isApproverMR, isApproverRO, isApproverOL })
Deni Rinaldi's avatar
Deni Rinaldi committed
668
            this.getDashboardMB()
d.arizona's avatar
d.arizona committed
669 670
            // this.getDashboardMB()
            this.getDashboard()
Deni Rinaldi's avatar
Deni Rinaldi committed
671
            // console.log(actAM)
d.arizona's avatar
d.arizona committed
672
            this.setState({ loading: false })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
673 674 675
        })
    }

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
676
    getDashboardMB() {
Deni Rinaldi's avatar
Deni Rinaldi committed
677
        api.create().getDashboardMB().then((response) => {
d.arizona's avatar
d.arizona committed
678
            // console.log(response)
Deni Rinaldi's avatar
Deni Rinaldi committed
679
            if (String(response.data.status).toLocaleLowerCase() == 'success') {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
680 681 682 683 684 685 686 687
                let data = response.data.data
                let listdmb = data.sort((a, b) => a.company_id - b.company_id).map((item, index) => {
                    return [
                        item.company_name,
                        item.master_budget,
                        item.operating_indicator
                    ]
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
688
                this.setState({ dataTableMB: listdmb, loading: false })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
689 690 691 692
            }
        })
    }

d.arizona's avatar
d.arizona committed
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
    handleBackgroundPerform(total) {
        let color = 'white'
        if (total >= 1.00 && total <= 2.00) {
            color = 'red'
        } else if (total >= 2.01 && total <= 2.75) {
            color = 'yellow'
        } else if (total >= 2.76 && total <= 3.00) {
            color = 'lightgreen'
        } else if (total >= 3.01 && total <= 3.75) {
            color = 'yellowgreen'
        } else if (total >= 3.76 && total <= 4.00) {
            color = 'forestgreen'
        } else if (total >= 4.01 && total <= 4.75) {
            color = 'deepskyblue'
        } else if (total >= 4.76 && total <= 5.00) {
            color = 'dodgerblue'
        }
        return color
    }

d.arizona's avatar
d.arizona committed
713 714 715 716 717 718 719 720 721
    getParameterGroupPerfom() {
        api.create().getParameterByGroupName({
            "group_name": "PERFORMANCE_KPI"
        }).then((response) => {
            console.log(response.data)
            if (response.data) {
                this.setState({ parameterPerfom: response.data.data } , () => {
                    this.getListUserSubcoMB()
                    this.getListUserSubcoMR()
r.kurnia's avatar
r.kurnia committed
722 723
                    this.getListUserSubcoRO()
                    this.getListUserSubcoOL()
d.arizona's avatar
d.arizona committed
724 725 726 727 728 729
                    this.getDetailUser()
                })
            } else {
                this.setState({ parameterPerfom: [] } , () => {
                    this.getListUserSubcoMB()
                    this.getListUserSubcoMR()
r.kurnia's avatar
r.kurnia committed
730 731
                    this.getListUserSubcoRO()
                    this.getListUserSubcoOL()
d.arizona's avatar
d.arizona committed
732 733 734 735 736 737
                    this.getDetailUser()
                })
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
738
    render() {
d.arizona's avatar
d.arizona committed
739 740 741 742 743 744 745 746
        const getDataMonth = (item) => {
            let months = item.months
            let dataMonth = this.state.listMonth.options
            let indexID = dataMonth.findIndex((val) => val.month_id == months)
            // console.log(dataMonth[indexID])
            return dataMonth[indexID]
        }

d.arizona's avatar
d.arizona committed
747 748 749 750 751
        const columns = ["#", "ID", "Company", "Report Type", "Revision",
            {
                name: "",
                options: {
                    display: false
Deni Rinaldi's avatar
Deni Rinaldi committed
752
                }
d.arizona's avatar
d.arizona committed
753 754 755 756 757
            }, 'Status', {
                name: "Action",
                options: {
                    customBodyRender: (val, tableMeta) => {
                        // console.log(tableMeta);
r.kurnia's avatar
r.kurnia committed
758
                        // console.log(this.state.rawData);
d.arizona's avatar
d.arizona committed
759 760 761
                        return (
                            <div style={{ display: 'flex' }}>
                                <Link to={{
r.kurnia's avatar
r.kurnia committed
762
                                    pathname: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? `/home/master-budget/` : String(tableMeta.rowData[3]).toLocaleLowerCase().includes("monthly") ? `/home/monthly-report/` : String(tableMeta.rowData[3]).toLocaleLowerCase().includes("rolling") ? `/home/rolling-outlook/` : `/home/outlook-performance/`,
d.arizona's avatar
d.arizona committed
763 764
                                    state: {
                                        userType: 'approver',
r.kurnia's avatar
r.kurnia committed
765
                                        rawData: {...this.state.rawData[tableMeta.rowIndex], quarter: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("rolling") ? this.state.rawData[tableMeta.rowIndex].quartal : null },
r.kurnia's avatar
r.kurnia committed
766
                                        month: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? null : getDataMonth(this.state.rawData[tableMeta.rowIndex]),
r.kurnia's avatar
r.kurnia committed
767
                                        quarter: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("rolling") ? this.state.rawData[tableMeta.rowIndex].quartal : null
d.arizona's avatar
d.arizona committed
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786
                                    }
                                }}>
                                    <button
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            marginRight: 10
                                        }}
                                        onClick={() => null}
                                    >
                                        <img src={Images.editCopy2} />
                                    </button>
                                </Link>
                            </div >
                        );
                    }
                }
            }]
Deni Rinaldi's avatar
Deni Rinaldi committed
787 788 789 790 791 792 793 794
        const data = [
            ["1", "TRIPUTRA AGRO PERSADA", "Laporan Bulanan - September 2020", "1 (20 Oktober 2020)", "Belum Disetujui"],
            ["2", "DAYA GROUP", "Laporan Bulanan - September 2020", "1 (20 Oktober 2020)", "Belum Disetujui"],
            ["3", "PUNINAR INFINITE RAYA", "Budget Tahunan 2021", "0 (20 Oktober 2020)", "Belum Disetujui"],
            ["4", "DHARMA GROUP", "Laporan Bulanan - September 2020", "0 (20 Oktober 2020)", "Belum Disetujui"],
            ["5", "PUNINAR INFINITE RAYA", "Budget Tahunan 2021", "0 (20 Oktober 2020)", "Belum Disetujui"],
        ]
        const options = {
d.arizona's avatar
d.arizona committed
795
            filter: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
796 797 798 799 800
            sort: false,
            responsive: "scroll",
            print: false,
            download: false,
            selectableRows: false,
d.arizona's avatar
d.arizona committed
801
            viewColumns: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
802
            rowsPerPage: 5,
d.arizona's avatar
d.arizona committed
803
            search: true
Deni Rinaldi's avatar
Deni Rinaldi committed
804
        }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
805 806 807

        const columnsMB = ["Company", "Master Budget & CAT", "Operating Indicator"]

Deni Rinaldi's avatar
Deni Rinaldi committed
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
        const dataChart = [{
            count: 90,
            color: '#5198ea',
            name: 'My name',
        }, {
            count: 10,
            color: '#ffd600',
            name: 'name',
        }]
        const dataChart2 = [{
            count: 90,
            color: '#f65a4c',
            name: 'My name',
        }, {
            count: 10,
            color: '#5198ea',
            name: 'name',
        }]
        const dataChart3 = [{
            count: 90,
            color: '#4caf51',
            name: 'My name',
        }, {
            count: 10,
            color: '#f65a4c',
            name: 'name',
        }]
d.arizona's avatar
d.arizona committed
835 836 837 838 839 840 841 842 843 844
        const loadingComponent = (
            <div style={{ position: 'absolute', 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>
        );
d.arizona's avatar
d.arizona committed
845
        let bulan = format(new Date(), 'MMM')
rifkaki's avatar
rifkaki committed
846
        let tahun = new Date().getFullYear()
Deni Rinaldi's avatar
Deni Rinaldi committed
847
        return (
d.arizona's avatar
d.arizona committed
848
            <div style={{ flex: 1, backgroundColor: '#f8f8f8', minHeight: this.props.height }}>
d.arizona's avatar
d.arizona committed
849
                {(this.state.loading || this.state.loading2 || this.state.loading3) && loadingComponent}
Deni Rinaldi's avatar
Deni Rinaldi committed
850
                {this.state.isApprover === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
851
                    <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
852 853 854
                        <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                            <Typography style={{ fontSize: '24px', color: 'white' }}>{this.state.userData === null ? '' : `Welcome, ${this.state.userData.fullname} !`}</Typography>
                        </div>
rifkaki's avatar
rifkaki committed
855
                        <div>
d.arizona's avatar
d.arizona committed
856 857 858 859 860 861
                            <div style={{ flex: 1, padding: 20, width: '100%' }}>
                                <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Dashboard CAT</Typography>
                                <div style={{ display: 'flex' }}>
                                    <Autocomplete
                                        {...this.state.listMonthCAT}
                                        id="monthCAT"
d.arizona's avatar
d.arizona committed
862
                                        onChange={(event, newInputValue) => this.setState({ monthCAT: newInputValue, loading: true, loading3: true}, () => {
d.arizona's avatar
d.arizona committed
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878
                                            this.getDashboardCAT()
                                            // if (this.state.isApprover === true) {
                                            //     this.getCompanySubmitted()
                                            // } else {
                                            // this.setState({ visibleTableHistory: false })
                                            // this.getRevision()
                                            // }
                                        })}
                                        disableClearable
                                        style={{ minWidth: 250, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Month CAT" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.monthCAT}
                                    />
                                    <Autocomplete
                                        {...this.state.listPeriodeCAT}
                                        id="periodeCAT"
d.arizona's avatar
d.arizona committed
879
                                        onChange={(event, newInputValue) => this.setState({ periodeCAT: newInputValue, loading: true, loading3: true }, () => {
d.arizona's avatar
d.arizona committed
880 881 882 883 884 885 886 887 888 889 890 891 892 893
                                            this.getDashboardCAT()
                                            // if (this.state.isApprover === true) {
                                            //         this.getCompanySubmitted()
                                            // } else {
                                            // this.setState({ visibleTableHistory: false })
                                            // this.getRevision()
                                            // }
                                        })}
                                        disableClearable
                                        style={{ width: 250 }}
                                        renderInput={(params) => <TextField {...params} label="Periode CAT" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.periodeCAT}
                                    />
                                </div>
d.arizona's avatar
d.arizona committed
894
                                {this.state.dataDashboardCAT.map((item, index) => {
d.arizona's avatar
d.arizona committed
895 896
                                    return (
                                        <div>
d.arizona's avatar
d.arizona committed
897
                                            <Typography style={{ color: '#656565', fontSize: '16px', marginTop: 20 }}>{item.item_business}</Typography>
d.arizona's avatar
d.arizona committed
898
                                            <div style={{ display: 'flex', overflowX: 'scroll', width: this.props.width * 0.95 }}>
d.arizona's avatar
d.arizona committed
899
                                                {item.category.map((items, indexs) => {
d.arizona's avatar
d.arizona committed
900
                                                    return (
d.arizona's avatar
d.arizona committed
901 902 903 904
                                                        <Link to={{
                                                            pathname: `/home/cat-dashboard/`,
                                                            state: {
                                                                userType: 'user',
d.arizona's avatar
d.arizona committed
905
                                                                rawData: { month: this.state.monthCAT.month_id, periode: this.state.periodeCAT.value, companyId: items.company_id }
d.arizona's avatar
d.arizona committed
906 907
                                                            }
                                                        }}>
d.arizona's avatar
d.arizona committed
908
                                                            <div style={{ padding: 10, backgroundColor: '#fff', height: 350, borderRadius: 6, paddingBottom: 20, margin: 10, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', width: 250, marginRight: indexs == item.category.length - 1 ? 25 : 0, marginLeft: indexs == 0 ? 5 : 25 }}>
d.arizona's avatar
d.arizona committed
909 910
                                                                {/* <span style={{ fontSize: '17px', color: this.state.selectIndex === index ? '#fff' : '#7e8085', maxWidth: 100 }}>{item.category_name}</span> */}
                                                                <div style={{ fontSize: '17px', width: '100%', height: 25 }}>
d.arizona's avatar
d.arizona committed
911
                                                                    <Typography style={{ textAlign: 'left', color: '#4b4b4b' }}>{items.category_name}</Typography>
d.arizona's avatar
d.arizona committed
912
                                                                </div>
d.arizona's avatar
d.arizona committed
913
                                                                {items.total_kpi != null &&
d.arizona's avatar
d.arizona committed
914 915 916 917
                                                                    <div style={{ width: '100%', display: 'flex', justifyContent: 'center', marginTop: 10 }}>
                                                                        <span style={{ textAlign: 'center', fontSize: '18px', color: "#fff" }}>{item.total_kpi}</span>
                                                                        {/* <span style={{ textAlign: 'center', fontSize: '11px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>KPIs</span> */}
                                                                    </div>}
d.arizona's avatar
d.arizona committed
918 919
                                                                <div style={{ display: 'flex', justifyContent: 'center', marginTop: items.total_kpi == null ? 50 : 0 }}>
                                                                    <div style={{ backgroundColor: items.performanceColor, textAlign: 'center', display: 'flex', justifyContent: 'center', width: 40, height: 21 }}>
d.arizona's avatar
d.arizona committed
920
                                                                        <Typography style={{ textAlign: 'center', color: '#4b4b4b' }}>{items.performanceScore}</Typography>
d.arizona's avatar
d.arizona committed
921
                                                                    </div>
d.arizona's avatar
d.arizona committed
922 923 924 925 926
                                                                </div>
                                                                <div style={{ display: 'flex', justifyContent: 'center' }}>
                                                                    <ReactSpeedometer
                                                                        maxSegmentLabels={0}
                                                                        segmentColors={[
d.arizona's avatar
d.arizona committed
927
                                                                            items.performanceColor,
d.arizona's avatar
d.arizona committed
928 929 930
                                                                            "#d8d8d8"
                                                                        ]}
                                                                        needleColor={"#4b4b4b"}
d.arizona's avatar
d.arizona committed
931
                                                                        value={Number(items.current_value).toFixed(2)}
d.arizona's avatar
d.arizona committed
932
                                                                        valueFormat={'.2f'}
d.arizona's avatar
d.arizona committed
933 934 935
                                                                        minValue={Number(items.low)}
                                                                        maxValue={Number(items.high)}
                                                                        customSegmentStops={[0, Number(items.current_value), 5]}
d.arizona's avatar
d.arizona committed
936 937 938 939 940 941 942
                                                                        width={200}
                                                                        height={140}
                                                                        ringWidth={25}
                                                                        textColor={'#4b4b4b'}
                                                                    />
                                                                </div>
                                                                <div style={{ backgroundColor: 'transparent', display: 'flex', marginTop: 20, placeContent: 'center' }}>
d.arizona's avatar
d.arizona committed
943
                                                                    {items.is_higher == '-' ?
d.arizona's avatar
d.arizona committed
944 945 946 947 948
                                                                        <div style={{ textAlign: '-webkit-center' }}>
                                                                            <Typography style={{ fontSize: 16, color: '#4b4b4b' }}> - </Typography>
                                                                        </div>
                                                                        :
                                                                        <div style={{ textAlign: '-webkit-center' }}>
d.arizona's avatar
d.arizona committed
949
                                                                            {items.is_higher == 'true' ?
d.arizona's avatar
d.arizona committed
950 951 952 953 954
                                                                                <img src={Images.up} /> : <img src={Images.down} />}
                                                                            <Typography style={{ fontSize: 16, color: '#4b4b4b' }}>vs Last Month</Typography>
                                                                        </div>
                                                                    }
                                                                </div>
d.arizona's avatar
d.arizona committed
955
                                                            </div>
d.arizona's avatar
d.arizona committed
956
                                                        </Link>
d.arizona's avatar
d.arizona committed
957 958 959 960 961 962 963 964
                                                    )
                                                })}
                                            </div>
                                        </div>
                                    )

                                })}
                            </div>
rifkaki's avatar
rifkaki committed
965 966 967 968
                            <div style={{ flex: 1, padding: 20, width: '100%' }}>
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Waiting Your Approval</Typography>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
969

Deni Rinaldi's avatar
Deni Rinaldi committed
970
                            </div>
rifkaki's avatar
rifkaki committed
971 972 973

                            <div style={{ flex: 1, padding: 20, width: '100%' }}>
                                <div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
974 975
                                    <MuiThemeProvider theme={getMuiTheme()}>
                                        <MUIDataTable
rifkaki's avatar
rifkaki committed
976 977
                                            data={this.state.listDashboard}
                                            columns={columns}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
978 979 980 981
                                            options={options}
                                        />
                                    </MuiThemeProvider>
                                </div>
rifkaki's avatar
rifkaki committed
982 983 984 985 986 987 988 989 990 991 992 993
                                <div style={{ marginTop: 20 }}>
                                    <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Master Budget & CAT</Typography>
                                    <div style={{ marginTop: 10, width: '100%' }}>
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={this.state.dataTableMB}
                                                columns={columnsMB}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    </div>
                                </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
994
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
995
                            {/* <div style={{ marginTop: 20 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
                                <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Status Laporan</Typography>
                                <div style={{ marginTop: 10, display: 'flex' }}>
                                    <div style={{ width: 280, height: 400, padding: 20, backgroundColor: 'white', borderRadius: 6, border: 'solid 1px #c4c4c4', marginRight: 25 }}>
                                        <Typography style={{ color: '#4b4b4b', fontSize: '24px', fontWeight: 'bold' }}>Budget Tahunan - 2021</Typography>
                                        <div style={{ textAlign: 'center' }}>
                                            <DonutChart
                                                innerRadius={70}
                                                outerRadius={100}
                                                transition={true}
                                                pieClass="pie1"
                                                displayTooltip={true}
                                                strokeWidth={3}
                                                data={dataChart} />
Deni Rinaldi's avatar
Deni Rinaldi committed
1009
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
                                        <div style={{ display: 'flex', width: '100%', marginTop: 10 }}>
                                            <div style={{ width: '33%' }}>
                                                <Typography style={{ color: '#656565', fontSize: '15px', textAlign: 'left' }}>Submit</Typography>
                                                <Typography style={{ color: '#656565', fontSize: '20px', textAlign: 'left' }}>92.8 %</Typography>
                                                <div style={{ display: 'flex' }} >
                                                    <img src={Images.red} />
                                                    <Typography style={{ color: '#656565', fontSize: '14px', textAlign: 'left' }}>-0.6%</Typography>
                                                </div>
                                            </div>
                                            <div style={{ width: '33%' }}>
                                                <Typography style={{ color: '#656565', fontSize: '15px', textAlign: 'left' }}>On Time</Typography>
                                                <Typography style={{ color: '#656565', fontSize: '20px', textAlign: 'left' }}>6.1 %</Typography>
                                                <div style={{ display: 'flex' }} >
                                                    <img src={Images.green} />
                                                    <Typography style={{ color: '#656565', fontSize: '14px', textAlign: 'left' }}>0.7%</Typography>
                                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1026

Deni Rinaldi's avatar
Deni Rinaldi committed
1027 1028 1029 1030 1031 1032 1033 1034 1035
                                            </div>
                                            <div style={{ width: '33%' }}>
                                                <Typography style={{ color: '#656565', fontSize: '15px', textAlign: 'left' }}>Overdue</Typography>
                                                <Typography style={{ color: '#656565', fontSize: '20px', textAlign: 'left' }}>1.1 %</Typography>
                                                <div style={{ display: 'flex' }} >
                                                    <img src={Images.green} />
                                                    <Typography style={{ color: '#656565', fontSize: '14px', textAlign: 'left' }}>0.1%</Typography>
                                                </div>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1036 1037
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
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

                                    <div style={{ width: 280, height: 400, padding: 20, backgroundColor: 'white', borderRadius: 6, border: 'solid 1px #c4c4c4', marginRight: 25 }}>
                                        <Typography style={{ color: '#4b4b4b', fontSize: '24px', fontWeight: 'bold' }}>Laporan Bulanan - Oct 2020</Typography>
                                        <div style={{ textAlign: 'center' }}>
                                            <DonutChart
                                                innerRadius={70}
                                                outerRadius={100}
                                                transition={true}
                                                pieClass="pie5"
                                                displayTooltip={true}
                                                strokeWidth={3}
                                                data={dataChart2}
                                            />
                                        </div>
                                        <div style={{ display: 'flex', width: '100%', marginTop: 10 }}>
                                            <div style={{ width: '33%' }}>
                                                <Typography style={{ color: '#656565', fontSize: '15px', textAlign: 'left' }}>Submit</Typography>
                                                <Typography style={{ color: '#656565', fontSize: '20px', textAlign: 'left' }}>92.8 %</Typography>
                                                <div style={{ display: 'flex' }} >
                                                    <img src={Images.red} />
                                                    <Typography style={{ color: '#656565', fontSize: '14px', textAlign: 'left' }}>-0.6%</Typography>
                                                </div>
                                            </div>
                                            <div style={{ width: '33%' }}>
                                                <Typography style={{ color: '#656565', fontSize: '15px', textAlign: 'left' }}>On Time</Typography>
                                                <Typography style={{ color: '#656565', fontSize: '20px', textAlign: 'left' }}>6.1 %</Typography>
                                                <div style={{ display: 'flex' }} >
                                                    <img src={Images.green} />
                                                    <Typography style={{ color: '#656565', fontSize: '14px', textAlign: 'left' }}>0.7%</Typography>
                                                </div>

                                            </div>
                                            <div style={{ width: '33%' }}>
                                                <Typography style={{ color: '#656565', fontSize: '15px', textAlign: 'left' }}>Overdue</Typography>
                                                <Typography style={{ color: '#656565', fontSize: '20px', textAlign: 'left' }}>1.1 %</Typography>
                                                <div style={{ display: 'flex' }} >
                                                    <img src={Images.green} />
                                                    <Typography style={{ color: '#656565', fontSize: '14px', textAlign: 'left' }}>0.1%</Typography>
                                                </div>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1078 1079
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091
                                    <div style={{ width: 280, height: 400, padding: 20, backgroundColor: 'white', borderRadius: 6, border: 'solid 1px #c4c4c4', }}>
                                        <Typography style={{ color: '#4b4b4b', fontSize: '24px', fontWeight: 'bold', height: 71 }}>Lainnya</Typography>
                                        <div style={{ textAlign: 'center' }}>
                                            <DonutChart
                                                innerRadius={70}
                                                outerRadius={100}
                                                transition={true}
                                                pieClass="pie2"
                                                displayTooltip={true}
                                                strokeWidth={3}
                                                data={dataChart3}
                                            />
Deni Rinaldi's avatar
Deni Rinaldi committed
1092
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
                                        <div style={{ display: 'flex', width: '100%', marginTop: 10 }}>
                                            <div style={{ width: '33%' }}>
                                                <Typography style={{ color: '#656565', fontSize: '15px', textAlign: 'left' }}>Submit</Typography>
                                                <Typography style={{ color: '#656565', fontSize: '20px', textAlign: 'left' }}>92.8 %</Typography>
                                                <div style={{ display: 'flex' }} >
                                                    <img src={Images.red} />
                                                    <Typography style={{ color: '#656565', fontSize: '14px', textAlign: 'left' }}>-0.6%</Typography>
                                                </div>
                                            </div>
                                            <div style={{ width: '33%' }}>
                                                <Typography style={{ color: '#656565', fontSize: '15px', textAlign: 'left' }}>On Time</Typography>
                                                <Typography style={{ color: '#656565', fontSize: '20px', textAlign: 'left' }}>6.1 %</Typography>
                                                <div style={{ display: 'flex' }} >
                                                    <img src={Images.green} />
                                                    <Typography style={{ color: '#656565', fontSize: '14px', textAlign: 'left' }}>0.7%</Typography>
                                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1109

Deni Rinaldi's avatar
Deni Rinaldi committed
1110 1111 1112 1113 1114 1115 1116 1117 1118
                                            </div>
                                            <div style={{ width: '33%' }}>
                                                <Typography style={{ color: '#656565', fontSize: '15px', textAlign: 'left' }}>Overdue</Typography>
                                                <Typography style={{ color: '#656565', fontSize: '20px', textAlign: 'left' }}>1.1 %</Typography>
                                                <div style={{ display: 'flex' }} >
                                                    <img src={Images.green} />
                                                    <Typography style={{ color: '#656565', fontSize: '14px', textAlign: 'left' }}>0.1%</Typography>
                                                </div>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1119 1120 1121
                                        </div>
                                    </div>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1122
                            </div> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
1123
                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1124
                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1125 1126 1127 1128 1129
                    :
                    <div>
                        <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                            <Typography style={{ fontSize: '24px', color: 'white' }}>{this.state.userData === null ? '' : `Welcome, ${this.state.userData.fullname} !`}</Typography>
                        </div>
d.arizona's avatar
d.arizona committed
1130 1131 1132 1133 1134 1135
                        <div style={{ flex: 1, padding: 20, width: '100%' }}>
                            <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Dashboard CAT</Typography>
                            <div style={{ display: 'flex' }}>
                                <Autocomplete
                                    {...this.state.listMonthCAT}
                                    id="monthCAT"
d.arizona's avatar
d.arizona committed
1136
                                    onChange={(event, newInputValue) => this.setState({ monthCAT: newInputValue, loading: true, loading3: true }, () => {
d.arizona's avatar
d.arizona committed
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152
                                        this.getDashboardCAT()
                                        // if (this.state.isApprover === true) {
                                        //     this.getCompanySubmitted()
                                        // } else {
                                        // this.setState({ visibleTableHistory: false })
                                        // this.getRevision()
                                        // }
                                    })}
                                    disableClearable
                                    style={{ minWidth: 250, marginRight: 20 }}
                                    renderInput={(params) => <TextField {...params} label="Month CAT" margin="normal" style={{ marginTop: 7 }} />}
                                    value={this.state.monthCAT}
                                />
                                <Autocomplete
                                    {...this.state.listPeriodeCAT}
                                    id="periodeCAT"
d.arizona's avatar
d.arizona committed
1153
                                    onChange={(event, newInputValue) => this.setState({ periodeCAT: newInputValue, loading: true, loading3: true }, () => {
d.arizona's avatar
d.arizona committed
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
                                        this.getDashboardCAT()
                                        // if (this.state.isApprover === true) {
                                        //         this.getCompanySubmitted()
                                        // } else {
                                        // this.setState({ visibleTableHistory: false })
                                        // this.getRevision()
                                        // }
                                    })}
                                    disableClearable
                                    style={{ width: 250 }}
                                    renderInput={(params) => <TextField {...params} label="Periode CAT" margin="normal" style={{ marginTop: 7 }} />}
                                    value={this.state.periodeCAT}
                                />
                            </div>
d.arizona's avatar
d.arizona committed
1168
                            {this.state.dataDashboardCAT.map((item, index) => {
d.arizona's avatar
d.arizona committed
1169 1170
                                return (
                                    <div>
d.arizona's avatar
d.arizona committed
1171
                                        <Typography style={{ color: '#656565', fontSize: '16px', marginTop: 20 }}>{item.item_business}</Typography>
d.arizona's avatar
d.arizona committed
1172
                                        <div style={{ display: 'flex', overflowX: 'scroll', width: this.props.width * 0.95 }}>
d.arizona's avatar
d.arizona committed
1173
                                            {item.category.map((items, indexs) => {
d.arizona's avatar
d.arizona committed
1174 1175 1176 1177 1178
                                                return (
                                                    <Link to={{
                                                        pathname: `/home/cat-dashboard/`,
                                                        state: {
                                                            userType: 'user',
d.arizona's avatar
d.arizona committed
1179
                                                            rawData: { month: this.state.monthCAT.month_id, periode: this.state.periodeCAT.value, companyId: items.company_id }
d.arizona's avatar
d.arizona committed
1180 1181
                                                        }
                                                    }}>
d.arizona's avatar
d.arizona committed
1182
                                                        <div style={{ padding: 10, backgroundColor: '#fff', height: 350, borderRadius: 6, paddingBottom: 20, margin: 10, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', width: 250, marginRight: indexs == item.category.length - 1 ? 25 : 0, marginLeft: indexs == 0 ? 5 : 25 }}>
d.arizona's avatar
d.arizona committed
1183
                                                            {/* <span style={{ fontSize: '17px', color: this.state.selectIndex === index ? '#fff' : '#7e8085', maxWidth: 100 }}>{item.category_name}</span> */}
d.arizona's avatar
d.arizona committed
1184
                                                            <div style={{ fontSize: '17px', width: '100%', height: 25 }}>
d.arizona's avatar
d.arizona committed
1185
                                                                <Typography style={{ textAlign: 'left', color: '#4b4b4b' }}>{items.category_name}</Typography>
d.arizona's avatar
d.arizona committed
1186
                                                            </div>
d.arizona's avatar
d.arizona committed
1187
                                                            {items.total_kpi != null &&
d.arizona's avatar
d.arizona committed
1188
                                                                <div style={{ width: '100%', display: 'flex', justifyContent: 'center', marginTop: 10 }}>
d.arizona's avatar
d.arizona committed
1189
                                                                    <span style={{ textAlign: 'center', fontSize: '18px', color: "#fff" }}>{items.total_kpi}</span>
d.arizona's avatar
d.arizona committed
1190 1191
                                                                    {/* <span style={{ textAlign: 'center', fontSize: '11px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>KPIs</span> */}
                                                                </div>}
d.arizona's avatar
d.arizona committed
1192 1193
                                                            <div style={{ display: 'flex', justifyContent: 'center', marginTop: items.total_kpi == null ? 50 : 0 }}>
                                                                <div style={{ backgroundColor: items.performanceColor, textAlign: 'center', display: 'flex', justifyContent: 'center', width: 40, height: 21 }}>
d.arizona's avatar
d.arizona committed
1194
                                                                    <Typography style={{ textAlign: 'center', color: '#4b4b4b' }}>{items.performanceScore}</Typography>
d.arizona's avatar
d.arizona committed
1195 1196
                                                                </div>
                                                            </div>
d.arizona's avatar
d.arizona committed
1197
                                                            {!this.state.loading3 && <div style={{ display: 'flex', justifyContent: 'center' }}>
d.arizona's avatar
d.arizona committed
1198 1199 1200
                                                                <ReactSpeedometer
                                                                    maxSegmentLabels={0}
                                                                    segmentColors={[
d.arizona's avatar
d.arizona committed
1201
                                                                        items.performanceColor,
d.arizona's avatar
d.arizona committed
1202 1203 1204
                                                                        "#d8d8d8"
                                                                    ]}
                                                                    needleColor={"#4b4b4b"}
d.arizona's avatar
d.arizona committed
1205
                                                                    value={Number(items.current_value).toFixed(2)}
d.arizona's avatar
d.arizona committed
1206
                                                                    valueFormat={'.2f'}
d.arizona's avatar
d.arizona committed
1207 1208 1209
                                                                    minValue={Number(items.low)}
                                                                    maxValue={Number(items.high)}
                                                                    customSegmentStops={[0, Number(items.current_value), 5]}
d.arizona's avatar
d.arizona committed
1210 1211 1212 1213 1214
                                                                    width={200}
                                                                    height={140}
                                                                    ringWidth={25}
                                                                    textColor={'#4b4b4b'}
                                                                />
d.arizona's avatar
d.arizona committed
1215
                                                            </div>}
d.arizona's avatar
d.arizona committed
1216
                                                            <div style={{ backgroundColor: 'transparent', display: 'flex', marginTop: 20, placeContent: 'center' }}>
d.arizona's avatar
d.arizona committed
1217
                                                                {items.is_higher == '-' ?
d.arizona's avatar
d.arizona committed
1218 1219 1220 1221 1222
                                                                    <div style={{ textAlign: '-webkit-center' }}>
                                                                        <Typography style={{ fontSize: 16, color: '#4b4b4b' }}> - </Typography>
                                                                    </div>
                                                                    :
                                                                    <div style={{ textAlign: '-webkit-center' }}>
d.arizona's avatar
d.arizona committed
1223
                                                                        {items.is_higher == 'true' ?
d.arizona's avatar
d.arizona committed
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238
                                                                            <img src={Images.up} /> : <img src={Images.down} />}
                                                                        <Typography style={{ fontSize: 16, color: '#4b4b4b' }}>vs Last Month</Typography>
                                                                    </div>
                                                                }
                                                            </div>
                                                        </div>
                                                    </Link>
                                                )
                                            })}
                                        </div>
                                    </div>
                                )

                            })}
                        </div>
r.kurnia's avatar
r.kurnia committed
1239
                        {(this.state.accessMB || this.state.accessMR || this.state.accessRO || this.state.accessOL ) &&
d.arizona's avatar
d.arizona committed
1240
                            <div style={{ flex: 1, paddingLeft: 20, paddingRight: 20, paddingTop: 20, paddingBottom: 0, width: '100%' }}>
rifkaki's avatar
rifkaki committed
1241
                                <div style={{ display: 'flex' }}>
d.arizona's avatar
d.arizona committed
1242
                                    <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Tasks to be Completed</Typography>
rifkaki's avatar
rifkaki committed
1243
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1244
                            </div>
rifkaki's avatar
rifkaki committed
1245
                        }
r.kurnia's avatar
r.kurnia committed
1246
                        {(this.state.accessMB === false && this.state.accessMR === false && this.state.accessRO === false && this.state.accessOL === false ) &&
rifkaki's avatar
rifkaki committed
1247 1248 1249 1250 1251 1252
                            <div style={{ flex: 1, padding: 20, width: '100%' }}>
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>You don't have pending task</Typography>
                                </div>
                            </div>
                        }
r.kurnia's avatar
r.kurnia committed
1253
                        <div style={{ display: 'flex', overflowX: 'scroll', width: this.props.width * 0.95 }}>
rifkaki's avatar
rifkaki committed
1254
                            {this.state.accessMB &&
d.arizona's avatar
d.arizona committed
1255 1256 1257 1258 1259 1260 1261 1262 1263
                                <div style={{ flex: 1, padding: 20, width: '100%' }}>
                                    <div style={{ display: 'flex' }}>
                                        <Autocomplete
                                            {...this.state.listPeriodeMB}
                                            id="periodeMB"
                                            onChange={(event, newInputValue) => this.setState({ periodeMB: newInputValue, loading: true }, () => {
                                                // if (this.state.isApprover === true) {
                                                //         this.getCompanySubmitted()
                                                // } else {
d.arizona's avatar
d.arizona committed
1264 1265
                                                // this.setState({ visibleTableHistory: false })
                                                // this.getRevision()
d.arizona's avatar
d.arizona committed
1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300
                                                // }\
                                                this.getListUserSubcoMB()
                                            })}
                                            disableClearable
                                            style={{ width: 250 }}
                                            renderInput={(params) => <TextField {...params} label="Periode MB" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.periodeMB}
                                        />
                                    </div>
                                    <Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5 }}>
                                        <Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Master Budget ${this.state.valueSubmit}/${this.state.listSubcoMB.length}`}</Typography>
                                        {this.state.listSubcoMB.map((item, index) => {
                                            return (
                                                <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
                                                    <div style={{ display: 'flex' }}>
                                                        <img src={item.is_submit === true ? Images.dotDone : item.is_overdue === true ? Images.dotOverdue : Images.dotOpen} />
                                                        <Link to={{
                                                            pathname: `/home/master-budget/`,
                                                            state: {
                                                                userType: 'user',
                                                                rawData: item
                                                            }
                                                        }}>
                                                            <button
                                                                style={{
                                                                    backgroundColor: 'transparent',
                                                                    cursor: 'pointer',
                                                                    borderColor: 'transparent',
                                                                    margin: 5,
                                                                    outline: 'none'
                                                                }}>
                                                                <Typography style={{ marginLeft: 10, color: '#5198ea', fontSize: 13 }}>{item.company_name}</Typography>
                                                            </button>
                                                        </Link>
                                                    </div>
d.arizona's avatar
d.arizona committed
1301
                                                    {item.is_submit === false && item.is_overdue && (
d.arizona's avatar
d.arizona committed
1302 1303 1304 1305 1306 1307
                                                        <div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
                                                            <Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
                                                        </div>
                                                    )}
                                                </div>
                                            )
d.arizona's avatar
d.arizona committed
1308
                                        })}
d.arizona's avatar
d.arizona committed
1309
                                    </Paper>
d.arizona's avatar
d.arizona committed
1310
                                </div>
rifkaki's avatar
rifkaki committed
1311 1312
                            }
                            {this.state.accessMR &&
d.arizona's avatar
d.arizona committed
1313 1314 1315 1316 1317 1318 1319 1320 1321 1322
                                <div style={{ flex: 1, padding: 20, width: '100%' }}>
                                    <div style={{ display: 'flex' }}>
                                        <Autocomplete
                                            {...this.state.listMonth}
                                            id="month"
                                            onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
                                                this.getListUserSubcoMR()
                                                // if (this.state.isApprover === true) {
                                                //     this.getCompanySubmitted()
                                                // } else {
d.arizona's avatar
d.arizona committed
1323 1324
                                                // this.setState({ visibleTableHistory: false })
                                                // this.getRevision()
d.arizona's avatar
d.arizona committed
1325 1326 1327
                                                // }
                                            })}
                                            disableClearable
r.kurnia's avatar
r.kurnia committed
1328
                                            style={{ minWidth: 210, marginRight: 20 }}
d.arizona's avatar
d.arizona committed
1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339
                                            renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.month}
                                        />
                                        <Autocomplete
                                            {...this.state.listPeriodeMR}
                                            id="periodeMR"
                                            onChange={(event, newInputValue) => this.setState({ periodeMR: newInputValue, loading: true }, () => {
                                                this.getListUserSubcoMR()
                                                // if (this.state.isApprover === true) {
                                                //         this.getCompanySubmitted()
                                                // } else {
d.arizona's avatar
d.arizona committed
1340 1341
                                                // this.setState({ visibleTableHistory: false })
                                                // this.getRevision()
d.arizona's avatar
d.arizona committed
1342 1343 1344
                                                // }
                                            })}
                                            disableClearable
r.kurnia's avatar
r.kurnia committed
1345
                                            style={{ width: 210 }}
d.arizona's avatar
d.arizona committed
1346 1347 1348 1349 1350
                                            renderInput={(params) => <TextField {...params} label="Periode MR" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.periodeMR}
                                        />
                                    </div>
                                    <Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5 }}>
1351
                                        {!this.state.loading2 && <Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Monthly Report - ${this.state.month.month_value} ${this.state.periodeMR.value} ${this.state.valueSubmitMR}/${this.state.listSubcoMR.length}`}</Typography>}
d.arizona's avatar
d.arizona committed
1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363
                                        {this.state.listSubcoMR.map((item, index) => {
                                            return (
                                                <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
                                                    <div style={{ display: 'flex' }}>
                                                        <img src={item.is_submit === true ? Images.dotDone : item.is_overdue === true ? Images.dotOverdue : Images.dotOpen} />
                                                        <Link to={{
                                                            pathname: `/home/monthly-report/`,
                                                            state: {
                                                                userType: 'user',
                                                                rawData: item,
                                                                month: this.state.month
                                                            }
r.kurnia's avatar
r.kurnia committed
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437
                                                        }}>
                                                            <button
                                                                style={{
                                                                    backgroundColor: 'transparent',
                                                                    cursor: 'pointer',
                                                                    borderColor: 'transparent',
                                                                    margin: 5,
                                                                    outline: 'none'
                                                                }}>
                                                                <Typography style={{ marginLeft: 10, color: '#5198ea', fontSize: 13 }}>{item.company_name}</Typography>
                                                            </button>
                                                        </Link>
                                                    </div>
                                                    {item.is_submit === false && item.is_overdue && (
                                                        <div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
                                                            <Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
                                                        </div>
                                                    )}
                                                </div>
                                            )
                                        })}
                                    </Paper>
                                </div>
                            }
                            {this.state.accessRO &&
                                <div style={{ flex: 1, padding: 20, width: '100%' }}>
                                    <div style={{ display: 'flex' }}>
                                        <Autocomplete
                                            {...this.state.listPeriodeRO}
                                            id="periodeRO"
                                            onChange={(event, newInputValue) => this.setState({ periodeRO: newInputValue, loading: true }, () => {
                                                this.getListUserSubcoRO()
                                                // if (this.state.isApprover === true) {
                                                //         this.getCompanySubmitted()
                                                // } else {
                                                // this.setState({ visibleTableHistory: false })
                                                // this.getRevision()
                                                // }
                                            })}
                                            disableClearable
                                            style={{ minWidth: 210, marginRight: 20 }}
                                            renderInput={(params) => <TextField {...params} label="Periode RO" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.periodeRO}
                                        />
                                        <Autocomplete
                                            {...this.state.listQuarter}
                                            id="quartal"
                                            disabled={this.state.intent === 'Home' ? true : false}
                                            onChange={(event, newInputValue) => this.setState({ quarter: newInputValue, loading: true }, () => {
                                                this.getListUserSubcoRO()
                                                // this.setState({ visibleTableHistory: false })
                                                // if (this.state.listCompany == null) {
                                                //     this.getCompanySubmitted()
                                                // } else {
                                                //     this.getRevision()
                                                // }
                                            })}
                                            disableClearable
                                            style={{ width: 210 }}
                                            renderInput={(params) => <TextField {...params} label="Quarter" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.quarter}
                                        />
                                    </div>
                                    <Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5 }}>
                                        {!this.state.loading2 && <Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Rolling Outlook & CAT - ${this.state.periodeRO.value} ${this.state.quarter.value} ${this.state.valueSubmitRO}/${this.state.listSubcoRO.length}`}</Typography>}
                                        {this.state.listSubcoRO.map((item, index) => {
                                            return (
                                                <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
                                                    <div style={{ display: 'flex' }}>
                                                        <img src={item.is_submit === true ? Images.dotDone : item.is_overdue === true ? Images.dotOverdue : Images.dotOpen} />
                                                        <Link to={{
                                                            pathname: `/home/rolling-outlook/`,
                                                            state: {
                                                                userType: 'user',
r.kurnia's avatar
r.kurnia committed
1438
                                                                rawData: {...item, quarter: this.state.quarter.value},
r.kurnia's avatar
r.kurnia committed
1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485
                                                            }
                                                        }}>
                                                            <button
                                                                style={{
                                                                    backgroundColor: 'transparent',
                                                                    cursor: 'pointer',
                                                                    borderColor: 'transparent',
                                                                    margin: 5,
                                                                    outline: 'none'
                                                                }}>
                                                                <Typography style={{ marginLeft: 10, color: '#5198ea', fontSize: 13 }}>{item.company_name}</Typography>
                                                            </button>
                                                        </Link>
                                                    </div>
                                                    {item.is_submit === false && item.is_overdue && (
                                                        <div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
                                                            <Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
                                                        </div>
                                                    )}
                                                </div>
                                            )
                                        })}
                                    </Paper>
                                </div>
                            }
                            {this.state.accessOL &&
                                <div style={{ flex: 1, padding: 20, width: '100%' }}>
                                    <div style={{ display: 'flex' }}>
                                        <Autocomplete
                                            {...this.state.listPeriodeOL}
                                            id="periodeOL"
                                            onChange={(event, newInputValue) => this.setState({ periodeOL: newInputValue, loading: true }, () => {
                                                // if (this.state.isApprover === true) {
                                                //         this.getCompanySubmitted()
                                                // } else {
                                                // this.setState({ visibleTableHistory: false })
                                                // this.getRevision()
                                                // }\
                                                this.getListUserSubcoOL()
                                            })}
                                            disableClearable
                                            style={{ width: 250 }}
                                            renderInput={(params) => <TextField {...params} label="Periode OL" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.periodeOL}
                                        />
                                    </div>
                                    <Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5 }}>
r.kurnia's avatar
r.kurnia committed
1486
                                        {!this.state.loading2 && <Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Outlook Performance Appraisal - ${this.state.periodeOL.value} ${this.state.valueSubmit}/${this.state.listSubcoOL.length}`}</Typography>}
r.kurnia's avatar
r.kurnia committed
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497
                                        {this.state.listSubcoOL.map((item, index) => {
                                            return (
                                                <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
                                                    <div style={{ display: 'flex' }}>
                                                        <img src={item.is_submit === true ? Images.dotDone : item.is_overdue === true ? Images.dotOverdue : Images.dotOpen} />
                                                        <Link to={{
                                                            pathname: `/home/outlook-performance/`,
                                                            state: {
                                                                userType: 'user',
                                                                rawData: item
                                                            }
d.arizona's avatar
d.arizona committed
1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510
                                                        }}>
                                                            <button
                                                                style={{
                                                                    backgroundColor: 'transparent',
                                                                    cursor: 'pointer',
                                                                    borderColor: 'transparent',
                                                                    margin: 5,
                                                                    outline: 'none'
                                                                }}>
                                                                <Typography style={{ marginLeft: 10, color: '#5198ea', fontSize: 13 }}>{item.company_name}</Typography>
                                                            </button>
                                                        </Link>
                                                    </div>
d.arizona's avatar
d.arizona committed
1511
                                                    {item.is_submit === false && item.is_overdue && (
d.arizona's avatar
d.arizona committed
1512 1513 1514 1515 1516 1517
                                                        <div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
                                                            <Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
                                                        </div>
                                                    )}
                                                </div>
                                            )
d.arizona's avatar
d.arizona committed
1518
                                        })}
d.arizona's avatar
d.arizona committed
1519
                                    </Paper>
d.arizona's avatar
d.arizona committed
1520
                                </div>
rifkaki's avatar
rifkaki committed
1521
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1522 1523 1524
                        </div>
                    </div>
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1525 1526
            </div>
        );
1527

Deni Rinaldi's avatar
Deni Rinaldi committed
1528 1529 1530
    }
}

Deni Rinaldi's avatar
Deni Rinaldi committed
1531
export default HomePage;