CreatePerusahaan.js 36.1 KB
Newer Older
1 2
import React, { Component } from 'react';
import { TextField, Typography } from '@material-ui/core';
faisalhamdi's avatar
faisalhamdi committed
3 4 5
import * as R from 'ramda';
import { DateTimePicker, KeyboardDatePicker, DatePicker } from "@material-ui/pickers";
import format from "date-fns/format";
6 7
import Autocomplete from '@material-ui/lab/Autocomplete';
import api from '../../../api';
d.arizona's avatar
d.arizona committed
8
import Images from '../../../assets/Images';
9 10

export default class CreatePerusahaan extends Component {
faisalhamdi's avatar
faisalhamdi committed
11 12 13 14 15
    constructor(props) {
        super(props)
        this.state = {
            id: '',
            company: '',
faisalhamdi's avatar
faisalhamdi committed
16
            companyID: '',
faisalhamdi's avatar
faisalhamdi committed
17 18
            parentCompany: '',
            unitBisnis: '',
faisalhamdi's avatar
faisalhamdi committed
19
            totalReport: '',
faisalhamdi's avatar
faisalhamdi committed
20
            startDate: '',
21
            endDate: '',
faisalhamdi's avatar
faisalhamdi committed
22
            status: '',
23 24 25 26
            types: null,
            getTypes: null,
            perusahaan: null,
            getPerusahaan: null,
faisalhamdi's avatar
faisalhamdi committed
27 28 29 30 31 32 33 34 35 36 37 38
            errorNP: false,
            errorPC: false,
            errorSD: false,
            errorED: false,
            errorJL: false,
            errorUB: false,
            msgErrorNP: '',
            msgErrorPC: '',
            msgErrorSD: '',
            msgErrorED: '',
            msgErrorJL: '',
            msgErrorUB: ''
faisalhamdi's avatar
faisalhamdi committed
39 40
        }
    }
41

faisalhamdi's avatar
faisalhamdi committed
42 43 44 45 46
    render() {
        let { type } = this.props
        return type === 'edit' ? this.renderEdit() : this.renderCreate()
    }

faisalhamdi's avatar
faisalhamdi committed
47
    componentDidMount() {
48 49
        this.getParentCompany()
        this.getAllUnitBisnis()
faisalhamdi's avatar
faisalhamdi committed
50
        if(this.props.type === 'edit') {
faisalhamdi's avatar
faisalhamdi committed
51 52
            this.getDetailPerusahaan()
            // console.log(this.props.data);
faisalhamdi's avatar
faisalhamdi committed
53 54 55 56 57 58 59 60
        } else {
            let date = format(new Date, 'yyyy-MM-dd')
            // console.log(date);
            this.setState({
                startDate: date,
                endDate: date
            })
        }
61 62
    }

faisalhamdi's avatar
faisalhamdi committed
63 64
    getDetailPerusahaan() {
        api.create().getDetailPerusahaan(this.props.data[1]).then(response => {
faisalhamdi's avatar
faisalhamdi committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
            if (response.data.status === "success") {
                console.log(response);
                this.setState({
                    businessID: response.data.data.business_unit_id,
                    companyID: response.data.data.company_id,
                    status: response.data.data.status,
                    company: response.data.data.company_name,
                    parentID: response.data.data.parent,
                    parent: response.data.data.parent_name,
                    startDate: response.data.data.start_date,
                    endDate: response.data.data.end_date,
                    totalReport: response.data.data.total_report,
                    created: response.data.data.created,
                    updated: response.data.data.updated === null ? "" : response.data.data.updated
                }, () => this.getAllUnitBisnis(), this.getCompanyActive())
            }
        })
    }

