EditReportItems.js 47.4 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 39 40 41 42 43 44
            formula: '',
            realVal: '',
            condition: null,
            date: new Date(),
            listInputType: null,
            listCompany: null,
            listReportType: null,
            listParent: null,
            errorOrder: false,
            errorDesc: false,
            errorFormula: false,
            errorRV: false,
            errorStartDate: false,
            errorEndDate: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
45 46 47 48
            errorJenisLaporan: false,
            errorPerusahaan: false,
            msgErrorJenisLaporan: '',
            msgErrorPerusahaan: '',
EKSAD's avatar
EKSAD committed
49 50 51
            msgErrorOrder: '',
            msgErrorDesc: '',
            msgErrorFormula: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
52 53 54 55
            errorTipeData: false,
            msgErrorTipeData: '',
            errorCondition: false,
            msgErrorCondition: '',
EKSAD's avatar
EKSAD committed
56 57 58 59 60 61
            msgErrorRV: '',
            msgErrorSD: '',
            msgErrorED: '',
            disabledFormula: true,
            disabledCondt: true,
            disabledValue: true,
62 63 64 65
            options: ['WARNING', 'STOPPER'],
            alert: false,
            tipeAlert: '',
            messageAlert: ''
EKSAD's avatar
EKSAD committed
66 67 68 69 70

        }
    }

    componentDidMount() {
EKSAD's avatar
EKSAD committed
71
        this.getDetailReportItems();
Deni Rinaldi's avatar
Deni Rinaldi committed
72

EKSAD's avatar
EKSAD committed
73 74
    }

EKSAD's avatar
EKSAD committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
    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')
Deni Rinaldi's avatar
Deni Rinaldi committed
131
        if (R.isNil(this.state.reportType)){
EKSAD's avatar
EKSAD committed
132
            this.setState({errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty.'})
Deni Rinaldi's avatar
Deni Rinaldi committed
133
        } else if (R.isNil(this.state.company)){
EKSAD's avatar
EKSAD committed
134
            this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty.'})
Deni Rinaldi's avatar
Deni Rinaldi committed
135
        } else if (R.isEmpty(this.state.tempData.order)) {
EKSAD's avatar
EKSAD committed
136
            this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty.' })
EKSAD's avatar
EKSAD committed
137
        } else if (R.isEmpty(this.state.tempData.description)) {
EKSAD's avatar
EKSAD committed
138
            this.setState({ errorDesc: true, msgErrorDesc: 'Description Cannot be Empty.' })
Deni Rinaldi's avatar
Deni Rinaldi committed
139
        } else if (R.isNil(this.state.InputType)) {
EKSAD's avatar
EKSAD committed
140
            this.setState({ errorTipeData: true, msgErrorTipeData: 'Data Type Cannot be Empty.' })
a.bairuha's avatar
a.bairuha committed
141
        } 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
142
            this.setState({ errorFormula: true, msgErrorFormula: 'Formula Cannot be Empty.' })
a.bairuha's avatar
a.bairuha committed
143
        } else if (this.state.InputType.type_item_report_name === 'Validation' && R.isEmpty(this.state.tempData.condition_it_should_be)) {
EKSAD's avatar
EKSAD committed
144
            this.setState({ errorRV: true, msgErrorRV: 'True Value Cannot be Empty.' })
a.bairuha's avatar
a.bairuha committed
145
        } else if (this.state.InputType.type_item_report_name === 'Validation' && R.isNil(this.state.tempData.condition_if_wrong)) {
EKSAD's avatar
EKSAD committed
146
            this.setState({ errorCondition: true, msgErrorCondition: 'False Condition Cannot be Empty.' })
Deni Rinaldi's avatar
Deni Rinaldi committed
147
        } else if (R.isNil(this.state.tempData.start_date)) {
EKSAD's avatar
EKSAD committed
148
            this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty.' })
EKSAD's avatar
EKSAD committed
149
        } else if (R.isNil(this.state.tempData.end_date)) {
EKSAD's avatar
EKSAD committed
150
            this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty.' })
EKSAD's avatar
EKSAD committed
151
        } else {
EKSAD's avatar
EKSAD committed
152
            this.updateReportItems()
EKSAD's avatar
EKSAD committed
153 154 155 156
        }

    }

