EditReportItems.js 60.5 KB
Newer Older
EKSAD's avatar
EKSAD committed
1
import React, { Component } from 'react';
2
import { TextField, Typography, withStyles, Snackbar } from '@material-ui/core';
EKSAD's avatar
EKSAD committed
3
import { DatePicker } from '@material-ui/pickers';
EKSAD's avatar
EKSAD committed
4 5
import format from "date-fns/format";
import Autocomplete from '@material-ui/lab/Autocomplete';
6
import MuiAlert from '@material-ui/lab/Alert';
EKSAD's avatar
EKSAD committed
7
import api from '../../../api';
EKSAD's avatar
EKSAD committed
8
import * as R from 'ramda'
EKSAD's avatar
EKSAD committed
9
import { titleCase } from '../../../library/Utils';
d.arizona's avatar
d.arizona committed
10
import Images from '../../../assets/Images';
a.bairuha's avatar
a.bairuha committed
11
import Constant from '../../../library/Constant';
12 13
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
EKSAD's avatar
EKSAD committed
14

EKSAD's avatar
EKSAD committed
15
export default class EditReportItems extends Component {
EKSAD's avatar
EKSAD committed
16 17 18
    constructor(props) {
        super(props)
        this.state = {
Deni Rinaldi's avatar
Deni Rinaldi committed
19

EKSAD's avatar
EKSAD committed
20 21 22 23 24 25 26 27 28 29
            tempData: null,
            InputType: null,
            company: null,
            parent: null,
            reportType: null,
            startDate: null,
            endDate: null,
            order: null,
            description: '',
            uom: '',
30
            weight: "",
EKSAD's avatar
EKSAD committed
31 32 33 34 35 36 37 38
            formula: '',
            realVal: '',
            condition: null,
            date: new Date(),
            listInputType: null,
            listCompany: null,
            listReportType: null,
            listParent: null,
39 40 41 42
            listKPI: null,
            listMaxAch: null,
            MaxAchValue: null,
            KPIValue: null,
EKSAD's avatar
EKSAD committed
43 44 45 46 47 48
            errorOrder: false,
            errorDesc: false,
            errorFormula: false,
            errorRV: false,
            errorStartDate: false,
            errorEndDate: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
49 50 51 52
            errorJenisLaporan: false,
            errorPerusahaan: false,
            msgErrorJenisLaporan: '',
            msgErrorPerusahaan: '',
EKSAD's avatar
EKSAD committed
53 54 55
            msgErrorOrder: '',
            msgErrorDesc: '',
            msgErrorFormula: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
56 57 58 59
            errorTipeData: false,
            msgErrorTipeData: '',
            errorCondition: false,
            msgErrorCondition: '',
EKSAD's avatar
EKSAD committed
60 61 62 63 64 65
            msgErrorRV: '',
            msgErrorSD: '',
            msgErrorED: '',
            disabledFormula: true,
            disabledCondt: true,
            disabledValue: true,
66 67 68
            options: ['WARNING', 'STOPPER'],
            alert: false,
            tipeAlert: '',
a.bairuha's avatar
a.bairuha committed
69 70 71
            messageAlert: '',
            kpiType: ['HIG', 'HIB'],
            maxAch: ['50%', '100%', 'Unlimited'],
d.arizona's avatar
d.arizona committed
72
            formulaYtd: ['SUM', 'AVG', 'LAST', 'FORMULA'],
a.bairuha's avatar
a.bairuha committed
73 74
            kpiTypeValue: null,
            maxAchValue: null,
75 76 77 78 79 80 81 82 83 84 85 86
            formulaYTDValue: null,
            convertible: null,
            listConvert: [
                {
                    "id": 0,
                    "value": "No"
                },
                {
                    "id": 1,
                    "value": "Yes"
                }
            ],
EKSAD's avatar
EKSAD committed
87 88 89 90 91

        }
    }