    getCompanyActive() {
        api.create().getPerusahaanActive().then(response => {
86 87
            if (response.data.status == 'success') {
                let data = response.data.data
faisalhamdi's avatar
faisalhamdi committed
88
                let perusahaanData = data.map((item) => {
89 90 91 92 93
                    return {
                        company_id: item.company_id,
                        company_name: item.company_name
                    }
                })
faisalhamdi's avatar
faisalhamdi committed
94
                let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.parentID)
95
                let typeProps = {
faisalhamdi's avatar
faisalhamdi committed
96
                    options: perusahaanData,
97 98
                    getOptionLabel: (option) => option.company_name,
                };
a.bairuha's avatar
a.bairuha committed
99
                this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index] })
100 101 102 103 104 105 106 107
            } else {
                alert(response.data.message)
            }
        })
    }

    getAllUnitBisnis() {
        api.create().getUnitBisnisActive().then(response => {
faisalhamdi's avatar
faisalhamdi committed
108
            if (response.data.status === 'success') {
109 110 111 112 113 114 115
                let data = response.data.data
                let typeData = data.map((item) => {
                    return {
                        business_unit_id: item.business_unit_id,
                        business_unit_name: item.business_unit_name
                    }
                })
faisalhamdi's avatar
faisalhamdi committed
116 117 118
                // console.log(typeData)
                let index = typeData.findIndex((val) => val.business_unit_id == this.state.businessID)
                console.log(index)
119 120 121 122
                let typeProps = {
                    options: typeData,
                    getOptionLabel: (option) => option.business_unit_name,
                };
a.bairuha's avatar
a.bairuha committed
123
                this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index] })
faisalhamdi's avatar
faisalhamdi committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
            } else {
                alert(response.data.message)
            }
        })
    }

    getParentCompany() {
        api.create().getPerusahaanActive().then((response) => {
            if (response.data.status === 'success') {
                let data = response.data.data
                let typeData = data.map((item) => {
                    return {
                        company_id: item.company_id,
                        company_name: item.company_name
                    }
                })
                let typeProps = {
                    options: typeData.sort((a, b) => a.company_id - b.company_id),
                    getOptionLabel: (option) => option.company_name,
                };
                this.setState({ perusahaan: typeProps, perusahaanData: response.data.data })
145 146 147 148
            } else {
                alert(response.data.message)
            }
        })
faisalhamdi's avatar
faisalhamdi committed
149 150 151 152 153 154
    }

    handleChange(e, type) {
        let data = this.state
        let isDate = type !== '' ? true : false
        if (isDate && type == 'start_date') {
155
            this.setState({ startDate: format(e, 'yyyy-MM-dd'), endDate: null }, () => {
faisalhamdi's avatar
faisalhamdi committed
156
                this.clearError()
faisalhamdi's avatar
faisalhamdi committed
157 158 159 160
                console.log(this.state.startDate)
            })
        } else if (isDate && type == 'end_date') {
            this.setState({ endDate: format(e, 'yyyy-MM-dd') }, () => {
faisalhamdi's avatar
faisalhamdi committed
161
                this.clearError()
faisalhamdi's avatar
faisalhamdi committed
162 163 164 165 166 167 168 169
                console.log(this.state.endDate)
            })
        } else {
            // this.setState({...data, tempData: {...this.state.tempData, [e.target.name] :  e.target.value}})
        }

    }

faisalhamdi's avatar
faisalhamdi committed
170 171 172 173 174 175 176
    clearError() {
        this.setState({
            errorNP: false,
            errorPC: false,
            errorSD: false,
            errorED: false,
            errorJL: false,
a.bairuha's avatar
a.bairuha committed
177
            errorUB: false,
faisalhamdi's avatar
faisalhamdi committed
178 179 180 181 182
            msgErrorNP: '',
            msgErrorPC: '',
            msgErrorSD: '',
            msgErrorED: '',
            msgErrorJL: '',
a.bairuha's avatar
a.bairuha committed
183
            msgErrorUB: ''
faisalhamdi's avatar
faisalhamdi committed
184 185 186 187 188 189
        })
    }

    validasiEdit() {
        if (R.isEmpty(this.state.company)) {
            this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' })
a.bairuha's avatar
a.bairuha committed
190 191
        } else if (R.isNil(this.state.getTypes)) {
            this.setState({ errorUB: true, msgErrorUB: 'Unit Bisnis harus diisi' })        
faisalhamdi's avatar
faisalhamdi committed
192 193 194 195 196 197 198 199 200
        } else if (R.isNil(this.state.startDate)) {
            this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' })
        } else if (R.isNil(this.state.endDate)) {
            this.setState({ errorED: true, msgErrorED: 'End Date tidak boleh kosong' })
        } else {
            let payload = {
                "company_id": this.state.companyID,
                "company_name": this.state.company,
                "business_unit_id": this.state.getTypes.business_unit_id,
a.bairuha's avatar
a.bairuha committed
201
                "parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
faisalhamdi's avatar
faisalhamdi committed
202 203 204 205 206 207 208 209 210
                // "total_report": this.state.totalReport,
                "start_date": this.state.startDate,
                "end_date": this.state.endDate
            }
            // console.log(payload);
            this.props.updatePerusahaan(payload)            
        }
    }

