Parameter.js 46.9 KB
Newer Older
faisalhamdi's avatar
faisalhamdi committed
1 2 3 4
import React, { Component } from 'react';
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import Images from '../../../assets/Images';
import MUIDataTable from "mui-datatables";
5 6
import { InputBase, Snackbar, withStyles } from "@material-ui/core";
import MuiAlert from '@material-ui/lab/Alert';
faisalhamdi's avatar
faisalhamdi committed
7
import CreateParameter from '../Parameter/CreateParameter';
8 9 10 11 12
import api from '../../../api';
import PopUpFailedSave from "../../../library/PopUpFailedSave";
import ReactTooltip from 'react-tooltip';
import UploadFile from "../../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
faisalhamdi's avatar
faisalhamdi committed
13 14 15 16

var ct = require("../../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
17
const options2 = ct.customOptions2();
faisalhamdi's avatar
faisalhamdi committed
18

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

faisalhamdi's avatar
faisalhamdi committed
22 23 24 25 26 27
export default class Parameter extends Component {
    constructor(props) {
        super(props)
        this.state = {
            visibleCreate: false,
            visibleEdit: false,
28 29 30
            visibleParameter: true,
            popupError: false,
            data: [],
31 32 33
            dataTable: [],
            alert: false,
            tipeAlert: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
34 35 36 37
            messageAlert: '',
            create: false,
            edit: false,
            load: false
faisalhamdi's avatar
faisalhamdi committed
38
        }
39
        this.fileHandler = this.fileHandler.bind(this);
faisalhamdi's avatar
faisalhamdi committed
40 41 42
    }

    componentDidMount() {
43
        this.getAllParameter()
Deni Rinaldi's avatar
Deni Rinaldi committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
        this.getPermission()
    }

    getPermission() {
        let payload = {
            menu: "parameters"
        }
        api.create().getPermission(payload).then(response => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        create: response.data.data.create,
                        edit: response.data.data.edit,
                        load: true
                    })
                } else {
                    this.setState({ load: true })
                }
            }
        })
65 66 67 68
    }

    getAllParameter() {
        api.create().getAllParameter().then(response => {
69 70 71 72 73 74
            if (response.data) {
                if (response.data.status === "success") {
                    console.log(response);
                    let data = response.data.data
                    let listData = data.map((item, index) => {
                        return [
Deni Rinaldi's avatar
Deni Rinaldi committed
75
                            item.setting_id,
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
                            item.setting_id,
                            item.setting_group,
                            item.setting_type,
                            item.company_name,
                            item.description,
                            item.order,
                            item.value,
                            item.min_value,
                            item.max_value,
                            item.status
                        ]
                    })
                    this.setState({ dataTable: listData, data: response.data.data })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
                }
92
            } else {
93
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
94 95 96 97
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
98
    openPopUp(rowData, type) {
99 100
        if (type === 'edit') {
            this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
101
                rowData: rowData,
102 103 104 105
                visibleEdit: true
            })
        } else {
            this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
106
                rowData: rowData,
107 108 109 110 111 112 113 114
                visibleCreate: true
            })
        }
    }

    updateParameter = (payload) => {
        this.setState({ visibleEdit: false })
        api.create().updateParameter(payload).then(response => {
115
            console.log(response);
116 117 118 119 120 121 122
            if (response.data) {
                if (response.data.status == 'success') {
                    this.getAllParameter()
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
                }
123
            } else {
124
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
125 126 127 128 129 130 131
            }
        })
    }

    createParameter = (payload) => {
        this.setState({ visibleCreate: false })
        api.create().createParameter(payload).then(response => {
132 133 134 135 136 137 138
            if (response.data) {
                if (response.data.status == 'success') {
                    this.getAllParameter()
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
                }
139
            } else {
140
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
141 142 143 144 145 146 147 148 149 150 151 152 153 154
            }
        })
    }

    downloadFile = async () => {
        let res = await fetch(
            "https://tia.eksad.com/tia-reporting-dev/public/attachment/download_file?fileName=ParameterTemplate&&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;
Deni Rinaldi's avatar
Deni Rinaldi committed
155
            a.download = 'Template Parameter.xlsx';
156 157 158 159 160 161 162 163 164 165 166 167 168 169
            a.click();
        }
    }

    downloadDataTable = async () => {
        let res = await fetch(
            "https://tia.eksad.com/tia-reporting-dev/public/setting/export_setting"
        )
        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;
Deni Rinaldi's avatar
Deni Rinaldi committed
170
            a.download = 'Parameter.xlsx';
171 172 173 174
            a.click();
        }
    }

