CreateParameter.js 65.2 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'
d.arizona's avatar
d.arizona committed
8
import Images from '../../../assets/Images';
a.bairuha's avatar
a.bairuha committed
9
import Constant from '../../../library/Constant';
faisalhamdi's avatar
faisalhamdi committed
10 11

export default class CreateParameter extends Component {
12 13 14 15 16 17
    constructor(props) {
        super(props)
        this.state = {
            enableParameter: false,
            id: '',
            description: '',
18
            value: '',
19
            order: null,
20 21
            minValue: '',
            maxValue: '',
22
            startDate: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
23
            endDate: null,
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
            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,
Deni Rinaldi's avatar
Deni Rinaldi committed
44 45 46 47
            errorGroup: false,
            errorPerusahaan: false,
            msgErrorPerusahaan: '',
            msgErrorGroup: '',
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
            msgErrorParameter: '',
            msgErrorDeskripsi: '',
            msgErrorValue: '',
            msgErrorMinValue: '',
            msgErrorOrder: '',
            msgErrorMaxValue: '',
            msgErrorStartDate: '',
            msgErrorEndDate: ''
        }
    }

    componentDidMount() {
        if (this.props.type === 'edit') {
            this.getDetailParameter()
        } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
63 64 65 66 67
            let date = format(new Date, 'yyyy-MM-dd')
            this.setState({
                startDate: date,
                endDate: date
            })
68 69 70 71 72 73
            this.getDataGroup()
            this.getDataPerusahaan()
        }
    }

    getDetailParameter() {
Deni Rinaldi's avatar
Deni Rinaldi committed
74
        api.create().getDetailParameter(this.props.data[0]).then((response) => {
75
            console.log(response);
a.bairuha's avatar
a.bairuha committed
76
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
77 78 79 80 81
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        this.setState({
                            tempData: response.data.data,
82
                            getSettingGroupID: response.data.data.setting_group_id,
a.bairuha's avatar
a.bairuha committed
83 84
                            getCompanyID: data.company_id,
                            settingType: data.setting_type,
Deni Rinaldi's avatar
Deni Rinaldi committed
85
                            getSettingTypeID: data.setting_type_id
a.bairuha's avatar
a.bairuha committed
86 87 88 89 90 91 92
                        }, () => {
                            this.getAllGroup()
                            this.getPerusahaan()
                            console.log(this.state.tempData)
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
93
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
94 95 96 97 98 99 100
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
a.bairuha's avatar
a.bairuha committed
101
                } else {
a.bairuha's avatar
a.bairuha committed
102
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
a.bairuha's avatar
a.bairuha committed
103
                }
104
            } else {
a.bairuha's avatar
a.bairuha committed
105
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
106 107 108 109 110 111 112
            }
        })
    }

    getAllGroup() {
        api.create().getAllGroup().then(response => {
            console.log(response);
a.bairuha's avatar
a.bairuha committed
113
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127
                if (response.ok) {
                    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,
                        };
128 129
                        this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] }, ()=> { 
                            this.getParameterByGroup(this.state.getTypes.setting_group_id)})
a.bairuha's avatar
a.bairuha committed
130 131
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
132
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
133 134 135 136 137 138
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
139
                    }
a.bairuha's avatar
a.bairuha committed
140
                } else {
a.bairuha's avatar
a.bairuha committed
141
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
a.bairuha's avatar
a.bairuha committed
142
                }
143
            } else {
a.bairuha's avatar
a.bairuha committed
144
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
145 146 147 148 149 150
            }
        })
    }

    getPerusahaan() {
        api.create().getPerusahaanActive().then(response => {
a.bairuha's avatar
a.bairuha committed
151
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
                if (response.ok) {
                    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,
                        };
a.bairuha's avatar
a.bairuha committed
170
                        this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index], msgErrorPerusahaan: index === -1 ? 'Company has been Inactive' : "", errorPerusahaan: index === -1 ? true : false })
a.bairuha's avatar
a.bairuha committed
171 172
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
173
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
174 175 176 177 178 179
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
180
                    }
a.bairuha's avatar
a.bairuha committed
181
                } else {
a.bairuha's avatar
a.bairuha committed
182
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
a.bairuha's avatar
a.bairuha committed
183
                }
