HomePage.js 25.4 KB
Newer Older
Deni Rinaldi's avatar
Deni Rinaldi committed
1
import React, { Component } from 'react';
Deni Rinaldi's avatar
Deni Rinaldi committed
2
import { Typography, MuiThemeProvider, createMuiTheme, Paper } from '@material-ui/core';
Deni Rinaldi's avatar
Deni Rinaldi committed
3
import MUIDataTable from "mui-datatables";
Deni Rinaldi's avatar
Deni Rinaldi committed
4
import Images from '../assets/Images';
Deni Rinaldi's avatar
Deni Rinaldi committed
5
import DonutChart from 'react-d3-donut';
d.arizona's avatar
d.arizona 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';
d.arizona's avatar
d.arizona committed
10
import { titleCase } from '../library/Utils';
Deni Rinaldi's avatar
Deni Rinaldi committed
11

Deni Rinaldi's avatar
Deni Rinaldi committed
12 13 14
var ct = require("../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());

Deni Rinaldi's avatar
Deni Rinaldi committed
15
class HomePage extends Component {
d.arizona's avatar
d.arizona committed
16 17 18
    constructor(props) {
        super(props)
        this.state = {
d.arizona's avatar
d.arizona committed
19
            userData: null,
Deni Rinaldi's avatar
Deni Rinaldi committed
20 21 22 23 24 25
            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
26
            ],
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
27
            isApprover: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
28 29
            listSubcoMB: [],
            valueSubmit: 0,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
30
            listdmb: [],
Deni Rinaldi's avatar
Deni Rinaldi committed
31 32
            dataTableMB: [],
            loading: false
d.arizona's avatar
d.arizona committed
33 34 35 36
        }
    }

    componentDidMount() {
Deni Rinaldi's avatar
Deni Rinaldi committed
37
        this.setState({ loading: true })
d.arizona's avatar
d.arizona committed
38 39 40
        let userId = localStorage.getItem(Constant.USER)
        api.create().getDetailUser(userId).then((response) => {
            if (response.data) {
Deni Rinaldi's avatar
Deni Rinaldi committed
41
                if (response.data.status === 'success') {
Deni Rinaldi's avatar
Deni Rinaldi committed
42
                    this.setState({ userData: response.data.data }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
43
                        // console.log(this.state.userData)
d.arizona's avatar
d.arizona committed
44 45 46 47
                    })
                }
            }
        })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
48 49 50 51 52 53 54 55 56 57
        // 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 })
        //     }
        // })
        this.getApprMat()
Deni Rinaldi's avatar
Deni Rinaldi committed
58
        this.getListUserSubco()
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
59
        this.getDashboardMB()
d.arizona's avatar
d.arizona committed
60
        this.getDashboard()
d.arizona's avatar
d.arizona committed
61 62
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
63
    componentDidUpdate() {
d.arizona's avatar
d.arizona committed
64
        window.onpopstate = e => {
Deni Rinaldi's avatar
Deni Rinaldi committed
65 66
            //your code...
            this.props.selectIndex('Home')
d.arizona's avatar
d.arizona committed
67 68 69
        }
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
70 71
    getListUserSubco() {
        api.create().getDashboardUser().then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
72
            // console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
73 74 75 76 77 78 79 80 81 82
            let valueSubmit = 0
            if (response.data) {
                if (response.data.status === "success") {
                    response.data.data.map((item, index) => {
                        if (item.is_submit === true) {
                            valueSubmit += 1
                        }
                    })
                    this.setState({
                        listSubcoMB: response.data.data,
Deni Rinaldi's avatar
Deni Rinaldi committed
83 84
                        valueSubmit,
                        loading: false
Deni Rinaldi's avatar
Deni Rinaldi committed
85 86 87 88 89 90
                    })
                }
            }
        })
    }