175 176 177 178 179 180 181 182 183 184 185
    handleInputChange(e) {
        this.setState({ search: e })
        let body = {
            "keyword": e
        }
        api.create().searchParameter(body).then(response => {
            console.log(response.data);
            if (response.data.status == 'success') {
                let data = response.data.data
                let listData = data.map((item, index) => {
                    return [
Deni Rinaldi's avatar
Deni Rinaldi committed
186 187
                        item.setting_id,
                        item.setting_id,
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
                        item.setting_group,
                        item.setting_type,
                        item.company_name,
                        item.description,
                        item.order,
                        item.value,
                        item.min_value,
                        item.max_value,
                        item.status
                    ]
                })
                this.setState({ dataTable: listData, listData: response.data.data })
            } else {
                alert(response.data.message)
            }
        })
    }

206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                console.log(err);
            }
            else {
                let judul = resp.rows[2]
                let isi = resp.rows.slice(3)
                let payload = []
                isi.map((item, index) => {
                    if (item.length > 0) {
                        payload.push({
                            id: index + 1,
                            group: item[0],
                            parameter: item[1],
Deni Rinaldi's avatar
Deni Rinaldi committed
223
                            company: item[2],
224
                            description: item[3],
Deni Rinaldi's avatar
Deni Rinaldi committed
225
                            orders: item[4],
226 227 228 229 230 231 232 233 234
                            value: item[5],
                            min_value: item[6],
                            max_value: item[7],
                            start_date: item[8],
                            end_date: item[9],
                        })
                    }
                })
                let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
235
                    setting: payload
236
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
237
                this.setState({ payload: body, buttonError: false })
Deni Rinaldi's avatar
Deni Rinaldi committed
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
                api.create().checkUploadParameter(body).then(response => {
                    console.log(response);
                    if (response.data !== null) {
                        if (response.data.status === "success") {
                            let dataRow = response.data.data.map((item, index) => {
                                return [
                                    index + 1,
                                    item.group,
                                    item.parameter,
                                    item.company,
                                    item.description,
                                    item.orders,
                                    item.value,
                                    item.min_value,
                                    item.max_value,
                                    item.start_date,
                                    item.end_date,
                                    item.error,
                                ]
                            })
                            let columns = [
Deni Rinaldi's avatar
Deni Rinaldi committed
259
                                "Data",
Deni Rinaldi's avatar
Deni Rinaldi committed
260 261 262 263 264 265 266 267 268 269
                                {
                                    name: "Group",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('group'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
270
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
271 272 273 274 275 276
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="group">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
277
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
278 279 280 281 282
                                                    }
                                                    <ReactTooltip border={true} id="group" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
283
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
284 285 286 287 288 289 290 291 292 293 294
                                },
                                {
                                    name: "Parameter",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('parameter'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
295
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
296 297 298 299 300 301
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="parameter">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
302
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
303 304 305 306 307
                                                    }
                                                    <ReactTooltip border={true} id="parameter" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
308
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
309 310
                                },
                                {
311
                                    name: "Company",
Deni Rinaldi's avatar
Deni Rinaldi committed
312 313 314 315 316 317 318 319
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('company'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
320
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
321 322 323 324 325 326
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="company">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
327
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
328 329 330 331 332
                                                    }
                                                    <ReactTooltip border={true} id="company" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
333
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
334 335
                                },
                                {
336
                                    name: "Description",
Deni Rinaldi's avatar
Deni Rinaldi committed
337 338 339 340 341 342 343 344
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('description'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
345
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
346 347 348 349 350 351
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="description">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
352
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
353 354 355 356 357
                                                    }
                                                    <ReactTooltip border={true} id="description" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
358
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
359 360 361 362 363 364 365 366 367 368 369
                                },
                                {
                                    name: "Order",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('order'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
370
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
371 372 373 374 375 376
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="order">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
377
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
378 379 380 381 382
                                                    }
                                                    <ReactTooltip border={true} id="order" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
383
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
384 385 386 387 388 389 390 391 392 393 394
                                },
                                {
                                    name: "Value",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('value'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
395
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
396 397 398 399 400 401
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="value">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
402
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
403 404 405 406 407
                                                    }
                                                    <ReactTooltip border={true} id="value" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
408
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
409 410 411 412 413 414 415 416 417 418 419
                                },
                                {
                                    name: "Min Value",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('min_value'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
420
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
421 422 423 424 425 426
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="min_value">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
427
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
428 429 430 431 432
                                                    }
                                                    <ReactTooltip border={true} id="min_value" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
433
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
434 435 436 437 438 439 440 441 442 443 444
                                },
                                {
                                    name: "Max Value",
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('max_value'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
445
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
446 447 448 449 450 451
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="max_value">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
452
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
453 454 455 456 457
                                                    }
                                                    <ReactTooltip border={true} id="max_value" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
458
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
459 460
                                },
                                {
Deni Rinaldi's avatar
Deni Rinaldi committed
461
                                    name: "Valid To",
Deni Rinaldi's avatar
Deni Rinaldi committed
462 463 464 465 466 467 468 469
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('start_date'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
470
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
471 472 473 474 475 476
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="start_date">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
477
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
478 479 480 481 482
                                                    }
                                                    <ReactTooltip border={true} id="start_date" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
483
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
484 485
                                },
                                {
Deni Rinaldi's avatar
Deni Rinaldi committed
486
                                    name: "Valid From",
Deni Rinaldi's avatar
Deni Rinaldi committed
487 488 489 490 491 492 493 494
                                    options: {
                                        customBodyRender: (val, tableMeta) => {
                                            let check = null
                                            if (tableMeta.rowData[11] != null) {
                                                check = tableMeta.rowData[11].findIndex((val) => val.field.includes('end_date'))
                                                if (check > -1) {
                                                    this.setState({ buttonError: true })
                                                }
495
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
496 497 498 499 500 501
                                            return (
                                                <div style={{ display: 'flex' }}>
                                                    {tableMeta.rowData[11] != null && check > -1 ?
                                                        <a data-tip={tableMeta.rowData[11][check].message} data-for="enddate">
                                                            <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
                                                        </a> :
502
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
503 504 505 506 507 508 509 510 511 512 513
                                                    }
                                                    <ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" />
                                                </div >
                                            );
                                        }
                                    }
                                },
                                {
                                    name: "",
                                    options: {
                                        display: false
514 515
                                    }
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
516
                            ]
517

Deni Rinaldi's avatar
Deni Rinaldi committed
518 519 520 521 522 523 524 525 526 527 528 529 530 531
                            console.log(dataRow);
                            this.setState({
                                dataLoaded: true,
                                cols: columns,
                                rows: dataRow
                            });
                        } else {
                            this.setState({
                                dataLoaded: true,
                                cols: [],
                                rows: []
                            });
                        }
                    } else {
532 533
                        this.setState({
                            dataLoaded: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
534 535
                            cols: [],
                            rows: []
536 537 538 539 540 541 542
                        });
                    }

                })

            }
        });
