Company.js 52.2 KB
Newer Older
1 2 3 4 5
import React, { Component } from 'react';
import { Container, Row, Col } from "react-bootstrap";
import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import { Typography } from '@material-ui/core';
import Images from '../../../assets/Images';
faisalhamdi's avatar
faisalhamdi committed
6
import UploadFile from "../../../library/Upload";
7 8
import MUIDataTable from "mui-datatables";
import { render } from '@testing-library/react';
faisalhamdi's avatar
faisalhamdi committed
9
import { ExcelRenderer } from 'react-excel-renderer';
syadziy's avatar
syadziy committed
10 11 12
import CreatePerusahaan from "./CreateCompany";
import EditPerusahaan from "./EditCompany"
import VisualPerusahaan from "./VisualCompany";
faisalhamdi's avatar
faisalhamdi committed
13
import api from "../../../api";
14
import ReactTooltip from 'react-tooltip';
faisalhamdi's avatar
faisalhamdi committed
15 16
import MuiAlert from '@material-ui/lab/Alert';
import { TextField, InputBase, Snackbar, withStyles } from "@material-ui/core";
faisalhamdi's avatar
faisalhamdi committed
17
// import DeletePerusahaan from "./DeletePerusahaan";
18
import PopUpFailedSave from '../../../library/PopUpFailedSave';
faisalhamdi's avatar
faisalhamdi committed
19
import PopUpDelete from "../../../library/PopUpDelete";
a.bairuha's avatar
a.bairuha committed
20
import Constant from '../../../library/Constant';
d.arizona's avatar
d.arizona committed
21 22
import { css } from "@emotion/core";
import PropagateLoader from "react-spinners/PropagateLoader"
23 24 25 26

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

faisalhamdi's avatar
faisalhamdi committed
29 30 31
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);

