Parameter.js 55.3 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";
Deni Rinaldi's avatar
Deni Rinaldi committed
5
import { InputBase, Snackbar, withStyles, Typography, Tooltip } from "@material-ui/core";
6
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';
a.bairuha's avatar
a.bairuha committed
13
import Constant from '../../../library/Constant';
Deni Rinaldi's avatar
Deni Rinaldi committed
14
import PopUpDelete from '../../../library/PopUpDelete';
d.arizona's avatar
d.arizona committed
15 16
import { css } from "@emotion/core";
import PropagateLoader from "react-spinners/PropagateLoader"
faisalhamdi's avatar
faisalhamdi committed
17

Deni Rinaldi's avatar
Deni Rinaldi committed
18 19 20 21 22 23 24 25 26
const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);

faisalhamdi's avatar
faisalhamdi committed
27 28 29
var ct = require("../../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
30
const options2 = ct.customOptions2();
faisalhamdi's avatar
faisalhamdi committed
31

32 33 34
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);

faisalhamdi's avatar
faisalhamdi committed
35 36 37 38 39 40
export default class Parameter extends Component {
    constructor(props) {
        super(props)
        this.state = {
            visibleCreate: false,
            visibleEdit: false,
41 42 43
            visibleParameter: true,
            popupError: false,
            data: [],
44 45 46
            dataTable: [],
            alert: false,
            tipeAlert: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
47 48 49
            messageAlert: '',
            create: false,
            edit: false,
d.arizona's avatar
d.arizona committed
50
            delete: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
51
            load: false,
d.arizona's avatar
d.arizona committed
52
            judul: '',
53 54
            loading: false,
            sizeUpload: "1"
faisalhamdi's avatar
faisalhamdi committed
55
        }
56
        this.fileHandler = this.fileHandler.bind(this);
faisalhamdi's avatar
faisalhamdi committed
57 58 59
    }

    componentDidMount() {
60
        this.getAllParameter()
Deni Rinaldi's avatar
Deni Rinaldi committed
61
        this.getPermission()
62 63 64 65 66 67 68 69 70 71
        this.getSizeUpload()
    }

    getSizeUpload(){
        let body = {
            group: 'MAX_FILE_SIZE',
            company_id: 0,
            type: 'MAX_FILE_SIZE'
        }
        api.create().getAllSettingByType(body).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
72
            // console.log(response.data.data[0]);
73 74 75
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
76
                        sizeUpload: response.data.data[0] ? response.data.data[0].value === undefined ? "1" : response.data.data[0].value : "1"
77 78 79 80
                    })
                }
            }
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
81 82 83 84 85 86 87
    }

    getPermission() {
        let payload = {
            menu: "parameters"
        }
        api.create().getPermission(payload).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
88
            // console.log(response)
Deni Rinaldi's avatar
Deni Rinaldi committed
89 90 91 92 93
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        create: response.data.data.create,
                        edit: response.data.data.edit,
d.arizona's avatar
d.arizona committed
94
                        delete: response.data.data.delete,
Deni Rinaldi's avatar
Deni Rinaldi committed
95 96 97 98 99 100 101
                        load: true
                    })
                } else {
                    this.setState({ load: true })
                }
            }
        })