EKSAD's avatar
EKSAD committed
157 158 159
    updateReportItems() {
        // alert('test')
        let payload = {
d.arizona's avatar
d.arizona committed
160
            "item_report_id": this.state.tempData.item_report_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
161 162
            "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
163 164
            "description": this.state.tempData.description,
            "orders": this.state.tempData.order,
Deni Rinaldi's avatar
Deni Rinaldi committed
165
            "parent": this.state.parent == null ? null : this.state.parent.item_report_id,
a.bairuha's avatar
a.bairuha committed
166
            "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
167 168
            "formula": this.state.tempData.formula,
            "uom": this.state.tempData.uom,
Deni Rinaldi's avatar
Deni Rinaldi committed
169
            "weight": this.state.tempData.weight == null ? "" : this.state.tempData.weight,
EKSAD's avatar
EKSAD committed
170 171 172 173 174 175
            "condition_if_wrong": this.state.tempData.condition_if_wrong,
            "condition_it_should_be": this.state.tempData.condition_it_should_be,
            "start_date": this.state.tempData.start_date,
            "end_date": this.state.tempData.end_date
        }
        console.log(payload)
176
        this.props.updateReportItems(payload)
EKSAD's avatar
EKSAD committed
177 178
    }

EKSAD's avatar
EKSAD committed
179
    getDetailReportItems() {
EKSAD's avatar
EKSAD committed
180
        api.create().getDetailReportItems(this.props.data[1]).then((response) => {
181
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        this.setState({ 
                            tempData: response.data.data,
                            getCompanyID: data.company_id 
                        }, () => this.getInputType(), 
                                this.getPerusahaan(),
                                this.getReportType(),)
                                console.log(response.data.data)
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Token")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
202
                } else {
a.bairuha's avatar
a.bairuha committed
203
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
204
                }
EKSAD's avatar
EKSAD committed
205
            } else {
206
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
207 208 209 210 211 212 213
            }
        })
    }

    getInputType() {
        api.create().getInputType().then((response) => {
            // console.log(response)
214
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
215 216 217 218 219 220 221 222 223 224 225 226 227
                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
228

a.bairuha's avatar
a.bairuha committed
229 230 231 232 233 234 235 236 237 238 239 240
                        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' }, () => {
                            if (response.data.message.includes("Token")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
241
                } else {
a.bairuha's avatar
a.bairuha committed
242
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
243
                }
EKSAD's avatar
EKSAD committed
244
            } else {
245
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
246 247 248 249 250 251 252
            }
        })
    }

    getPerusahaan() {
        api.create().getPerusahaanActive().then((response) => {
            console.log(response)
253
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
                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)
                        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())
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Token")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
284
                } else {
a.bairuha's avatar
a.bairuha committed
285
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
286
                }
EKSAD's avatar
EKSAD committed
287
            } else {
288
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
289 290 291 292 293 294 295
            }
        })
    }

    getReportType() {
        api.create().getReportType().then((response) => {
            console.log(response)
296
            if (response.data) {
a.bairuha's avatar
a.bairuha committed
297 298 299 300 301 302 303 304 305 306 307 308 309
                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
310

a.bairuha's avatar
a.bairuha committed
311 312 313 314 315 316 317 318 319 320 321 322
                        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' }, () => {
                            if (response.data.message.includes("Token")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
323
                } else {
a.bairuha's avatar
a.bairuha committed
324
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
325
                }
EKSAD's avatar
EKSAD committed
326
            } else {
327
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
EKSAD's avatar
EKSAD committed
328 329 330 331 332
            }
        })
    }

    getParent() {
d.arizona's avatar
d.arizona committed
333
        if (this.state.reportType !== null && this.state.company !== null) {
EKSAD's avatar
EKSAD committed
334
            console.log(this.state.tempData.item_report_id)
d.arizona's avatar
d.arizona committed
335 336 337
            let payload = {
                "report_id": this.state.reportType.report_id,
                "company_id": this.state.company.company_id
EKSAD's avatar
EKSAD committed
338
            }
d.arizona's avatar
d.arizona committed
339 340
            api.create().getReportParent(payload).then((response) => {
                console.log(response)
341
                if (response.data) {
a.bairuha's avatar
a.bairuha committed
342 343 344 345 346 347 348 349 350 351 352 353
                    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
354
                                }
a.bairuha's avatar
a.bairuha committed
355 356 357
                            })
                            if (currentIndex !== null) {
                                parentData.splice(currentIndex, 1)
358
                            }
a.bairuha's avatar
a.bairuha committed
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
                            console.log(parentData)
                            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' }, () => {
                                if (response.data.message.includes("Token")) {
                                    setTimeout(() => {
                                        localStorage.removeItem(Constant.TOKEN)
                                        window.location.reload();
                                    }, 1000);
                                }
                            })