32 33 34 35 36 37
export default class Perusahaan extends Component {
    constructor(props) {
        super(props)
        this.state = {
            visibleCreate: false,
            visibleEdit: false,
faisalhamdi's avatar
faisalhamdi committed
38
            visibleVisual: false,
faisalhamdi's avatar
faisalhamdi committed
39
            visibleDelete: false,
faisalhamdi's avatar
faisalhamdi committed
40 41 42 43 44 45 46
            dataTable: [],
            listData: [],
            data: [],
            search: "",
            visiblePerusahaan: true,
            cols: null,
            rows: null,
47
            dataLoaded: false,
faisalhamdi's avatar
faisalhamdi committed
48 49 50
            popupError: false,
            alert: false,
            tipeAlert: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
51 52 53
            messageAlert: '',
            create: false,
            edit: false,
d.arizona's avatar
d.arizona committed
54
            delete: false,
faisalhamdi's avatar
faisalhamdi committed
55
            load: false,
faisalhamdi's avatar
faisalhamdi committed
56 57
            judul: '',
            rowData: [],
d.arizona's avatar
d.arizona committed
58 59
            companyName: '',
            loading: false
faisalhamdi's avatar
faisalhamdi committed
60

61
        }
faisalhamdi's avatar
faisalhamdi committed
62 63 64 65 66 67 68 69 70 71
        this.fileHandler = this.fileHandler.bind(this);
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            if (err) {
                console.log(err);
            }
            else {
72 73 74 75 76 77
                let isi = resp.rows.slice(3)
                let payload = []
                isi.map((item, index) => {
                    if (item.length > 0) {
                        payload.push({
                            "id": index + 1,
faisalhamdi's avatar
faisalhamdi committed
78 79 80
                            "company_name": item[0] === undefined ? "" : item[0],
                            "company_parent": item[1] === undefined ? "" : item[1],
                            "unit_bisnis": item[2] === undefined ? "" : item[2],
Riri Novita's avatar
Riri Novita committed
81 82 83 84
                            "currency": item[3] === undefined ? "" :item[3],
                            "default_currency": item[4] === undefined ? "" :item[4],
                            "start_date": item[5] === undefined ? "" : item[5],
                            "end_date": item[6] === undefined ? "" :item[6]
85 86 87 88 89 90
                        })
                    }
                })
                let body = {
                    company: payload
                }
faisalhamdi's avatar
faisalhamdi committed
91 92
                console.log(resp.rows[1])
                this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
faisalhamdi's avatar
faisalhamdi committed
93 94 95 96 97 98 99
            }
        });
    }

    checkUpload() {
        api.create().checkUploadPerusahaan(this.state.payload).then(response => {
            console.log(response);
faisalhamdi's avatar
faisalhamdi committed
100
            let dataRow = []
faisalhamdi's avatar
faisalhamdi committed
101 102 103
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === "success") {
faisalhamdi's avatar
faisalhamdi committed
104
                        dataRow = response.data.data.map((item, index) => {
faisalhamdi's avatar
faisalhamdi committed
105 106 107 108
                            return [
                                item.company_name,
                                item.company_parent,
                                item.unit_bisnis,
109 110
                                item.currency,
                                item.default_currency,
Riri Novita's avatar
Riri Novita committed
111 112
                                item.start_date,
                                item.end_date,
faisalhamdi's avatar
faisalhamdi committed
113 114 115 116 117 118 119 120 121
                                item.error
                            ]
                        })
                        let columns = [
                            {
                                name: "Company Name",
                                options: {
                                    customBodyRender: (val, tableMeta) => {
                                        let check = null
122 123
                                        if (tableMeta.rowData[7] != null) {
                                            check = tableMeta.rowData[7].findIndex((val) => val.field.includes('company_name'))
faisalhamdi's avatar
faisalhamdi committed
124 125
                                            if (check > -1) {
                                                this.setState({ buttonError: true })
126 127
                                            }
                                        }
faisalhamdi's avatar
faisalhamdi committed
128 129
                                        return (
                                            <div style={{ display: 'flex' }}>
130 131
                                                {tableMeta.rowData[7] != null && check > -1 ?
                                                    <a data-tip={tableMeta.rowData[7][check].message} data-for="company_name">
faisalhamdi's avatar
faisalhamdi committed
132
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
faisalhamdi's avatar
faisalhamdi committed
133
                                                    </a> :
faisalhamdi's avatar
faisalhamdi committed
134
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
135
                                                }
faisalhamdi's avatar
faisalhamdi committed
136 137 138 139 140 141 142 143 144 145 146
                                                <ReactTooltip border={true} id="company_name" place="bottom" type="light" effect="solid" />
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                name: "Parent Company",
                                options: {
                                    customBodyRender: (val, tableMeta) => {
                                        let check = null
147 148
                                        if (tableMeta.rowData[7] != null) {
                                            check = tableMeta.rowData[7].findIndex((val) => val.field.includes('company_parent'))
faisalhamdi's avatar
faisalhamdi committed
149 150
                                            if (check > -1) {
                                                this.setState({ buttonError: true })
151 152
                                            }
                                        }
faisalhamdi's avatar
faisalhamdi committed
153 154
                                        return (
                                            <div style={{ display: 'flex' }}>
155 156
                                                {tableMeta.rowData[7] != null && check > -1 ?
                                                    <a data-tip={tableMeta.rowData[7][check].message} data-for="company_parent">
faisalhamdi's avatar
faisalhamdi committed
157
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
faisalhamdi's avatar
faisalhamdi committed
158
                                                    </a> :
faisalhamdi's avatar
faisalhamdi committed
159
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
160
                                                }
faisalhamdi's avatar
faisalhamdi committed
161 162 163 164 165 166 167 168 169 170 171
                                                <ReactTooltip border={true} id="company_parent" place="bottom" type="light" effect="solid" />
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
                                name: "Business Unit",
                                options: {
                                    customBodyRender: (val, tableMeta) => {
                                        let check = null
172 173
                                        if (tableMeta.rowData[7] != null) {
                                            check = tableMeta.rowData[7].findIndex((val) => val.field.includes('unit_bisnis'))
faisalhamdi's avatar
faisalhamdi committed
174 175
                                            if (check > -1) {
                                                this.setState({ buttonError: true })
176 177
                                            }
                                        }
faisalhamdi's avatar
faisalhamdi committed
178 179
                                        return (
                                            <div style={{ display: 'flex' }}>
180 181
                                                {tableMeta.rowData[7] != null && check > -1 ?
                                                    <a data-tip={tableMeta.rowData[7][check].message} data-for="unit_bisnis">
faisalhamdi's avatar
faisalhamdi committed
182
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
faisalhamdi's avatar
faisalhamdi committed
183
                                                    </a> :
faisalhamdi's avatar
faisalhamdi committed
184
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
185
                                                }
faisalhamdi's avatar
faisalhamdi committed
186 187 188 189 190 191 192
                                                <ReactTooltip border={true} id="unit_bisnis" place="bottom" type="light" effect="solid" />
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
Riri Novita's avatar
Riri Novita committed
193
                                name: "Currency",
faisalhamdi's avatar
faisalhamdi committed
194 195 196
                                options: {
                                    customBodyRender: (val, tableMeta) => {
                                        let check = null
197
                                        if (tableMeta.rowData[7] != null) {
qorri_di's avatar
qorri_di committed
198
                                            check = tableMeta.rowData[7].findIndex((val) => val.field.includes('currency'))
faisalhamdi's avatar
faisalhamdi committed
199 200
                                            if (check > -1) {
                                                this.setState({ buttonError: true })
201 202
                                            }
                                        }
faisalhamdi's avatar
faisalhamdi committed
203 204
                                        return (
                                            <div style={{ display: 'flex' }}>
205
                                                {tableMeta.rowData[7] != null && check > -1 ?
qorri_di's avatar
qorri_di committed
206
                                                    <a data-tip={tableMeta.rowData[7][check].message} data-for="currency">
faisalhamdi's avatar
faisalhamdi committed
207
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
faisalhamdi's avatar
faisalhamdi committed
208
                                                    </a> :
faisalhamdi's avatar
faisalhamdi committed
209
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
210
                                                }
qorri_di's avatar
qorri_di committed
211
                                                <ReactTooltip border={true} id="currency" place="bottom" type="light" effect="solid" />
faisalhamdi's avatar
faisalhamdi committed
212 213 214 215 216 217
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
Riri Novita's avatar
Riri Novita committed
218
                                name: "Default Currency",
faisalhamdi's avatar
faisalhamdi committed
219 220 221
                                options: {
                                    customBodyRender: (val, tableMeta) => {
                                        let check = null
222
                                        if (tableMeta.rowData[7] != null) {
qorri_di's avatar
qorri_di committed
223
                                            check = tableMeta.rowData[7].findIndex((val) => val.field.includes('default_currency'))
faisalhamdi's avatar
faisalhamdi committed
224 225
                                            if (check > -1) {
                                                this.setState({ buttonError: true })
226 227
                                            }
                                        }
faisalhamdi's avatar
faisalhamdi committed
228 229
                                        return (
                                            <div style={{ display: 'flex' }}>
230
                                                {tableMeta.rowData[7] != null && check > -1 ?
qorri_di's avatar
qorri_di committed
231
                                                    <a data-tip={tableMeta.rowData[7][check].message} data-for="default_currency">
faisalhamdi's avatar
faisalhamdi committed
232
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
faisalhamdi's avatar
faisalhamdi committed
233
                                                    </a> :
faisalhamdi's avatar
faisalhamdi committed
234
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
faisalhamdi's avatar
faisalhamdi committed
235
                                                }
qorri_di's avatar
qorri_di committed
236
                                                <ReactTooltip border={true} id="default_currency" place="bottom" type="light" effect="solid" />
faisalhamdi's avatar
faisalhamdi committed
237 238
                                            </div >
                                        );
a.bairuha's avatar
a.bairuha committed
239
                                    }
faisalhamdi's avatar
faisalhamdi committed
240 241
                                }
                            },
242
                            {
Riri Novita's avatar
Riri Novita committed
243
                                name: "Valid From",
244 245 246 247
                                options: {
                                    customBodyRender: (val, tableMeta) => {
                                        let check = null
                                        if (tableMeta.rowData[7] != null) {
Riri Novita's avatar
Riri Novita committed
248
                                            check = tableMeta.rowData[7].findIndex((val) => val.field.includes('start_date'))
249 250 251 252 253 254 255
                                            if (check > -1) {
                                                this.setState({ buttonError: true })
                                            }
                                        }
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[7] != null && check > -1 ?
Riri Novita's avatar
Riri Novita committed
256
                                                    <a data-tip={tableMeta.rowData[7][check].message} data-for="startdate">
257 258 259 260
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
                                                    </a> :
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
                                                }
Riri Novita's avatar
Riri Novita committed
261
                                                <ReactTooltip border={true} id="startdate" place="bottom" type="light" effect="solid" />
262 263 264 265 266 267
                                            </div >
                                        );
                                    }
                                }
                            },
                            {
Riri Novita's avatar
Riri Novita committed
268
                                name: "Valid To",
269 270 271 272
                                options: {
                                    customBodyRender: (val, tableMeta) => {
                                        let check = null
                                        if (tableMeta.rowData[7] != null) {
Riri Novita's avatar
Riri Novita committed
273
                                            check = tableMeta.rowData[7].findIndex((val) => val.field.includes('end_date'))
274 275 276 277 278 279 280
                                            if (check > -1) {
                                                this.setState({ buttonError: true })
                                            }
                                        }
                                        return (
                                            <div style={{ display: 'flex' }}>
                                                {tableMeta.rowData[7] != null && check > -1 ?
Riri Novita's avatar
Riri Novita committed
281
                                                    <a data-tip={tableMeta.rowData[7][check].message} data-for="enddate">
282 283 284 285
                                                        <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
                                                    </a> :
                                                    <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
                                                }
Riri Novita's avatar
Riri Novita committed
286
                                                <ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" />
287 288 289 290 291
                                            </div >
                                        );
                                    }
                                }
                            },
faisalhamdi's avatar
faisalhamdi committed
292 293 294 295 296
                            {
                                name: "",
                                options: {
                                    display: false
                                }
297
                            }
faisalhamdi's avatar
faisalhamdi committed
298 299
                        ]

faisalhamdi's avatar
faisalhamdi committed
300
                        console.log(dataRow);
faisalhamdi's avatar
faisalhamdi committed
301 302 303 304 305 306
                        this.setState({
                            dataLoaded: true,
                            cols: columns,
                            rows: dataRow, visibleUpload: false, 
                            visiblePerusahaan: false
                        });
a.bairuha's avatar
a.bairuha committed
307
                    } else {
faisalhamdi's avatar
faisalhamdi committed
308
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
309
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
310 311 312 313 314 315
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
316
                    }
faisalhamdi's avatar
faisalhamdi committed
317 318 319 320 321
                } 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
322
            }
faisalhamdi's avatar
faisalhamdi committed
323
        })
324 325 326
    }

    componentDidMount() {
faisalhamdi's avatar
faisalhamdi committed
327
        this.getData()
328 329 330 331 332 333 334 335 336 337 338 339 340 341
        this.getPermission()
    }

    getPermission() {
        let payload = {
            menu: "company"
        }
        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
342
                        delete: response.data.data.delete,
343 344 345 346 347 348 349 350 351
                        load: true
                    })
                } else {
                    this.setState({
                        load: true
                    })
                }
            }
        })
faisalhamdi's avatar
faisalhamdi committed
352 353 354
    }

    getData() {
d.arizona's avatar
d.arizona committed
355
        this.setState({loading: true})
faisalhamdi's avatar
faisalhamdi committed
356
        api.create().getPerusahaan().then((response) => {
faisalhamdi's avatar
faisalhamdi committed
357
            // console.log(response)
faisalhamdi's avatar
faisalhamdi committed
358
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
359 360 361 362 363 364
                if (response.ok) {
                    if (response.data.status == 'success') {
                        let data = response.data.data
                        let listData = data.sort((a, b) => a.company_id - b.company_id).map((item, index) => {
                            return [index, item.company_id, item.company_name, item.parent_name, item.business_unit_name, item.status]
                        })
d.arizona's avatar
d.arizona committed
365 366 367 368 369
                        this.setState({ dataTable: listData, listData: response.data.data }, () => {
                            setTimeout(() => {
                              this.setState({loading: false})
                            }, 2000);
                          })
a.bairuha's avatar
a.bairuha committed
370
                    } else {
d.arizona's avatar
d.arizona committed
371
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
372
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
373 374 375 376 377 378 379
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
380
                } else {
d.arizona's avatar
d.arizona committed
381
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
382
                }
faisalhamdi's avatar
faisalhamdi committed
383
            } else {
d.arizona's avatar
d.arizona committed
384
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
Deni Rinaldi's avatar
Deni Rinaldi committed
385
            }
faisalhamdi's avatar
faisalhamdi committed
386
        })
387 388
    }

faisalhamdi's avatar
faisalhamdi committed
389
    openPopUp(rowData, type) {
faisalhamdi's avatar
faisalhamdi committed
390 391
        if (type === 'edit') {
            this.setState({
faisalhamdi's avatar
faisalhamdi committed
392
                rowData: rowData,
faisalhamdi's avatar
faisalhamdi committed
393 394
                visibleEdit: true
            })
faisalhamdi's avatar
faisalhamdi committed
395 396 397 398 399 400
        } else if (type === 'delete') {
            this.setState({
                rowData: rowData,
                companyName: String(rowData[2]),
                visibleDelete: true
            })
faisalhamdi's avatar
faisalhamdi committed
401 402
        } else {
            this.setState({
faisalhamdi's avatar
faisalhamdi committed
403
                rowData: rowData,
faisalhamdi's avatar
faisalhamdi committed
404 405 406 407 408 409 410 411 412 413 414
                visibleCreate: true
            })
        }
    }

    handleInputChange(e) {
        this.setState({ search: e })
        let body = {
            "keyword": e
        }
        api.create().searchPerusahaan(body).then(response => {
faisalhamdi's avatar
faisalhamdi committed
415
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
416 417 418 419 420 421 422 423 424
                if (response.ok) {
                    if (response.data.status == 'success') {
                        let data = response.data.data
                        let listData = data.map((item, index) => {
                            return [index, item.company_id, item.company_name, item.parent_name, item.business_unit_name, item.status]
                        })
                        this.setState({ dataTable: listData, listData: response.data.data })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
425
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
426 427 428 429 430 431 432
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
433
                } else {
a.bairuha's avatar
a.bairuha committed
434
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
435
                }
faisalhamdi's avatar
faisalhamdi committed
436
            } else {
faisalhamdi's avatar
faisalhamdi committed
437
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
438 439 440 441 442 443 444
            }
        })
    }

    updatePerusahaan = (payload) => {
        this.setState({ visibleEdit: false })
        api.create().updatePerusahaan(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
445
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
446 447 448 449 450 451
                if (response.ok) {
                    if (response.data.status == 'success') {
                        this.getData()
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
452
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
453 454 455 456 457 458 459
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
460
                } else {
a.bairuha's avatar
a.bairuha committed
461
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
462
                }
faisalhamdi's avatar
faisalhamdi committed
463
            } else {
faisalhamdi's avatar
faisalhamdi committed
464
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
465 466 467 468 469 470 471
            }
        })
    }

    createPerusahaan = (payload) => {
        this.setState({ visibleCreate: false })
        api.create().createPerusahaan(payload).then(response => {
472
            console.log(response);
faisalhamdi's avatar
faisalhamdi committed
473
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
474 475 476 477 478 479
                if (response.ok) {
                    if (response.data.status == 'success') {
                        this.getData()
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
480
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
481 482 483 484 485 486 487
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
488
                } else {
a.bairuha's avatar
a.bairuha committed
489
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
490
                }
faisalhamdi's avatar
faisalhamdi committed
491
            } else {
faisalhamdi's avatar
faisalhamdi committed
492
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
493 494 495 496
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
497 498 499 500 501 502 503 504 505 506
    updateHierarchy = (payload) => {
        this.setState({ visibleVisual: false, visiblePerusahaan: true })
        api.create().saveVisualisasiPerusahaan(payload).then((response) => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status == 'success') {
                        this.getData()
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
507
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
                                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
524 525
    downloadFile = async () => {
        let res = await fetch(
d.arizona's avatar
d.arizona committed
526
            `${process.env.REACT_APP_URL_MAIN_BE}/public/attachment/download_file?fileName=CompanyTemplate&&fileType=xlsx`
faisalhamdi's avatar
faisalhamdi committed
527 528 529 530 531 532 533
        )
        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;
faisalhamdi's avatar
faisalhamdi committed
534
            a.download = 'Template Company.xlsx';
faisalhamdi's avatar
faisalhamdi committed
535 536 537 538 539 540
            a.click();
        }
    }

    downloadDataTable = async () => {
        let res = await fetch(
d.arizona's avatar
d.arizona committed
541
            `${process.env.REACT_APP_URL_MAIN_BE}/public/company/export_company`
faisalhamdi's avatar
faisalhamdi committed
542 543 544 545 546 547 548
        )
        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;
faisalhamdi's avatar
faisalhamdi committed
549
            a.download = 'Company.xlsx';
faisalhamdi's avatar
faisalhamdi committed
550 551 552 553
            a.click();
        }
    }

554 555 556
    uploadPerusahaan() {
        api.create().uploadPerusahaan(this.state.payload).then(response => {
            console.log(response)
faisalhamdi's avatar
faisalhamdi committed
557
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
558 559 560 561 562 563
                if (response.ok) {
                    if (response.data.status == "success") {
                        this.getData()
                        this.setState({ visiblePerusahaan: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
564
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
565 566 567 568 569 570 571
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
572
                } else {
a.bairuha's avatar
a.bairuha committed
573
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
574 575 576 577
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
578 579 580
        })
    }

faisalhamdi's avatar
faisalhamdi committed
581 582 583 584 585 586 587 588 589 590
    deleteCompany = (payload) => {
        let id = String(payload[1])
        api.create().deletePerusahaan(id).then(response => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status == 'success') {
                        this.getData()
                        this.setState({ visibleDelete: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
591
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
                                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
608 609 610 611
    closeAlert() {
        this.setState({ alert: false })
    }

612 613 614 615
    render() {
        const columns = [{
            name: "Action",
            options: {
faisalhamdi's avatar
faisalhamdi committed
616 617
                filter: false,
                sort: false,
618 619
                customBodyRender: (val, tableMeta) => {
                    return (
d.arizona's avatar
d.arizona committed
620 621 622 623 624 625 626 627 628 629 630 631 632 633
                        <div style={{ display: 'flex' }}>
                            {this.state.edit && 
                                <span>
                                    <a data-tip={'Edit'} data-for="edit">
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent'
                                            }}
                                            // onClick={() => this.setState({ visibleEdit: true, data: tableMeta.rowData })}
                                            onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
                                        >
                                            <div style={{ display: 'flex' }}>
faisalhamdi's avatar
faisalhamdi committed
634
                                                {!tableMeta.rowData[2].includes("PT TRIPUTRA INVESTINDO ARYA") ?
d.arizona's avatar
d.arizona committed
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
                                                <img src={Images.editCopy} /> :
                                                null
                                                }
                                            </div >
                                        </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',
                                                marginLeft: 10
                                            }}
                                            // onClick={() => this.setState({ visibleEdit: true, data: tableMeta.rowData })}
                                            onClick={() => this.openPopUp(tableMeta.rowData, 'delete')}
                                        >                                        
                                            <div style={{ display: 'flex' }}>
faisalhamdi's avatar
faisalhamdi committed
658
                                                {!tableMeta.rowData[2].includes("PT TRIPUTRA INVESTINDO ARYA") ?
d.arizona's avatar
d.arizona committed
659 660 661 662 663 664 665 666 667 668
                                                <img src={Images.delete} /> :
                                                null
                                                }
                                            </div >
                                        </button>
                                    </a>
                                    <ReactTooltip border={true} id="delete" place="bottom" type="light" effect="solid" />
                                </span>
                            }
                        </div>
669 670 671 672 673 674 675 676 677
                    );
                }
            }
        }, {
            name: "ID",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
678
                            <span style={{ color: tableMeta.rowData[5] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
679 680 681 682 683
                        </div >
                    );
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
684
            name: "Company Name",
685 686 687 688
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
689
                            <span style={{ color: tableMeta.rowData[5] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
690 691 692 693 694
                        </div >
                    );
                }
            }
        }, {
695
            name: "Parent Company",
696 697 698 699
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
700
                            <span style={{ color: tableMeta.rowData[5] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
faisalhamdi's avatar
faisalhamdi committed
701 702 703 704 705
                        </div >
                    );
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
706
            name: "Business Unit",
faisalhamdi's avatar
faisalhamdi committed
707 708 709 710
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
711
                            <span style={{ color: tableMeta.rowData[5] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
712 713 714 715 716 717 718 719 720 721
                        </div >
                    );
                }
            }
        }, {
            name: "Status",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
722
                            <span style={{ color: tableMeta.rowData[5] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
723 724 725 726 727 728
                        </div >
                    );
                }
            }
        }]
        const data = [
faisalhamdi's avatar
faisalhamdi committed
729 730 731 732
            ["", "1", "Triputra Agro Persada Group", "Triputra Investindo Arya", "Agrobisnis", "5", "Aktif"],
            ["", "2", "Gawi Bahandep Sawit Mekar", "Triputra Agro Persada Group", "Agrobisnis", "2", "Aktif"],
            ["", "3", "Puninar Group", "Triputra Investindo Arya", "Service", "5", "Aktif"],
            ["", "4", "Puninar Infinite Raya", "Puninar Group", "Service", "5", "Non Aktif"],
733
            ["", "-", "-", "-", "-", "-"],
734
        ]
d.arizona's avatar
d.arizona committed
735 736 737 738 739 740 741 742 743 744
        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>
          );
745 746 747
        return (
            <div style={{ height: this.props.height }}>
                {/* <Row> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
748
                <div className={"main-color"} style={{ height: 195, width: '100%' }} />
faisalhamdi's avatar
faisalhamdi committed
749 750 751 752 753
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
d.arizona's avatar
d.arizona committed
754
                {this.state.loading && loadingComponent}
faisalhamdi's avatar
faisalhamdi committed
755
                {this.state.visiblePerusahaan === true ?
756 757
                    this.state.load && (
                        <div>
faisalhamdi's avatar
faisalhamdi committed
758
                            <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -181 }}>
759
                                <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Company</label>
faisalhamdi's avatar
faisalhamdi committed
760
                                {/* <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
761 762 763 764 765 766 767 768
                                    <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' }}
                                    />
faisalhamdi's avatar
faisalhamdi committed
769
                                </div> */}
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784
                                <div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                    <a data-tip={'Download Template'} data-for="template">
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                margin: 5
                                            }}
                                            onClick={() => this.downloadFile()}
                                        >
                                            <img src={Images.template} />
                                        </button>
                                    </a>
                                    <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
Deni Rinaldi's avatar
Deni Rinaldi committed
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799
                                    {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>
                                    )}
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
                                    <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" />
                                    <a data-tip={'Visualization'} data-for="visual">
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                margin: 5
                                            }}
faisalhamdi's avatar
faisalhamdi committed
823
                                            onClick={() => this.setState({ visibleVisual: true, visiblePerusahaan: false })}
824
                                        >
faisalhamdi's avatar
faisalhamdi committed
825
                                            <img src={Images.visualisasi} />
826 827 828
                                        </button>
                                    </a>
                                    <ReactTooltip border={true} id="visual" place="bottom" type="light" effect="solid" />
Deni Rinaldi's avatar
Deni Rinaldi committed
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844
                                    {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>
                                    )}
845 846
                                    <ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
                                </div>
faisalhamdi's avatar
faisalhamdi committed
847
                            </div>
848 849 850 851 852 853 854 855 856
                            <div style={{ padding: 25 }}>
                                <MuiThemeProvider theme={getMuiTheme()}>
                                    <MUIDataTable
                                        theme={getMuiTheme()}
                                        data={this.state.dataTable}
                                        columns={columns}
                                        options={options}
                                    />
                                </MuiThemeProvider>
faisalhamdi's avatar
faisalhamdi committed
857

858
                            </div>
faisalhamdi's avatar
faisalhamdi committed
859
                        </div>
860
                    )
faisalhamdi's avatar
faisalhamdi committed
861
                    :
862
                    this.state.visibleVisual === true ?
863
                        <VisualPerusahaan
Deni Rinaldi's avatar
Deni Rinaldi committed
864 865
                            buttonCreate={this.state.create}
                            buttonEdit={this.state.edit}
866 867
                            onClickClose={() => this.setState({ visibleVisual: false, visiblePerusahaan: true })}
                            height={this.props.height}
faisalhamdi's avatar
faisalhamdi committed
868
                            updateHierarchy={this.updateHierarchy.bind(this)}
d.arizona's avatar
d.arizona committed
869
                            handleLoading={() => this.setState({loading: true}, () => console.log('aksdkas'))}
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894
                        />
                        :
                        <div>
                            <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
                                <label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
                            </div>
                            <div style={{ padding: 25 }}>
                                {this.state.dataLoaded && (
                                    <MuiThemeProvider theme={getMuiTheme()}>
                                        <MUIDataTable
                                            theme={getMuiTheme()}
                                            data={this.state.rows}
                                            columns={this.state.cols}
                                            options={options2}
                                        />
                                    </MuiThemeProvider>
                                )}
                            </div>
                            <div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
                                <button
                                    type="button"
                                    onClick={() => this.setState({ visiblePerusahaan: true })}
                                    style={{ marginRight: 20 }}
                                >
                                    <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
a.bairuha's avatar
a.bairuha committed
895
                                        <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
896 897 898 899
                                    </div>
                                </button>
                                <button
                                    type="button"
faisalhamdi's avatar
faisalhamdi committed
900 901 902
                                    disabled={this.state.buttonError == true ? true : false}
                                    onClick={() => this.uploadPerusahaan()}
                                    // onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadPerusahaan()}
903 904 905
                                    style={{}}
                                >
                                    <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
a.bairuha's avatar
a.bairuha committed
906
                                        <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
907 908
                                    </div>
                                </button>
faisalhamdi's avatar
faisalhamdi committed
909
                            </div>
910
                        </div>
faisalhamdi's avatar
faisalhamdi committed
911
                }
