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

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

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

faisalhamdi's avatar
faisalhamdi committed
50 51 52 53 54
    render() {
        let { type } = this.props
        return type === 'edit' ? this.renderEdit() : this.renderCreate()
    }

faisalhamdi's avatar
faisalhamdi committed
55
    componentDidMount() {
Deni Rinaldi's avatar
Deni Rinaldi committed
56
        if (this.props.type === 'edit') {
faisalhamdi's avatar
faisalhamdi committed
57 58
            this.getDetailPerusahaan()
            // console.log(this.props.data);
faisalhamdi's avatar
faisalhamdi committed
59
        } else {
a.bairuha's avatar
a.bairuha committed
60 61
            this.getCompanyActive()
            this.getAllUnitBisnis()
faisalhamdi's avatar
faisalhamdi committed
62 63 64 65 66 67 68
            let date = format(new Date, 'yyyy-MM-dd')
            // console.log(date);
            this.setState({
                startDate: date,
                endDate: date
            })
        }
69 70
    }

faisalhamdi's avatar
faisalhamdi committed
71 72
    getDetailPerusahaan() {
        api.create().getDetailPerusahaan(this.props.data[1]).then(response => {
faisalhamdi's avatar
faisalhamdi committed
73 74
            console.log(response)
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88
                if (response.ok) {
                    if (response.data.status === "success") {
                        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
a.bairuha's avatar
a.bairuha committed
89 90
                        }, () => {
                            // setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
91 92
                            this.getAllUnitBisnis()
                            this.getCompanyActive()
a.bairuha's avatar
a.bairuha committed
93 94
                            // }, 1000);
                        })
a.bairuha's avatar
a.bairuha committed
95 96
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
97
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
98 99 100 101 102 103 104
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
105
                } else {
a.bairuha's avatar
a.bairuha committed
106
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
107
                }
faisalhamdi's avatar
faisalhamdi committed
108 109
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
110
            }
faisalhamdi's avatar
faisalhamdi committed
111 112 113 114
        })
    }

    getCompanyActive() {
a.bairuha's avatar
a.bairuha committed
115
        console.log(this.state.company)
faisalhamdi's avatar
faisalhamdi committed
116 117 118 119
        if (this.state.company !== null) {
            console.log(this.state.company)
            let payload = {
                "company_id": this.state.company.company_id
120
            }
faisalhamdi's avatar
faisalhamdi committed
121 122
            api.create().getPerusahaanActive(payload).then(response => {
                console.log(response)
Deni Rinaldi's avatar
Deni Rinaldi committed
123
                if (response.data) {
a.bairuha's avatar
a.bairuha committed
124
                    if (response.ok) {
Deni Rinaldi's avatar
Deni Rinaldi committed
125
                        if (response.data.status === 'success') {
a.bairuha's avatar
a.bairuha committed
126
                            let data = response.data.data
a.bairuha's avatar
a.bairuha committed
127 128 129 130 131 132 133 134 135
                            let currentIndex = null
                            let perusahaanData = data.map((item, index) => {
                                if (this.state.companyID !== item.company_id) {
                                    return {
                                        company_id: item.company_id,
                                        company_name: item.company_name
                                    }
                                } else {
                                    currentIndex = index
a.bairuha's avatar
a.bairuha committed
136 137
                                }
                            })
a.bairuha's avatar
a.bairuha committed
138 139 140
                            if (currentIndex !== null) {
                                perusahaanData.splice(currentIndex, 1)
                            }
a.bairuha's avatar
a.bairuha committed
141 142 143 144 145
                            let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.parentID)
                            let typeProps = {
                                options: perusahaanData,
                                getOptionLabel: (option) => option.company_name,
                            };
faisalhamdi's avatar
faisalhamdi committed
146 147 148 149 150
                            if (this.props.type === 'edit') {
                                this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index], msgErrorPC: index === -1 ? 'Company has been Inactive' : "", errorPC: index === -1 ? true : false })
                            } else {
                                this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index] })
                            }
a.bairuha's avatar
a.bairuha committed
151 152
                        } else {
                            this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
153
                                if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
154 155 156 157 158 159 160
                                    setTimeout(() => {
                                        localStorage.removeItem(Constant.TOKEN)
                                        window.location.reload();
                                    }, 1000);
                                }
                            })
                        }