EKSAD's avatar
EKSAD committed
375
                        }
376
                    } else {
a.bairuha's avatar
a.bairuha committed
377
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
378
                    }
d.arizona's avatar
d.arizona committed
379
                } else {
380
                    this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
381 382 383
                }
            })
        }
EKSAD's avatar
EKSAD committed
384
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
385 386 387 388 389 390

    clearMessage() {
        this.setState({
            errorFormula: false, msgErrorFormula: '',
            errorTipeData: false, msgErrorTipeData: '',
            errorCondition: false, msgErrorCondition: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
391 392 393
            errorRV: false, msgErrorRV: '',
            errorJenisLaporan: false, msgErrorJenisLaporan: '',
            errorPerusahaan: false, msgErrorPerusahaan: ''
Deni Rinaldi's avatar
Deni Rinaldi committed
394 395 396
        })
    }

397 398 399 400
    closeAlert() {
        this.setState({ alert: false })
    }

EKSAD's avatar
EKSAD committed
401 402 403 404 405
    render() {

        return (
            <div className="test app-popup-show">
                <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
EKSAD's avatar
EKSAD committed
406
                    <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
EKSAD's avatar
EKSAD committed
407 408 409 410 411 412 413 414 415 416 417
                        <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
418
                                <img src={Images.close} />
EKSAD's avatar
EKSAD committed
419 420 421
                            </button>
                        </div>
                    </div>
422 423 424 425 426
                    <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
427

EKSAD's avatar
EKSAD committed
428
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
EKSAD's avatar
EKSAD committed
429
                        <div className="column-1">
a.bairuha's avatar
a.bairuha committed
430
                            <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
431 432
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
433
                                    value={this.state.tempData === null ? '' : this.state.tempData.item_report_id}
EKSAD's avatar
EKSAD committed
434 435 436
                                    id="ID"
                                    label="ID"
                                    disabled
EKSAD's avatar
EKSAD committed
437
                                    onChange={(e) => null}
EKSAD's avatar
EKSAD committed
438 439 440
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
441
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
442 443 444 445 446 447
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
448
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
449 450 451 452
                                        }
                                    }}
                                />
                            </div>
EKSAD's avatar
EKSAD committed
453 454
                        </div>
                        <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
455
                            <div className="margin-top-10px" style={{ padding: 10 }}>
EKSAD's avatar
EKSAD committed
456 457 458
                                <Autocomplete
                                    {...this.state.listReportType}
                                    id="reportType"
Deni Rinaldi's avatar
Deni Rinaldi committed
459
                                    onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () => this.getParent(), this.clearMessage() )}
EKSAD's avatar
EKSAD committed
460
                                    debug
Deni Rinaldi's avatar
Deni Rinaldi committed
461 462
                                    renderInput={(params) =>
                                        <TextField {...params}
463
                                            label="Report Type"
EKSAD's avatar
EKSAD committed
464 465 466 467 468 469 470
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
471 472
                                            error={this.state.errorJenisLaporan}
                                            helperText={this.state.msgErrorJenisLaporan}
EKSAD's avatar
EKSAD committed
473 474 475 476 477 478 479 480 481
                                            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
482
                            <div className="margin-top-10px" style={{ padding: 10 }} >
EKSAD's avatar
EKSAD committed
483 484
                                <Autocomplete
                                    {...this.state.listCompany}
EKSAD's avatar
EKSAD committed
485
                                    id="company"
Deni Rinaldi's avatar
Deni Rinaldi committed
486
                                    onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => this.getParent(), this.clearMessage())}
EKSAD's avatar
EKSAD committed
487
                                    debug