102 103 104
    }

    getAllParameter() {
Deni Rinaldi's avatar
Deni Rinaldi committed
105
        this.setState({ loading: true })
106
        api.create().getAllParameter().then(response => {
107
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
108 109
                if (response.ok) {
                    if (response.data.status === "success") {
Deni Rinaldi's avatar
Deni Rinaldi committed
110
                        // console.log(response);
a.bairuha's avatar
a.bairuha committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
                        let data = response.data.data
                        let listData = data.map((item, index) => {
                            return [
                                item.setting_id,
                                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
                            ]
                        })
d.arizona's avatar
d.arizona committed
127 128
                        this.setState({ dataTable: listData, data: response.data.data }, () => {
                            setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
129
                                this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
130
                            }, 2000);
Deni Rinaldi's avatar
Deni Rinaldi committed
131
                        })
a.bairuha's avatar
a.bairuha committed
132
                    } else {
d.arizona's avatar
d.arizona committed
133
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
a.bairuha's avatar
a.bairuha committed
134
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
135 136 137 138 139 140 141
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
142
                } else {
d.arizona's avatar
d.arizona committed
143
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
144
                }
145
            } else {
d.arizona's avatar
d.arizona committed
146
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
147 148 149 150
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
151
    openPopUp(rowData, type) {
152 153
        if (type === 'edit') {
            this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
154
                rowData: rowData,
155 156
                visibleEdit: true
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
157 158 159 160 161
        } else if (type === 'delete') {
            this.setState({
                rowData: rowData,
                visibleDelete: true
            })
162 163
        } else {
            this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
164
                rowData: rowData,
165 166 167 168 169 170 171 172
                visibleCreate: true
            })
        }
    }

    updateParameter = (payload) => {
        this.setState({ visibleEdit: false })
        api.create().updateParameter(payload).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
173
            // console.log(response);
174
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
175 176 177 178 179 180
                if (response.ok) {
                    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' }, () => {
a.bairuha's avatar
a.bairuha committed
181
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
182 183 184 185 186 187 188
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
189
                } else {
a.bairuha's avatar
a.bairuha committed
190
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
191
                }
192
            } else {
193
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
194 195 196 197 198 199 200
            }
        })
    }

    createParameter = (payload) => {
        this.setState({ visibleCreate: false })
        api.create().createParameter(payload).then(response => {
201
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
202 203 204 205 206 207
                if (response.ok) {
                    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' }, () => {
a.bairuha's avatar
a.bairuha committed
208
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
209 210 211 212 213 214 215
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
216
                } else {
a.bairuha's avatar
a.bairuha committed
217
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
218
                }
219
            } else {
220
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
221 222 223 224 225 226
            }
        })
    }

    downloadFile = async () => {
        let res = await fetch(
d.arizona's avatar
d.arizona committed
227
            `${process.env.REACT_APP_URL_MAIN_BE}/public/attachment/download_file?fileName=ParameterTemplate&&fileType=xlsx`
228 229
        )
        res = await res.blob()
Deni Rinaldi's avatar
Deni Rinaldi committed
230
        // console.log(res)
231 232 233 234
        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
235
            a.download = 'Template Parameter.xlsx';
236 237 238 239 240 241
            a.click();
        }
    }

    downloadDataTable = async () => {
        let res = await fetch(
d.arizona's avatar
d.arizona committed
242
            `${process.env.REACT_APP_URL_MAIN_BE}/public/setting/export_setting`
243 244
        )
        res = await res.blob()
Deni Rinaldi's avatar
Deni Rinaldi committed
245
        // console.log(res)
246 247 248 249
        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
250
            a.download = 'Parameter.xlsx';
251 252 253 254
            a.click();
        }
    }

255 256 257 258 259 260
    handleInputChange(e) {
        this.setState({ search: e })
        let body = {
            "keyword": e
        }
        api.create().searchParameter(body).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
261
            // console.log(response.data);
a.bairuha's avatar
a.bairuha committed
262
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
                if (response.ok) {
                    if (response.data.status == 'success') {
                        let data = response.data.data
                        let listData = data.map((item, index) => {
                            return [
                                item.setting_id,
                                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, listData: response.data.data })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
284
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
285 286 287 288 289 290 291
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
a.bairuha's avatar
a.bairuha committed
292
                } else {
a.bairuha's avatar
a.bairuha committed
293
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
a.bairuha's avatar
a.bairuha committed
294
                }
295
            } else {
a.bairuha's avatar
a.bairuha committed
296
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
297 298 299 300
            }
        })
    }

301 302 303 304 305
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
Deni Rinaldi's avatar
Deni Rinaldi committed
306
                // console.log(err);