    componentDidMount() {
EKSAD's avatar
EKSAD committed
92
        this.getDetailReportItems();
Deni Rinaldi's avatar
Deni Rinaldi committed
93

EKSAD's avatar
EKSAD committed
94 95
    }

EKSAD's avatar
EKSAD committed
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
    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 },
                errorOrder: false,
                errorDesc: false,
                errorFormula: false,
                errorRV: false,
                errorStartDate: false,
                errorEndDate: false,
                msgErrorOrder: '',
                msgErrorDesc: '',
                msgErrorFormula: '',
                msgErrorRV: '',
                msgErrorSD: '',
                msgErrorED: '',
            })
        } else if (isDate && type === 'end_date') {
            this.setState({
                ...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
                errorOrder: false,
                errorDesc: false,
                errorFormula: false,
                errorRV: false,
                errorStartDate: false,
                errorEndDate: false,
                msgErrorOrder: '',
                msgErrorDesc: '',
                msgErrorFormula: '',
                msgErrorRV: '',
                msgErrorSD: '',
                msgErrorED: '',
            })
        } else {
            this.setState({
                ...data, tempData: { ...this.state.tempData, [e.target.name]: e.target.value },
                errorOrder: false,
                errorDesc: false,
                errorFormula: false,
                errorRV: false,
                errorStartDate: false,
                errorEndDate: false,
                msgErrorOrder: '',
                msgErrorDesc: '',
                msgErrorFormula: '',
                msgErrorRV: '',
                msgErrorSD: '',
                msgErrorED: '',
            })
        }
    }

    validasi() {
        // alert('coba ya')
152 153 154 155
        if (R.isNil(this.state.reportType)) {
            this.setState({ errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty' })
        } else if (R.isNil(this.state.company)) {
            this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
156
        } else if (R.isEmpty(this.state.tempData.order)) {
EKSAD's avatar
EKSAD committed
157
            this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty' })
EKSAD's avatar
EKSAD committed
158
        } else if (R.isEmpty(this.state.tempData.description)) {
EKSAD's avatar
EKSAD committed
159
            this.setState({ errorDesc: true, msgErrorDesc: 'Description Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
160
        } else if (R.isNil(this.state.InputType)) {
EKSAD's avatar
EKSAD committed
161
            this.setState({ errorTipeData: true, msgErrorTipeData: 'Data Type Cannot be Empty' })
a.bairuha's avatar
a.bairuha committed
162
        } else if ((this.state.InputType.type_item_report_name === 'Formula' && R.isEmpty(this.state.tempData.formula)) || (this.state.InputType.type_item_report_name === 'Validation' && R.isEmpty(this.state.tempData.formula))) {
EKSAD's avatar
EKSAD committed
163
            this.setState({ errorFormula: true, msgErrorFormula: 'Formula Cannot be Empty' })
a.bairuha's avatar
a.bairuha committed
164
        } else if (this.state.InputType.type_item_report_name === 'Validation' && R.isEmpty(this.state.tempData.condition_it_should_be)) {
EKSAD's avatar
EKSAD committed
165
            this.setState({ errorRV: true, msgErrorRV: 'True Value Cannot be Empty' })
a.bairuha's avatar
a.bairuha committed
166
        } else if (this.state.InputType.type_item_report_name === 'Validation' && R.isNil(this.state.tempData.condition_if_wrong)) {
EKSAD's avatar
EKSAD committed
167
            this.setState({ errorCondition: true, msgErrorCondition: 'False Condition Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
168
        } else if (R.isNil(this.state.tempData.start_date)) {
EKSAD's avatar
EKSAD committed
169
            this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty' })
EKSAD's avatar
EKSAD committed
170
        } else if (R.isNil(this.state.tempData.end_date)) {
EKSAD's avatar
EKSAD committed
171
            this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty' })
EKSAD's avatar
EKSAD committed
172
        } else {
EKSAD's avatar
EKSAD committed
173
            this.updateReportItems()
EKSAD's avatar
EKSAD committed
174 175 176 177
        }

    }

EKSAD's avatar
EKSAD committed
178 179 180
    updateReportItems() {
        // alert('test')
        let payload = {
d.arizona's avatar
d.arizona committed
181
            "item_report_id": this.state.tempData.item_report_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
182 183
            "report_id": this.state.reportType == null ? this.state.tempData.report_id : this.state.reportType.report_id,
            "company_id": this.state.company == null ? this.state.tempData.company_id : this.state.company.company_id,
EKSAD's avatar
EKSAD committed
184 185
            "description": this.state.tempData.description,
            "orders": this.state.tempData.order,
Deni Rinaldi's avatar
Deni Rinaldi committed
186
            "parent": this.state.parent == null ? null : this.state.parent.item_report_id,
a.bairuha's avatar
a.bairuha committed
187
            "type_report_id": this.state.InputType == null ? this.state.tempData.type_item_report_id : this.state.InputType.type_item_report_id,
EKSAD's avatar
EKSAD committed
188 189
            "formula": this.state.tempData.formula,
            "uom": this.state.tempData.uom,
Deni Rinaldi's avatar
Deni Rinaldi committed
190
            "weight": this.state.tempData.weight == null ? "" : this.state.tempData.weight,
EKSAD's avatar
EKSAD committed
191 192
            "condition_if_wrong": this.state.tempData.condition_if_wrong,
            "condition_it_should_be": this.state.tempData.condition_it_should_be,
a.bairuha's avatar
a.bairuha committed
193 194 195
            "type_kpi": this.state.tempData.kpi_type,
            "max_ach": this.state.tempData.max_ach,
            "formula_ytd": this.state.tempData.formula_ytd,
EKSAD's avatar
EKSAD committed
196
            "start_date": this.state.tempData.start_date,
197 198
            "end_date": this.state.tempData.end_date,
            "is_can_convert_value": this.state.convertible.id
EKSAD's avatar
EKSAD committed
199
        }
EKSAD's avatar
EKSAD committed
200
        // console.log(payload)
201
        this.props.updateReportItems(payload)
EKSAD's avatar
EKSAD committed
202 203
    }

EKSAD's avatar
EKSAD committed
204
    getDetailReportItems() {
EKSAD's avatar
EKSAD committed
205
        api.create().getDetailReportItems(this.props.data[1]).then((response) => {
206
            console.log(response);
207
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
208 209 210
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
211
                        let index = this.state.listConvert.findIndex((val) => val.id === data.is_can_convert_value)
212
                        this.setState({
a.bairuha's avatar
a.bairuha committed
213
                            tempData: response.data.data,
214 215
                            getCompanyID: data.company_id,
                            convertible: index === -1 ? null : this.state.listConvert[index]
216 217 218
                        }, () => this.getInputType(),
                            this.getPerusahaan(),
                            this.getReportType())
219
                        // console.log(this.state.convertible)
a.bairuha's avatar
a.bairuha committed
220 221
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
222
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
223 224 225 226 227 228 229
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
230
                } else {
a.bairuha's avatar
a.bairuha committed
231
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
232
                }
EKSAD's avatar
EKSAD committed
233
            } else {
234
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
235 236 237 238 239 240 241
            }
        })
    }

    getInputType() {
        api.create().getInputType().then((response) => {
            // console.log(response)
242
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
243 244 245 246 247 248 249 250 251 252 253 254 255
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let inputData = data.map((item) => {
                            return {
                                type_item_report_id: item.type_item_report_id,
                                type_item_report_name: item.type_item_report_name
                            }
                        })
                        let defaultProps = {
                            options: inputData,
                            getOptionLabel: (option) => titleCase(option.type_item_report_name),
                        };
Deni Rinaldi's avatar
Deni Rinaldi committed
256

a.bairuha's avatar
a.bairuha committed
257 258 259 260
                        let index = inputData.findIndex((val) => val.type_item_report_id === this.state.tempData.type_item_report_id)
                        this.setState({ listInputType: defaultProps, InputType: index === -1 ? null : inputData[index] })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
261
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
262 263 264 265 266 267 268
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
269
                } else {
a.bairuha's avatar
a.bairuha committed
270
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
271
                }
EKSAD's avatar
EKSAD committed
272
            } else {
273
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
274 275 276 277 278 279
            }
        })
    }

    getPerusahaan() {
        api.create().getPerusahaanActive().then((response) => {
EKSAD's avatar
EKSAD committed
280
            // console.log(response)
281
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let companyData = data.map((item) => {
                            return {
                                company_id: item.company_id,
                                company_name: item.company_name
                            }
                        })
                        companyData.push({
                            company_id: 0,
                            company_name: 'Default'
                        })
                        let index = companyData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.getCompanyID)
                        let defaultProps = {
                            options: companyData,
                            getOptionLabel: (option) => option.company_name,
                        };
                        // let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id)
301 302 303 304 305 306 307
                        this.setState({ listCompany: defaultProps, companyData: response.data.data, company: index === -1 ? null : companyData[index], msgErrorPerusahaan: index === -1 ? 'Company has been Inactive.' : "", errorPerusahaan: index === -1 ? true : false }, () => {
                            this.getParent()
                            this.getKPIType()
                            this.getMaxAch()
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
308
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
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
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

    getKPIType() {
        let body = {
            group: 'CAT',
            company_id: this.state.company.company_id,
            type: 'KPI_TYPE'
        }
        api.create().getAllSettingByType(body).then(response => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let inputKPI = data.map((item) => {
                            return {
                                value: item.value
                            }
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
                        let index = inputKPI.findIndex((val) => val.value === this.state.tempData.kpi_type)
346
                        this.setState({ listKPI: defaultProps, inputKPI: response.data.data, KPIValue: index === -1 ? null : inputKPI[index] })
a.bairuha's avatar
a.bairuha committed
347 348
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
349
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
350 351 352 353 354 355
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
                        // alert(response.data.message)
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

    getMaxAch() {
        let body = {
            group: 'CAT',
            company_id: this.state.company.company_id,
            type: 'MAX_ACHIEVEMENT'
        }
        api.create().getAllSettingByType(body).then(response => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let inputMaxAch = data.map((item) => {
                            return {
                                value: item.value
                            }
                        })
                        let defaultProps = {
                            options: inputMaxAch,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
                        let index = inputMaxAch.findIndex((val) => val.value === this.state.tempData.max_ach)
                        this.setState({ listMaxAch: defaultProps, inputMaxAch: response.data.data, MaxAchValue: index === -1 ? null : inputMaxAch[index] })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
391
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
392 393 394 395 396 397 398
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                        // alert(response.data.message)
a.bairuha's avatar
a.bairuha committed
399
                    }
400
                } else {
a.bairuha's avatar
a.bairuha committed
401
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
402
                }
EKSAD's avatar
EKSAD committed
403
            } else {
404
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
405 406 407 408 409 410
            }
        })
    }

    getReportType() {
        api.create().getReportType().then((response) => {
EKSAD's avatar
EKSAD committed
411
            // console.log(response)
412
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
413 414 415 416 417 418 419 420 421 422 423 424 425
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let reportTypeData = data.map((item) => {
                            return {
                                report_id: item.report_id,
                                report_name: item.report_name,
                            }
                        })
                        let defaultProps = {
                            options: reportTypeData,
                            getOptionLabel: (option) => titleCase(option.report_name),
                        };
EKSAD's avatar
EKSAD committed
426

a.bairuha's avatar
a.bairuha committed
427 428 429 430
                        let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id)
                        this.setState({ listReportType: defaultProps, reportType: index === -1 ? null : reportTypeData[index] }, () => this.getParent())
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
431
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
432 433 434 435 436 437 438
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
439
                } else {
a.bairuha's avatar
a.bairuha committed
440
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
441
                }
EKSAD's avatar
EKSAD committed
442
            } else {
443
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
444 445 446 447 448
            }
        })
    }

    getParent() {
d.arizona's avatar
d.arizona committed
449
        if (this.state.reportType !== null && this.state.company !== null) {
EKSAD's avatar
EKSAD committed
450
            // console.log(this.state.tempData.item_report_id)
d.arizona's avatar
d.arizona committed
451 452 453
            let payload = {
                "report_id": this.state.reportType.report_id,
                "company_id": this.state.company.company_id
EKSAD's avatar
EKSAD committed
454
            }
d.arizona's avatar
d.arizona committed
455
            api.create().getReportParent(payload).then((response) => {
EKSAD's avatar
EKSAD committed
456
                // console.log(response)
457
                if (response.data) {
a.bairuha's avatar
a.bairuha committed
458 459 460 461 462 463 464 465 466 467 468 469
                    if (response.ok) {
                        if (response.data.status === 'success') {
                            let data = response.data.data
                            let currentIndex = null
                            let parentData = data.map((item, index) => {
                                if (this.state.tempData.item_report_id !== item.item_report_id) {
                                    return {
                                        item_report_id: item.item_report_id,
                                        description: item.description
                                    }
                                } else {
                                    currentIndex = index
EKSAD's avatar
EKSAD committed
470
                                }
a.bairuha's avatar
a.bairuha committed
471 472 473
                            })
                            if (currentIndex !== null) {
                                parentData.splice(currentIndex, 1)
474
                            }
EKSAD's avatar
EKSAD committed
475
                            // console.log(parentData)
a.bairuha's avatar
a.bairuha committed
476 477 478 479 480 481 482 483
                            let defaultProps = {
                                options: parentData,
                                getOptionLabel: (option) => titleCase(option.description),
                            };
                            let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent)
                            this.setState({ listParent: defaultProps, parent: index == -1 ? null : parentData[index] })
                        } else {
                            this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
484
                                if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
a.bairuha's avatar
a.bairuha committed
485 486 487 488 489 490
                                    setTimeout(() => {
                                        localStorage.removeItem(Constant.TOKEN)
                                        window.location.reload();
                                    }, 1000);
                                }
                            })
EKSAD's avatar
EKSAD committed
491
                        }
492
                    } else {
a.bairuha's avatar
a.bairuha committed
493
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
494
                    }
d.arizona's avatar
d.arizona committed
495
                } else {
496
                    this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
497 498 499
                }
            })
        }
EKSAD's avatar
EKSAD committed
500
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
501 502 503 504 505 506

    clearMessage() {
        this.setState({
            errorFormula: false, msgErrorFormula: '',
            errorTipeData: false, msgErrorTipeData: '',
            errorCondition: false, msgErrorCondition: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
507 508 509
            errorRV: false, msgErrorRV: '',
            errorJenisLaporan: false, msgErrorJenisLaporan: '',
            errorPerusahaan: false, msgErrorPerusahaan: ''
Deni Rinaldi's avatar
Deni Rinaldi committed
510 511 512
        })
    }

513 514 515 516
    closeAlert() {
        this.setState({ alert: false })
    }

EKSAD's avatar
EKSAD committed
517 518 519 520 521
    render() {

        return (
            <div className="test app-popup-show">
                <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
EKSAD's avatar
EKSAD committed
522
                    <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
EKSAD's avatar
EKSAD committed
523 524 525 526 527 528 529 530 531 532 533
                        <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                            <div className="popup-title">
                                <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Edit 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
534
                                <img src={Images.close} />
EKSAD's avatar
EKSAD committed
535 536 537
                            </button>
                        </div>
                    </div>
538 539 540 541 542
                    <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                        <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                            {this.state.messageAlert}
                        </Alert>
                    </Snackbar>
EKSAD's avatar
EKSAD committed
543

EKSAD's avatar
EKSAD committed
544
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
EKSAD's avatar
EKSAD committed
545
                        <div className="column-1">
a.bairuha's avatar
a.bairuha committed
546
                            <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
547 548
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
549
                                    value={this.state.tempData === null ? '' : this.state.tempData.item_report_id}
EKSAD's avatar
EKSAD committed
550 551 552
                                    id="ID"
                                    label="ID"
                                    disabled
EKSAD's avatar
EKSAD committed
553
                                    onChange={(e) => null}
EKSAD's avatar
EKSAD committed
554 555 556
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
557
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
558 559 560 561 562 563
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
564
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
565 566 567 568
                                        }
                                    }}
                                />
                            </div>
