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

export default class CreateParameter extends Component {
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 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 358
    constructor(props) {
        super(props)
        this.state = {
            enableParameter: false,
            id: '',
            description: '',
            value: null,
            order: null,
            minValue: null,
            maxValue: null,
            startDate: '',
            endDate: '',
            date: new Date(),
            approvedBy: null,
            getApprovedBy: null,
            types: null,
            getTypes: null,
            perusahaan: null,
            getPerusahaan: null,
            parameter: null,
            getParameter: null,
            operators: null,
            getOperators: null,
            tempData: null,
            errorParameter: false,
            errorDeskripsi: false,
            errorValue: false,
            errorMinValue: false,
            errorOrder: false,
            errorMaxValue: false,
            errorStartDate: false,
            errorEndDate: false,
            msgErrorParameter: '',
            msgErrorDeskripsi: '',
            msgErrorValue: '',
            msgErrorMinValue: '',
            msgErrorOrder: '',
            msgErrorMaxValue: '',
            msgErrorStartDate: '',
            msgErrorEndDate: ''
        }
    }

    componentDidMount() {
        if (this.props.type === 'edit') {
            this.setState({
                getSettingTypeID: this.props.data.setting_type_id,
            })
            this.getDetailParameter()
            this.getParameterByGroup(this.props.data.setting_group_id)
        } else {
            this.getDataGroup()
            this.getDataPerusahaan()
        }
    }

    getDetailParameter() {
        api.create().getDetailParameter(this.props.data.setting_id).then((response) => {
            console.log(response);
            if (response.data.status === 'success') {
                let data = response.data.data
                this.setState({
                    tempData: response.data.data,
                    getSettingGroupID: data.setting_group_id,
                    getCompanyID: data.company_id,
                    settingType: data.setting_type,
                }, () => this.getAllGroup(), this.getPerusahaan())
            } else {
                alert(response.data.message)
            }
        })
    }