307 308
            }
            else {
Deni Rinaldi's avatar
Deni Rinaldi committed
309
                // let judul = resp.rows[2]
310 311 312 313 314 315
                let isi = resp.rows.slice(3)
                let payload = []
                isi.map((item, index) => {
                    if (item.length > 0) {
                        payload.push({
                            id: index + 1,
Deni Rinaldi's avatar
Deni Rinaldi committed
316
                            group: item[0] === undefined ? "" : item[0],
Deni Rinaldi's avatar
Deni Rinaldi committed
317 318
                            parameter: item[1] === undefined ? "" : item[1],
                            company: item[2] === undefined ? "" : item[2],
Deni Rinaldi's avatar
Deni Rinaldi committed
319 320 321 322 323
                            description: item[3] === undefined ? "" : item[3],
                            orders: item[4] === undefined ? "" : item[4],
                            value: item[5] === undefined ? "" : item[5],
                            min_value: item[6] === undefined ? "" : item[6],
                            max_value: item[7] === undefined ? "" : item[7],
Deni Rinaldi's avatar
Deni Rinaldi committed
324 325
                            start_date: item[8] === undefined ? "" : item[8],
                            end_date: item[9] === undefined ? "" : item[9],
326 327 328 329
                        })
                    }
                })
                let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
330
                    setting: payload
331
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
332
                // console.log(resp.rows[1]);
Deni Rinaldi's avatar
Deni Rinaldi committed
333
                this.setState({ payload: body, buttonError: false, judul: resp.rows[1] === undefined ? "" : resp.rows[1][0] })
Deni Rinaldi's avatar
Deni Rinaldi committed
334 335 336 337
            }
        });
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
338
    checkUpload() {
Deni Rinaldi's avatar
Deni Rinaldi committed
339
        api.create().checkUploadParameter(this.state.payload).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
340
            // console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
            if (response.data) {
                if (response.ok) {
                    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 = [
                            "Data",
                            {
                                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 })
a.bairuha's avatar
a.bairuha committed
371
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
372
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
373 374 375
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
376
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
Deni Rinaldi's avatar
Deni Rinaldi committed
377
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
378
                                                    </LightTooltip> :
Deni Rinaldi's avatar
Deni Rinaldi committed
379
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
380
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
381 382 383 384 385 386 387 388 389 390 391 392 393 394
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                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 })
a.bairuha's avatar
a.bairuha committed
395
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
396
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
397 398 399
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
400
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
Deni Rinaldi's avatar
Deni Rinaldi committed
401
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
402
                                                    </LightTooltip> :
Deni Rinaldi's avatar
Deni Rinaldi committed
403
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
404
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
405 406 407 408 409 410 411 412 413 414 415 416 417 418
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                name: "Company",
                                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 })
a.bairuha's avatar
a.bairuha committed
419
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
420
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
421 422 423
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
424
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
Deni Rinaldi's avatar
Deni Rinaldi committed
425
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
426
                                                    </LightTooltip> :
Deni Rinaldi's avatar
Deni Rinaldi committed
427
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
428
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
429 430 431 432 433 434 435 436 437 438 439 440 441 442
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                name: "Description",
                                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 })
a.bairuha's avatar
a.bairuha committed
443
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
444
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
445 446 447
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
448 449 450
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
                                                    </LightTooltip> :
Deni Rinaldi's avatar
Deni Rinaldi committed
451
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
452
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
453 454 455 456 457 458 459 460 461 462 463 464 465 466
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                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 })
a.bairuha's avatar
a.bairuha committed
467
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
468
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
469 470 471
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
472 473 474
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
                                                    </LightTooltip> :
Deni Rinaldi's avatar
Deni Rinaldi committed
475
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
476
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
477 478 479 480 481 482 483 484 485 486 487 488 489 490
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                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 })
a.bairuha's avatar
a.bairuha committed
491
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
492
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
493 494 495
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
496 497 498
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
                                                    </LightTooltip> :
