ReportItems.js 57.7 KB
Newer Older
EKSAD's avatar
EKSAD committed
1
import React, { Component } from "react";
2
import { createMuiTheme, MuiThemeProvider, withStyles } from '@material-ui/core/styles';
EKSAD's avatar
EKSAD committed
3 4
import Images from "../../assets/Images";
import MUIDataTable from "mui-datatables";
5
import { InputBase, Snackbar } from "@material-ui/core";
EKSAD's avatar
EKSAD committed
6 7
import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload";
8
import MuiAlert from '@material-ui/lab/Alert';
EKSAD's avatar
EKSAD committed
9 10 11
import CreateReportItems from "./formReportItems/CreateReportItems";
import EditReportItems from "./formReportItems/EditReportItems";
import VisualReportItems from "./formReportItems/VisualReportItems";
EKSAD's avatar
EKSAD committed
12
import api from "../../api";
EKSAD's avatar
EKSAD committed
13 14
import ReactTooltip from "react-tooltip";
import PopUpFailedSave from "../../library/PopUpFailedSave";
a.bairuha's avatar
a.bairuha committed
15
import Constant from "../../library/Constant";
EKSAD's avatar
EKSAD committed
16 17 18 19 20 21

var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
const options2 = ct.customOptions2();

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

EKSAD's avatar
EKSAD committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38
export default class ReportItems extends Component {
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
            listData: [],
            data: [],
            search: "",
            itemReport: true,
            visualisasi: false,
            add: false,
            edit: false,
            dataLoaded: false,
            cols: null,
EKSAD's avatar
EKSAD committed
39
            rows: null,
40 41 42
            popupError: false,
            alert: false,
            tipeAlert: '',
a.bairuha's avatar
a.bairuha committed
43
            messageAlert: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
44 45 46
            buttonCreate: false,
            buttonEdit: false,
            load: false
EKSAD's avatar
EKSAD committed
47 48 49 50 51 52 53 54 55
        }

        this.fileHandler = this.fileHandler.bind(this);
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            if (err) {
EKSAD's avatar
EKSAD committed
56
                console.log(err);
EKSAD's avatar
EKSAD committed
57 58 59
            }
            else {
                let judul = resp.rows[0]
EKSAD's avatar
EKSAD committed
60 61 62
                let isi = resp.rows.slice(3)
                let payload = []
                isi.map((item, index) => {
63
                    if (item.length > 0) {
EKSAD's avatar
EKSAD committed
64 65 66 67 68
                        payload.push({
                            id: index + 1,
                            report: item[0],
                            company: item[1],
                            orders: item[2],
a.bairuha's avatar
a.bairuha committed
69
                            description: item[3] === undefined ? "-" : item[3],
a.bairuha's avatar
a.bairuha committed
70
                            parent: item[4] === undefined ? 0 : item[4],
Deni Rinaldi's avatar
Deni Rinaldi committed
71 72
                            uom: item[5] === undefined ? null : item[5],
                            weight: item[6] === undefined ? "" : item[6],
EKSAD's avatar
EKSAD committed
73 74
                            type_report: item[7],
                            formula: item[8],
Deni Rinaldi's avatar
Deni Rinaldi committed
75 76
                            condition_it_should_be: item[9] === undefined ? null : item[9],
                            condition_if_wrong: item[10] === undefined ? null : item[10],
EKSAD's avatar
EKSAD committed
77 78 79 80 81 82 83 84
                            start_date: item[11],
                            end_date: item[12],
                        })
                    }
                })
                let body = {
                    item_report: payload
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
85
                console.log(JSON.stringify(body))
Deni Rinaldi's avatar
Deni Rinaldi committed
86
                this.setState({ payload: body, buttonError: false })
EKSAD's avatar
EKSAD committed
87
                api.create().checkUploadReportItems(body).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
88
                    console.log(response)
a.bairuha's avatar
a.bairuha committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
                    if (response.data) {
                        if (response.ok) {
                        if (response.data.status === "success") {
                            let dataRow = response.data.data.map((item, index) => {
                                return [
                                    index + 1,
                                    item.report,
                                    item.company,
                                    item.orders,
                                    item.description,
                                    item.parent,
                                    item.uom,
                                    item.weight,
                                    item.type_report,
                                    item.formula,
                                    item.condition_it_should_be,
                                    item.condition_if_wrong,
                                    item.start_date,
                                    item.end_date,
                                    item.error
                                ]
                            })
                            let columns = [
                                "Data",
                                {
                                    name: "Report Type",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('report'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
123
                                            }
a.bairuha's avatar
a.bairuha committed
124 125 126 127 128 129
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="reportname">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
130
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
131 132 133 134 135
                                                    }
                                                    <ReactTooltip border={true} id="reportname" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
136
                                    }
a.bairuha's avatar
a.bairuha committed
137 138 139 140 141 142 143 144 145 146 147
                                },
                                {
                                    name: "Company Name",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('company'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
148
                                            }
a.bairuha's avatar
a.bairuha committed
149 150 151 152 153 154
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="companyname">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
155
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
156 157 158 159 160
                                                    }
                                                    <ReactTooltip border={true} id="companyname" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
161
                                    }
a.bairuha's avatar
a.bairuha committed
162 163 164 165 166 167 168 169 170 171 172
                                },
                                {
                                    name: "Order",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('orders'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
173
                                            }
a.bairuha's avatar
a.bairuha committed
174 175 176 177 178 179
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="order">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
180
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
181 182 183 184 185
                                                    }
                                                    <ReactTooltip border={true} id="order" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
186
                                    }
a.bairuha's avatar
a.bairuha committed
187 188 189 190 191 192 193 194 195 196 197
                                },
                                {
                                    name: "Description",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('description'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
198
                                            }
a.bairuha's avatar
a.bairuha committed
199 200 201 202 203 204
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="desc">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
205
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
206 207 208 209 210
                                                    }
                                                    <ReactTooltip border={true} id="desc" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
