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 } 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 18 19 20

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

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

faisalhamdi's avatar
faisalhamdi committed
26 27 28 29 30 31
export default class Parameter extends Component {
    constructor(props) {
        super(props)
        this.state = {
            visibleCreate: false,
            visibleEdit: false,
32 33 34
            visibleParameter: true,
            popupError: false,
            data: [],
35 36 37
            dataTable: [],
            alert: false,
            tipeAlert: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
38 39 40
            messageAlert: '',
            create: false,
            edit: false,
d.arizona's avatar
d.arizona committed
41
            delete: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
42
            load: false,
d.arizona's avatar
d.arizona committed
43 44
            judul: '',
            loading: false
faisalhamdi's avatar
faisalhamdi committed
45
        }
46
        this.fileHandler = this.fileHandler.bind(this);
faisalhamdi's avatar
faisalhamdi committed
47 48 49
    }

    componentDidMount() {
50
        this.getAllParameter()
Deni Rinaldi's avatar
Deni Rinaldi committed
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,
d.arizona's avatar
d.arizona committed
65
                        delete: response.data.data.delete,
Deni Rinaldi's avatar
Deni Rinaldi committed
66 67 68 69 70 71 72
                        load: true
                    })
                } else {
                    this.setState({ load: true })
                }
            }
        })
73 74 75
    }

    getAllParameter() {
d.arizona's avatar
d.arizona committed
76
        this.setState({loading: true})
77
        api.create().getAllParameter().then(response => {
78
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
                if (response.ok) {
                    if (response.data.status === "success") {
                        console.log(response);
                        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
98 99 100 101 102
                        this.setState({ dataTable: listData, data: response.data.data }, () => {
                            setTimeout(() => {
                              this.setState({loading: false})
                            }, 2000);
                          })
a.bairuha's avatar
a.bairuha committed
103
                    } else {
d.arizona's avatar
d.arizona committed
104
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
a.bairuha's avatar
a.bairuha committed
105
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
106 107 108 109 110 111 112
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
113
                } else {
d.arizona's avatar
d.arizona committed
114
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
115
                }
116
            } else {
d.arizona's avatar
d.arizona committed
117
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
118 119 120 121
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
122
    openPopUp(rowData, type) {
123 124
        if (type === 'edit') {
            this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
125
                rowData: rowData,
126 127
                visibleEdit: true
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
128 129 130 131 132
        } else if (type === 'delete') {
            this.setState({
                rowData: rowData,
                visibleDelete: true
            })
133 134
        } else {
            this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
135
                rowData: rowData,
136 137 138 139 140 141 142 143
                visibleCreate: true
            })
        }
    }

    updateParameter = (payload) => {
        this.setState({ visibleEdit: false })
        api.create().updateParameter(payload).then(response => {
144
            console.log(response);
145
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
146 147 148 149 150 151
                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
152
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
153 154 155 156 157 158 159
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
160
                } else {
a.bairuha's avatar
a.bairuha committed
161
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
162
                }
163
            } else {
164
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
165 166 167 168 169 170 171
            }
        })
    }

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

    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
206
            a.download = 'Template Parameter.xlsx';
207 208 209 210 211 212 213 214 215 216 217 218 219 220
            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
221
            a.download = 'Parameter.xlsx';
222 223 224 225
            a.click();
        }
    }

226 227 228 229 230 231 232
    handleInputChange(e) {
        this.setState({ search: e })
        let body = {
            "keyword": e
        }
        api.create().searchParameter(body).then(response => {
            console.log(response.data);
a.bairuha's avatar
a.bairuha committed
233
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
                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
255
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
256 257 258 259 260 261 262
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
a.bairuha's avatar
a.bairuha committed
263
                } else {
a.bairuha's avatar
a.bairuha committed
264
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
a.bairuha's avatar
a.bairuha committed
265
                }
266
            } else {
a.bairuha's avatar
a.bairuha committed
267
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
268 269 270 271
            }
        })
    }