EKSAD's avatar
EKSAD committed
569 570
                        </div>
                        <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
571
                            <div className="margin-top-10px" style={{ padding: 10 }}>
EKSAD's avatar
EKSAD committed
572 573 574
                                <Autocomplete
                                    {...this.state.listReportType}
                                    id="reportType"
575 576 577
                                    onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () =>
                                        newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ tempData: { ...this.state.tempData, kpi_type: null, max_ach: null, formula_ytd: null } }, () => this.getParent(), this.clearMessage())
                                            : this.getParent(), this.clearMessage()
a.bairuha's avatar
a.bairuha committed
578
                                    )}
EKSAD's avatar
EKSAD committed
579
                                    debug
Deni Rinaldi's avatar
Deni Rinaldi committed
580 581
                                    renderInput={(params) =>
                                        <TextField {...params}
582
                                            label="Report Type"
EKSAD's avatar
EKSAD committed
583 584 585 586 587 588 589
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
590 591
                                            error={this.state.errorJenisLaporan}
                                            helperText={this.state.msgErrorJenisLaporan}
EKSAD's avatar
EKSAD committed
592 593 594 595 596 597 598 599 600
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
                                        />}
                                    value={this.state.reportType}
                                />
                            </div>
                        </div>
                    </div>
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
601
                            <div className="margin-top-10px" style={{ padding: 10 }} >