faisalhamdi's avatar
faisalhamdi committed
211
    validasi() {
faisalhamdi's avatar
faisalhamdi committed
212 213
        if (R.isEmpty(this.state.company)) {
            this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' })
a.bairuha's avatar
a.bairuha committed
214
        } else if (R.isNil(this.state.getTypes)) {
faisalhamdi's avatar
faisalhamdi committed
215 216 217 218 219 220 221
            this.setState({ errorUB: true, msgErrorUB: 'Unit Bisnis harus diisi' })        
        } else if (R.isNil(this.state.startDate)) {
            this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' })
        } else if (R.isNil(this.state.endDate)) {
            this.setState({ errorED: true, msgErrorED: 'End Date tidak boleh kosong' })
        } else if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) {
            return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai")
a.bairuha's avatar
a.bairuha committed
222 223
        } 
        // else if (R.isEmpty(this.state.totalReport)) {
faisalhamdi's avatar
faisalhamdi committed
224
        //     this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' })
a.bairuha's avatar
a.bairuha committed
225 226
        // } 
        else {
faisalhamdi's avatar
faisalhamdi committed
227 228
            let payload = {
                "company_name": this.state.company,
a.bairuha's avatar
a.bairuha committed
229
                "parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
faisalhamdi's avatar
faisalhamdi committed
230
                "business_unit_id": this.state.getTypes.business_unit_id,
faisalhamdi's avatar
faisalhamdi committed
231
                // "total_report": this.state.totalReport,
faisalhamdi's avatar
faisalhamdi committed
232 233 234 235 236
                "start_date": this.state.startDate,
                "end_date": this.state.endDate
            }
            console.log(payload);
            this.props.createPerusahaan(payload)
faisalhamdi's avatar
faisalhamdi committed
237
        }
238 239
    }

faisalhamdi's avatar
faisalhamdi committed
240
    renderEdit() {
241
        return (
faisalhamdi's avatar
faisalhamdi committed
242
            <div className="test app-popup-show">
243
                <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
faisalhamdi's avatar
faisalhamdi committed
244
                    <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
245 246
                        <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                            <div className="popup-title">
faisalhamdi's avatar
faisalhamdi committed
247
                                <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Ubah Data</span>
248 249 250 251 252 253 254 255
                            </div>
                        </div>
                        <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                            <button
                                type="button"
                                className="btn btn-circle btn-white"
                                onClick={() => this.props.onClickClose()}
                            >
d.arizona's avatar
d.arizona committed
256
                                <img src={Images.close}/>
257 258 259 260 261 262 263
                            </button>
                        </div>
                    </div>


                    <div className="border-bottom grid grid-2x grid-mobile-none gap-15px" style={{ padding: 20 }}>
                        <div className="column-1">
faisalhamdi's avatar
faisalhamdi committed
264 265 266
                            <div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
faisalhamdi's avatar
faisalhamdi committed
267
                                    value={this.state.companyID}
faisalhamdi's avatar
faisalhamdi committed
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
                                    id="id"
                                    label="ID"
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                />
                            </div>
faisalhamdi's avatar
faisalhamdi committed
284
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
285 286 287 288
                                <Autocomplete
                                    {...this.state.types}
                                    debug
                                    id="tipe"
a.bairuha's avatar
a.bairuha committed
289 290 291 292 293 294 295 296 297 298 299
                                    onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, ()=> this.clearError())}
                                    renderInput={(params) => 
                                        <TextField 
                                        {...params} 
                                        InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} 
                                        InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} 
                                        label="Unit Bisnis"
                                        error={this.state.errorUB}
                                        helperText={this.state.msgErrorUB}
                                         />
                                    }
300 301
                                    value={this.state.getTypes}
                                />
faisalhamdi's avatar
faisalhamdi committed
302
                            </div>