912

913 914 915
                {this.state.visibleCreate && (
                    <CreatePerusahaan
                        onClickClose={() => this.setState({ visibleCreate: false })}
faisalhamdi's avatar
faisalhamdi committed
916 917
                        type={"create"}
                        createPerusahaan={this.createPerusahaan.bind(this)}
918 919 920 921
                    />
                )}

                {this.state.visibleEdit && (
faisalhamdi's avatar
faisalhamdi committed
922
                    <CreatePerusahaan
923 924
                        type={"edit"}
                        onClickClose={() => this.setState({ visibleEdit: false })}
faisalhamdi's avatar
faisalhamdi committed
925
                        data={this.state.rowData}
faisalhamdi's avatar
faisalhamdi committed
926
                        updatePerusahaan={this.updatePerusahaan.bind(this)}
927 928
                    />
                )}
faisalhamdi's avatar
faisalhamdi committed
929

faisalhamdi's avatar
faisalhamdi committed
930 931 932 933 934 935 936 937 938
                {/* {this.state.visibleEdit && (
                    <EditPerusahaan
                        type={"edit"}
                        onClickClose={() => this.setState({ visibleEdit: false })}
                        data={this.state.listData[this.state.selectIndex]}
                        updatePerusahaan={this.updatePerusahaan.bind(this)}
                    />
                )} */}