272 273 274 275 276 277 278 279
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                console.log(err);
            }
            else {
Deni Rinaldi's avatar
Deni Rinaldi committed
280
                // let judul = resp.rows[2]
281 282 283 284 285 286
                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
287
                            group: item[0] === undefined ? "" : item[0],
Deni Rinaldi's avatar
Deni Rinaldi committed
288 289
                            parameter: item[1] === undefined ? "" : item[1],
                            company: item[2] === undefined ? "" : item[2],
Deni Rinaldi's avatar
Deni Rinaldi committed
290 291 292 293 294
                            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
295 296
                            start_date: item[8] === undefined ? "" : item[8],
                            end_date: item[9] === undefined ? "" : item[9],
297 298 299 300
                        })
                    }
                })
                let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
301
                    setting: payload
302
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
303
                console.log(resp.rows[1]);
Deni Rinaldi's avatar
Deni Rinaldi committed
304
                this.setState({ payload: body, buttonError: false, judul: resp.rows[1] === undefined ? "" : resp.rows[1][0] })
Deni Rinaldi's avatar
Deni Rinaldi committed
305 306 307 308
            }
        });
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
309
    checkUpload() {
Deni Rinaldi's avatar
Deni Rinaldi committed
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
        api.create().checkUploadParameter(this.state.payload).then(response => {
            console.log(response);
            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
342
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
343
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
344 345 346 347
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
                                                    <a data-tip={tableMeta.rowData[11][check].message} data-for="group">
Deni Rinaldi's avatar
Deni Rinaldi committed
348
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
349
                                                    </a> :
Deni Rinaldi's avatar
Deni Rinaldi committed
350
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
351
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
                                                <ReactTooltip border={true} id="group" place="bottom" type="light" effect="solid" />
                                            </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
367
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
368
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
369 370 371 372
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
                                                    <a data-tip={tableMeta.rowData[11][check].message} data-for="parameter">
Deni Rinaldi's avatar
Deni Rinaldi committed
373
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
374
                                                    </a> :
Deni Rinaldi's avatar
Deni Rinaldi committed
375
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
376
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
                                                <ReactTooltip border={true} id="parameter" place="bottom" type="light" effect="solid" />
                                            </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
392
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
393
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
394 395 396 397
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
                                                    <a data-tip={tableMeta.rowData[11][check].message} data-for="company">
Deni Rinaldi's avatar
Deni Rinaldi committed
398
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
399
                                                    </a> :
Deni Rinaldi's avatar
Deni Rinaldi committed
400
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
401
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
                                                <ReactTooltip border={true} id="company" place="bottom" type="light" effect="solid" />
                                            </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
417
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
418
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
419 420 421 422 423 424 425
                                        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> :
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
426
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
                                                <ReactTooltip border={true} id="description" place="bottom" type="light" effect="solid" />
                                            </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
442
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
443
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
444 445 446 447 448 449 450
                                        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> :
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
451
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
                                                <ReactTooltip border={true} id="order" place="bottom" type="light" effect="solid" />
                                            </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
467
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
468
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
469 470 471 472 473 474 475
                                        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> :
                                                    <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 491
                                                <ReactTooltip border={true} id="value" place="bottom" type="light" effect="solid" />
                                            </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
492
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
493
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
494 495 496 497 498 499 500
                                        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> :
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
501
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
                                                <ReactTooltip border={true} id="min_value" place="bottom" type="light" effect="solid" />
                                            </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
517
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
518
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
519 520 521 522 523 524 525
                                        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> :
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
526
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
                                                <ReactTooltip border={true} id="max_value" place="bottom" type="light" effect="solid" />
                                            </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
542
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
543
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
544 545 546 547
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
                                                    <a data-tip={tableMeta.rowData[11][check].message} data-for="start_date">
Deni Rinaldi's avatar
Deni Rinaldi committed
548
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
549
                                                    </a> :
Deni Rinaldi's avatar
Deni Rinaldi committed
550
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
551
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
                                                <ReactTooltip border={true} id="start_date" place="bottom" type="light" effect="solid" />
                                            </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
567 568
                                            }
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
569 570 571 572
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[11] != null && check > -1 ?
                                                    <a data-tip={tableMeta.rowData[11][check].message} data-for="enddate">
Deni Rinaldi's avatar
Deni Rinaldi committed
573
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
574
                                                    </a> :
Deni Rinaldi's avatar
Deni Rinaldi committed
575
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
576 577 578 579
                                                }
                                                <ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" />
                                            </div >
                                        );