211
                                    }
a.bairuha's avatar
a.bairuha committed
212 213 214 215 216 217 218 219 220 221 222
                                },
                                {
                                    name: "Parent ID",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('parent'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
223
                                            }
a.bairuha's avatar
a.bairuha committed
224 225 226 227 228 229
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="parents">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
230
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
231 232 233 234 235
                                                    }
                                                    <ReactTooltip border={true} id="parents" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
236
                                    }
a.bairuha's avatar
a.bairuha committed
237 238 239 240 241 242 243 244 245 246 247
                                },
                                {
                                    name: "UOM",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('uom'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
248
                                            }
a.bairuha's avatar
a.bairuha committed
249 250 251 252 253 254
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="uoms">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
255
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
256 257 258 259 260
                                                    }
                                                    <ReactTooltip border={true} id="uoms" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
261
                                    }
a.bairuha's avatar
a.bairuha committed
262 263 264 265 266 267 268 269 270 271 272
                                },
                                {
                                    name: "Weight",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('weight'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
273
                                            }
a.bairuha's avatar
a.bairuha committed
274 275 276 277 278 279
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="weights">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
280
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
281 282 283 284 285
                                                    }
                                                    <ReactTooltip border={true} id="weights" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
286
                                    }
a.bairuha's avatar
a.bairuha committed
287 288 289 290 291 292 293 294 295 296 297
                                },
                                {
                                    name: "Data Type",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('type_report'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
298
                                            }
a.bairuha's avatar
a.bairuha committed
299 300 301 302 303 304
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="datatype">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
305
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
306 307 308 309 310
                                                    }
                                                    <ReactTooltip border={true} id="datatype" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
311
                                    }
a.bairuha's avatar
a.bairuha committed
312 313 314 315 316 317 318 319 320 321 322
                                },
                                {
                                    name: "Formula",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('formula'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
323
                                            }
a.bairuha's avatar
a.bairuha committed
324 325 326 327 328 329
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="formulas">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
330
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
331 332 333 334 335
                                                    }
                                                    <ReactTooltip border={true} id="formulas" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
336
                                    }
a.bairuha's avatar
a.bairuha committed
337 338 339 340 341 342 343 344 345 346 347
                                },
                                {
                                    name: "True Value",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('condition_it_should_be'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
348
                                            }
a.bairuha's avatar
a.bairuha committed
349 350 351 352 353 354
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="values">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
355
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
356 357 358 359 360
                                                    }
                                                    <ReactTooltip border={true} id="values" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
361
                                    }
a.bairuha's avatar
a.bairuha committed
362 363 364 365 366 367 368 369 370 371 372
                                },
                                {
                                    name: "False Condition",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('condition_if_wrong'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
373
                                            }
a.bairuha's avatar
a.bairuha committed
374 375 376 377 378 379
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="conditions">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
380
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
381 382 383 384 385
                                                    }
                                                    <ReactTooltip border={true} id="conditions" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