faisalhamdi's avatar
faisalhamdi committed
161
                    } else {
a.bairuha's avatar
a.bairuha committed
162
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
163
                    }
faisalhamdi's avatar
faisalhamdi committed
164 165
                } else {
                    this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
166
                }
faisalhamdi's avatar
faisalhamdi committed
167 168
            })
        }
169 170 171 172
    }

    getAllUnitBisnis() {
        api.create().getUnitBisnisActive().then(response => {
faisalhamdi's avatar
faisalhamdi committed
173
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
                if (response.ok) {
                    if (response.data.status === 'success') {
                        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
                            }
                        })
                        // console.log(typeData)
                        let index = typeData.findIndex((val) => val.business_unit_id == this.state.businessID)
                        console.log(index)
                        let typeProps = {
                            options: typeData,
                            getOptionLabel: (option) => option.business_unit_name,
Deni Rinaldi's avatar
Deni Rinaldi committed
189
                        };
faisalhamdi's avatar
faisalhamdi committed
190 191 192 193 194
                        if (this.props.type === 'edit') {
                            this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index], msgErrorUB: index === -1 ? 'Business Unit has been Inactive' : "", errorUB: index === -1 ? true : false })
                        } else {
                            this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index] })
                        }
a.bairuha's avatar
a.bairuha committed
195 196
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
197
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
198 199 200 201 202 203 204
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
205
                } else {
a.bairuha's avatar
a.bairuha committed
206
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
207
                }
faisalhamdi's avatar
faisalhamdi committed
208
            } else {
faisalhamdi's avatar
faisalhamdi committed
209
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
210
            }
faisalhamdi's avatar
faisalhamdi committed
211 212 213
        })
    }

faisalhamdi's avatar
faisalhamdi committed
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
    // 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 })
    //         } else {
    //             alert(response.data.message)
    //         }
    //     })
    // }
faisalhamdi's avatar
faisalhamdi committed
234 235 236 237 238

    handleChange(e, type) {
        let data = this.state
        let isDate = type !== '' ? true : false
        if (isDate && type == 'start_date') {
239
            this.setState({ startDate: format(e, 'yyyy-MM-dd'), endDate: null }, () => {
faisalhamdi's avatar
faisalhamdi committed
240
                this.clearError()
faisalhamdi's avatar
faisalhamdi committed
241 242 243 244
                console.log(this.state.startDate)
            })
        } else if (isDate && type == 'end_date') {
            this.setState({ endDate: format(e, 'yyyy-MM-dd') }, () => {
faisalhamdi's avatar
faisalhamdi committed
245
                this.clearError()
faisalhamdi's avatar
faisalhamdi committed
246 247 248 249 250 251 252 253
                console.log(this.state.endDate)
            })
        } else {
            // this.setState({...data, tempData: {...this.state.tempData, [e.target.name] :  e.target.value}})
        }

    }