faisalhamdi's avatar
faisalhamdi committed
303 304 305 306 307 308 309 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 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="startDate"
                                    label="Berlaku Mulai"
                                    format="dd MMMM yyyy"
                                    value={this.state.startDate}
                                    onChange={(e) => this.handleChange(e, 'start_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                    error={this.state.errorSD}
                                    helperText={this.state.msgErrorSD}
                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
                            </div>
                            <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
                                    value={this.state.status}
                                    id="status"
                                    label="Status"
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                />
                            </div>

                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography>
                                    <Typography style={{ fontSize: 11 }}>: {this.state.created}</Typography>
                                </div>
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
faisalhamdi's avatar
faisalhamdi committed
358
                                    <Typography style={{ fontSize: 11 }}>: {this.state.updated}</Typography>
faisalhamdi's avatar
faisalhamdi committed
359 360 361 362 363
                                </div>
                            </div>
                        </div>

                        <div className="column-2">
faisalhamdi's avatar
faisalhamdi committed
364
                            <div style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
                                <TextField
                                    style={{ width: '100%' }}
                                    id="perusahaan"
                                    label="Nama Perusahaan"
                                    value={this.state.company}
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                    error={this.state.errorNP}
                                    helperText={this.state.msgErrorNP}
                                    onChange={(e) => this.setState({ company: e.target.value }, () => this.clearError())}
                                >
                                </TextField>
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                            <Autocomplete
                                    {...this.state.perusahaan}
                                    debug
                                    id="tipe"
                                    onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })}
                                    renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parent Company" />}
                                    value={this.state.getPerusahaan}
                                />
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="endDate"
                                    label="Berlaku Hingga"
                                    format="dd MMMM yyyy"
                                    value={this.state.endDate}
                                    minDate={this.state.startDate}
                                    onChange={(e) => this.handleChange(e, 'end_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                    error={this.state.errorED}
                                    helperText={this.state.msgErrorED}
                                />
                            </div>
                            {/* <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
426 427
                                <TextField
                                    style={{ width: '100%' }}
faisalhamdi's avatar
faisalhamdi committed
428 429 430
                                    id="report"
                                    label="Jumlah Laporan"
                                    value={this.state.totalReport}
faisalhamdi's avatar
faisalhamdi committed
431 432 433 434 435 436 437 438 439 440 441
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
faisalhamdi's avatar
faisalhamdi committed
442 443 444
                                    onChange={(e) => this.setState({ totalReport: e.target.value }, () => this.clearError())}
                                    error={this.state.errorJL}
                                    helperText={this.state.msgErrorJL}
445 446
                                >
                                </TextField>
faisalhamdi's avatar
faisalhamdi committed
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
                            </div> */}
                        </div>
                    </div>

                    <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1" style={{ alignSelf: 'center' }}>
                            <button
                                type="button"
                                onClick={() => this.props.onClickClose()}
                            >
                                <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                    <span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
                                </div>
                            </button>
                        </div>
                        <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
                            <button
                                type="button"
                                onClick={() => this.validasiEdit()}
                            >
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                    <span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
                                </div>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        )
    }

    renderCreate() {
        return (
            <div className="test app-popup-show" style={{ paddingTop: 100 }}>
                <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                    <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                        <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                            <div className="popup-title">
                                <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Create Data</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.props.onClickClose()}
                            >
                                <img src={Images.close}/>
                            </button>
                        </div>
                    </div>


                    <div className="border-bottom grid grid-2x grid-mobile-none gap-15px" style={{ padding: 20 }}>
                        <div className="column-1">
                            <div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
                                    id="id"
                                    label="ID"
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                />
520
                            </div>
faisalhamdi's avatar
faisalhamdi committed
521 522 523 524 525
                            <div style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    {...this.state.types}
                                    debug
                                    id="tipe"
a.bairuha's avatar
a.bairuha committed
526
                                    onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, ()=> this.clearError())}
faisalhamdi's avatar
faisalhamdi committed
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
                                    renderInput={(params) => 
                                    <TextField 
                                        {...params} 
                                        label="Unit Bisnis" 
                                        margin="normal" 
                                        style={{marginTop: 7}}
                                        error={this.state.errorUB}
                                        helperText={this.state.msgErrorUB}
                                        InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} 
                                        InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} 
                                        // onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => this.clearError())}                                    
                                    />
                                    }
                                    value={this.state.types}
                                    // value={this.state.getTypes}
                                    
                                    // error={this.state.errorUB}
                                    // helperText={this.state.msgErrorUB}
                                    // onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => this.clearError())}

                                />
                            </div>                            