Deni Rinaldi's avatar
Deni Rinaldi committed
488 489
                                    renderInput={(params) =>
                                        <TextField {...params}
EKSAD's avatar
EKSAD committed
490
                                            label="Company Name"
EKSAD's avatar
EKSAD committed
491 492 493 494 495 496 497
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
498 499
                                            error={this.state.errorPerusahaan}
                                            helperText={this.state.msgErrorPerusahaan}
EKSAD's avatar
EKSAD committed
500
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
EKSAD's avatar
EKSAD committed
501 502 503
                                        />}
                                    value={this.state.company}
                                />
EKSAD's avatar
EKSAD committed
504
                            </div>
EKSAD's avatar
EKSAD committed
505 506 507
                        </div>
                        <div className="column-2">
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
508 509
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
510 511 512
                                    id="order"
                                    label="Order"
                                    name="order"
513
                                    type="number"
EKSAD's avatar
EKSAD committed
514 515 516
                                    value={this.state.tempData === null ? '' : this.state.tempData.order}
                                    error={this.state.errorOrder}
                                    helperText={this.state.msgErrorOrder}
d.arizona's avatar
d.arizona committed
517
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
518
                                    inputProps={{
519
                                        min: 0,
EKSAD's avatar
EKSAD committed
520 521
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
522
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
523 524 525 526 527 528
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
529
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
530 531 532 533 534
                                        }
                                    }}
                                >
                                </TextField>
                            </div>
EKSAD's avatar
EKSAD committed
535 536 537 538
                        </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
539
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
540 541
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
542
                                    id="description"
543
                                    label="Description"
EKSAD's avatar
EKSAD committed
544 545 546
                                    name="description"
                                    error={this.state.errorDesc}
                                    helperText={this.state.msgErrorDesc}
d.arizona's avatar
d.arizona committed
547
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
548
                                    value={this.state.tempData === null ? '' : this.state.tempData.description}
EKSAD's avatar
EKSAD committed
549 550 551
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
552
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
553 554 555 556 557 558
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
559
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
560 561 562 563 564
                                        }
                                    }}
                                >
                                </TextField>
                            </div>
EKSAD's avatar
EKSAD committed
565 566
                        </div>
                        <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
567
                            <div className="margin-top-10px" style={{ padding: 10 }} >
EKSAD's avatar
EKSAD committed
568
                                <Autocomplete
EKSAD's avatar
EKSAD committed
569 570
                                    {...this.state.listParent}
                                    id="parentId"
Deni Rinaldi's avatar
Deni Rinaldi committed
571
                                    onChange={(event, newInputValue) => this.setState({ parent: newInputValue })}
EKSAD's avatar
EKSAD committed
572
                                    disabled={this.state.reportType == null || this.state.company == null}
EKSAD's avatar
EKSAD committed
573
                                    debug
Deni Rinaldi's avatar
Deni Rinaldi committed
574 575 576
                                    renderInput={(params) =>
                                        <TextField {...params}
                                            label="Parent ID"
EKSAD's avatar
EKSAD committed
577 578 579 580 581 582 583
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
EKSAD's avatar
EKSAD committed
584
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
EKSAD's avatar
EKSAD committed
585
                                        />}
EKSAD's avatar
EKSAD committed
586
                                    value={this.state.parent}
EKSAD's avatar
EKSAD committed
587 588
                                />
                            </div>
EKSAD's avatar
EKSAD committed
589 590 591 592
                        </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
593
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
594 595
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
596 597 598 599 600
                                    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
601 602 603
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
604
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
605 606 607 608 609 610
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
611
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
612 613
                                        }
                                    }}
EKSAD's avatar
EKSAD committed
614 615
                                >
                                </TextField>
EKSAD's avatar
EKSAD committed
616 617 618
                            </div>
                        </div>
                        <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
619
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
620 621
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
622 623 624
                                    id="weight"
                                    label="Weight"
                                    name="weight"
EKSAD's avatar
EKSAD committed
625
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
626
                                    value={this.state.tempData === null ? '' : this.state.tempData.weight}
EKSAD's avatar
EKSAD committed
627 628 629
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
630
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
631 632 633 634 635 636
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
637
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
638 639 640 641 642
                                        }
                                    }}
                                >
                                </TextField>
                            </div>