faisalhamdi's avatar
faisalhamdi committed
543 544
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
545 546
    uploadParameter() {
        api.create().uploadParameter(this.state.payload).then(response => {
547 548 549 550
            if (response.data) {
                if (response.data.status === "success") {
                    console.log(response)
                    this.getAllParameter()
Deni Rinaldi's avatar
Deni Rinaldi committed
551
                    this.setState({ visibleParameter: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
552 553
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
554
                }
555 556
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
557
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
558 559 560
        })
    }

561 562 563 564
    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
565 566 567 568
    render() {
        const columns = [{
            name: "Action",
            options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
569
                sort: false,
faisalhamdi's avatar
faisalhamdi committed
570 571 572
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
573 574 575 576 577 578 579 580 581 582 583 584 585
                            {this.state.edit && (
                                <button
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent'
                                    }}
                                    onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
                                // onClick={()=> console.log(tableMeta)}
                                >
                                    <img src={Images.editCopy} />
                                </button>
                            )}
faisalhamdi's avatar
faisalhamdi committed
586 587 588 589
                        </div >
                    );
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
590
        }, {
Deni Rinaldi's avatar
Deni Rinaldi committed
591 592 593 594 595
            name: "ID",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
596
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
597 598 599 600
                        </div >
                    );
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
601
        }, {
faisalhamdi's avatar
faisalhamdi committed
602 603 604 605 606
            name: "Group",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
607
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
608 609 610 611 612 613 614 615 616 617
                        </div >
                    );
                }
            }
        }, {
            name: "Parameter",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
618
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
619 620 621 622 623
                        </div >
                    );
                }
            }
        }, {
624
            name: "Company",
faisalhamdi's avatar
faisalhamdi committed
625 626 627 628
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
629
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
630 631 632 633 634
                        </div >
                    );
                }
            }
        }, {
635
            name: "Description",
faisalhamdi's avatar
faisalhamdi committed
636 637 638 639
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
640
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
641 642 643 644 645 646 647 648 649 650
                        </div >
                    );
                }
            }
        }, {
            name: "Order",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
651
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
652 653 654 655 656 657 658 659 660 661
                        </div >
                    );
                }
            }
        }, {
            name: "Value",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
662
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
663 664 665 666 667 668 669 670 671 672
                        </div >
                    );
                }
            }
        }, {
            name: "Min Value",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
673
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
674 675 676 677 678 679 680 681 682 683
                        </div >
                    );
                }
            }
        }, {
            name: "Max Value",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
684
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
685 686 687 688 689 690 691 692 693 694
                        </div >
                    );
                }
            }
        }, {
            name: "Status",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
695
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
696 697 698 699 700 701 702 703 704 705
                        </div >
                    );
                }
            }
        }]
        const data = [
            ["", "LAPORAN_BULANAN", "BALANCE_SHEET", "Default", "Range Periode Lap", "1", "-", "1", "10", "Aktif"],
            ["", "LAPORAN_BULANAN", "BALANCE_SHEET", "Puninar Group", "Range Periode Lap", "2", "-", "1", "15", "Aktif"],
            ["", "LAPORAN_BULANAN", "BALANCE_SHEET", "TAP Group", "Range Periode Lap", "3", "-", "1", "15", "Aktif"],
            ["", "LAPORAN_BULANAN", "BALANCE_SHEET", "Daya Group", "Range Periode Lap", "4", "-", "1", "20", "Non Aktif"],
706
            ["", "-", "-", "-", "-", "-"]
faisalhamdi's avatar
faisalhamdi committed
707 708 709 710
        ]
        return (
            <div style={{ height: this.props.height }}>
                {/* <Row> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
711
                <div className={"main-color"} style={{ height: 195, width: '100%' }} />
712 713 714 715 716
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
717 718
                {this.state.visibleParameter === true ?
                    <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795
                        {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%', }}>Parameter</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.create && (
                                        <a data-tip={'Upload'} data-for="upload">
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5
                                                }}
                                                onClick={() => this.setState({ visibleUpload: true })}
                                            >
                                                <img src={Images.upload} />
                                            </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>
                                    <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                    {this.state.create && (
                                        <a data-tip={'Add New'} data-for="create">
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5,
                                                    marginRight: 20
                                                }}
                                                onClick={() => this.setState({ visibleCreate: true })}
                                            >
                                                <img src={Images.add} />
                                            </button>
                                        </a>
                                    )}

                                    <ReactTooltip multiline={false} border={true} id="create" place="bottom" type="light" effect="solid" />
                                </div>
796
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
797 798

                        )}
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814
                        <div style={{ padding: 25 }}>
                            <MuiThemeProvider theme={getMuiTheme()}>
                                <MUIDataTable
                                    theme={getMuiTheme()}
                                    data={this.state.dataTable}
                                    columns={columns}
                                    options={options}
                                />
                            </MuiThemeProvider>

                        </div>
                    </div>
                    :
                    <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>
faisalhamdi's avatar
faisalhamdi committed
815
                        </div>
816
                        <div style={{ padding: 25 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
817
                            {this.state.dataLoaded && (
818 819 820 821 822 823 824 825
                                <MuiThemeProvider theme={getMuiTheme()}>
                                    <MUIDataTable
                                        theme={getMuiTheme()}
                                        data={this.state.rows}
                                        columns={this.state.cols}
                                        options={options2}
                                    />
                                </MuiThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
826
                            )}
827 828
                        </div>
                        <div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
829
                            <button
830 831 832
                                type="button"
                                onClick={() => this.setState({ visibleParameter: true })}
                                style={{ marginRight: 20 }}
faisalhamdi's avatar
faisalhamdi committed
833
                            >
834
                                <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
835
                                    <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
836 837 838 839 840 841 842 843
                                </div>
                            </button>
                            <button
                                type="button"
                                onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadParameter()}
                                style={{}}
                            >
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
844
                                    <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
845
                                </div>
faisalhamdi's avatar
faisalhamdi committed
846 847 848
                            </button>
                        </div>
                    </div>
849
                }
faisalhamdi's avatar
faisalhamdi committed
850
                {this.state.visibleCreate && (
851
                    <CreateParameter
faisalhamdi's avatar
faisalhamdi committed
852
                        onClickClose={() => this.setState({ visibleCreate: false })}
853
                        createParameter={this.createParameter.bind(this)}
faisalhamdi's avatar
faisalhamdi committed
854 855 856 857
                    />
                )}

                {this.state.visibleEdit && (
858
                    <CreateParameter
faisalhamdi's avatar
faisalhamdi committed
859 860
                        type={"edit"}
                        onClickClose={() => this.setState({ visibleEdit: false })}
Deni Rinaldi's avatar
Deni Rinaldi committed
861
                        data={this.state.rowData}
862
                        updateParameter={this.updateParameter.bind(this)}
faisalhamdi's avatar
faisalhamdi committed
863 864
                    />
                )}
865
                {this.state.popupError && (
Deni Rinaldi's avatar
Deni Rinaldi committed
866
                    <PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
867 868 869 870
                )}
                {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
871
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
872 873 874 875 876 877 878 879 880 881 882
                                <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 })}
                                    >
883
                                        <img src={Images.close} />
884 885 886 887 888 889 890
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
891
                                acceptedFiles={["xlsx"]}
892 893 894 895 896 897 898 899 900
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
                                onUpload={() => this.setState({ visibleUpload: false, visibleParameter: false })}
                            />
                        </div>
                    </div>
                )}
faisalhamdi's avatar
faisalhamdi committed
901 902 903 904
            </div>
        );
    }
}