386
                                    }
a.bairuha's avatar
a.bairuha committed
387 388 389 390 391 392 393 394 395 396 397
                                },
                                {
                                    name: "Valid From",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('start_date'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
398
                                            }
a.bairuha's avatar
a.bairuha committed
399 400 401 402 403 404
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="startdate">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
405
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
406 407 408 409 410
                                                    }
                                                    <ReactTooltip border={true} id="startdate" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
EKSAD's avatar
EKSAD committed
411
                                    }
a.bairuha's avatar
a.bairuha committed
412 413 414 415 416 417 418 419 420 421 422
                                },
                                {
                                    name: "Valid To",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[14] != null) {
                                                check = tableMeta.rowData[14].findIndex((val) => val.field.includes('end_date'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
EKSAD's avatar
EKSAD committed
423
                                            }
a.bairuha's avatar
a.bairuha committed
424 425 426 427 428 429
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[14] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[14][check].message} data-for="enddate">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
EKSAD's avatar
EKSAD committed
430
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
a.bairuha's avatar
a.bairuha committed
431 432 433 434 435 436 437 438 439 440 441
                                                    }
                                                    <ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
                                    }
                                },
                                {
                                    name: "",
                                    options: {
                                        display: false
EKSAD's avatar
EKSAD committed
442 443
                                    }
                                }
a.bairuha's avatar
a.bairuha committed
444
                            ]
EKSAD's avatar
EKSAD committed
445

a.bairuha's avatar
a.bairuha committed
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
                            console.log(dataRow);
                            this.setState({
                                dataLoaded: true,
                                cols: columns,
                                rows: dataRow
                            });
                        } else {
                            this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                                if (response.data.message.includes("Token")) {
                                    setTimeout(() => {
                                        localStorage.removeItem(Constant.TOKEN)
                                        window.location.reload();
                                    }, 1000);
                                }
                            })
                        }
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
464
                    }
a.bairuha's avatar
a.bairuha committed
465 466 467
                } else {
                    this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
                }
EKSAD's avatar
EKSAD committed
468 469
                    console.log(response);
                })
EKSAD's avatar
EKSAD committed
470 471 472 473
            }
        });
    }

EKSAD's avatar
EKSAD committed
474 475
    componentDidMount() {
        this.getData()
Deni Rinaldi's avatar
Deni Rinaldi committed
476
        this.getPermission()
a.bairuha's avatar
a.bairuha committed
477 478 479 480 481 482 483 484 485 486 487
    }

    getPermission() {
        let payload = {
            menu: "report items"
        }
        api.create().getPermission(payload).then(response => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
488 489 490
                        buttonCreate: response.data.data.create,
                        buttonEdit: response.data.data.edit,
                        load: true
a.bairuha's avatar
a.bairuha committed
491
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
492 493
                } else {
                    this.setState({ load: true })
a.bairuha's avatar
a.bairuha committed
494 495 496
                }
            }
        })
EKSAD's avatar
EKSAD committed
497
    }
EKSAD's avatar
EKSAD committed
498 499 500 501

    getData() {
        api.create().getReportItems().then((response) => {
            console.log(response)
502
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
                if (response.ok) {
                    if (response.data.status == 'success') {
                        let data = response.data.data
                        let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => {
                            return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_item_report_name, item.status]
                        })
                        this.setState({ dataTable: listData, listData: response.data.data })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Token")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
520
                } else {
a.bairuha's avatar
a.bairuha committed
521
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
522
                }
EKSAD's avatar
EKSAD committed
523
            } else {
524
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
525 526 527 528 529 530 531
            }
        })
    }

    openPopUp(index, type) {
        if (type === 'edit') {
            this.setState({
EKSAD's avatar
EKSAD committed
532
                rowData: index,
EKSAD's avatar
EKSAD committed
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
                edit: true
            })
        } else {
            this.setState({
                add: true
            })
        }
    }

    handleInputChange(e) {
        this.setState({ search: e })
        let body = {
            "keyword": e
        }
        api.create().searchReportItems(body).then(response => {
            // console.log(response.data);
549
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
                if (response.ok) {
                    if (response.data.status == 'success') {
                        let data = response.data.data
                        let listData = data.map((item, index) => {
                            return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_item_report_name, item.status]
                        })
                        this.setState({ dataTable: listData, listData: response.data.data })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Token")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
567
                } else {
a.bairuha's avatar
a.bairuha committed
568
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
569
                }
EKSAD's avatar
EKSAD committed
570
            } else {
571
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
572 573 574 575 576 577 578
            }
        })
    }

    createReportItems = (payload) => {
        this.setState({ add: false })
        api.create().createReportItems(payload).then(response => {
579
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
580 581 582 583 584 585 586 587 588 589 590 591 592 593
                if (response.ok) {
                    if (response.data.status == 'success') {
                        this.getData()
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Token")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
594
                } else {
a.bairuha's avatar
a.bairuha committed
595
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
596
                }
EKSAD's avatar
EKSAD committed
597
            } else {
598
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
599 600 601 602
            }
        })
    }