Deni Rinaldi's avatar
Deni Rinaldi committed
499
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
500
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
501 502 503 504 505 506 507 508 509 510 511 512 513 514
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                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 })
a.bairuha's avatar
a.bairuha committed
515
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
516
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
517 518 519
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
520 521 522
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
                                                    </LightTooltip> :
Deni Rinaldi's avatar
Deni Rinaldi committed
523
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
524
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
525 526 527 528 529 530 531 532 533 534 535 536 537 538
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                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 })
a.bairuha's avatar
a.bairuha committed
539
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
540
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
541 542 543
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
544 545 546 547
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
                                                    </LightTooltip> :
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
548
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
549 550 551 552 553 554 555 556 557 558 559 560 561 562
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                name: "Valid To",
                                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 })
a.bairuha's avatar
a.bairuha committed
563
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
564
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
565 566 567
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
568
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
Deni Rinaldi's avatar
Deni Rinaldi committed
569
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
570
                                                    </LightTooltip> :
Deni Rinaldi's avatar
Deni Rinaldi committed
571
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
572
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
573 574 575 576 577 578 579 580 581 582 583 584 585 586
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                name: "Valid From",
                                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 })
a.bairuha's avatar
a.bairuha committed
587 588
                                            }
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
589 590 591
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
592
                                                    <LightTooltip title={tableMeta.rowData[11][check].message} arrow>
Deni Rinaldi's avatar
Deni Rinaldi committed
593
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
594
                                                    </LightTooltip> :
Deni Rinaldi's avatar
Deni Rinaldi committed
595
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
596 597 598
                                                }
                                            </div >
                                        );
a.bairuha's avatar
a.bairuha committed
599
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
600 601 602 603 604 605 606
                                }
                            },
                            {
                                name: "",
                                options: {
                                    display: false
                                }
a.bairuha's avatar
a.bairuha committed
607
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
608 609
                        ]

Deni Rinaldi's avatar
Deni Rinaldi committed
610
                        // console.log(dataRow);
611 612
                        this.setState({
                            dataLoaded: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
613 614
                            cols: columns,
                            rows: dataRow,
Deni Rinaldi's avatar
Deni Rinaldi committed
615
                            visibleUpload: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
616
                            visibleParameter: false
617
                        });
