EditDocumentManagement.js 29.7 KB
Newer Older
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
1 2
import React, { Component } from 'react'
import Images from '../../assets/Images'
3
import { TextField, withStyles, Snackbar, Typography } from '@material-ui/core'
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
import MuiAlert from '@material-ui/lab/Alert';
import api from '../../api'
import Autocomplete from '@material-ui/lab/Autocomplete'
import Constant from '../../library/Constant'
import { format } from 'date-fns';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
import * as R from 'ramda'

const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);

export default class EditManagementDoc extends Component {
    constructor(props) {
        super(props)
        this.state = {
            perusahaan: null,
            perusahaanData: null,
            getPerusahaan: null,
            errorPerusahaan: false,
            msgErrorPerusahaan: '',
            document: null,
            documentData: null,
            getDocument: null,
            errorDocument: false,
            msgErrorDocument: '',
            listPeriode: null,
            periode: null,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
32 33
            listMonth: null,
            monthId: null,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
34 35 36
            description: '',
            errorDesc: false,
            msgErrorDesc: '',
37 38 39 40
            errorMonth: false,
            msgErrorMonth: '',
            errorPeriode: false,
            msgErrorPeriode: '',
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
41 42 43 44 45 46
            file: null,
            alert: false,
            tipeAlert: '',
            messageAlert: '',
            fileType: '',
            konfirmasi: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
47 48 49
            docId: '',
            document_name: "",
            document_size: 0,
Deni Rinaldi's avatar
Deni Rinaldi committed
50
            loadUpload: false,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
51
            sizeUpload: "1",
52 53
            name: '',
            disabledPeriode: false
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
54 55 56 57
        }
    }