EKSAD's avatar
EKSAD committed
643 644 645 646
                        </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
647
                            <div className="margin-top-10px" style={{ padding: 10 }}>
EKSAD's avatar
EKSAD committed
648
                                <Autocomplete
EKSAD's avatar
EKSAD committed
649 650
                                    {...this.state.listInputType}
                                    id="inputType"
Deni Rinaldi's avatar
Deni Rinaldi committed
651 652 653 654 655 656
                                    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
657
                                    debug
Deni Rinaldi's avatar
Deni Rinaldi committed
658 659
                                    renderInput={(params) =>
                                        <TextField {...params}
660
                                            label="Data Type"
EKSAD's avatar
EKSAD committed
661 662 663 664 665 666 667
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
668 669
                                            error={this.state.errorTipeData}
                                            helperText={this.state.msgErrorTipeData}
EKSAD's avatar
EKSAD committed
670
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
EKSAD's avatar
EKSAD committed
671
                                        />}
EKSAD's avatar
EKSAD committed
672
                                    value={this.state.InputType}
EKSAD's avatar
EKSAD committed
673
                                />
EKSAD's avatar
EKSAD committed
674
                            </div>
EKSAD's avatar
EKSAD committed
675 676 677
                        </div>
                        <div className="column-2">
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
678 679
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
680 681
                                    id="formula"
                                    label="Formula"
a.bairuha's avatar
a.bairuha committed
682
                                    disabled={this.state.InputType == null ? true : (this.state.InputType.type_item_report_name === 'Formula' || this.state.InputType.type_item_report_name === 'Validation' ? false : true)}
EKSAD's avatar
EKSAD committed
683 684 685
                                    name="formula"
                                    error={this.state.errorFormula}
                                    helperText={this.state.msgErrorFormula}
d.arizona's avatar
d.arizona committed
686
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
687
                                    value={this.state.tempData === null ? '' : this.state.tempData.formula}
EKSAD's avatar
EKSAD committed
688 689 690
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
691
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
692 693 694 695 696 697
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
698
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
699 700 701 702 703
                                        }
                                    }}
                                >
                                </TextField>
                            </div>
EKSAD's avatar
EKSAD committed
704 705 706 707 708
                        </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
709 710
                                <TextField
                                    style={{ width: '100%' }}
EKSAD's avatar
EKSAD committed
711
                                    id="condition_it_should_be"
712
                                    label="True Value"
EKSAD's avatar
EKSAD committed
713 714
                                    error={this.state.errorRV}
                                    helperText={this.state.msgErrorRV}
a.bairuha's avatar
a.bairuha committed
715
                                    disabled={this.state.InputType == null ? true : (this.state.InputType.type_item_report_name === 'Validation' ? false : true)}
Deni Rinaldi's avatar
Deni Rinaldi committed
716 717
                                    name="condition_it_should_be"
                                    onChange={(e) => this.handleChange(e, '')}
EKSAD's avatar
EKSAD committed
718
                                    value={this.state.tempData === null ? '' : this.state.tempData.condition_it_should_be}
EKSAD's avatar
EKSAD committed
719 720 721
                                    inputProps={{
                                        style: {
                                            fontSize: 11,
EKSAD's avatar
EKSAD committed
722
                                            fontFamily: 'Nunito Sans, sans-serif'
EKSAD's avatar
EKSAD committed
723 724 725 726 727 728
                                        }
                                    }}
                                    InputLabelProps={{
                                        style: {
                                            fontSize: 11,
                                            fontFamily: 'Nunito Sans, sans-serif',
EKSAD's avatar
EKSAD committed
729
                                            color: '#7e8085'
EKSAD's avatar
EKSAD committed
730 731
                                        }
                                    }}
EKSAD's avatar
EKSAD committed
732
                                />
EKSAD's avatar
EKSAD committed
733
                            </div>
EKSAD's avatar
EKSAD committed
734 735
                        </div>
                        <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
736
                            <div className="margin-top-10px" style={{ padding: 10 }}>
EKSAD's avatar
EKSAD committed
737
                                <Autocomplete
Deni Rinaldi's avatar
Deni Rinaldi committed
738
                                    value={this.state.tempData === null ? "" : this.state.tempData.condition_if_wrong}