    getAllGroup() {
        api.create().getAllGroup().then(response => {
            console.log(response);
            if (response.data.status == 'success') {
                let data = response.data.data
                let typeData = data.map((item) => {
                    return {
                        setting_group_id: item.setting_group_id,
                        setting_group_name: item.setting_group_name
                    }
                })
                let index = typeData.findIndex((val) => val.setting_group_id == this.state.getSettingGroupID)
                let typeProps = {
                    options: typeData,
                    getOptionLabel: (option) => option.setting_group_name,
                };
                this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] })
            } else {
                alert(response.data.message)
            }
        })
    }

    getPerusahaan() {
        api.create().getPerusahaanActive().then(response => {
            if (response.data.status == 'success') {
                let data = response.data.data
                let perusahaanData = data.map((item) => {
                    return {
                        company_id: item.company_id,
                        company_name: item.company_name
                    }
                })
                perusahaanData.push({
                    company_id: 0,
                    company_name: 'Default'
                })
                let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.getCompanyID)
                let typeProps = {
                    options: perusahaanData,
                    getOptionLabel: (option) => option.company_name,
                };
                this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? perusahaanData[0] : perusahaanData[index] })
            } else {
                alert(response.data.message)
            }
        })
    }

    getDataGroup() {
        api.create().getAllGroup().then((response) => {
            if (response.data.status == 'success') {
                let data = response.data.data
                let typeData = data.map((item) => {
                    return {
                        setting_group_id: item.setting_group_id,
                        setting_group_name: item.setting_group_name
                    }
                })
                let typeProps = {
                    options: typeData,
                    getOptionLabel: (option) => option.setting_group_name,
                };
                this.setState({ types: typeProps, typeData: response.data.data })
            } else {
                alert(response.data.message)
            }
        })
    }

    getDataPerusahaan() {
        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
                    }
                })
                typeData.push({
                    company_id: 0,
                    company_name: 'Default'
                })
                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)
            }
        })
    }

    getParameterByGroup(id) {
        api.create().getParameterByGroup(id).then(response => {
            console.log(response);
            if (response.data.status == 'success') {
                let data = response.data.data
                let typeData = data.map((item) => {
                    return {
                        setting_type_id: item.setting_type_id,
                        setting_type_name: item.setting_type_name
                    }
                })
                let index = typeData.findIndex((val) => val.setting_type_id == this.state.getSettingTypeID)
                let typeProps = {
                    options: typeData,
                    getOptionLabel: (option) => option.setting_type_name,
                };
                this.setState({ enableParameter: true, parameter: typeProps, parameterData: response.data.data, getParameter: index == -1 ? typeData[0] : typeData[index] })
            } else {
                alert(response.data.message)
            }
        })
    }

    handleChange(e, type) {
        let data = this.state
        let isDate = type !== '' ? true : false
        if (isDate && type == 'start_date') {
            this.setState({
                ...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null },
                errorParameter: false,
                errorDeskripsi: false,
                errorValue: false,
                errorMinValue: false,
                errorOrder: false,
                errorMaxValue: false,
                errorStartDate: false,
                errorEndDate: false,
                msgErrorParameter: '',
                msgErrorDeskripsi: '',
                msgErrorValue: '',
                msgErrorMinValue: '',
                msgErrorOrder: '',
                msgErrorMaxValue: '',
                msgErrorStartDate: '',
                msgErrorEndDate: ''
            })
        } else if (isDate && type == 'end_date') {
            this.setState({
                ...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
                errorParameter: false,
                errorDeskripsi: false,
                errorValue: false,
                errorMinValue: false,
                errorOrder: false,
                errorMaxValue: false,
                errorStartDate: false,
                errorEndDate: false,
                msgErrorParameter: '',
                msgErrorDeskripsi: '',
                msgErrorValue: '',
                msgErrorMinValue: '',
                msgErrorOrder: '',
                msgErrorMaxValue: '',
                msgErrorStartDate: '',
                msgErrorEndDate: ''
            })
        } else {
            this.setState({
                ...data,
                tempData: { ...this.state.tempData, [e.target.name]: e.target.value },
                errorParameter: false,
                errorDeskripsi: false,
                errorValue: false,
                errorMinValue: false,
                errorOrder: false,
                errorMaxValue: false,
                errorStartDate: false,
                errorEndDate: false,
                msgErrorParameter: '',
                msgErrorDeskripsi: '',
                msgErrorValue: '',
                msgErrorMinValue: '',
                msgErrorOrder: '',
                msgErrorMaxValue: '',
                msgErrorStartDate: '',
                msgErrorEndDate: ''
            })
        }
    }

    handleChangeCreate(e, type) {
        let data = this.state
        let isDate = type !== '' ? true : false
        if (isDate && type == 'start_date') {
            this.setState({ startDate: format(e, 'yyyy-MM-dd') }, () => {
                console.log(this.state.startDate)
            })
        } else if (isDate && type == 'end_date') {
            this.setState({ endDate: format(e, 'yyyy-MM-dd') }, () => {
                console.log(this.state.endDate)
            })
        } else {
            this.setState({ ...data, [e.target.name]: e.target.value })
        }
    }

    validasi() {
        if (R.isEmpty(this.state.tempData.description)) {
            this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
        } else if (R.isEmpty(this.state.tempData.value)) {
            this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
        } else if (R.isNil(this.state.tempData.min_value)) {
            this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' })
        } else if (R.isNil(this.state.tempData.start_date)) {
            this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' })
        } else if (R.isNil(this.state.tempData.order)) {
            this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
        } else if (R.isNil(this.state.tempData.max_value)) {
            this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' })
        } else if (R.isNil(this.state.tempData.end_date)) {
            this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' })
        } else {
            this.updateParameter()
        }
    }

    validasiCreate() {
        if (R.isEmpty(this.state.description)) {
            this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
        } else if (R.isEmpty(this.state.value)) {
            this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
        } else if (R.isNil(this.state.minValue)) {
            this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' })
        } else if (R.isNil(this.state.startDate)) {
            this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' })
        } else if (R.isNil(this.state.order)) {
            this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
        } else if (R.isNil(this.state.maxValue)) {
            this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' })
        } else if (R.isNil(this.state.endDate)) {
            this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' })
        } else {
            this.createParameter()
        }
    }

    updateParameter() {
        let body = {
            "setting_id": this.state.tempData.setting_id,
            "setting_group_id": this.state.getTypes.setting_group_id,
            "setting_type_id": this.state.getParameter.setting_type_id,
            "company_id": this.state.getPerusahaan.company_id,
            "description": this.state.tempData.description,
            "orders": this.state.tempData.order,
            "value": this.state.tempData.value,
            "max_value": this.state.tempData.max_value,
            "min_value": this.state.tempData.min_value,
            "start_date": this.state.tempData.start_date,
            "end_date": this.state.tempData.end_date
        }
        console.log(body);
        this.props.updateParameter(body)
    }

    createParameter() {
        let body = {
            "setting_group_id": this.state.getTypes.setting_group_id,
            "setting_type_id": this.state.getParameter.setting_type_id,
            "company_id": this.state.getPerusahaan.company_id,
            "description": this.state.description,
            "orders": this.state.order,
            "value": this.state.value,
            "max_value": this.state.maxValue,
            "min_value": this.state.minValue,
            "start_date": this.state.startDate,
            "end_date": this.state.endDate
        }
        console.log(body);
        this.props.createParameter(body)
    }