184
            } else {
a.bairuha's avatar
a.bairuha committed
185
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
186 187 188 189 190 191
            }
        })
    }

    getDataGroup() {
        api.create().getAllGroup().then((response) => {
a.bairuha's avatar
a.bairuha committed
192
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
                if (response.ok) {
                    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 {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
209
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
210 211 212 213 214 215
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
216
                    }
a.bairuha's avatar
a.bairuha committed
217
                } else {
a.bairuha's avatar
a.bairuha committed
218
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
a.bairuha's avatar
a.bairuha committed
219
                }
220
            } else {
a.bairuha's avatar
a.bairuha committed
221
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
222 223 224 225 226 227
            }
        })
    }

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

    getParameterByGroup(id) {
        api.create().getParameterByGroup(id).then(response => {
268
            console.log(id, response);
a.bairuha's avatar
a.bairuha committed
269
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
270 271 272 273 274 275 276 277 278 279 280 281 282 283
                if (response.ok) {
                    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,
                        };
Deni Rinaldi's avatar
Deni Rinaldi committed
284
                        this.setState({ enableParameter: true, parameter: typeProps, parameterData: response.data.data, getParameter: index == -1 ? null : typeData[index] })
a.bairuha's avatar
a.bairuha committed
285 286
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
a.bairuha's avatar
a.bairuha committed
287
                            if (response.data.message.includes("Someone Logged In")) {
a.bairuha's avatar
a.bairuha committed
288 289 290 291 292 293
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
294
                    }
a.bairuha's avatar
a.bairuha committed
295
                } else {
a.bairuha's avatar
a.bairuha committed
296
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
a.bairuha's avatar
a.bairuha committed
297
                }
298
            } else {
a.bairuha's avatar
a.bairuha committed
299
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
            }
        })
    }

    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,
Deni Rinaldi's avatar
Deni Rinaldi committed
318 319 320 321
                errorGroup: false,
                errorPerusahaan: false,
                msgErrorPerusahaan: '',
                msgErrorGroup: '',
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
                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,
Deni Rinaldi's avatar
Deni Rinaldi committed
342 343 344 345
                errorGroup: false,
                errorPerusahaan: false,
                msgErrorPerusahaan: '',
                msgErrorGroup: '',
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
                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,
Deni Rinaldi's avatar
Deni Rinaldi committed
367 368 369 370
                errorGroup: false,
                errorPerusahaan: false,
                msgErrorPerusahaan: '',
                msgErrorGroup: '',
371 372 373 374 375 376 377 378 379 380 381 382
                msgErrorParameter: '',
                msgErrorDeskripsi: '',
                msgErrorValue: '',
                msgErrorMinValue: '',
                msgErrorOrder: '',
                msgErrorMaxValue: '',
                msgErrorStartDate: '',
                msgErrorEndDate: ''
            })
        }
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
    clearMessage() {
        this.setState({
            errorParameter: false,
            errorDeskripsi: false,
            errorValue: false,
            errorMinValue: false,
            errorOrder: false,
            errorMaxValue: false,
            errorStartDate: false,
            errorEndDate: false,
            errorGroup: false,
            errorPerusahaan: false,
            msgErrorPerusahaan: '',
            msgErrorGroup: '',
            msgErrorParameter: '',
            msgErrorDeskripsi: '',
            msgErrorValue: '',
            msgErrorMinValue: '',
            msgErrorOrder: '',
            msgErrorMaxValue: '',
            msgErrorStartDate: '',
            msgErrorEndDate: ''
        })
    }