EKSAD's avatar
EKSAD committed
602 603
                                <Autocomplete
                                    {...this.state.listCompany}
EKSAD's avatar
EKSAD committed
604
                                    id="company"
Deni Rinaldi's avatar
Deni Rinaldi committed
605
                                    onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => this.getParent(), this.clearMessage())}
EKSAD's avatar
EKSAD committed
606
                                    debug
Deni Rinaldi's avatar
Deni Rinaldi committed
607 608
                                    renderInput={(params) =>
                                        <TextField {...params}
EKSAD's avatar
EKSAD committed
609
                                            label="Company Name"
EKSAD's avatar
EKSAD committed
610 611 612 613 614 615 616
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
617 618
                                            error={this.state.errorPerusahaan}
                                            helperText={this.state.msgErrorPerusahaan}
EKSAD's avatar
EKSAD committed
619
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
EKSAD's avatar
EKSAD committed
620 621 622
                                        />}
                                    value={this.state.company}
                                />
EKSAD's avatar
EKSAD committed
623
                            </div>
EKSAD's avatar
EKSAD committed
624 625 626
                        </div>
                        <div className="column-2">
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
627 628
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
629 630 631
                                    id="order"
                                    label="Order"
                                    name="order"
632
                                    type="number"
EKSAD's avatar
EKSAD committed
633 634 635
                                    value={this.state.tempData === null ? '' : this.state.tempData.order}
                                    error={this.state.errorOrder}
                                    helperText={this.state.msgErrorOrder}