faisalhamdi's avatar
faisalhamdi committed
359 360 361 362 363 364 365
    render() {
        let { type } = this.props
        return type === 'edit' ? this.renderEdit() : this.renderCreate()
    }

    renderEdit() {
        return (
366
            <div className="test app-popup-show">
faisalhamdi's avatar
faisalhamdi committed
367
                <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
368
                    <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
faisalhamdi's avatar
faisalhamdi committed
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
                        <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                            <div className="popup-title">
                                <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Ubah 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()}
                            >
                                <i className="fa fa-lg fa-times" style={{ color: 'white' }} />
                            </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%' }}
391
                                    value={this.state.tempData === null ? '' : this.state.tempData.setting_id}
faisalhamdi's avatar
faisalhamdi committed
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
                                    id="id"
                                    label="ID"
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                />
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
409 410 411 412 413 414 415 416
                                <Autocomplete
                                    {...this.state.parameter}
                                    debug
                                    id="tipe"
                                    onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue })}
                                    renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parameter" />}
                                    value={this.state.getParameter}
                                />
faisalhamdi's avatar
faisalhamdi committed
417 418 419 420
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
421 422 423
                                    id="description"
                                    label="Description"
                                    value={this.state.tempData === null ? '' : this.state.tempData.description}
faisalhamdi's avatar
faisalhamdi committed
424 425 426 427 428 429 430 431 432 433 434
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
435 436 437 438
                                    name="description"
                                    onChange={(e) => this.handleChange(e, '')}
                                    error={this.state.errorDeskripsi}
                                    helperText={this.state.msgErrorDeskripsi}
faisalhamdi's avatar
faisalhamdi committed
439 440 441 442 443 444 445 446
                                >
                                </TextField>
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
                                    id="value"
                                    label="Value"
447 448
                                    value={this.state.tempData === null ? '' : this.state.tempData.value}
                                    type={"number"}
faisalhamdi's avatar
faisalhamdi committed
449 450 451 452 453 454 455 456 457 458 459
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
460 461 462 463
                                    name="value"
                                    onChange={(e) => this.handleChange(e, '')}
                                    error={this.state.errorValue}
                                    helperText={this.state.msgErrorValue}
faisalhamdi's avatar
faisalhamdi committed
464 465 466 467 468 469
                                >
                                </TextField>
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
470
                                    id="min_value"
faisalhamdi's avatar
faisalhamdi committed
471
                                    label="Min Value"
472 473
                                    type={"number"}
                                    value={this.state.tempData === null ? '' : this.state.tempData.min_value}
faisalhamdi's avatar
faisalhamdi committed
474 475 476 477 478 479 480 481 482 483 484
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
485 486 487 488
                                    name="min_value"
                                    onChange={(e) => this.handleChange(e, '')}
                                    error={this.state.errorMinValue}
                                    helperText={this.state.msgErrorMinValue}