408 409 410 411
    handleChangeCreate(e, type) {
        let data = this.state
        let isDate = type !== '' ? true : false
        if (isDate && type == 'start_date') {
Deni Rinaldi's avatar
Deni Rinaldi committed
412
            this.setState({ startDate: format(e, 'yyyy-MM-dd'), endDate: null }, () => {
413 414 415 416 417 418 419
                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 {
Deni Rinaldi's avatar
Deni Rinaldi committed
420
            this.setState({ ...data, [e.target.name]: e.target.value }, () => this.clearMessage())
421 422 423 424
        }
    }

    validasi() {
Deni Rinaldi's avatar
Deni Rinaldi committed
425
        if (R.isNil(this.state.getTypes)) {
EKSAD's avatar
EKSAD committed
426
            this.setState({ errorGroup: true, msgErrorGroup: 'Group Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
427
        } else if (R.isNil(this.state.getParameter)) {
EKSAD's avatar
EKSAD committed
428
            this.setState({ errorParameter: true, msgErrorParameter: 'Parameter Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
429
        } else if (R.isNil(this.state.getPerusahaan)) {
EKSAD's avatar
EKSAD committed
430
            this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
431 432
            // } else if (R.isEmpty(this.state.tempData.description)) {
            //     this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
433
        } else if (R.isEmpty(this.state.tempData.value) && R.isEmpty(this.state.tempData.min_value) && R.isEmpty(this.state.tempData.max_value)) {
EKSAD's avatar
EKSAD committed
434
            this.setState({ errorValue: true, msgErrorValue: 'Value Cannot be Empty' })
435
        } else if ((!R.isEmpty(this.state.tempData.max_value) && R.isEmpty(this.state.tempData.min_value))) {
EKSAD's avatar
EKSAD committed
436
            this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value Cannot be Empty' })
437
        } else if (R.isNil(this.state.tempData.start_date)) {
EKSAD's avatar
EKSAD committed
438
            this.setState({ errorStartDate: true, msgErrorStartDate: 'Valid From Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
439 440
            // } else if (R.isNil(this.state.tempData.order)) {
            //     this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
441
        } else if ((!R.isEmpty(this.state.tempData.min_value) && R.isEmpty(this.state.tempData.max_value))) {
EKSAD's avatar
EKSAD committed
442
            this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value Cannot be Empty' })
443
        } else if (R.isNil(this.state.tempData.end_date)) {
EKSAD's avatar
EKSAD committed
444
            this.setState({ errorEndDate: true, msgErrorEndDate: 'Valid To Cannot be Empty' })
445 446 447 448 449 450
        } else {
            this.updateParameter()
        }
    }

    validasiCreate() {
Deni Rinaldi's avatar
Deni Rinaldi committed
451
        if (R.isNil(this.state.getTypes)) {
EKSAD's avatar
EKSAD committed
452
            this.setState({ errorGroup: true, msgErrorGroup: 'Group Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
453
        } else if (R.isNil(this.state.getParameter)) {
EKSAD's avatar
EKSAD committed
454
            this.setState({ errorParameter: true, msgErrorParameter: 'Parameter Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
455
        } else if (R.isNil(this.state.getPerusahaan)) {
EKSAD's avatar
EKSAD committed
456
            this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
457 458
            // } else if (R.isEmpty(this.state.description)) {
            //     this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
459
        } else if ((R.isEmpty(this.state.value) && R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) {
EKSAD's avatar
EKSAD committed
460
            this.setState({ errorValue: true, msgErrorValue: 'Value Cannot be Empty' })
461
        } else if ((!R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) {
EKSAD's avatar
EKSAD committed
462
            this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value Cannot be Empty' })
463
        } else if (R.isNil(this.state.startDate)) {
EKSAD's avatar
EKSAD committed
464
            this.setState({ errorStartDate: true, msgErrorStartDate: 'Valid From Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
465 466
            // } else if (R.isNil(this.state.order)) {
            //     this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
467
        } else if ((!R.isEmpty(this.state.minValue) && R.isEmpty(this.state.maxValue))) {
EKSAD's avatar
EKSAD committed
468
            this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value Cannot be Empty' })
469
        } else if (R.isNil(this.state.endDate)) {
EKSAD's avatar
EKSAD committed
470
            this.setState({ errorEndDate: true, msgErrorEndDate: 'Valid To Cannot be Empty' })
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
        } 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
511 512 513 514 515 516 517
    render() {
        let { type } = this.props
        return type === 'edit' ? this.renderEdit() : this.renderCreate()
    }

    renderEdit() {
        return (
518
            <div className="test app-popup-show">
faisalhamdi's avatar
faisalhamdi committed
519
                <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
520
                    <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
faisalhamdi's avatar
faisalhamdi committed
521 522 523 524 525 526 527 528 529 530 531
                        <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()}
                            >
Deni Rinaldi's avatar
Deni Rinaldi committed
532
                                <img src={Images.close} />
faisalhamdi's avatar
faisalhamdi committed
533 534 535 536 537 538 539 540 541 542
                            </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%' }}
543
                                    value={this.state.tempData === null ? '' : this.state.tempData.setting_id}
faisalhamdi's avatar
faisalhamdi committed
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
                                    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 }}>
561 562 563 564
                                <Autocomplete
                                    {...this.state.parameter}
                                    debug
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
565
                                    onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, () => this.clearMessage())}
Deni Rinaldi's avatar
Deni Rinaldi committed
566 567 568 569 570 571 572 573 574
                                    renderInput={(params) =>
                                        <TextField
                                            {...params}
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                            InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                            label="Parameter"
                                            error={this.state.errorParameter}
                                            helperText={this.state.msgErrorParameter}
                                        />}
575 576
                                    value={this.state.getParameter}
                                />
faisalhamdi's avatar
faisalhamdi committed
577 578 579 580
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
581 582 583
                                    id="description"
                                    label="Description"
                                    value={this.state.tempData === null ? '' : this.state.tempData.description}
faisalhamdi's avatar
faisalhamdi committed
584 585 586 587 588 589 590 591 592 593 594
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
595 596
                                    name="description"
                                    onChange={(e) => this.handleChange(e, '')}
Deni Rinaldi's avatar
Deni Rinaldi committed
597 598
                                // error={this.state.errorDeskripsi}
                                // helperText={this.state.msgErrorDeskripsi}
faisalhamdi's avatar
faisalhamdi committed
599 600 601 602 603 604 605 606
                                >
                                </TextField>
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
                                    id="value"
                                    label="Value"
607
                                    value={this.state.tempData === null ? '' : this.state.tempData.value}
faisalhamdi's avatar
faisalhamdi committed
608
                                    inputProps={{
609
                                        min: 0,
faisalhamdi's avatar
faisalhamdi committed
610 611 612 613 614 615 616 617 618 619
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
620
                                    name="value"
Deni Rinaldi's avatar
Deni Rinaldi committed
621 622 623 624
                                    onChange={(e) => {
                                        this.setState({
                                            tempData: {
                                                ...this.state.tempData,
Deni Rinaldi's avatar
Deni Rinaldi committed
625
                                                value: e.target.value
Deni Rinaldi's avatar
Deni Rinaldi committed
626 627 628 629 630 631
                                            }
                                        })
                                        this.clearMessage()
                                    }
                                        // this.handleChange(coba, 'value')}
                                    }
632 633
                                error={this.state.errorValue}
                                helperText={this.state.msgErrorValue}
faisalhamdi's avatar
faisalhamdi committed
634 635 636 637 638 639
                                >
                                </TextField>
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
640
                                    id="min_value"
faisalhamdi's avatar
faisalhamdi committed
641
                                    label="Min Value"
642
                                    value={this.state.tempData === null ? '' : this.state.tempData.min_value}
faisalhamdi's avatar
faisalhamdi committed
643
                                    inputProps={{
644
                                        min: 0,
faisalhamdi's avatar
faisalhamdi committed
645 646 647 648 649 650 651 652 653 654
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
655
                                    name="min_value"
Deni Rinaldi's avatar
Deni Rinaldi committed
656
                                    onChange={(e) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
657
                                        // let coba = String(e.target.value).replace(/[^\d]/g, '');
Deni Rinaldi's avatar
Deni Rinaldi committed
658 659 660
                                        this.setState({
                                            tempData: {
                                                ...this.state.tempData,
Deni Rinaldi's avatar
Deni Rinaldi committed
661
                                                min_value: e.target.value
Deni Rinaldi's avatar
Deni Rinaldi committed
662 663 664 665 666 667
                                            }
                                        })
                                        this.clearMessage()
                                    }
                                        // this.handleChange(coba, 'value')}
                                    }
668 669
                                    error={this.state.errorMinValue}
                                    helperText={this.state.msgErrorMinValue}
faisalhamdi's avatar
faisalhamdi committed
670 671 672 673
                                >
                                </TextField>
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
674 675 676
                                <DatePicker
                                    margin="normal"
                                    id="start_date"
Deni Rinaldi's avatar
Deni Rinaldi committed
677
                                    label="Valid From"
Deni Rinaldi's avatar
Deni Rinaldi committed
678
                                    format="dd-MM-yyyy"
679 680 681 682 683 684 685
                                    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
686 687 688 689 690 691 692 693 694 695 696
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
697 698 699

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

702
                            <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
703 704 705 706
                                <TextField
                                    style={{ width: '100%' }}
                                    id="status"
                                    label="Status"
707
                                    value={this.state.tempData === null ? '' : this.state.tempData.status}
faisalhamdi's avatar
faisalhamdi committed
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                />
                            </div>

                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
724
                                <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
725
                                    <Typography style={{ fontSize: 11, width: '25%' }}>Created By</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
726
                                    <Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.created}</Typography>
727 728
                                </div>
                                <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
729
                                    <Typography style={{ fontSize: 11, width: '25%' }}>Updated By</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
730
                                    <Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.updated === null ? "" : this.state.tempData.updated}</Typography>
731
                                </div>
faisalhamdi's avatar
faisalhamdi committed
732 733 734 735
                            </div>
                        </div>

                        <div className="column-2">
736 737 738 739 740
                            <div className="" style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    {...this.state.types}
                                    debug
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
741 742 743 744 745 746 747 748 749
                                    onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id), this.clearMessage())}
                                    renderInput={(params) =>
                                        <TextField
                                            {...params}
                                            error={this.state.errorGroup}
                                            helperText={this.state.msgErrorGroup}
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                            InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                            label="Group" />}
750 751
                                    value={this.state.getTypes}
                                />
faisalhamdi's avatar
faisalhamdi committed
752 753
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
754 755 756 757
                                <Autocomplete
                                    {...this.state.perusahaan}
                                    debug
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
758 759 760 761 762 763 764
                                    onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearMessage())}
                                    renderInput={(params) =>
                                        <TextField {...params}
                                            error={this.state.errorPerusahaan}
                                            helperText={this.state.msgErrorPerusahaan}
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                            InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
Deni Rinaldi's avatar
Deni Rinaldi committed
765
                                            label="Company Name" />}
766 767
                                    value={this.state.getPerusahaan}
                                />
faisalhamdi's avatar
faisalhamdi committed
768 769 770 771 772 773
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
                                    id="order"
                                    label="Order"
774
                                    value={this.state.tempData === null ? '' : this.state.tempData.order}
faisalhamdi's avatar
faisalhamdi committed
775
                                    inputProps={{
776
                                        min: 0,
faisalhamdi's avatar
faisalhamdi committed
777 778 779 780 781 782 783 784 785 786
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
787
                                    name="order"
Deni Rinaldi's avatar
Deni Rinaldi committed
788
                                    onChange={(e) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
789
                                        let coba = String(e.target.value).replace(/[^\d]/g, '');
Deni Rinaldi's avatar
Deni Rinaldi committed
790 791 792 793 794 795
                                        this.setState({
                                            tempData: {
                                                ...this.state.tempData,
                                                order: coba
                                            }
                                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
796 797
                                        this.clearMessage()
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
798 799
                                        // this.handleChange(coba, 'value')}
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
800 801
                                // error={this.state.errorOrder}
                                // helperText={this.state.msgErrorOrder}
faisalhamdi's avatar
faisalhamdi committed
802 803 804 805 806 807
                                >
                                </TextField>
                            </div>
                            <div style={{ marginTop: '80px', padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
808
                                    id="max_value"
faisalhamdi's avatar
faisalhamdi committed
809
                                    label="Max Value"
810
                                    value={this.state.tempData === null ? '' : this.state.tempData.max_value}
faisalhamdi's avatar
faisalhamdi committed
811
                                    inputProps={{
812
                                        min: 0,
faisalhamdi's avatar
faisalhamdi committed
813 814 815 816 817 818 819 820 821 822
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
823
                                    name="max_value"
Deni Rinaldi's avatar
Deni Rinaldi committed
824
                                    onChange={(e) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
825
                                        // let coba = String(e.target.value).replace(/[^\d]/g, '');
Deni Rinaldi's avatar
Deni Rinaldi committed
826 827 828
                                        this.setState({
                                            tempData: {
                                                ...this.state.tempData,
Deni Rinaldi's avatar
Deni Rinaldi committed
829
                                                max_value: e.target.value
Deni Rinaldi's avatar
Deni Rinaldi committed
830 831 832 833 834 835
                                            }
                                        })
                                        this.clearMessage()
                                    }
                                        // this.handleChange(coba, 'value')}
                                    }
836 837
                                    error={this.state.errorMaxValue}
                                    helperText={this.state.msgErrorMaxValue}
faisalhamdi's avatar
faisalhamdi committed
838 839 840 841
                                >
                                </TextField>
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
842 843 844
                                <DatePicker
                                    margin="normal"
                                    id="end_date"
Deni Rinaldi's avatar
Deni Rinaldi committed
845
                                    label="Valid To"
Deni Rinaldi's avatar
Deni Rinaldi committed
846
                                    format="dd-MM-yyyy"
847 848 849 850 851 852 853 854
                                    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
855 856 857 858 859 860 861 862 863 864 865
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
866 867 868

                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
faisalhamdi's avatar
faisalhamdi committed
869 870 871 872 873 874
                            </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' }}>
875 876 877 878 879
                            <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' }}>
a.bairuha's avatar
a.bairuha committed
880
                                    <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
881 882
                                </div>
                            </button>
faisalhamdi's avatar
faisalhamdi committed
883 884
                        </div>
                        <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
885 886 887 888 889
                            <button
                                type="button"
                                onClick={() => this.validasi()}
                            >
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
a.bairuha's avatar
a.bairuha committed
890
                                    <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
891 892
                                </div>
                            </button>
faisalhamdi's avatar
faisalhamdi committed
893 894 895 896 897 898 899 900 901
                        </div>
                    </div>
                </div>
            </div>
        )
    }

    renderCreate() {
        return (
902
            <div className="test app-popup-show">
faisalhamdi's avatar
faisalhamdi committed
903
                <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
904
                    <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
faisalhamdi's avatar
faisalhamdi committed
905 906 907 908 909 910 911 912 913 914 915
                        <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
916
                                <img src={Images.close} />
faisalhamdi's avatar
faisalhamdi committed
917 918 919 920 921 922 923
                            </button>
                        </div>
                    </div>


                    <div className="border-bottom grid grid-2x grid-mobile-none gap-15px" style={{ padding: 20 }}>
                        <div className="column-1">
924
                            <div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
925 926
                                <TextField
                                    style={{ width: '100%' }}
927 928 929 930
                                    value={this.state.tempData === null ? '' : this.state.tempData.setting_id}
                                    id="id"
                                    label="ID"
                                    disabled
faisalhamdi's avatar
faisalhamdi committed
931 932 933 934 935 936 937 938 939 940 941
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
942
                                />
faisalhamdi's avatar
faisalhamdi committed
943
                            </div>
944 945 946 947 948 949
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    {...this.state.parameter}
                                    debug
                                    disabled={!this.state.enableParameter}
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
950
                                    onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, () => this.clearMessage())}
Deni Rinaldi's avatar
Deni Rinaldi committed
951 952 953 954 955 956 957 958 959
                                    renderInput={(params) =>
                                        <TextField
                                            {...params}
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                            InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                            label="Parameter"
                                            error={this.state.errorParameter}
                                            helperText={this.state.msgErrorParameter}
                                        />}
960 961 962 963
                                    value={this.state.getParameter}
                                />
                            </div>
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
964 965
                                <TextField
                                    style={{ width: '100%' }}
966 967 968
                                    id="description"
                                    label="Description"
                                    value={this.state.description === '' ? '' : this.state.description}
faisalhamdi's avatar
faisalhamdi committed
969 970 971 972 973 974 975 976 977 978 979
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
980 981
                                    name="description"
                                    onChange={(e) => this.handleChangeCreate(e, '')}
faisalhamdi's avatar
faisalhamdi committed
982 983 984
                                >
                                </TextField>
                            </div>
985
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
986 987 988 989
                                <TextField
                                    style={{ width: '100%' }}
                                    id="value"
                                    label="Value"
990
                                    value={this.state.value}
faisalhamdi's avatar
faisalhamdi committed
991
                                    inputProps={{
992
                                        min: 0,
faisalhamdi's avatar
faisalhamdi committed
993 994 995 996
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
997

faisalhamdi's avatar
faisalhamdi committed
998 999 1000 1001 1002 1003
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
1004
                                    name="value"
Deni Rinaldi's avatar
Deni Rinaldi committed
1005 1006
                                    onChange={(e) => {
                                        this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
1007
                                            value: e.target.value
Deni Rinaldi's avatar
Deni Rinaldi committed
1008
                                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
1009 1010
                                        this.clearMessage()
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1011 1012
                                        // this.handleChange(coba, 'value')}
                                    }
1013 1014
                                    error={this.state.errorValue}
                                    helperText={this.state.msgErrorValue}
faisalhamdi's avatar
faisalhamdi committed
1015 1016 1017
                                >
                                </TextField>
                            </div>
1018
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
1019 1020
                                <TextField
                                    style={{ width: '100%' }}
1021
                                    id="min_value"
faisalhamdi's avatar
faisalhamdi committed
1022
                                    label="Min Value"
1023
                                    value={this.state.minValue}
faisalhamdi's avatar
faisalhamdi committed
1024
                                    inputProps={{
1025
                                        min: 0,
faisalhamdi's avatar
faisalhamdi committed
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
1036
                                    name="minValue"
Deni Rinaldi's avatar
Deni Rinaldi committed
1037
                                    onChange={(e) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1038
                                        // let coba = String(e.target.value).replace(/[^\d]/g, '');
Deni Rinaldi's avatar
Deni Rinaldi committed
1039
                                        this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
1040
                                            minValue: e.target.value
Deni Rinaldi's avatar
Deni Rinaldi committed
1041
                                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
1042 1043
                                        this.clearMessage()
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1044 1045
                                        // this.handleChange(coba, 'value')}
                                    }
1046 1047
                                    error={this.state.errorMinValue}
                                    helperText={this.state.msgErrorMinValue}
faisalhamdi's avatar
faisalhamdi committed
1048 1049 1050
                                >
                                </TextField>
                            </div>
1051 1052 1053 1054
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="startDate"
Deni Rinaldi's avatar
Deni Rinaldi committed
1055
                                    label="Valid From"
Deni Rinaldi's avatar
Deni Rinaldi committed
1056
                                    format="dd-MM-yyyy"
1057 1058 1059 1060 1061 1062 1063
                                    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
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
1075 1076 1077

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

1080
                            <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
1081 1082
                                <TextField
                                    style={{ width: '100%' }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1083
                                    defaultValue={"Active"}
faisalhamdi's avatar
faisalhamdi committed
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
                                    id="status"
                                    label="Status"
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
                                />
                            </div>

a.bairuha's avatar
a.bairuha committed
1101
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
a.bairuha's avatar
a.bairuha committed
1102 1103
                                <Typography style={{ fontSize: 11, width: '25%' }}>Created By	: </Typography>
                                <Typography style={{ fontSize: 11, width: '25%' }}>Updated By	: </Typography>
faisalhamdi's avatar
faisalhamdi committed
1104 1105 1106 1107
                            </div>
                        </div>

                        <div className="column-2">
1108 1109 1110 1111 1112
                            <div className="" style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    {...this.state.types}
                                    debug
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
1113
                                    onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id), this.clearMessage())}
Deni Rinaldi's avatar
Deni Rinaldi committed
1114 1115 1116 1117 1118 1119 1120 1121 1122
                                    renderInput={(params) =>
                                        <TextField
                                            {...params}
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                            InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                            label="Group"
                                            error={this.state.errorGroup}
                                            helperText={this.state.msgErrorGroup}
                                        />}
1123 1124
                                    value={this.state.getTypes}
                                />
faisalhamdi's avatar
faisalhamdi committed
1125
                            </div>
1126 1127 1128 1129 1130
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    {...this.state.perusahaan}
                                    debug
                                    id="tipe"
Deni Rinaldi's avatar
Deni Rinaldi committed
1131
                                    onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearMessage())}
Deni Rinaldi's avatar
Deni Rinaldi committed
1132 1133 1134 1135 1136
                                    renderInput={(params) =>
                                        <TextField
                                            {...params}
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                            InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1137
                                            label="Company Name"
Deni Rinaldi's avatar
Deni Rinaldi committed
1138 1139 1140
                                            error={this.state.errorPerusahaan}
                                            helperText={this.state.msgErrorPerusahaan}
                                        />}
1141 1142
                                    value={this.state.getPerusahaan}
                                />
faisalhamdi's avatar
faisalhamdi committed
1143
                            </div>
1144
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
1145 1146 1147 1148
                                <TextField
                                    style={{ width: '100%' }}
                                    id="order"
                                    label="Order"
1149
                                    value={this.state.order === null ? '' : this.state.order}
faisalhamdi's avatar
faisalhamdi committed
1150
                                    inputProps={{
1151
                                        min: 0,
faisalhamdi's avatar
faisalhamdi committed
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
1162
                                    name="order"
Deni Rinaldi's avatar
Deni Rinaldi committed
1163
                                    onChange={(e) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1164
                                        let coba = String(e.target.value).replace(/[^\d]/g, '');
Deni Rinaldi's avatar
Deni Rinaldi committed
1165 1166 1167
                                        this.setState({
                                            order: coba
                                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
1168 1169
                                        this.clearMessage()
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1170 1171
                                        // this.handleChange(coba, 'value')}
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1172 1173
                                // error={this.state.errorOrder}
                                // helperText={this.state.msgErrorOrder}
faisalhamdi's avatar
faisalhamdi committed
1174 1175 1176
                                >
                                </TextField>
                            </div>
1177
                            <div style={{ marginTop: '80px', padding: 10, borderRadius: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
1178 1179
                                <TextField
                                    style={{ width: '100%' }}
1180
                                    id="max_value"
faisalhamdi's avatar
faisalhamdi committed
1181
                                    label="Max Value"
1182
                                    value={this.state.maxValue}
faisalhamdi's avatar
faisalhamdi committed
1183
                                    inputProps={{
1184
                                        min: 0,
faisalhamdi's avatar
faisalhamdi committed
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
1195
                                    name="maxValue"
Deni Rinaldi's avatar
Deni Rinaldi committed
1196
                                    onChange={(e) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1197
                                        // let coba = String(e.target.value).replace(/[^\d]/g, '');
Deni Rinaldi's avatar
Deni Rinaldi committed
1198
                                        this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
1199
                                            maxValue: e.target.value
Deni Rinaldi's avatar
Deni Rinaldi committed
1200
                                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
1201 1202
                                        this.clearMessage()
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1203 1204
                                        // this.handleChange(coba, 'value')}
                                    }
1205 1206
                                    error={this.state.errorMaxValue}
                                    helperText={this.state.msgErrorMaxValue}
faisalhamdi's avatar
faisalhamdi committed
1207 1208 1209
                                >
                                </TextField>
                            </div>
1210 1211 1212 1213
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
                                    margin="normal"
                                    id="endDate"
Deni Rinaldi's avatar
Deni Rinaldi committed
1214
                                    label="Valid To"
Deni Rinaldi's avatar
Deni Rinaldi committed
1215
                                    format="dd-MM-yyyy"
1216 1217 1218 1219 1220 1221 1222 1223
                                    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
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234
                                    inputProps={{
                                        style: {
                                            fontSize: 11
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085'
                                        }
                                    }}
1235 1236 1237

                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
faisalhamdi's avatar
faisalhamdi committed
1238 1239 1240 1241 1242 1243
                            </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' }}>
1244 1245 1246 1247 1248
                            <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' }}>
a.bairuha's avatar
a.bairuha committed
1249
                                    <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
1250 1251
                                </div>
                            </button>
faisalhamdi's avatar
faisalhamdi committed
1252 1253
                        </div>
                        <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
1254 1255 1256 1257 1258
                            <button
                                type="button"
                                onClick={() => this.validasiCreate()}
                            >
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1259
                                    <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
1260 1261
                                </div>
                            </button>
faisalhamdi's avatar
faisalhamdi committed
1262 1263 1264 1265 1266 1267 1268
                        </div>
                    </div>
                </div>
            </div>
        )
    }
}