d.arizona's avatar
d.arizona committed
636
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
637
                                    inputProps={{
638
                                        min: 0,
EKSAD's avatar
EKSAD committed
639 640
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
641
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
642 643 644 645 646 647
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
648
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
649 650 651 652 653
                                        }
                                    }}
                                >
                                </TextField>
                            </div>
EKSAD's avatar
EKSAD committed
654 655 656 657
                        </div>
                    </div>
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
658
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
659 660
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
661
                                    id="description"
662
                                    label="Description"
EKSAD's avatar
EKSAD committed
663 664 665
                                    name="description"
                                    error={this.state.errorDesc}
                                    helperText={this.state.msgErrorDesc}
d.arizona's avatar
d.arizona committed
666
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
667
                                    value={this.state.tempData === null ? '' : this.state.tempData.description}
EKSAD's avatar
EKSAD committed
668 669 670
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
671
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
672 673 674 675 676 677
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
678
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
679 680 681 682 683
                                        }
                                    }}
                                >
                                </TextField>
                            </div>
EKSAD's avatar
EKSAD committed
684 685
                        </div>
                        <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
686
                            <div className="margin-top-10px" style={{ padding: 10 }} >
EKSAD's avatar
EKSAD committed
687
                                <Autocomplete
EKSAD's avatar
EKSAD committed
688 689
                                    {...this.state.listParent}
                                    id="parentId"
Deni Rinaldi's avatar
Deni Rinaldi committed
690
                                    onChange={(event, newInputValue) => this.setState({ parent: newInputValue })}
EKSAD's avatar
EKSAD committed
691
                                    disabled={this.state.reportType == null || this.state.company == null}
EKSAD's avatar
EKSAD committed
692
                                    debug