faisalhamdi's avatar
faisalhamdi committed
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
                            <div style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="startDate"
                                    label="Berlaku Mulai"
                                    format="dd MMMM yyyy"
                                    value={this.state.startDate == "" ? null : this.state.startDate}
                                    onChange={(e) => this.handleChange(e, 'start_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}

                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
                            </div>
faisalhamdi's avatar
faisalhamdi committed
575
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5, backgroundColor: '#e8e8e8', }}>
576 577 578 579 580 581
                                <TextField
                                    style={{ width: '100%' }}
                                    defaultValue={"Aktif"}
                                    id="status"
                                    label="Status"
                                    disabled
faisalhamdi's avatar
faisalhamdi committed
582 583 584 585 586 587 588 589 590 591 592
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
593 594 595
                                />
                            </div>

faisalhamdi's avatar
faisalhamdi committed
596
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
597 598
                                <Typography style={{ fontSize: 11 }}>Dibuat	: </Typography>
                                <Typography style={{ fontSize: 11 }}>Diubah	: </Typography>
599 600 601 602
                            </div>
                        </div>

                        <div className="column-2">
faisalhamdi's avatar
faisalhamdi committed
603
                            <div style={{ padding: 10, borderRadius: 5 }}>
604 605
                                <TextField
                                    style={{ width: '100%' }}
faisalhamdi's avatar
faisalhamdi committed
606 607
                                    id="perusahaan"
                                    label="Nama Perusahaan"
faisalhamdi's avatar
faisalhamdi committed
608
                                    value={this.state.company}
faisalhamdi's avatar
faisalhamdi committed
609 610 611 612 613 614 615 616 617 618 619
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
faisalhamdi's avatar
faisalhamdi committed
620 621 622
                                    error={this.state.errorNP}
                                    helperText={this.state.msgErrorNP}
                                    onChange={(e) => this.setState({ company: e.target.value }, () => this.clearError())}
623 624 625
                                >
                                </TextField>
                            </div>
faisalhamdi's avatar
faisalhamdi committed
626
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
627 628 629 630 631 632 633 634
                                <Autocomplete
                                    {...this.state.perusahaan}
                                    debug
                                    id="tipe"
                                    onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })}
                                    renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parent Company" />}
                                    value={this.state.getPerusahaan}
                                />
faisalhamdi's avatar
faisalhamdi committed
635
                            </div>
faisalhamdi's avatar
faisalhamdi committed
636
                            <div style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
637 638 639
                                <DatePicker
                                    margin="normal"
                                    id="endDate"
640
                                    label="Berlaku Hingga"
faisalhamdi's avatar
faisalhamdi committed
641
                                    format="dd MMMM yyyy"
faisalhamdi's avatar
faisalhamdi committed
642 643
                                    error={this.state.errorED}
                                    helperText={this.state.msgErrorED}
644
                                    minDate={this.state.startDate}
faisalhamdi's avatar
faisalhamdi committed
645 646
                                    // value={this.state.endDate == "" ? null : this.state.endDate}
                                    value={this.state.endDate}
faisalhamdi's avatar
faisalhamdi committed
647 648 649 650
                                    onChange={(e) => this.handleChange(e, 'end_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
faisalhamdi's avatar
faisalhamdi committed
651 652 653 654 655 656 657 658 659 660 661
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
faisalhamdi's avatar
faisalhamdi committed
662 663 664

                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
665
                            </div>
faisalhamdi's avatar
faisalhamdi committed
666
                            {/* <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687
                                <TextField
                                    style={{ width: '100%' }}
                                    id="report"
                                    label="Jumlah Laporan"
                                    value={this.state.totalReport}
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                    error={this.state.errorJL}
                                    helperText={this.state.msgErrorJL}
                                    onChange={(e) => this.setState({ totalReport: e.target.value }, () => this.clearError())}
                                >
                                </TextField>
faisalhamdi's avatar
faisalhamdi committed
688
                            </div> */}
689 690 691 692 693 694
                        </div>

                    </div>

                    <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1" style={{ alignSelf: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
695 696 697 698 699 700 701 702
                            <button
                                type="button"
                                onClick={() => this.props.onClickClose()}
                            >
                                <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                    <span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
                                </div>
                            </button>
703 704
                        </div>
                        <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
705 706 707 708 709 710 711 712
                            <button
                                type="button"
                                onClick={() => this.validasi()}
                            >
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                    <span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
                                </div>
                            </button>
713 714 715 716 717 718 719
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}