faisalhamdi's avatar
faisalhamdi committed
939 940 941 942 943 944 945 946 947
                {/* {this.state.visibleDelete && (
                    <DeletePerusahaan
                        type={"delete"}
                        onClickClose={() => this.setState({ visibleDelete: false })}
                        data={this.state.rowData}
                        deleteCompany={this.deleteCompany.bind(this)}
                    />
                )} */}

948 949 950 951
                {this.state.popupError && (
                    <PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
                )}

faisalhamdi's avatar
faisalhamdi committed
952 953 954
                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
faisalhamdi's avatar
faisalhamdi committed
955
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
faisalhamdi's avatar
faisalhamdi committed
956 957 958 959 960 961 962 963 964 965 966
                                <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 })}
                                    >
Deni Rinaldi's avatar
Deni Rinaldi committed
967
                                        <img src={Images.close} />
faisalhamdi's avatar
faisalhamdi committed
968 969 970 971 972 973 974
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
faisalhamdi's avatar
faisalhamdi committed
975
                                acceptedFiles={["xlsx"]}
faisalhamdi's avatar
faisalhamdi committed
976 977 978 979
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
faisalhamdi's avatar
faisalhamdi committed
980
                                onUpload={() => {
r.kurnia's avatar
r.kurnia committed
981
                                    String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("DATA") && String(this.state.judul).includes("COMPANY") ?
faisalhamdi's avatar
faisalhamdi committed
982
                                    this.checkUpload() :
faisalhamdi's avatar
faisalhamdi committed
983 984
                                    this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning'})
                                }}
faisalhamdi's avatar
faisalhamdi committed
985 986 987 988
                            />
                        </div>
                    </div>
                )}
faisalhamdi's avatar
faisalhamdi committed
989 990 991 992 993 994 995 996 997 998

                {this.state.visibleDelete && (
                    <PopUpDelete
                        rowData={this.state.rowData}
                        name={this.state.companyName}
                        onClickClose={() => this.setState({ visibleDelete: false })}
                        onClickDelete={this.deleteCompany.bind(this)}
                    />
                )}

999 1000 1001
            </div>
        );
    }
faisalhamdi's avatar
faisalhamdi committed
1002
}