Deni Rinaldi's avatar
Deni Rinaldi committed
693 694 695
                                    renderInput={(params) =>
                                        <TextField {...params}
                                            label="Parent ID"
EKSAD's avatar
EKSAD committed
696 697 698 699 700 701 702
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
EKSAD's avatar
EKSAD committed
703
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
EKSAD's avatar
EKSAD committed
704
                                        />}
EKSAD's avatar
EKSAD committed
705
                                    value={this.state.parent}
EKSAD's avatar
EKSAD committed
706 707
                                />
                            </div>
EKSAD's avatar
EKSAD committed
708 709 710 711
                        </div>
                    </div>
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
712
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
713 714
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
715 716 717 718 719
                                    id="uom"
                                    label="UOM"
                                    name="uom"
                                    onChange={(e) => this.handleChange(e, '')}
                                    value={this.state.tempData === null ? '' : this.state.tempData.uom}
EKSAD's avatar
EKSAD committed
720 721 722
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
723
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
724 725 726 727 728 729
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
730
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
731 732
                                        }
                                    }}
EKSAD's avatar
EKSAD committed
733 734
                                >
                                </TextField>
EKSAD's avatar
EKSAD committed
735 736 737
                            </div>
                        </div>
                        <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
738
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
739 740
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
741 742 743
                                    id="weight"
                                    label="Weight"
                                    name="weight"
EKSAD's avatar
EKSAD committed
744
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
745
                                    value={this.state.tempData === null ? '' : this.state.tempData.weight}
EKSAD's avatar
EKSAD committed
746 747 748
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
749
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
750 751 752 753 754 755
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
756
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
757 758 759 760 761
                                        }
                                    }}
                                >
                                </TextField>
                            </div>
EKSAD's avatar
EKSAD committed
762 763 764 765
                        </div>
                    </div>
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
766
                            <div className="margin-top-10px" style={{ padding: 10 }}>
EKSAD's avatar
EKSAD committed
767
                                <Autocomplete
EKSAD's avatar
EKSAD committed
768 769
                                    {...this.state.listInputType}
                                    id="inputType"
Deni Rinaldi's avatar
Deni Rinaldi committed
770 771 772 773 774 775
                                    onChange={(event, newInputValue) =>
                                        this.setState({
                                            InputType: newInputValue,
                                            tempData: { ...this.state.tempData, formula: '', condition_it_should_be: '', condition_if_wrong: '' },
                                        },
                                            () => console.log(this.state.InputType), this.clearMessage())}
EKSAD's avatar
EKSAD committed
776
                                    debug
Deni Rinaldi's avatar
Deni Rinaldi committed
777 778
                                    renderInput={(params) =>
                                        <TextField {...params}
779
                                            label="Data Type"
EKSAD's avatar
EKSAD committed
780 781 782 783 784 785 786
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
787 788
                                            error={this.state.errorTipeData}
                                            helperText={this.state.msgErrorTipeData}
EKSAD's avatar
EKSAD committed
789
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
EKSAD's avatar
EKSAD committed
790
                                        />}
EKSAD's avatar
EKSAD committed
791
                                    value={this.state.InputType}
EKSAD's avatar
EKSAD committed
792
                                />
EKSAD's avatar
EKSAD committed
793
                            </div>
EKSAD's avatar
EKSAD committed
794 795 796
                        </div>
                        <div className="column-2">
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
797 798
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
799 800
                                    id="formula"
                                    label="Formula"
EKSAD's avatar
EKSAD committed
801
                                    disabled={this.state.InputType == null ? true : (this.state.InputType.type_item_report_name === 'Formula' || this.state.InputType.type_item_report_name === 'Validation' || this.state.InputType.type_item_report_name === 'Formula - Summary' ? false : true)}
EKSAD's avatar
EKSAD committed
802 803 804
                                    name="formula"
                                    error={this.state.errorFormula}
                                    helperText={this.state.msgErrorFormula}
d.arizona's avatar
d.arizona committed
805
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
806
                                    value={this.state.tempData === null ? '' : this.state.tempData.formula}
EKSAD's avatar
EKSAD committed
807 808 809
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
810
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
811 812 813 814 815 816
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
817
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
818 819 820 821 822
                                        }
                                    }}
                                >
                                </TextField>
                            </div>
EKSAD's avatar
EKSAD committed
823 824 825 826 827
                        </div>
                    </div>
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1">
                            <div className="margin-top-10px" style={{ padding: 10 }}>
EKSAD's avatar
EKSAD committed
828 829
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
830
                                    id="condition_it_should_be"
831
                                    label="True Value"
EKSAD's avatar
EKSAD committed
832 833
                                    error={this.state.errorRV}
                                    helperText={this.state.msgErrorRV}
a.bairuha's avatar
a.bairuha committed
834
                                    disabled={this.state.InputType == null ? true : (this.state.InputType.type_item_report_name === 'Validation' ? false : true)}
Deni Rinaldi's avatar
Deni Rinaldi committed
835 836
                                    name="condition_it_should_be"
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
837
                                    value={this.state.tempData === null ? '' : this.state.tempData.condition_it_should_be}