EKSAD's avatar
EKSAD committed
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
    downloadFile = async () => {
        let res = await fetch(
            "https://tia.eksad.com/tia-reporting-dev/public/attachment/download_file?fileName=ItemReportTemplate&&fileType=xlsx"
        )
        res = await res.blob()
        console.log(res)
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Template Report Item.xlsx';
            a.click();
        }
    }

    downloadDataTable = async () => {
        let res = await fetch(
            "https://tia.eksad.com/tia-reporting-dev/public/item_report/export_item_report"
        )
        res = await res.blob()
        console.log(res)
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
628
            a.download = 'Report Items.xlsx';
EKSAD's avatar
EKSAD committed
629 630 631 632
            a.click();
        }
    }

EKSAD's avatar
EKSAD committed
633 634 635
    updateReportItems = (payload) => {
        this.setState({ edit: false })
        api.create().updateReportItems(payload).then(response => {
636
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
637 638 639 640 641 642 643 644 645 646 647 648 649 650
                if (response.ok) {
                    if (response.data.status == 'success') {
                        this.getData()
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Token")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
651
                } else {
a.bairuha's avatar
a.bairuha committed
652
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
653
                }
EKSAD's avatar
EKSAD committed
654
            } else {
655
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
656
            }
EKSAD's avatar
EKSAD committed
657
        })
EKSAD's avatar
EKSAD committed
658
    }
EKSAD's avatar
EKSAD committed
659 660 661

    uploadReportItems() {
        api.create().uploadReportItems(this.state.payload).then(response => {
662
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
                if (response.ok) {
                    if (response.data.status === "success") {
                        // alert(response.data.message)
                        this.getData()
                        this.setState({ itemReport: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Token")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
678
                } else {
a.bairuha's avatar
a.bairuha committed
679
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })    
680
                }
681 682
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
683
            }
EKSAD's avatar
EKSAD committed
684 685
        })
    }
686

687 688 689 690
    closeAlert() {
        this.setState({ alert: false })
    }

EKSAD's avatar
EKSAD committed
691 692 693 694
    render() {
        const columns = [{
            name: "Action",
            options: {
EKSAD's avatar
EKSAD committed
695
                sort: false,
EKSAD's avatar
EKSAD committed
696 697 698
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
699
                            {this.state.buttonEdit && (
a.bairuha's avatar
a.bairuha committed
700 701 702 703 704 705 706
                                <button
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent'
                                    }}
                                    onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
707

a.bairuha's avatar
a.bairuha committed
708 709 710 711
                                >
                                    <img src={Images.editCopy} />
                                </button>
                            )}
EKSAD's avatar
EKSAD committed
712 713 714 715
                        </div >
                    );
                }
            }