faisalhamdi's avatar
faisalhamdi committed
489 490 491 492
                                >
                                </TextField>
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
493 494 495
                                <DatePicker
                                    margin="normal"
                                    id="start_date"
faisalhamdi's avatar
faisalhamdi committed
496
                                    label="Berlaku Mulai"
497 498 499 500 501 502 503 504
                                    format="dd MMMM yyyy"
                                    value={this.state.tempData === null ? '' : this.state.tempData.start_date}
                                    error={this.state.errorStartDate}
                                    helperText={this.state.msgErrorStartDate}
                                    onChange={(e) => this.handleChange(e, 'start_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
faisalhamdi's avatar
faisalhamdi committed
505 506 507 508 509 510 511 512 513 514 515
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
516 517 518

                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
faisalhamdi's avatar
faisalhamdi committed
519 520
                            </div>

521
                            <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
522 523 524 525
                                <TextField
                                    style={{ width: '100%' }}
                                    id="status"
                                    label="Status"
526
                                    value={this.state.tempData === null ? '' : this.state.tempData.status}
faisalhamdi's avatar
faisalhamdi committed
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                />
                            </div>

                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
543 544 545 546 547 548 549 550
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography>
                                    <Typography style={{ fontSize: 11 }}>: {this.props.data.created}</Typography>
                                </div>
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
                                    <Typography style={{ fontSize: 11 }}>: {this.props.data.updated == - null ? "" : this.props.data.updated}</Typography>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
551 552 553 554
                            </div>
                        </div>

                        <div className="column-2">
555 556 557 558 559 560 561 562 563
                            <div className="" style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    {...this.state.types}
                                    debug
                                    id="tipe"
                                    onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }) : this.getParameterByGroup(newInputValue.setting_group_id))}
                                    renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Group" />}
                                    value={this.state.getTypes}
                                />
faisalhamdi's avatar
faisalhamdi committed
564 565
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
566 567 568 569 570 571 572 573
                                <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="Perusahaan" />}
                                    value={this.state.getPerusahaan}
                                />
faisalhamdi's avatar
faisalhamdi committed
574 575 576 577 578 579
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
                                    id="order"
                                    label="Order"
580 581
                                    type={"number"}
                                    value={this.state.tempData === null ? '' : this.state.tempData.order}
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 596
                                    name="order"
                                    onChange={(e) => this.handleChange(e, '')}
                                    error={this.state.errorOrder}
                                    helperText={this.state.msgErrorOrder}