EKSAD's avatar
EKSAD committed
838 839 840
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
841
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
842 843 844 845 846 847
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
848
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
849 850
                                        }
                                    }}
EKSAD's avatar
EKSAD committed
851
                                />
EKSAD's avatar
EKSAD committed
852
                            </div>
EKSAD's avatar
EKSAD committed
853 854
                        </div>
                        <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
855
                            <div className="margin-top-10px" style={{ padding: 10 }}>
EKSAD's avatar
EKSAD committed
856
                                <Autocomplete
Deni Rinaldi's avatar
Deni Rinaldi committed
857
                                    value={this.state.tempData === null ? "" : this.state.tempData.condition_if_wrong}
EKSAD's avatar
EKSAD committed
858
                                    id="isWrongCondition"
a.bairuha's avatar
a.bairuha committed
859
                                    disabled={this.state.InputType == null ? true : (this.state.InputType.type_item_report_name === 'Validation' ? false : true)}
EKSAD's avatar
EKSAD committed
860
                                    onChange={(event, newValue) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
861
                                        this.setState({ tempData: { ...this.state.tempData, condition_if_wrong: newValue } }, () => this.clearMessage());
EKSAD's avatar
EKSAD committed
862 863
                                    }}
                                    options={this.state.options}
Deni Rinaldi's avatar
Deni Rinaldi committed
864 865
                                    renderInput={(params) =>
                                        <TextField {...params}
866
                                            label="False Condition"
EKSAD's avatar
EKSAD committed
867 868 869 870 871 872 873
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
874 875
                                            error={this.state.errorCondition}
                                            helperText={this.state.msgErrorCondition}
EKSAD's avatar
EKSAD committed
876
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
EKSAD's avatar
EKSAD committed
877
                                        />}
EKSAD's avatar
EKSAD committed
878 879
                                />
                            </div>
EKSAD's avatar
EKSAD committed
880 881
                        </div>
                    </div>
a.bairuha's avatar
a.bairuha committed
882 883

                    {this.state.reportType !== null && (
884 885 886 887 888 889 890 891 892 893
                        this.state.reportType.report_name === 'CAT' && (
                            <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                                <div className="column-1">
                                    <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                        <Autocomplete
                                            {...this.state.listKPI}
                                            value={this.state.KPIValue}
                                            id="kpiType"
                                            onChange={(event, newValue) => {
                                                this.setState({ tempData: { ...this.state.tempData, kpi_type: newValue.value }, KPIValue: newValue }, () => this.clearMessage());
a.bairuha's avatar
a.bairuha committed
894
                                            }}
895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
                                            renderInput={(params) =>
                                                <TextField {...params}
                                                    label="KPI Type"
                                                    InputLabelProps={{
                                                        style: {
                                                            fontSize: 11,
                                                            fontFamily: 'Nunito Sans, sans-serif',
                                                            color: '#7e8085'
                                                        }
                                                    }}
                                                    InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
                                                />}
                                        />
                                    </div>
                                </div>
                                <div className="column-2">
                                    <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                        <Autocomplete
                                            {...this.state.listMaxAch}
                                            value={this.state.MaxAchValue}
                                            id="maxAch"
                                            onChange={(event, newValue) => {
                                                this.setState({ tempData: { ...this.state.tempData, max_ach: newValue.value }, MaxAchValue: newValue }, () => this.clearMessage());
a.bairuha's avatar
a.bairuha committed
918
                                            }}
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
                                            renderInput={(params) =>
                                                <TextField {...params}
                                                    label="Max Achievement"
                                                    InputLabelProps={{
                                                        style: {
                                                            fontSize: 11,
                                                            fontFamily: 'Nunito Sans, sans-serif',
                                                            color: '#7e8085'
                                                        }
                                                    }}
                                                    InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
                                                />}
                                        />
                                    </div>
                                </div>
a.bairuha's avatar
a.bairuha committed
934
                            </div>
935
                        ))}
a.bairuha's avatar
a.bairuha committed
936 937

                    {this.state.reportType !== null && (
938 939 940 941 942 943 944 945 946
                        this.state.reportType.report_name === 'CAT' && (
                            <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                                <div className="column-1">
                                    <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                        <Autocomplete
                                            value={this.state.tempData === null ? "" : this.state.tempData.formula_ytd}
                                            id="kpiType"
                                            onChange={(event, newValue) => {
                                                this.setState({ tempData: { ...this.state.tempData, formula_ytd: newValue } }, () => this.clearMessage());
a.bairuha's avatar
a.bairuha committed
947
                                            }}
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963
                                            options={this.state.formulaYtd}
                                            renderInput={(params) =>
                                                <TextField {...params}
                                                    label="Formula YTD"
                                                    InputLabelProps={{
                                                        style: {
                                                            fontSize: 11,
                                                            fontFamily: 'Nunito Sans, sans-serif',
                                                            color: '#7e8085'
                                                        }
                                                    }}
                                                    InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
                                                />}
                                        />
                                    </div>
                                </div>
a.bairuha's avatar
a.bairuha committed
964
                            </div>
965
                        ))}