    componentDidMount() {
Deni Rinaldi's avatar
Deni Rinaldi committed
58
        this.getFileSize()
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
59 60 61 62 63
        if (this.props.type === 'edit') {
            this.getDetailDoc()
        }
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
64 65 66 67 68 69 70
    getFileSize(){
        let body = {
            group: 'MAX_FILE_SIZE',
            company_id: 0,
            type: 'MAX_FILE_SIZE'
        }
        api.create().getAllSettingByType(body).then(response => {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
71
            // console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
72 73
            if (response.data) {
                if (response.data.status === "success") {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
74 75 76
                    this.setState({
                        sizeUpload: response.data.data[0] ? response.data.data[0].value === undefined ? "1" : response.data.data[0].value : "1"
                    })
Riri Novita's avatar
Riri Novita committed
77 78
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
79
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
80 81 82 83 84 85
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
86 87 88 89 90
                }
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
91
    getDetailDoc() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
92
        api.create().getDetailDocument(this.props.idoc).then(response => {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
93
            // console.log(response)
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
94 95 96 97 98 99 100 101 102 103
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === "success") {
                        let data = response.data.data
                        this.setState({
                            companyId: data.company_id,
                            companyName: data.company_name,
                            categoryId: data.setting_id,
                            categoryName: data.values,
                            period: data.document_periode,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
104
                            getMonthName: data.document_month,
105
                            description: data.description,
106
                            filePath: data.document_filepath,
Deni Rinaldi's avatar
Deni Rinaldi committed
107
                            file: data.document_filepath,
Deni Rinaldi's avatar
Deni Rinaldi committed
108 109
                            document_name: data.document_name,
                            document_size: data.document_size,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
110 111
                            // id: data.approval_matrix_id,
                            // status: data.status,
Deni Rinaldi's avatar
Deni Rinaldi committed
112
                            fileType: data.document_type,
113
                            created: data.created,
Deni Rinaldi's avatar
Deni Rinaldi committed
114
                            updated: data.updated === null ? "" : data.updated,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
115
                            loadUpload: true,
116 117
                            name: data.values,
                            disabledPeriode: data.values === 'Manual Book TIA 4.0' ? true : false
Deni Rinaldi's avatar
Deni Rinaldi committed
118 119 120
                        }, () => {
                            this.getDataCompany()
                            this.getDataDocument()
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
121 122 123
                            this.getPeriode()
                            this.getMonth()
                        })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
124 125
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
126
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

    getDataCompany() {
        api.create().getPerusahaanUserActive().then((response) => {
            if (response.data) {
                if (response.data.status == 'success') {
                    let data = response.data.data
                    let typeData = data.map((item) => {
                        return {
                            company_id: item.company_id,
                            company_name: item.company_name
                        }
                    })
                    let typeProps = {
Deni Rinaldi's avatar
Deni Rinaldi committed
155
                        options: typeData,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
156 157
                        getOptionLabel: (option) => option.company_name,
                    };
Deni Rinaldi's avatar
Deni Rinaldi committed
158
                    let index = typeData.findIndex((val) => val.company_id == this.state.companyId)
Deni Rinaldi's avatar
Deni Rinaldi committed
159
                    this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index === -1 ? typeData[0] : typeData[index] })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
160 161
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
162
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
163 164 165 166 167 168 169 170
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
171
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
172 173 174 175 176
            }
        })
    }

    getDataDocument() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
177 178 179 180
        // let payload = {
        //     "setting_group_id": 7,
        //     "setting_type_id": 167,
        //     "company_id": 0
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
181

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
182 183
        // }
        api.create().getDocumentCategory().then(response => {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
184
            // console.log(response);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
185 186 187 188 189 190 191 192 193 194
            if (response.data) {
                if (response.data.status == 'success') {
                    let data = response.data.data
                    let typeData = data.map((item) => {
                        return {
                            document_category_id: item.setting_id,
                            document_category_name: item.value
                        }
                    })
                    let typeProps = {
Deni Rinaldi's avatar
Deni Rinaldi committed
195
                        options: typeData,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
196 197
                        getOptionLabel: (option) => option.document_category_name,
                    };
Deni Rinaldi's avatar
Deni Rinaldi committed
198
                    let index = typeData.findIndex((val) => val.document_category_id == this.state.categoryId)
Deni Rinaldi's avatar
Deni Rinaldi committed
199
                    this.setState({ document: typeProps, documentData: response.data.data, getDocument: index === -1 ? typeData[0] : typeData[index] })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
200 201
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
202
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
203 204 205 206 207 208 209 210
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
211
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
            }
        })
    }

    getPeriode() {
        api.create().getPeriodeTransaction().then(response => {
            let dateNow = new Date
            let year = format(dateNow, 'yyyy')
            if (response.data) {
                if (response.data.status === "success") {
                    let data = response.data.data
                    let periodeData = data.map((item) => {
                        return {
                            periode: item,
                        }
                    })
                    let defaultProps = {
                        options: periodeData,
                        getOptionLabel: (option) => option.periode,
                    };
                    let index = data.sort((a, b) => a - b).findIndex((val) => val == this.state.period)
                    this.setState({ listPeriode: defaultProps, periode: index == -1 ? periodeData[0] : periodeData[index] })
                }
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
239
    getMonth() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
        api.create().getMonthTransaction().then(response => {
            let dateNow = new Date
            // let bulan = format(dateNow, 'MMMM')
            if (response.data) {
                if (response.data.status === "success") {
                    let data = response.data.data
                    let monthData = data.map((item) => {
                        return {
                            month_name: item.month_name,
                            month_id: item.month_id
                        }
                    })
                    let index = monthData.findIndex((val) => val.month_name == this.state.getMonthName)
                    let defaultProps = {
                        options: monthData,
                        getOptionLabel: (option) => option.month_name,
                    };
                    // let index = data.sort((a, b) => a - b).findIndex((val) => val.month_name == this.state.getMonth)
                    this.setState({ listMonth: defaultProps, monthId: index == -1 ? monthData[0] : monthData[index] })
                }
            }
        })
    }

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
264 265 266 267 268 269
    clearMessage() {
        this.setState({
            errorPerusahaan: false,
            msgErrorPerusahaan: '',
            errorDocument: false,
            msgErrorDocument: '',
270 271 272 273
            errorMonth: false,
            msgErrorMonth: '',
            errorPeriode: false,
            msgErrorPeriode: '',
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
274 275 276 277 278 279 280
        })
    }

    fileHandler = (event) => {
        let fileObj = event
        let length = event.name.split(".").length
        let fileType = event.name.split(".")[length - 1]
281 282 283 284 285 286
        if (fileType === 'zip' || 'rar') {
            this.setState({ file: event, fileType: String(fileType) })
        } else {
            ExcelRenderer(fileObj, (err, resp) => {
                // console.log(fileType)
                if (err) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
287
                    // console.log(err);
288 289 290 291 292 293
                }
                else {
                    this.setState({ file: event, fileType: String(fileType) })
                }
            })
        }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
294 295 296
    }

    validasi() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
297 298 299 300 301 302
        if (String(this.props.name).includes('Manual Book TIA')){
        } else {
            if (R.isNil(this.state.periode)) {
                this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
            }  else if (R.isNil(this.state.monthId)) {
                this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
303 304 305
            } else if (R.isNil(this.state.getPerusahaan)) {
                this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
            }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
306
        }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
307
        if (R.isNil(this.state.getDocument)) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
308 309 310
            this.setState({ errorDocument: true, msgErrorDocument: 'Category Cannot be Empty' })
        } else if (R.isNil(this.state.file)) {
            this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
311
        } 
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
312
        
313
        else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
314
            const formData = new FormData();
315 316
            if (this.state.file == this.state.filePath){
                formData.append("updated", 0);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
317 318 319 320
                formData.append("file", null);
            } else {
                formData.append("updated", 1);
                formData.append("file", this.state.file);
321
            }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
322 323 324
            if (String(this.props.name).includes('Manual Book TIA')){
                formData.append("documentMonth", null);
                formData.append("documentPeriode", null);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
325 326
                formData.append("companyId", 1);

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
327 328 329
            } else {
                formData.append("documentMonth", this.state.monthId.month_id);
                formData.append("documentPeriode", this.state.periode.periode);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
330
                formData.append("companyId", this.state.getPerusahaan.company_id);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
331
            }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
332 333 334
            formData.append("settingId", this.state.getDocument.document_category_id);
            formData.append("description", this.state.description);
            formData.append("extension", this.state.fileType);
335
            formData.append("documentId", this.props.idoc);
Deni Rinaldi's avatar
Deni Rinaldi committed
336
            this.setState({ formData }, () => {
337
                this.props.updateDocument(this.state.formData)
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
338 339 340 341
            })
        }
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
342 343
    deleteFile(e) {
        this.setState({ file: null })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
344 345 346 347 348 349 350 351 352
    }

    closeAlert() {
        this.setState({ alert: false })
    }

    render() {
        return (
            <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
                <div className="test app-popup-show">
                    <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                        <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                            <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                <div className="popup-title">
                                    <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Edit</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()}
                                >
                                    <img src={Images.close} />
                                </button>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
369 370 371
                            </div>
                        </div>

Deni Rinaldi's avatar
Deni Rinaldi committed
372
                        <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20, paddingTop: 20 }}>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
373
                            {this.state.disabledPeriode === false ?
Deni Rinaldi's avatar
Deni Rinaldi committed
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
                            <div className="column-1">
                                <div style={{ padding: 10, borderRadius: 5 }}>
                                    <Autocomplete
                                        {...this.state.perusahaan}
                                        debug
                                        // clearOnEscape
                                        id="tipe"
                                        onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearMessage())}
                                        renderInput={(params) =>
                                            <TextField {...params}
                                                error={this.state.errorPerusahaan}
                                                helperText={this.state.msgErrorPerusahaan}
                                                InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                                InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                                label="Company Name" />}
                                        value={this.state.getPerusahaan}
                                    />
                                </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
392
                            </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
393 394
                            :true}
                            {this.state.disabledPeriode === false ?
Deni Rinaldi's avatar
Deni Rinaldi committed
395 396 397 398 399 400 401
                            <div className="column-2">
                                <div style={{ padding: 10, borderRadius: 5 }}>
                                    <Autocomplete
                                        {...this.state.document}
                                        // debug
                                        clearOnEscape
                                        id="tipe"
402 403 404 405 406 407
                                        onChange={(event, newInputValue) => this.setState({ getDocument: newInputValue }, 
                                        () => newInputValue === null ? this.setState({ disabledPeriode: false })
                                            : newInputValue.document_category_name === 'Manual Book TIA 4.0' ?
                                                this.setState({ disabledPeriode: true }, () => this.clearMessage())
                                            : this.setState({ disabledPeriode: false }, () => this.clearMessage())
                                        )}
Deni Rinaldi's avatar
Deni Rinaldi committed
408 409 410 411 412 413 414 415 416 417
                                        renderInput={(params) =>
                                            <TextField {...params}
                                                error={this.state.errorDocument}
                                                helperText={this.state.msgErrorDocument}
                                                InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                                InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                                label="Category" />}
                                        value={this.state.getDocument}
                                    />
                                </div>
418
                            </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
                            :
                            <div className="column-1">
                                <div style={{ padding: 10, borderRadius: 5 }}>
                                    <Autocomplete
                                        {...this.state.document}
                                        // debug
                                        clearOnEscape
                                        id="tipe"
                                        onChange={(event, newInputValue) => this.setState({ getDocument: newInputValue }, 
                                        () => newInputValue === null ? this.setState({ disabledPeriode: false })
                                            : newInputValue.document_category_name === 'Manual Book TIA 4.0' ?
                                                this.setState({ disabledPeriode: true }, () => this.clearMessage())
                                            : this.setState({ disabledPeriode: false }, () => this.clearMessage())
                                        )}
                                        renderInput={(params) =>
                                            <TextField {...params}
                                                error={this.state.errorDocument}
                                                helperText={this.state.msgErrorDocument}
                                                InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                                InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                                label="Category" />}
                                        value={this.state.getDocument}
                                    />
                                </div>
                            </div>
                            }
445
                            {this.state.disabledPeriode === false ?
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
                            <div className="column-1">
                                <div style={{ padding: 10, borderRadius: 5 }}>
                                    <Autocomplete
                                        {...this.state.listMonth}
                                        // debug
                                        clearOnEscape
                                        id="month"
                                        onChange={(event, newInputValue) => this.setState({ monthId: newInputValue }, () => this.clearMessage())}
                                        style={{ width: 250 }}
                                        renderInput={(params) =>
                                            <TextField {...params} label="Period Month" margin="normal" style={{ marginTop: 7 }}
                                                InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                                InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                                error={this.state.errorMonth}
                                                helperText={this.state.msgErrorMonth}
                                            />}
                                        value={this.state.monthId}
                                    />
                                </div>
                            </div>
466 467
                            : true }
                            {this.state.disabledPeriode === false ?
468 469
                            <div className="column-2">
                                <div style={{ padding: 10, borderRadius: 5 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
470 471 472 473 474
                                    <Autocomplete
                                        {...this.state.listPeriode}
                                        // debug
                                        clearOnEscape
                                        id="periode"
475
                                        onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => this.clearMessage())}
Deni Rinaldi's avatar
Deni Rinaldi committed
476 477
                                        style={{ width: 250 }}
                                        renderInput={(params) =>
478
                                            <TextField {...params} label="Period Year" margin="normal" style={{ marginTop: 7 }}
Deni Rinaldi's avatar
Deni Rinaldi committed
479 480
                                                InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                                InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
481 482
                                                error={this.state.errorPeriode}
                                                helperText={this.state.msgErrorPeriode}
Deni Rinaldi's avatar
Deni Rinaldi committed
483 484 485 486
                                            />}
                                        value={this.state.periode}
                                    />
                                </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
487
                            </div>
488
                            : true}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
489
                        </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
490
                        <div style={{ paddingLeft: 30, paddingRight: 30, paddingTop: 10 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
491 492 493 494 495
                            {this.state.loadUpload && (
                                <UploadFile
                                    type={this.state.uploadStatus}
                                    percentage={this.state.percentage}
                                    result={this.state.result}
496
                                    acceptedFiles={["xls", "xlsx", "pdf", "PDF", "docx", "doc", "pptx", "ppt", "ods", "odf" ]}
Deni Rinaldi's avatar
Deni Rinaldi committed
497 498 499 500 501 502 503 504 505 506 507 508
                                    intent={"management"}
                                    onHandle={(dt) => {
                                        this.fileHandler(dt)
                                        this.setState({ uploadStatus: 'idle', percentage: '0' })
                                    }}
                                    onDelete={(e) => {
                                        this.deleteFile(e)
                                    }}
                                    onUpload={() => alert('sukses')}
                                    value={this.state.file}
                                    docSize={this.state.document_size}
                                    docName={this.state.document_name}
Deni Rinaldi's avatar
Deni Rinaldi committed
509
                                    sizeUpload={Number(this.state.sizeUpload)}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
510
                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
511
                            )}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
512
                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
                        <div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}>
                            <TextField
                                style={{ width: '100%' }}
                                id="description"
                                label="Description"
                                value={this.state.description}
                                inputProps={{
                                    min: 0,
                                    style: {
                                        fontSize: 11
                                    }
                                }}

                                InputLabelProps={{
                                    style: {
                                        fontSize: 11,
                                        color: '#7e8085'
                                    }
                                }}
                                name="Description"
                                onChange={(e) => {
                                    this.setState({
                                        description: e.target.value
                                    })
                                    this.clearMessage()
                                }}
                                error={this.state.errorDesc}
                                helperText={this.state.msgErrorDesc}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
541
                            >
Deni Rinaldi's avatar
Deni Rinaldi committed
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
                            </TextField>
                        </div>
                        <div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}>
                            <div style={{ display: 'flex' }}>
                                <Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography>
                                <Typography style={{ fontSize: 11 }}>: {this.state.created}</Typography>
                            </div>
                            <div style={{ display: 'flex' }}>
                                <Typography style={{ fontSize: 11, width: '12%' }}>Updated By</Typography>
                                <Typography style={{ fontSize: 11 }}>: {this.state.updated == - null ? "" : this.state.updated}</Typography>
                            </div>
                        </div>
                        <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
                            <div className="column-1" style={{ alignSelf: 'center' }}>
                                <button
                                    type="button"
                                    onClick={() => this.props.onClickClose()}
                                >
                                    <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                        <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
                                    </div>
                                </button>
                            </div>
                            <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
                                <button
                                    type="button"
568 569 570 571 572 573 574
                                    onClick={() => 
                                        this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.validasi()
                                            }, 100);
                                        })
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
575 576 577 578 579 580
                                >
                                    <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                        <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
                                    </div>
                                </button>
                            </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
581 582
                        </div>
                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
583 584 585 586 587
                    <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                        <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                            {this.state.messageAlert}
                        </Alert>
                    </Snackbar>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
588 589 590 591 592
                </div>
            </div>
        )
    }
}