d.arizona's avatar
d.arizona committed
91 92 93
    getDashboard() {
        let listDashboard = []
        api.create().getDashboard().then((response) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
94
            // console.log(response);
d.arizona's avatar
d.arizona committed
95 96
            if (String(response.data.status).toLocaleLowerCase() == 'success') {
                let data = response.data.data
Deni Rinaldi's avatar
Deni Rinaldi committed
97
                data.map((item, index) => {
d.arizona's avatar
d.arizona committed
98 99
                    let statusConvert = item.status == 'approval_review'? 'Waiting For Review' : item.status == 'approval_proccess'? 'Waiting For Approval' : titleCase(item.status) 
                    listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} - ${item.periode}`, item.revision, item.status, statusConvert])
d.arizona's avatar
d.arizona committed
100
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
101
                this.setState({ listDashboard, rawData: response.data.data })
d.arizona's avatar
d.arizona committed
102 103
            }
        })
d.arizona's avatar
d.arizona committed
104 105
    }

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
106
    getApprMat() {
d.arizona's avatar
d.arizona committed
107
        this.setState({loading: true})
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
108
        api.create().getAM().then((response) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
109
            // console.log(response);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
110
            let actAM = response.data.data.map((item, index) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
111
                if (String(item.status).toLocaleLowerCase() == 'active') {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
112
                    return item
Deni Rinaldi's avatar
Deni Rinaldi committed
113

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
114 115 116 117
                }
            })
            let userId = localStorage.getItem(Constant.USER)
            let indexId = actAM.findIndex((val) => val.user_id == userId)
Deni Rinaldi's avatar
Deni Rinaldi committed
118
            if (indexId === -1) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
119
                this.setState({ isApprover: false })
Deni Rinaldi's avatar
Deni Rinaldi committed
120
                this.getListUserSubco()
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
121
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
122
            this.getDashboardMB()
Deni Rinaldi's avatar
Deni Rinaldi committed
123
            // console.log(actAM)
d.arizona's avatar
d.arizona committed
124
            this.setState({loading: false})
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
125 126 127
        })
    }

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
128
    getDashboardMB() {
Deni Rinaldi's avatar
Deni Rinaldi committed
129
        api.create().getDashboardMB().then((response) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
130
            // console.log(response)
Deni Rinaldi's avatar
Deni Rinaldi committed
131
            if (String(response.data.status).toLocaleLowerCase() == 'success') {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
132 133 134 135 136 137 138 139
                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
140
                this.setState({ dataTableMB: listdmb, loading: false })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
141 142 143 144
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
145
    render() {
d.arizona's avatar
d.arizona committed
146 147 148 149 150 151 152
        const columns = ["#", "ID", "Company", "Report Type", "Revision", 
        {
            name: "",
            options: {
                display: false
            }
        }, 'Status', {
Deni Rinaldi's avatar
Deni Rinaldi committed
153 154 155
            name: "Action",
            options: {
                customBodyRender: (val, tableMeta) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
156
                    // console.log(tableMeta);
Deni Rinaldi's avatar
Deni Rinaldi committed
157 158
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
159 160
                            <Link to={{
                                pathname: `/home/master-budget/`,
Deni Rinaldi's avatar
Deni Rinaldi committed
161
                                state: {
Deni Rinaldi's avatar
Deni Rinaldi committed
162 163 164 165
                                    userType: 'approver',
                                    rawData: this.state.rawData[tableMeta.rowIndex]
                                }
                            }}>
d.arizona's avatar
d.arizona committed
166 167 168 169 170 171 172 173 174 175 176 177
                                <button
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent',
                                        marginRight: 10
                                    }}
                                    onClick={() => null}
                                >
                                    <img src={Images.editCopy2} />
                                </button>
                            </Link>
Deni Rinaldi's avatar
Deni Rinaldi committed
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
                        </div >
                    );
                }
            }
        }]
        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 = {
            filter: false,
            sort: false,
            responsive: "scroll",
            print: false,
            download: false,
            selectableRows: false,
            viewColumns: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
198 199
            rowsPerPage: 5,
            search: false
Deni Rinaldi's avatar
Deni Rinaldi committed
200
        }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
201 202 203

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

Deni Rinaldi's avatar
Deni Rinaldi committed
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
        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
231 232 233 234 235 236 237 238 239 240
        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>
        );
Deni Rinaldi's avatar
Deni Rinaldi committed
241
        return (
d.arizona's avatar
d.arizona committed
242
            <div style={{ flex: 1, backgroundColor: '#f8f8f8', minHeight: this.props.height }}>
d.arizona's avatar
d.arizona committed
243
                {this.state.loading && loadingComponent}
Deni Rinaldi's avatar
Deni Rinaldi committed
244
                {this.state.isApprover === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
245
                    <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
246 247 248 249 250
                        <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>
                        <div style={{ flex: 1, padding: 20, width: '100%' }}>
                            <div style={{ display: 'flex' }}>
d.arizona's avatar
d.arizona committed
251
                                <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Waiting Your Approval</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
252 253
                            </div>

Deni Rinaldi's avatar
Deni Rinaldi committed
254 255 256 257 258 259 260 261
                        </div>
                        <div style={{ flex: 1, padding: 20, width: '100%' }}>
                            <div>
                                <MuiThemeProvider theme={getMuiTheme()}>
                                    <MUIDataTable
                                        data={this.state.listDashboard}
                                        columns={columns}
                                        options={options}
Deni Rinaldi's avatar
Deni Rinaldi committed
262
                                    />
Deni Rinaldi's avatar
Deni Rinaldi committed
263 264
                                </MuiThemeProvider>
                            </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
265 266 267 268 269 270 271 272 273 274 275 276
                            <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>
Deni Rinaldi's avatar
Deni Rinaldi committed
277
                            {/* <div style={{ marginTop: 20 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
278 279 280 281 282 283 284 285 286 287 288 289 290
                                <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
291
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
                                        <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
308

Deni Rinaldi's avatar
Deni Rinaldi committed
309 310 311 312 313 314 315 316 317
                                            </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
318 319
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359

                                    <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
360 361
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
362 363 364 365 366 367 368 369 370 371 372 373
                                    <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
374
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
                                        <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
391

Deni Rinaldi's avatar
Deni Rinaldi committed
392 393 394 395 396 397 398 399 400
                                            </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
401 402 403
                                        </div>
                                    </div>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
404
                            </div> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
405
                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
406
                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
407 408 409 410 411 412 413
                    :
                    <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>
                        <div style={{ flex: 1, padding: 20, width: '100%' }}>
                            <div style={{ display: 'flex' }}>
d.arizona's avatar
d.arizona committed
414
                                <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Tasks to be Complete</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
415 416 417
                            </div>
                        </div>
                        <div style={{ flex: 1, padding: 20, width: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
418 419 420
                            <Paper style={{ width: 450, padding: 20, borderRadius: 10 }}>
                                <Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Master Budget ${this.state.valueSubmit}/${this.state.listSubcoMB.length}`}</Typography>
                                {this.state.listSubcoMB.map((item, index) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
421 422 423
                                    return (
                                        <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
                                            <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
                                                <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>
Deni Rinaldi's avatar
Deni Rinaldi committed
443
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
444
                                            {item.is_overdue && (
Deni Rinaldi's avatar
Deni Rinaldi committed
445 446 447 448 449 450 451 452 453 454 455
                                                <div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
                                                    <Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
                                                </div>
                                            )}
                                        </div>
                                    )
                                })}
                            </Paper>
                        </div>
                    </div>
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
456 457
            </div>
        );
458

Deni Rinaldi's avatar
Deni Rinaldi committed
459 460 461
    }
}

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