faisalhamdi's avatar
faisalhamdi committed
597 598 599 600 601 602
                                >
                                </TextField>
                            </div>
                            <div style={{ marginTop: '80px', padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
603
                                    id="max_value"
faisalhamdi's avatar
faisalhamdi committed
604
                                    label="Max Value"
605 606
                                    type={"number"}
                                    value={this.state.tempData === null ? '' : this.state.tempData.max_value}
faisalhamdi's avatar
faisalhamdi committed
607 608 609 610 611 612 613 614 615 616 617
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
618 619 620 621
                                    name="max_value"
                                    onChange={(e) => this.handleChange(e, '')}
                                    error={this.state.errorMaxValue}
                                    helperText={this.state.msgErrorMaxValue}
faisalhamdi's avatar
faisalhamdi committed
622 623 624 625
                                >
                                </TextField>
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
626 627 628 629 630 631 632 633 634 635 636 637 638
                                <DatePicker
                                    margin="normal"
                                    id="end_date"
                                    label="Berakhir Hingga"
                                    format="dd MMMM yyyy"
                                    error={this.state.errorEndDate}
                                    helperText={this.state.msgErrorEndDate}
                                    minDate={this.state.tempData === null ? null : this.state.tempData.start_date}
                                    value={this.state.tempData === null ? '' : this.state.tempData.end_date}
                                    onChange={(e) => this.handleChange(e, 'end_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
faisalhamdi's avatar
faisalhamdi committed
639 640 641 642 643 644 645 646 647 648 649
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
650 651 652

                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
faisalhamdi's avatar
faisalhamdi committed
653 654 655 656 657 658
                            </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' }}>
659 660 661 662 663 664 665 666
                            <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>
faisalhamdi's avatar
faisalhamdi committed
667 668
                        </div>
                        <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
669 670 671 672 673 674 675 676
                            <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>
faisalhamdi's avatar
faisalhamdi committed
677 678 679 680 681 682 683 684 685
                        </div>
                    </div>
                </div>
            </div>
        )
    }

    renderCreate() {
        return (
686
            <div className="test app-popup-show">
faisalhamdi's avatar
faisalhamdi committed
687
                <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
688
                    <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
faisalhamdi's avatar
faisalhamdi committed
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
                        <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()}
                            >
                                <i className="fa fa-lg fa-times" style={{ color: 'white' }} />
                            </button>
                        </div>
                    </div>


                    <div className="border-bottom grid grid-2x grid-mobile-none gap-15px" style={{ padding: 20 }}>
                        <div className="column-1">
708
                            <div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
709 710
                                <TextField
                                    style={{ width: '100%' }}
711 712 713 714
                                    value={this.state.tempData === null ? '' : this.state.tempData.setting_id}
                                    id="id"
                                    label="ID"
                                    disabled
faisalhamdi's avatar
faisalhamdi committed
715 716 717 718 719 720 721 722 723 724 725
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
726
                                />
faisalhamdi's avatar
faisalhamdi committed
727
                            </div>
728 729 730 731 732 733 734 735 736 737 738 739
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    {...this.state.parameter}
                                    debug
                                    disabled={!this.state.enableParameter}
                                    id="tipe"
                                    onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue })}
                                    renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parameter" />}
                                    value={this.state.getParameter}
                                />
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
740 741
                                <TextField
                                    style={{ width: '100%' }}
742 743 744
                                    id="description"
                                    label="Description"
                                    value={this.state.description === '' ? '' : this.state.description}
faisalhamdi's avatar
faisalhamdi committed
745 746 747 748 749 750 751 752 753 754 755
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
756 757 758 759
                                    name="description"
                                    onChange={(e) => this.handleChangeCreate(e, '')}
                                    error={this.state.errorDeskripsi}
                                    helperText={this.state.msgErrorDeskripsi}
faisalhamdi's avatar
faisalhamdi committed
760 761 762
                                >
                                </TextField>
                            </div>
763
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
764 765 766 767
                                <TextField
                                    style={{ width: '100%' }}
                                    id="value"
                                    label="Value"
768 769
                                    value={this.state.value === null ? '' : this.state.value}
                                    type={"number"}
faisalhamdi's avatar
faisalhamdi committed
770 771 772 773 774 775 776 777 778 779 780
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
781 782 783 784
                                    name="value"
                                    onChange={(e) => this.handleChangeCreate(e, '')}
                                    error={this.state.errorValue}
                                    helperText={this.state.msgErrorValue}
faisalhamdi's avatar
faisalhamdi committed
785 786 787
                                >
                                </TextField>
                            </div>
788
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
789 790
                                <TextField
                                    style={{ width: '100%' }}
791
                                    id="min_value"
faisalhamdi's avatar
faisalhamdi committed
792
                                    label="Min Value"
793 794
                                    type={"number"}
                                    value={this.state.minValue === null ? '' : this.state.minValue}
faisalhamdi's avatar
faisalhamdi committed
795 796 797 798 799 800 801 802 803 804 805
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
806 807 808 809
                                    name="minValue"
                                    onChange={(e) => this.handleChangeCreate(e, '')}
                                    error={this.state.errorMinValue}
                                    helperText={this.state.msgErrorMinValue}
faisalhamdi's avatar
faisalhamdi committed
810 811 812
                                >
                                </TextField>
                            </div>
813 814 815 816
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="startDate"
faisalhamdi's avatar
faisalhamdi committed
817
                                    label="Berlaku Mulai"