a.bairuha's avatar
a.bairuha committed
580
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
581 582 583 584 585 586 587
                                }
                            },
                            {
                                name: "",
                                options: {
                                    display: false
                                }
a.bairuha's avatar
a.bairuha committed
588
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
589 590 591
                        ]

                        console.log(dataRow);
592 593
                        this.setState({
                            dataLoaded: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
594 595
                            cols: columns,
                            rows: dataRow,
Deni Rinaldi's avatar
Deni Rinaldi committed
596
                            visibleUpload: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
597
                            visibleParameter: false
598
                        });
Deni Rinaldi's avatar
Deni Rinaldi committed
599 600
                    } else {
                        this.setState({ dataLoaded: true, cols: [], rows: [], alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
601
                            if (response.data.message.includes("Someone Logged In")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
602 603 604 605 606 607
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
608
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
                } 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: []
                });
624
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
625 626

        })
faisalhamdi's avatar
faisalhamdi committed
627 628
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
629 630
    uploadParameter() {
        api.create().uploadParameter(this.state.payload).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
631
            console.log(response)
632
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
633 634 635 636 637 638
                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
639
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
640 641 642 643 644 645 646
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
647
                } else {
a.bairuha's avatar
a.bairuha committed
648
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
649
                }
650 651
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
652
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
653 654 655
        })
    }