faisalhamdi's avatar
faisalhamdi committed
254 255 256 257 258 259 260
    clearError() {
        this.setState({
            errorNP: false,
            errorPC: false,
            errorSD: false,
            errorED: false,
            errorJL: false,
a.bairuha's avatar
a.bairuha committed
261
            errorUB: false,
faisalhamdi's avatar
faisalhamdi committed
262 263 264 265 266
            msgErrorNP: '',
            msgErrorPC: '',
            msgErrorSD: '',
            msgErrorED: '',
            msgErrorJL: '',
a.bairuha's avatar
a.bairuha committed
267
            msgErrorUB: ''
faisalhamdi's avatar
faisalhamdi committed
268 269 270 271 272
        })
    }

    validasiEdit() {
        if (R.isEmpty(this.state.company)) {
EKSAD's avatar
EKSAD committed
273
            this.setState({ errorNP: true, msgErrorNP: 'Company Name Cannot be Empty' })
faisalhamdi's avatar
faisalhamdi committed
274
        } else if (R.isNil(this.state.getPerusahaan)) {
EKSAD's avatar
EKSAD committed
275
            this.setState({ errorPC: true, msgErrorPC: 'Parent Company Cannot be Empty' })
a.bairuha's avatar
a.bairuha committed
276
        } else if (R.isNil(this.state.getTypes)) {
Deni Rinaldi's avatar
Deni Rinaldi committed
277
            this.setState({ errorUB: true, msgErrorUB: 'Business Unit Cannot be Empty' })
faisalhamdi's avatar
faisalhamdi committed
278
        } else if (R.isNil(this.state.startDate)) {
EKSAD's avatar
EKSAD committed
279
            this.setState({ errorSD: true, msgErrorSD: 'Valid From Cannot be Empty' })
faisalhamdi's avatar
faisalhamdi committed
280
        } else if (R.isNil(this.state.endDate)) {
EKSAD's avatar
EKSAD committed
281
            this.setState({ errorED: true, msgErrorED: 'Valid To Cannot be Empty' })
faisalhamdi's avatar
faisalhamdi committed
282 283 284 285 286
        } else {
            let payload = {
                "company_id": this.state.companyID,
                "company_name": this.state.company,
                "business_unit_id": this.state.getTypes.business_unit_id,
faisalhamdi's avatar
faisalhamdi committed
287 288
                // "parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
                "parent": this.state.getPerusahaan.company_id,
faisalhamdi's avatar
faisalhamdi committed
289 290 291
                "start_date": this.state.startDate,
                "end_date": this.state.endDate
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
292
            this.props.updatePerusahaan(payload)
faisalhamdi's avatar
faisalhamdi committed
293 294 295
        }
    }

faisalhamdi's avatar
faisalhamdi committed
296
    validasi() {
faisalhamdi's avatar
faisalhamdi committed
297
        if (R.isEmpty(this.state.company)) {
298
            this.setState({ errorNP: true, msgErrorNP: 'Company Name Cannot be Empty.' })
faisalhamdi's avatar
faisalhamdi committed
299 300
        } else if (R.isNil(this.state.getPerusahaan)) {
            this.setState({ errorPC: true, msgErrorPC: 'Parent Company Cannot be Empty.' })
a.bairuha's avatar
a.bairuha committed
301
        } else if (R.isNil(this.state.getTypes)) {
Deni Rinaldi's avatar
Deni Rinaldi committed
302
            this.setState({ errorUB: true, msgErrorUB: 'Business Unit Cannot be Empty.' })
faisalhamdi's avatar
faisalhamdi committed
303
        } else if (R.isNil(this.state.startDate)) {
304
            this.setState({ errorSD: true, msgErrorSD: 'Valid From Cannot be Empty.' })
faisalhamdi's avatar
faisalhamdi committed
305
        } else if (R.isNil(this.state.endDate)) {
306
            this.setState({ errorED: true, msgErrorED: 'Valid To Cannot be Empty.' })
Deni Rinaldi's avatar
Deni Rinaldi committed
307
        }
a.bairuha's avatar
a.bairuha committed
308
        else {
faisalhamdi's avatar
faisalhamdi committed
309 310
            let payload = {
                "company_name": this.state.company,
faisalhamdi's avatar
faisalhamdi committed
311 312
                // "parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
                "parent": this.state.getPerusahaan.company_id,
faisalhamdi's avatar
faisalhamdi committed
313 314 315 316 317 318
                "business_unit_id": this.state.getTypes.business_unit_id,
                "start_date": this.state.startDate,
                "end_date": this.state.endDate
            }
            console.log(payload);
            this.props.createPerusahaan(payload)
faisalhamdi's avatar
faisalhamdi committed
319
        }
320 321
    }

faisalhamdi's avatar
faisalhamdi committed
322 323 324 325
    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
326
    renderEdit() {
327
        return (
faisalhamdi's avatar
faisalhamdi committed
328
            <div className="test app-popup-show">
faisalhamdi's avatar
faisalhamdi committed
329 330 331 332 333
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
334
                <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
faisalhamdi's avatar
faisalhamdi committed
335
                    <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
336 337
                        <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                            <div className="popup-title">
faisalhamdi's avatar
faisalhamdi committed
338
                                <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Edit Data</span>
339 340 341 342 343 344 345 346
                            </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()}
                            >
Deni Rinaldi's avatar
Deni Rinaldi committed
347
                                <img src={Images.close} />
348 349 350 351 352
                            </button>
                        </div>
                    </div>


Deni Rinaldi's avatar
Deni Rinaldi committed
353
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ padding: 20 }}>
354
                        <div className="column-1">
faisalhamdi's avatar
faisalhamdi committed
355 356 357
                            <div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