EKSAD's avatar
EKSAD committed
739
                                    id="isWrongCondition"
a.bairuha's avatar
a.bairuha committed
740
                                    disabled={this.state.InputType == null ? true : (this.state.InputType.type_item_report_name === 'Validation' ? false : true)}
EKSAD's avatar
EKSAD committed
741
                                    onChange={(event, newValue) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
742
                                        this.setState({ tempData: { ...this.state.tempData, condition_if_wrong: newValue } }, () => this.clearMessage());
EKSAD's avatar
EKSAD committed
743 744
                                    }}
                                    options={this.state.options}
Deni Rinaldi's avatar
Deni Rinaldi committed
745 746
                                    renderInput={(params) =>
                                        <TextField {...params}
747
                                            label="False Condition"
EKSAD's avatar
EKSAD committed
748 749 750 751 752 753 754
                                            InputLabelProps={{
                                                style: {
                                                    fontSize: 11,
                                                    fontFamily: 'Nunito Sans, sans-serif',
                                                    color: '#7e8085'
                                                }
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
755 756
                                            error={this.state.errorCondition}
                                            helperText={this.state.msgErrorCondition}
EKSAD's avatar
EKSAD committed
757
                                            InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
EKSAD's avatar
EKSAD committed
758
                                        />}
EKSAD's avatar
EKSAD committed
759 760
                                />
                            </div>
EKSAD's avatar
EKSAD committed
761 762 763 764
                        </div>
                    </div>
                    <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
                        <div className="column-1">
EKSAD's avatar
EKSAD committed
765
                            <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
EKSAD's avatar
EKSAD committed
766 767 768
                                <DatePicker
                                    margin="normal"
                                    id="startDate"
769
                                    label="Valid From"
EKSAD's avatar
EKSAD committed
770 771 772 773 774 775 776 777
                                    format="dd MMMM yyyy"
                                    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',
                                    }}
778 779 780 781 782 783 784 785 786 787 788 789 790
                                    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
791 792 793 794 795 796 797
                                    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
798 799
                                    margin="normal"
                                    id="endDate"
800
                                    label="Valid To"
EKSAD's avatar
EKSAD committed
801 802 803 804 805 806 807 808 809
                                    format="dd MMMM yyyy"
                                    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',
                                    }}
810 811 812 813 814 815 816 817 818 819 820 821 822
                                    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
823 824

                                    style={{ padding: 0, margin: 0, width: '100%' }}
EKSAD's avatar
EKSAD committed
825 826 827
                                />
                            </div>
                        </div>
EKSAD's avatar
EKSAD committed
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854
                    </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={{ 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>
a.bairuha's avatar
a.bairuha committed
855
                    <div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30}}>
856
                        <div style={{ display: 'flex' }}>
a.bairuha's avatar
a.bairuha committed
857
                            <Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography>
EKSAD's avatar
EKSAD committed
858
                            <Typography style={{ fontSize: 11 }}>:  {this.state.tempData === null ? "" : this.state.tempData.created}</Typography>
859 860
                        </div>
                        <div style={{ display: 'flex' }}>
a.bairuha's avatar
a.bairuha committed
861
                            <Typography style={{ fontSize: 11, width: '12%' }}>Updated By</Typography>
EKSAD's avatar
EKSAD committed
862
                            <Typography style={{ fontSize: 11 }}>:  {this.state.tempData === null ? "" : this.state.tempData.updated}</Typography>
EKSAD's avatar
EKSAD committed
863
                        </div>
EKSAD's avatar
EKSAD committed
864 865 866 867 868 869 870 871 872
                    </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' }}>
873
                                    <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
EKSAD's avatar
EKSAD committed
874 875 876 877
                                </div>
                            </button>
                        </div>
                        <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
EKSAD's avatar
EKSAD committed
878
                            <button onClick={() => this.validasi()}>
EKSAD's avatar
EKSAD committed
879
                                <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
880
                                    <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
EKSAD's avatar
EKSAD committed
881 882
                                </div>
                            </button>
EKSAD's avatar
EKSAD committed
883 884 885 886 887 888 889
                        </div>
                    </div>
                </div>
            </div>
        )
    }
}