Deni Rinaldi's avatar
Deni Rinaldi committed
618 619
                    } else {
                        this.setState({ dataLoaded: true, cols: [], rows: [], alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
620
                            if (response.data.message.includes("Someone Logged In")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
621 622 623 624 625 626
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
627
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
                } else {
                    this.setState({
                        alert: true, messageAlert: response.data.message, tipeAlert: 'error',
                        dataLoaded: true,
                        cols: [],
                        rows: []
                    });
                }
            } else {
                this.setState({
                    alert: true, messageAlert: response.problem, tipeAlert: 'error',
                    dataLoaded: true,
                    cols: [],
                    rows: []
                });
643
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
644 645

        })
faisalhamdi's avatar
faisalhamdi committed
646 647
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
648 649
    uploadParameter() {
        api.create().uploadParameter(this.state.payload).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
650
            // console.log(response)
651
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
652 653 654 655 656 657
                if (response.ok) {
                    if (response.data.status === "success") {
                        this.getAllParameter()
                        this.setState({ visibleParameter: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
658
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
659 660 661 662 663 664 665
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
666
                } else {
a.bairuha's avatar
a.bairuha committed
667
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
668
                }
669 670
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
671
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
672 673 674
        })
    }

675 676 677 678
    closeAlert() {
        this.setState({ alert: false })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
679 680 681 682 683 684 685 686 687 688
    deleteParameter(payload) {
        let id = String(payload[1])
        api.create().deleteParameter(id).then(response => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === "success") {
                        this.getAllParameter()
                        this.setState({ visibleDelete: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
689
                            if (response.data.message.includes("Someone Logged In")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
706 707 708 709
    render() {
        const columns = [{
            name: "Action",
            options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
710
                sort: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
711
                filter: false,
faisalhamdi's avatar
faisalhamdi committed
712 713
                customBodyRender: (val, tableMeta) => {
                    return (
d.arizona's avatar
d.arizona committed
714
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
715
                            {this.state.edit &&
d.arizona's avatar
d.arizona committed
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733
                                <span>
                                    <a data-tip={'Edit'} data-for="edit">
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                marginRight: 15
                                            }}
                                            // onClick={() => console.log(tableMeta)}
                                            onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
                                        >
                                            <img src={Images.editCopy} />
                                        </button>
                                    </a>
                                    <ReactTooltip border={true} id="edit" place="bottom" type="light" effect="solid" />
                                </span>
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
734
                            {this.state.delete &&
d.arizona's avatar
d.arizona committed
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
                                <span>
                                    <a data-tip={'Delete'} data-for="delete">
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                            }}
                                            // onClick={() => console.log(tableMeta)}
                                            onClick={() => this.openPopUp(tableMeta.rowData, 'delete')}
                                        >
                                            <img src={Images.delete} />
                                        </button>
                                    </a>
                                    <ReactTooltip border={true} id="delete" place="bottom" type="light" effect="solid" />
                                </span>
                            }
                        </div >
Deni Rinaldi's avatar
Deni Rinaldi committed
753

faisalhamdi's avatar
faisalhamdi committed
754 755 756
                    );
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
757
        }, {
Deni Rinaldi's avatar
Deni Rinaldi committed
758 759 760 761 762
            name: "ID",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
763
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
764 765 766 767
                        </div >
                    );
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
768
        }, {
faisalhamdi's avatar
faisalhamdi committed
769 770 771 772 773
            name: "Group",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
774
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
775 776 777 778 779 780 781 782 783 784
                        </div >
                    );
                }
            }
        }, {
            name: "Parameter",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
785
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
786 787 788 789 790
                        </div >
                    );
                }
            }
        }, {
791
            name: "Company",
faisalhamdi's avatar
faisalhamdi committed
792 793 794 795
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
796
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
797 798 799 800 801
                        </div >
                    );
                }
            }
        }, {
802
            name: "Description",
faisalhamdi's avatar
faisalhamdi committed
803 804 805 806
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
807
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
808 809 810 811 812 813 814 815 816 817
                        </div >
                    );
                }
            }
        }, {
            name: "Order",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
818
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
819 820 821 822 823 824 825 826 827 828
                        </div >
                    );
                }
            }
        }, {
            name: "Value",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
829
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
830 831 832 833 834 835 836 837 838 839
                        </div >
                    );
                }
            }
        }, {
            name: "Min Value",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
840
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
841 842 843 844 845 846 847 848 849 850
                        </div >
                    );
                }
            }
        }, {
            name: "Max Value",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
851
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
852 853 854 855 856 857 858 859 860 861
                        </div >
                    );
                }
            }
        }, {
            name: "Status",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
862
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
863 864 865 866 867 868 869 870 871 872
                        </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"],
873
            ["", "-", "-", "-", "-", "-"]
faisalhamdi's avatar
faisalhamdi committed
874
        ]
d.arizona's avatar
d.arizona committed
875
        const loadingComponent = (
Deni Rinaldi's avatar
Deni Rinaldi committed
876 877 878 879 880 881 882
            <div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
d.arizona's avatar
d.arizona committed
883
            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
884
        );