a.bairuha's avatar
a.bairuha committed
966

EKSAD's avatar
EKSAD committed
967 968
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1">
EKSAD's avatar
EKSAD committed
969
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
970 971 972
                                <DatePicker
                                    margin="normal"
                                    id="startDate"
973
                                    label="Valid From"
EKSAD's avatar
EKSAD committed
974
                                    format="dd-MM-yyyy"
EKSAD's avatar
EKSAD committed
975 976 977 978 979 980 981
                                    value={this.state.tempData === null ? null : this.state.tempData.start_date}
                                    error={this.state.errorStartDate}
                                    helperText={this.state.msgErrorSD}
                                    onChange={(e) => this.handleChange(e, 'start_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
982 983 984 985 986 987 988 989 990 991 992 993 994
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085',
                                            fontFamily: 'Nunito Sans, sans-serif',
                                        }
                                    }}
EKSAD's avatar
EKSAD committed
995 996 997 998 999 1000 1001
                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                />
                            </div>
                        </div>
                        <div className="column-2">
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <DatePicker
EKSAD's avatar
EKSAD committed
1002 1003
                                    margin="normal"
                                    id="endDate"
1004
                                    label="Valid To"
EKSAD's avatar
EKSAD committed
1005
                                    format="dd-MM-yyyy"
EKSAD's avatar
EKSAD committed
1006 1007 1008 1009 1010 1011 1012 1013
                                    value={this.state.tempData === null ? null : this.state.tempData.end_date}
                                    error={this.state.errorEndDate}
                                    helperText={this.state.msgErrorED}
                                    minDate={this.state.tempData === null ? null : this.state.tempData.start_date}
                                    onChange={(e) => this.handleChange(e, 'end_date')}
                                    KeyboardButtonProps={{
                                        'aria-label': 'change date',
                                    }}
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            color: '#7e8085',
                                            fontFamily: 'Nunito Sans, sans-serif',
                                        }
                                    }}
EKSAD's avatar
EKSAD committed
1027 1028

                                    style={{ padding: 0, margin: 0, width: '100%' }}
EKSAD's avatar
EKSAD committed
1029 1030 1031
                                />
                            </div>
                        </div>
EKSAD's avatar
EKSAD committed
1032 1033 1034
                    </div>
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1">
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
                                <Autocomplete
                                    debug
                                    id="tipe"
                                    options={this.state.listConvert}
                                    getOptionLabel={(option) => option.value}
                                    value={this.state.convertible}
                                    onChange={(event, newInputValue) => this.setState({ convertible: newInputValue }, () => this.clearMessage())}
                                    renderInput={(params) =>
                                        <TextField
                                            {...params}
                                            label="Convertible"
                                            margin="normal"
                                            style={{ marginTop: 7 }}
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                            InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                        />
                                    }

                                />
                            </div>
                        </div>
                        <div className="column-2">
EKSAD's avatar
EKSAD committed
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081
                            <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
                                <TextField
                                    style={{ width: '100%' }}
                                    value={this.state.tempData === null ? '' : this.state.tempData.status}
                                    id="status"
                                    label="Status"
                                    disabled
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif'
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
                                            color: '#7e8085'
                                        }
                                    }}
                                />
                            </div>
                        </div>
                    </div>
1082
                    <div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30 }}>
1083
                        <div style={{ display: 'flex' }}>
a.bairuha's avatar
a.bairuha committed
1084
                            <Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography>
EKSAD's avatar
EKSAD committed
1085
                            <Typography style={{ fontSize: 11 }}>:  {this.state.tempData === null ? "" : this.state.tempData.created}</Typography>
1086 1087
                        </div>
                        <div style={{ display: 'flex' }}>
a.bairuha's avatar
a.bairuha committed
1088
                            <Typography style={{ fontSize: 11, width: '12%' }}>Updated By</Typography>
EKSAD's avatar
EKSAD committed
1089
                            <Typography style={{ fontSize: 11 }}>:  {this.state.tempData === null ? "" : this.state.tempData.updated}</Typography>
EKSAD's avatar
EKSAD committed
1090
                        </div>
EKSAD's avatar
EKSAD committed
1091 1092 1093 1094 1095 1096 1097 1098 1099
                    </div>

                    <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1" style={{ alignSelf: 'center' }}>
                            <button
                                type="button"
                                onClick={() => this.props.onClickClose()}
                            >
                                <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
1100
                                    <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
EKSAD's avatar
EKSAD committed
1101 1102 1103 1104
                                </div>
                            </button>
                        </div>
                        <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
EKSAD's avatar
EKSAD committed
1105
                            <button onClick={() => this.validasi()}>
EKSAD's avatar
EKSAD committed
1106
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
1107
                                    <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
EKSAD's avatar
EKSAD committed
1108 1109
                                </div>
                            </button>
EKSAD's avatar
EKSAD committed
1110 1111 1112 1113 1114 1115 1116
                        </div>
                    </div>
                </div>
            </div>
        )
    }
}