656 657 658 659
    closeAlert() {
        this.setState({ alert: false })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
660 661 662 663 664 665 666 667 668 669
    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
670
                            if (response.data.message.includes("Someone Logged In")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
                                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
687 688 689 690
    render() {
        const columns = [{
            name: "Action",
            options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
691
                sort: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
692
                filter: false,
faisalhamdi's avatar
faisalhamdi committed
693 694
                customBodyRender: (val, tableMeta) => {
                    return (
d.arizona's avatar
d.arizona committed
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
                        <div style={{ display: 'flex' }}>
                            {this.state.edit && 
                                <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>
                            }
                            {this.state.delete && 
                                <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 >
                        
faisalhamdi's avatar
faisalhamdi committed
735 736 737
                    );
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
738
        }, {
Deni Rinaldi's avatar
Deni Rinaldi committed
739 740 741 742 743
            name: "ID",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
744
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
745 746 747 748
                        </div >
                    );
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
749
        }, {
faisalhamdi's avatar
faisalhamdi committed
750 751 752 753 754
            name: "Group",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
755
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
756 757 758 759 760 761 762 763 764 765
                        </div >
                    );
                }
            }
        }, {
            name: "Parameter",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
766
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
767 768 769 770 771
                        </div >
                    );
                }
            }
        }, {
772
            name: "Company",
faisalhamdi's avatar
faisalhamdi committed
773 774 775 776
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
777
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
778 779 780 781 782
                        </div >
                    );
                }
            }
        }, {
783
            name: "Description",
faisalhamdi's avatar
faisalhamdi committed
784 785 786 787
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
788
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
789 790 791 792 793 794 795 796 797 798
                        </div >
                    );
                }
            }
        }, {
            name: "Order",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
799
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
800 801 802 803 804 805 806 807 808 809
                        </div >
                    );
                }
            }
        }, {
            name: "Value",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
810
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
811 812 813 814 815 816 817 818 819 820
                        </div >
                    );
                }
            }
        }, {
            name: "Min Value",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
821
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
822 823 824 825 826 827 828 829 830 831
                        </div >
                    );
                }
            }
        }, {
            name: "Max Value",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
832
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
833 834 835 836 837 838 839 840 841 842
                        </div >
                    );
                }
            }
        }, {
            name: "Status",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
843
                            <span style={{ color: tableMeta.rowData[10] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
844 845 846 847 848 849 850 851 852 853
                        </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"],
854
            ["", "-", "-", "-", "-", "-"]
faisalhamdi's avatar
faisalhamdi committed
855
        ]
d.arizona's avatar
d.arizona committed
856 857 858 859 860 861 862 863 864 865
        const loadingComponent = (
            <div style={{position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)'}}>
              <PropagateLoader
                // css={override}
                size={20}
                color={"#274B80"}
                loading={this.state.loading}
              />
            </div>
          );
faisalhamdi's avatar
faisalhamdi committed
866 867 868
        return (
            <div style={{ height: this.props.height }}>
                {/* <Row> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
869
                <div className={"main-color"} style={{ height: 195, width: '100%' }} />
870 871 872 873 874
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
875 876
                {this.state.visibleParameter === true ?
                    <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
877
                        {this.state.load && (
Deni Rinaldi's avatar
Deni Rinaldi committed
878 879
                            <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
880
                                {/* <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
881 882 883 884 885 886 887 888
                                    <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
889
                                </div> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
890
                                <div style={{ width: '40%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 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
                                    <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>
954
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
955 956

                        )}
957
                        <div style={{ padding: 25 }}>
d.arizona's avatar
d.arizona committed
958
                        {this.state.loading && loadingComponent}
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973
                            <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
974
                        </div>
975
                        <div style={{ padding: 25 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
976
                            {this.state.dataLoaded && (
977 978 979 980 981 982 983 984
                                <MuiThemeProvider theme={getMuiTheme()}>
                                    <MUIDataTable
                                        theme={getMuiTheme()}
                                        data={this.state.rows}
                                        columns={this.state.cols}
                                        options={options2}
                                    />
                                </MuiThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
985
                            )}
986 987
                        </div>
                        <div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
988
                            <button
989
                                type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
990
                                onClick={() => this.setState({ visibleParameter: true, judul: "" })}
991
                                style={{ marginRight: 20 }}
faisalhamdi's avatar
faisalhamdi committed
992
                            >
993
                                <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
994
                                    <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
995 996 997 998
                                </div>
                            </button>
                            <button
                                type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
999 1000
                                disabled={this.state.buttonError ? true : false}
                                onClick={() => this.uploadParameter()}
1001 1002 1003
                                style={{}}
                            >
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1004
                                    <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
1005
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1006 1007 1008
                            </button>
                        </div>
                    </div>
1009
                }
faisalhamdi's avatar
faisalhamdi committed
1010
                {this.state.visibleCreate && (
1011
                    <CreateParameter
faisalhamdi's avatar
faisalhamdi committed
1012
                        onClickClose={() => this.setState({ visibleCreate: false })}
1013
                        createParameter={this.createParameter.bind(this)}
faisalhamdi's avatar
faisalhamdi committed
1014 1015 1016 1017
                    />
                )}

                {this.state.visibleEdit && (
1018
                    <CreateParameter
faisalhamdi's avatar
faisalhamdi committed
1019 1020
                        type={"edit"}
                        onClickClose={() => this.setState({ visibleEdit: false })}
Deni Rinaldi's avatar
Deni Rinaldi committed
1021
                        data={this.state.rowData}
1022
                        updateParameter={this.updateParameter.bind(this)}
faisalhamdi's avatar
faisalhamdi committed
1023 1024
                    />
                )}
1025
                {this.state.popupError && (
Deni Rinaldi's avatar
Deni Rinaldi committed
1026
                    <PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
1027 1028 1029 1030
                )}
                {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
1031
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042
                                <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 })}
                                    >
1043
                                        <img src={Images.close} />
1044 1045 1046 1047 1048 1049 1050
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
1051
                                acceptedFiles={["xlsx"]}
1052 1053 1054 1055
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1056 1057 1058 1059 1060
                                onUpload={() => {
                                    this.state.judul === "MASTER DATA - PARAMETER" ?
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
1061 1062 1063 1064
                            />
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
1065 1066 1067 1068 1069 1070 1071 1072 1073 1074

                {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
1075 1076 1077 1078
            </div>
        );
    }
}