EKSAD's avatar
EKSAD committed
716 717 718 719 720 721 722
        },
        {
            name: "ID",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
723
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
724 725 726 727 728 729
                        </div >
                    );
                }
            }
        },
        {
730
            name: "Report Type",
EKSAD's avatar
EKSAD committed
731 732 733 734
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
735
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
736 737 738 739 740 741
                        </div >
                    );
                }
            }
        },
        {
EKSAD's avatar
EKSAD committed
742
            name: "Company Name",
EKSAD's avatar
EKSAD committed
743 744 745 746
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
747
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
748 749 750 751 752 753 754 755 756 757 758
                        </div >
                    );
                }
            }
        },
        {
            name: "Order",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
759
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
760 761 762 763 764 765
                        </div >
                    );
                }
            }
        },
        {
766
            name: "Description",
EKSAD's avatar
EKSAD committed
767 768 769 770
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
771
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
772 773 774 775 776 777 778 779 780 781 782
                        </div >
                    );
                }
            }
        },
        {
            name: "Parent ID",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
783
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
784 785 786 787 788 789 790 791 792 793 794
                        </div >
                    );
                }
            }
        },
        {
            name: "UOM",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
795
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
796 797 798 799 800 801 802 803 804 805 806
                        </div >
                    );
                }
            }
        },
        {
            name: "Weight",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
807
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
808 809 810 811 812 813
                        </div >
                    );
                }
            }
        },
        {
814
            name: "Data Type",
EKSAD's avatar
EKSAD committed
815 816 817 818
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
819
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
820 821 822 823 824 825 826 827 828 829 830
                        </div >
                    );
                }
            }
        },
        {
            name: "Status",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
EKSAD's avatar
EKSAD committed
831
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
EKSAD's avatar
EKSAD committed
832 833 834 835
                        </div >
                    );
                }
            }
EKSAD's avatar
EKSAD committed
836
        }
837 838 839 840 841 842 843 844 845
        ]
        const data = [
            ["", "1", "KPI", "TIA", "1", "Financial Perspective", "0", "-", "35%", "Formula", "Aktif"],
            ["", "2", "KPI", "TIA", "2", "Trading Profit", "1", "Rp Bio", "35%", "Formula", "Aktif"],
            ["", "3", "KPI", "TIA", "3", "Revenue", "1", "Rp Bio", "0%", "Formula", "Aktif"],
            ["", "4", "KPI", "TIA", "4", "EBITDA", "1", "Rp Bio", "0%", "Formula", "Non Aktif"],
            ["", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"],
        ]

EKSAD's avatar
EKSAD committed
846
        return (
EKSAD's avatar
EKSAD committed
847 848
            <div style={{ height: this.props.height }}>
                {/* <Row> */}
EKSAD's avatar
EKSAD committed
849
                <div className={"main-color"} style={{ height: 195, width: '100%' }} />
850 851 852 853 854
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
EKSAD's avatar
EKSAD committed
855
                {this.state.itemReport === true ?
EKSAD's avatar
EKSAD committed
856
                    <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913
                        {this.state.load && (
                            <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -118 }}>
                                <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Report Items</label>
                                <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
                                    <img src={Images.searchBlack} style={{ marginRight: 10 }} />
                                    <InputBase
                                        style={{ width: '100%' }}
                                        placeholder="Search"
                                        value={this.state.search}
                                        onChange={(e) => this.handleInputChange(e.target.value)}
                                        inputProps={{ 'aria-label': 'naked' }}
                                    />
                                </div>
                                <div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                    <a data-tip={'Download Template'} data-for="template">
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                margin: 5
                                            }}
                                            onClick={() => this.downloadFile()}
                                        >
                                            <img src={Images.template} />
                                        </button>
                                    </a>
                                    <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                    {this.state.buttonCreate && (
                                        <a data-tip={'Upload'} data-for="upload">
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5
                                                }}
                                                onClick={() => null}
                                            >
                                                <img src={Images.upload} onClick={() => this.setState({ visibleUpload: true })} />
                                            </button>
                                        </a>
                                    )}
                                    <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                    <a data-tip={'Download'} data-for="download">
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                margin: 5
                                            }}
                                            onClick={() => this.downloadDataTable()}
                                        >
                                            <img src={Images.download} />
                                        </button>
                                    </a>
914
                                    <ReactTooltip border={true} id="visualisasi" place="bottom" type="light" effect="solid" />
Deni Rinaldi's avatar
Deni Rinaldi committed
915 916 917 918 919 920 921 922 923 924 925 926 927
                                    <a data-tip={'Visualization'} data-for="visualisasi">
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                margin: 5
                                            }}
                                            onClick={() => this.setState({ visualisasi: true, itemReport: false })}
                                        >
                                            <img src={Images.visualisasi} />
                                        </button>
                                    </a>
928
                                    <ReactTooltip border={true} id="tambah" place="bottom" type="light" effect="solid" />