faisalhamdi's avatar
faisalhamdi committed
885 886 887
        return (
            <div style={{ height: this.props.height }}>
                {/* <Row> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
888
                <div className={"main-color"} style={{ height: 195, width: '100%' }} />
889 890 891 892 893
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
894 895
                {this.state.visibleParameter === true ?
                    <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
896
                        {this.state.load && (
Deni Rinaldi's avatar
Deni Rinaldi committed
897 898
                            <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -182 }}>
                                <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '40%', }}>Parameter</label>
Deni Rinaldi's avatar
Deni Rinaldi committed
899
                                {/* <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
900 901 902 903 904 905 906 907
                                    <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' }}
                                    />
Deni Rinaldi's avatar
Deni Rinaldi committed
908
                                </div> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
909
                                <div style={{ width: '40%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972
                                    <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>
973
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
974 975

                        )}
976
                        <div style={{ padding: 25 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
977
                            {this.state.loading && loadingComponent}
978 979 980 981 982 983 984 985 986 987 988 989 990 991 992
                            <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
993
                        </div>
994
                        <div style={{ padding: 25 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
995
                            {this.state.dataLoaded && (
996 997 998 999 1000 1001 1002 1003
                                <MuiThemeProvider theme={getMuiTheme()}>
                                    <MUIDataTable
                                        theme={getMuiTheme()}
                                        data={this.state.rows}
                                        columns={this.state.cols}
                                        options={options2}
                                    />
                                </MuiThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
1004
                            )}
1005 1006
                        </div>
                        <div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
1007
                            <button
1008
                                type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
1009
                                onClick={() => this.setState({ visibleParameter: true, judul: "" })}
1010
                                style={{ marginRight: 20 }}
faisalhamdi's avatar
faisalhamdi committed
1011
                            >
1012
                                <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
1013
                                    <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
1014 1015 1016 1017
                                </div>
                            </button>
                            <button
                                type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
1018 1019
                                disabled={this.state.buttonError ? true : false}
                                onClick={() => this.uploadParameter()}
1020 1021 1022
                                style={{}}
                            >
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1023
                                    <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
1024
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1025 1026 1027
                            </button>
                        </div>
                    </div>
1028
                }
faisalhamdi's avatar
faisalhamdi committed
1029
                {this.state.visibleCreate && (
1030
                    <CreateParameter
faisalhamdi's avatar
faisalhamdi committed
1031
                        onClickClose={() => this.setState({ visibleCreate: false })}
1032
                        createParameter={this.createParameter.bind(this)}
faisalhamdi's avatar
faisalhamdi committed
1033 1034 1035 1036
                    />
                )}

                {this.state.visibleEdit && (
1037
                    <CreateParameter
faisalhamdi's avatar
faisalhamdi committed
1038 1039
                        type={"edit"}
                        onClickClose={() => this.setState({ visibleEdit: false })}
Deni Rinaldi's avatar
Deni Rinaldi committed
1040
                        data={this.state.rowData}
1041
                        updateParameter={this.updateParameter.bind(this)}
faisalhamdi's avatar
faisalhamdi committed
1042 1043
                    />
                )}
1044
                {this.state.popupError && (
Deni Rinaldi's avatar
Deni Rinaldi committed
1045
                    <PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
1046 1047 1048 1049
                )}
                {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
1050
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061
                                <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 })}
                                    >
1062
                                        <img src={Images.close} />
1063 1064 1065 1066 1067 1068 1069
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
1070
                                sizeUpload={Number(this.state.sizeUpload)}
1071
                                acceptedFiles={["xlsx"]}
1072 1073 1074 1075
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1076
                                onUpload={() => {
r.kurnia's avatar
r.kurnia committed
1077
                                    String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("DATA") && String(this.state.judul).includes("PARAMETER") ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1078 1079 1080
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
1081 1082 1083 1084
                            />
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094

                {this.state.visibleDelete && (
                    <PopUpDelete
                        rowData={this.state.rowData}
                        intent={'parameter'}
                        onClickClose={() => this.setState({ visibleDelete: false })}
                        onClickDelete={this.deleteParameter.bind(this)}
                    />
                )}

faisalhamdi's avatar
faisalhamdi committed
1095 1096 1097 1098
            </div>
        );
    }
}