818 819 820 821 822 823 824 825
                                    format="dd MMMM yyyy"
                                    error={this.state.errorStartDate}
                                    helperText={this.state.msgErrorStartDate}
                                    value={this.state.startDate == "" ? null : this.state.startDate}
                                    onChange={(e) => this.handleChangeCreate(e, 'start_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
faisalhamdi's avatar
faisalhamdi committed
826 827 828 829 830 831 832 833 834 835 836
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
837 838 839

                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
faisalhamdi's avatar
faisalhamdi committed
840 841
                            </div>

842
                            <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869
                                <TextField
                                    style={{ width: '100%' }}
                                    defaultValue={"Aktif"}
                                    id="status"
                                    label="Status"
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                />
                            </div>

                            <div style={{ padding: 10, borderRadius: 5 }}>
                                <Typography style={{ fontSize: 11 }}>Dibuat	: Admin - 21 Jul 2020, 18:45</Typography>
                                <Typography style={{ fontSize: 11 }}>Diubah	: Admin - 21 Jul 2020, 18:45</Typography>
                            </div>
                        </div>

                        <div className="column-2">
870 871 872 873 874 875 876 877 878
                            <div className="" style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    {...this.state.types}
                                    debug
                                    id="tipe"
                                    onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }) : this.getParameterByGroup(newInputValue.setting_group_id))}
                                    renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Group" />}
                                    value={this.state.getTypes}
                                />
faisalhamdi's avatar
faisalhamdi committed
879
                            </div>
880 881 882 883 884 885 886 887 888
                            <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="Perusahaan" />}
                                    value={this.state.getPerusahaan}
                                />
faisalhamdi's avatar
faisalhamdi committed
889
                            </div>
890
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
891 892 893 894
                                <TextField
                                    style={{ width: '100%' }}
                                    id="order"
                                    label="Order"
895 896
                                    type={"number"}
                                    value={this.state.order === null ? '' : this.state.order}
faisalhamdi's avatar
faisalhamdi committed
897 898 899 900 901 902 903 904 905 906 907
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
908 909 910 911
                                    name="order"
                                    onChange={(e) => this.handleChangeCreate(e, '')}
                                    error={this.state.errorOrder}
                                    helperText={this.state.msgErrorOrder}
faisalhamdi's avatar
faisalhamdi committed
912 913 914
                                >
                                </TextField>
                            </div>
915
                            <div style={{ marginTop: '80px', padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
916 917
                                <TextField
                                    style={{ width: '100%' }}
918
                                    id="max_value"
faisalhamdi's avatar
faisalhamdi committed
919
                                    label="Max Value"
920 921
                                    type={"number"}
                                    value={this.state.maxValue === null ? '' : this.state.maxValue}
faisalhamdi's avatar
faisalhamdi committed
922 923 924 925 926 927 928 929 930 931 932
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
933 934 935 936
                                    name="maxValue"
                                    onChange={(e) => this.handleChangeCreate(e, '')}
                                    error={this.state.errorMaxValue}
                                    helperText={this.state.msgErrorMaxValue}
faisalhamdi's avatar
faisalhamdi committed
937 938 939
                                >
                                </TextField>
                            </div>
940 941 942 943 944 945 946 947 948 949 950 951 952 953
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="endDate"
                                    label="Berakhir Hingga"
                                    format="dd MMMM yyyy"
                                    error={this.state.errorEndDate}
                                    helperText={this.state.msgErrorEndDate}
                                    minDate={this.state.startDate}
                                    value={this.state.endDate == "" ? null : this.state.endDate}
                                    onChange={(e) => this.handleChangeCreate(e, 'end_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
faisalhamdi's avatar
faisalhamdi committed
954 955 956 957 958 959 960 961 962 963 964
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
965 966 967

                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
faisalhamdi's avatar
faisalhamdi committed
968 969 970 971 972 973
                            </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' }}>
974 975 976 977 978 979 980 981
                            <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>
faisalhamdi's avatar
faisalhamdi committed
982 983
                        </div>
                        <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
984 985 986 987 988 989 990 991
                            <button
                                type="button"
                                onClick={() => this.validasiCreate()}
                            >
                                <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>
faisalhamdi's avatar
faisalhamdi committed
992 993 994 995 996 997 998
                        </div>
                    </div>
                </div>
            </div>
        )
    }
}