faisalhamdi's avatar
faisalhamdi committed
358
                                    value={this.state.companyID}
faisalhamdi's avatar
faisalhamdi committed
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
                                    id="id"
                                    label="ID"
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                />
                            </div>
faisalhamdi's avatar
faisalhamdi committed
375
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
376 377 378 379
                                <Autocomplete
                                    {...this.state.types}
                                    debug
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
380 381 382 383 384 385 386 387 388 389
                                    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="Business Unit"
                                            error={this.state.errorUB}
                                            helperText={this.state.msgErrorUB}
                                        />
a.bairuha's avatar
a.bairuha committed
390
                                    }
391 392
                                    value={this.state.getTypes}
                                />
faisalhamdi's avatar
faisalhamdi committed
393
                            </div>
faisalhamdi's avatar
faisalhamdi committed
394 395 396 397
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="startDate"
398
                                    label="Valid From"
faisalhamdi's avatar
faisalhamdi committed
399
                                    format="dd-MM-yyyy"
faisalhamdi's avatar
faisalhamdi committed
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 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
                                    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>

                        <div className="column-2">
faisalhamdi's avatar
faisalhamdi committed
444
                            <div style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
445 446 447
                                <TextField
                                    style={{ width: '100%' }}
                                    id="perusahaan"
faisalhamdi's avatar
faisalhamdi committed
448
                                    label="Company Name"
faisalhamdi's avatar
faisalhamdi committed
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
                                    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 }}>
faisalhamdi's avatar
faisalhamdi committed
468
                                <Autocomplete
faisalhamdi's avatar
faisalhamdi committed
469 470 471
                                    {...this.state.perusahaan}
                                    debug
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
472 473 474 475 476 477 478 479 480 481
                                    onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearError())}
                                    renderInput={(params) =>
                                        <TextField
                                            {...params}
                                            label="Parent Company"
                                            error={this.state.errorPC}
                                            helperText={this.state.msgErrorPC}
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                            InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                        />
faisalhamdi's avatar
faisalhamdi committed
482
                                    }
faisalhamdi's avatar
faisalhamdi committed
483 484 485 486 487 488 489
                                    value={this.state.getPerusahaan}
                                />
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="endDate"
490
                                    label="Valid To"
faisalhamdi's avatar
faisalhamdi committed
491
                                    format="dd-MM-yyyy"
faisalhamdi's avatar
faisalhamdi committed
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
                                    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>
                    </div>

Deni Rinaldi's avatar
Deni Rinaldi committed
517 518 519 520 521 522 523 524 525 526 527
                    <div className="border-bottom margin-top-10px" style={{ padding: '0px 20px 20px 20px', borderRadius: 5 }}>
                        <div style={{ display: 'flex' }}>
                            <Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography>
                            <Typography style={{ fontSize: 11 }}>: {this.state.created}</Typography>
                        </div>
                        <div style={{ display: 'flex' }}>
                            <Typography style={{ fontSize: 11, width: '12%' }}>Updated By</Typography>
                            <Typography style={{ fontSize: 11 }}>: {this.state.updated}</Typography>
                        </div>
                    </div>

faisalhamdi's avatar
faisalhamdi committed
528 529 530 531 532 533 534
                    <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' }}>
faisalhamdi's avatar
faisalhamdi committed
535
                                    <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
faisalhamdi's avatar
faisalhamdi committed
536 537 538 539 540 541 542 543 544
                                </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' }}>
faisalhamdi's avatar
faisalhamdi committed
545
                                    <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
faisalhamdi's avatar
faisalhamdi committed
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
                                </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()}
                            >
Deni Rinaldi's avatar
Deni Rinaldi committed
571
                                <img src={Images.close} />
faisalhamdi's avatar
faisalhamdi committed
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
                            </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'
                                        }
                                    }}
                                />
597
                            </div>
faisalhamdi's avatar
faisalhamdi committed
598 599 600 601 602
                            <div style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    {...this.state.types}
                                    debug
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
603 604 605 606 607 608 609 610 611 612 613 614
                                    onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => this.clearError())}
                                    renderInput={(params) =>
                                        <TextField
                                            {...params}
                                            label="Business Unit"
                                            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' } }}
                                        />
faisalhamdi's avatar
faisalhamdi committed
615 616 617 618
                                    }
                                    value={this.state.types}

                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