Deni Rinaldi's avatar
Deni Rinaldi committed
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945
                                    {this.state.buttonCreate && (
                                        <a data-tip={'Add New'} data-for="tambah">
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5,
                                                    marginRight: 20
                                                }}
                                            >
                                                <img src={Images.add} onClick={() => this.setState({ add: true })} />
                                            </button>
                                        </a>
                                    )}
                                    <ReactTooltip border={true} id="tambah" place="bottom" type="light" effect="solid" />
                                </div>
EKSAD's avatar
EKSAD committed
946
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
947
                        )}
EKSAD's avatar
EKSAD committed
948 949 950 951 952 953 954 955 956 957
                        <div style={{ padding: 25 }}>
                            <MuiThemeProvider theme={getMuiTheme()}>
                                <MUIDataTable
                                    theme={getMuiTheme()}
                                    data={this.state.dataTable}
                                    columns={columns}
                                    options={options}
                                />
                            </MuiThemeProvider>
                        </div>
EKSAD's avatar
EKSAD committed
958
                    </div>
959 960 961
                    :
                    this.state.visualisasi == true ?
                        <VisualReportItems
Deni Rinaldi's avatar
Deni Rinaldi committed
962 963
                            buttonCreate={this.state.buttonCreate}
                            buttonEdit={this.state.buttonEdit}
964 965 966
                            onClickClose={() => this.setState({ visualisasi: false, itemReport: true })}
                            height={this.props.height}
                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
                        :
                        <div>
                            <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
                                <label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
                            </div>
                            <div style={{ padding: 25 }}>
                                {this.state.dataLoaded && (
                                    <MuiThemeProvider theme={getMuiTheme()}>
                                        <MUIDataTable
                                            theme={getMuiTheme()}
                                            data={this.state.rows}
                                            columns={this.state.cols}
                                            options={options}
                                        />
                                    </MuiThemeProvider>
                                )}
                            </div>
                            <div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
                                <button
                                    type="button"
                                    onClick={() => this.setState({ itemReport: true })}
                                    style={{ marginRight: 20 }}
                                >
                                    <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                        <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
                                    </div>
                                </button>
                                <button
                                    type="button"
                                    onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadReportItems()}
                                    style={{}}
                                >
                                    <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                        <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
                                    </div>
                                </button>
                            </div>
EKSAD's avatar
EKSAD committed
1004 1005 1006
                        </div>
                }
                {this.state.add && (
1007
                    <CreateReportItems
EKSAD's avatar
EKSAD committed
1008
                        onClickClose={() => this.setState({ add: false })}
EKSAD's avatar
EKSAD committed
1009
                        data={this.state.listData}
EKSAD's avatar
EKSAD committed
1010
                        refresh={this.getData.bind(this)}
EKSAD's avatar
EKSAD committed
1011
                        createReportItems={this.createReportItems.bind(this)}
EKSAD's avatar
EKSAD committed
1012
                    />
1013
                )}
EKSAD's avatar
EKSAD committed
1014
                {this.state.edit && (
1015
                    <EditReportItems
EKSAD's avatar
EKSAD committed
1016
                        onClickClose={() => this.setState({ edit: false })}
EKSAD's avatar
EKSAD committed
1017
                        data={this.state.rowData}
EKSAD's avatar
EKSAD committed
1018
                        refresh={this.getData.bind(this)}
EKSAD's avatar
EKSAD committed
1019
                        updateReportItems={this.updateReportItems.bind(this)}
EKSAD's avatar
EKSAD committed
1020
                    />
1021
                )}
EKSAD's avatar
EKSAD committed
1022
                {this.state.popupError && (
1023 1024
                    <PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
                )}
EKSAD's avatar
EKSAD committed
1025 1026 1027
                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1028
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
EKSAD's avatar
EKSAD committed
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
                                    </div>
                                </div>
                                <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        className="btn btn-circle btn-white"
                                        onClick={() => this.setState({ visibleUpload: false })}
                                    >
1040
                                        <img src={Images.close} />
EKSAD's avatar
EKSAD committed
1041 1042 1043 1044 1045 1046 1047
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
1048
                                acceptedFiles={["xlsx"]}
EKSAD's avatar
EKSAD committed
1049 1050 1051 1052 1053 1054 1055 1056 1057
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
                                onUpload={() => this.setState({ visibleUpload: false, itemReport: false })}
                            />
                        </div>
                    </div>
                )}
1058
            </div>
EKSAD's avatar
EKSAD committed
1059 1060 1061
        );
    }
}