619
                            </div>
faisalhamdi's avatar
faisalhamdi committed
620 621 622 623
                            <div style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="startDate"
624
                                    label="Valid From"
faisalhamdi's avatar
faisalhamdi committed
625
                                    format="dd-MM-yyyy"
faisalhamdi's avatar
faisalhamdi committed
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
                                    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
646
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5, backgroundColor: '#e8e8e8', }}>
647 648
                                <TextField
                                    style={{ width: '100%' }}
faisalhamdi's avatar
faisalhamdi committed
649
                                    defaultValue={"Active"}
650 651 652
                                    id="status"
                                    label="Status"
                                    disabled
faisalhamdi's avatar
faisalhamdi committed
653 654 655 656 657 658 659 660 661 662 663
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
664 665 666
                                />
                            </div>

faisalhamdi's avatar
faisalhamdi committed
667
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
668 669
                                <Typography style={{ fontSize: 11, width: '25%' }}>Created By : </Typography>
                                <Typography style={{ fontSize: 11, width: '25%' }}>Updated By : </Typography>
670 671 672 673
                            </div>
                        </div>

                        <div className="column-2">
faisalhamdi's avatar
faisalhamdi committed
674
                            <div style={{ padding: 10, borderRadius: 5 }}>
675 676
                                <TextField
                                    style={{ width: '100%' }}
faisalhamdi's avatar
faisalhamdi committed
677
                                    id="perusahaan"
faisalhamdi's avatar
faisalhamdi committed
678
                                    label="Company Name"
faisalhamdi's avatar
faisalhamdi committed
679
                                    value={this.state.company}
faisalhamdi's avatar
faisalhamdi committed
680 681 682 683 684 685 686 687 688 689 690
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
faisalhamdi's avatar
faisalhamdi committed
691 692 693
                                    error={this.state.errorNP}
                                    helperText={this.state.msgErrorNP}
                                    onChange={(e) => this.setState({ company: e.target.value }, () => this.clearError())}
694 695 696
                                >
                                </TextField>
                            </div>
faisalhamdi's avatar
faisalhamdi committed
697
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
698 699 700 701
                                <Autocomplete
                                    {...this.state.perusahaan}
                                    debug
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
702 703 704 705 706 707 708 709 710 711
                                    onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearError())}
                                    renderInput={(params) =>
                                        <TextField
                                            {...params}
                                            label="Parent Company"
                                            error={this.state.errorPC}
                                            helperText={this.state.msgErrorPC}
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                            InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                        />
faisalhamdi's avatar
faisalhamdi committed
712 713
                                    }
                                    value={this.state.perusahaan}
714
                                />
faisalhamdi's avatar
faisalhamdi committed
715
                            </div>
faisalhamdi's avatar
faisalhamdi committed
716
                            <div style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
717 718 719
                                <DatePicker
                                    margin="normal"
                                    id="endDate"
720
                                    label="Valid To"
faisalhamdi's avatar
faisalhamdi committed
721
                                    format="dd-MM-yyyy"
faisalhamdi's avatar
faisalhamdi committed
722 723
                                    error={this.state.errorED}
                                    helperText={this.state.msgErrorED}
724
                                    minDate={this.state.startDate}
faisalhamdi's avatar
faisalhamdi committed
725
                                    value={this.state.endDate}
faisalhamdi's avatar
faisalhamdi committed
726 727 728 729
                                    onChange={(e) => this.handleChange(e, 'end_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
faisalhamdi's avatar
faisalhamdi committed
730 731 732 733 734 735 736 737 738 739 740
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
faisalhamdi's avatar
faisalhamdi committed
741 742 743

                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
744 745 746 747 748 749 750
                            </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' }}>
faisalhamdi's avatar
faisalhamdi committed
751 752 753 754 755
                            <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' }}>
faisalhamdi's avatar
faisalhamdi committed
756
                                    <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
faisalhamdi's avatar
faisalhamdi committed
757 758
                                </div>
                            </button>
759 760
                        </div>
                        <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
761 762 763 764 765
                            <button
                                type="button"
                                onClick={() => this.validasi()}
                            >
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
766
                                    <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
faisalhamdi's avatar
faisalhamdi committed
767 768
                                </div>
                            </button>
769 770 771 772 773 774 775
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}