CreateDocumentManagement.js 29.2 KB
Newer Older
Deni Rinaldi's avatar
Deni Rinaldi committed
1 2 3
import React, { Component } from 'react'
import Images from '../../assets/Images'
import { TextField, withStyles, Snackbar } from '@material-ui/core'
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
4
import MuiAlert from '@material-ui/lab/Alert';
Deni Rinaldi's avatar
Deni Rinaldi committed
5 6 7 8 9 10 11
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'
12
import PropagateLoader from "react-spinners/PropagateLoader"
Deni Rinaldi's avatar
Deni Rinaldi committed
13

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
14 15 16
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);

Deni Rinaldi's avatar
Deni Rinaldi committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
export default class CreateManagementDoc 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,
33 34
            errorPeriode: false,
            msgErrorPeriode: '',
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
35 36
            listMonth: null,
            monthId: null,
37 38
            errorMonth: false,
            msgErrorMonth: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
39 40 41 42 43 44 45
            description: '',
            errorDesc: false,
            msgErrorDesc: '',
            file: null,
            alert: false,
            tipeAlert: '',
            messageAlert: '',
46
            fileType: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
47
            docId: '',
48 49
            sizeUpload: "1",
            disabledPeriode: false
Deni Rinaldi's avatar
Deni Rinaldi committed
50 51 52 53 54 55 56
        }
    }

    componentDidMount() {
        this.getDataCompany()
        this.getDataDocument()
        this.getPeriode()
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
57
        this.getMonth()
Deni Rinaldi's avatar
Deni Rinaldi committed
58 59 60
        this.getFileSize()
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
61
    getFileSize() {
Deni Rinaldi's avatar
Deni Rinaldi committed
62 63 64 65 66 67
        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
68
            // console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
69 70
            if (response.data) {
                if (response.data.status === "success") {
Deni Rinaldi's avatar
Deni Rinaldi committed
71
                    if (response.data.data.length == 0) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
72 73 74
                        this.setState({
                            sizeUpload: "1"
                        })
75 76 77 78 79 80
                    } else {
                        this.setState({
                            sizeUpload: response.data.data[0].value
                        })
                    }
                    // 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
81 82
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
83
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
84 85 86 87 88 89
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
90 91 92
                }
            }
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
93 94 95
    }

    getDataCompany() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
96
        api.create().getPerusahaanUserActive().then((response) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
97 98 99 100 101 102 103 104 105
            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
                        }
                    })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
106 107 108 109
                    // typeData.push({
                    //     company_id: 0,
                    //     company_name: 'Default'
                    // })
Deni Rinaldi's avatar
Deni Rinaldi committed
110
                    let typeProps = {
111
                        options: typeData.sort((a, b) => a.company_name - b.company_name),
Deni Rinaldi's avatar
Deni Rinaldi committed
112 113 114 115 116
                        getOptionLabel: (option) => option.company_name,
                    };
                    this.setState({ perusahaan: typeProps, perusahaanData: response.data.data })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
117
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
118 119 120 121 122 123 124 125
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
126
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
127 128 129 130 131
            }
        })
    }

    getDataDocument() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
132 133 134 135
        // let payload = {
        //     "setting_group_id": 7,
        //     "setting_type_id": 167,
        //     "company_id": 0
Deni Rinaldi's avatar
Deni Rinaldi committed
136

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
137 138
        // }
        api.create().getDocumentCategory().then(response => {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
139
            // console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
140 141 142
            if (response.data) {
                if (response.data.status == 'success') {
                    let data = response.data.data
143 144
                    let typeData = []
                    data.map((item) => {
rifkaki's avatar
rifkaki committed
145
                        if (String(item.value).toLocaleLowerCase().includes('manual book tia')){
146 147 148 149 150 151 152 153 154 155 156
                            if( this.props.allsubcoCreate ){
                                typeData.push( {
                                    document_category_id: item.setting_id,
                                    document_category_name: item.value
                                })
                            }
                        } else {
                            typeData.push( {
                                document_category_id: item.setting_id,
                                document_category_name: item.value
                            })
Deni Rinaldi's avatar
Deni Rinaldi committed
157 158
                        }
                    })
rifkaki's avatar
rifkaki committed
159
                    // console.log(typeData)
Deni Rinaldi's avatar
Deni Rinaldi committed
160 161 162 163 164 165 166
                    let typeProps = {
                        options: typeData.sort((a, b) => a.document_category_id - b.document_category_id),
                        getOptionLabel: (option) => option.document_category_name,
                    };
                    this.setState({ document: typeProps, documentData: response.data.data })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
167
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
168 169 170 171 172 173 174 175
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
176
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
            }
        })
    }

    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 == year)
                    this.setState({ listPeriode: defaultProps, periode: index == -1 ? periodeData[0] : periodeData[index] })
Riri Novita's avatar
Riri Novita committed
199 200
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
201
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
202 203 204 205 206 207
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
208 209 210 211 212
                }
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
213
    getMonth() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
        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_id: item.month_id,
                            month_name: item.month_name
                        }
                    })
                    let defaultProps = {
                        options: monthData,
                        getOptionLabel: (option) => option.month_name,
                    };
                    // let index = data.sort((a, b) => a - b).findIndex((val) => val == bulan)
                    // this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] })
                    this.setState({ listMonth: defaultProps })
Riri Novita's avatar
Riri Novita committed
233 234
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
235
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
236 237 238 239 240 241
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
242 243 244 245 246
                }
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
247 248 249 250 251 252
    clearMessage() {
        this.setState({
            errorPerusahaan: false,
            msgErrorPerusahaan: '',
            errorDocument: false,
            msgErrorDocument: '',
253 254 255 256
            errorMonth: false,
            msgErrorMonth: '',
            errorPeriode: false,
            msgErrorPeriode: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
257 258 259 260 261 262 263
        })
    }

    fileHandler = (event) => {
        let fileObj = event
        let length = event.name.split(".").length
        let fileType = event.name.split(".")[length - 1]
264
        if (fileType === 'zip' || 'rar') {
Deni Rinaldi's avatar
Deni Rinaldi committed
265 266 267
            this.setState({ file: event, fileType: String(fileType) })
        } else {
            ExcelRenderer(fileObj, (err, resp) => {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
268
                // console.log(fileType)
Deni Rinaldi's avatar
Deni Rinaldi committed
269
                if (err) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
270
                    // console.log(err);
Deni Rinaldi's avatar
Deni Rinaldi committed
271 272 273 274 275 276
                }
                else {
                    this.setState({ file: event, fileType: String(fileType) })
                }
            })
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
277 278 279
    }

    validasi() {
Deni Rinaldi's avatar
Deni Rinaldi committed
280
        if (this.state.disabledPeriode === true) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
281
            if (R.isNil(this.state.getDocument)) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
282 283 284 285 286 287
                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' })
            } else {
                const formData = new FormData();
                formData.append("file", this.state.file);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
288
                formData.append("companyId", 1);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
289 290 291 292 293
                formData.append("settingId", this.state.getDocument.document_category_id);
                formData.append("description", this.state.description);
                formData.append("extension", this.state.fileType);
                formData.append("documentPeriode", null);
                formData.append("documentMonth", null);
Deni Rinaldi's avatar
Deni Rinaldi committed
294
                this.setState({ formData }, () => {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
295
                    this.props.createDocument(this.state.formData, this.props.setting_id, this.props.name)
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
296
                })
297
                var object = {};
Deni Rinaldi's avatar
Deni Rinaldi committed
298
                formData.forEach(function (value, key) {
299 300 301
                    object[key] = value;
                });
                var json = JSON.stringify(object);
302
                // console.log(object)
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
303
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
304

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
305
        } else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
306 307 308 309 310
            if (R.isNil(this.state.getPerusahaan)) {
                this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
            } else if (R.isNil(this.state.getDocument)) {
                this.setState({ errorDocument: true, msgErrorDocument: 'Category Cannot be Empty' })
            } else if (R.isNil(this.state.periode)) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
311
                this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
Deni Rinaldi's avatar
Deni Rinaldi committed
312
            } else if (R.isNil(this.state.monthId)) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
313
                this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
314 315 316
            }
            else if (R.isNil(this.state.file)) {
                this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
317
            } else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
318 319 320 321 322 323
                const formData = new FormData();
                formData.append("file", this.state.file);
                formData.append("companyId", this.state.getPerusahaan.company_id);
                formData.append("settingId", this.state.getDocument.document_category_id);
                formData.append("description", this.state.description);
                formData.append("extension", this.state.fileType);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
324 325
                formData.append("documentPeriode", this.state.periode.periode);
                formData.append("documentMonth", this.state.monthId.month_id);
Deni Rinaldi's avatar
Deni Rinaldi committed
326
                this.setState({ formData }, () => {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
327
                    this.props.createDocument(this.state.formData, this.props.setting_id, this.props.name)
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
328
                })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
329
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
330
        }
331
        this.props.handleLoading(0)
Deni Rinaldi's avatar
Deni Rinaldi committed
332 333
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
334 335
    deleteFile(e) {
        this.setState({ file: null })
Deni Rinaldi's avatar
Deni Rinaldi committed
336 337
    }

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
338 339 340 341
    closeAlert() {
        this.setState({ alert: false })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
342
    render() {
343 344 345 346 347 348 349 350 351 352
        const loadingComponent = (
            <div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );
Deni Rinaldi's avatar
Deni Rinaldi committed
353
        return (
354
            <div>
355
                <div className="test app-popup-show">
Deni Rinaldi's avatar
Deni Rinaldi committed
356 357 358 359 360 361
                    <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' }}>Create</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
362
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
363 364 365 366 367 368 369 370
                            <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>
Deni Rinaldi's avatar
Deni Rinaldi committed
371 372
                            </div>
                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
373 374

                        <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
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
                            {this.state.disabledPeriode === false ?
                                <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>
                                </div>
                            : true}
                            {this.state.disabledPeriode === false ?
                            <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
398 399
                                <div style={{ padding: 10, borderRadius: 5 }}>
                                    <Autocomplete
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
400
                                        {...this.state.document}
Deni Rinaldi's avatar
Deni Rinaldi committed
401 402 403
                                        // debug
                                        clearOnEscape
                                        id="tipe"
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
404 405 406 407 408 409
                                        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
410 411
                                        renderInput={(params) =>
                                            <TextField {...params}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
412 413
                                                error={this.state.errorDocument}
                                                helperText={this.state.msgErrorDocument}
Deni Rinaldi's avatar
Deni Rinaldi committed
414 415
                                                InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                                InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
416 417
                                                label="Category" />}
                                        value={this.state.getDocument}
Deni Rinaldi's avatar
Deni Rinaldi committed
418 419
                                    />
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
420
                            </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
421 422
                            :
                            <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
                                <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>
445
                            </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
446
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
                            {this.state.disabledPeriode === false ?
                                <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>
                                : true}
                            {this.state.disabledPeriode === false ?
                                <div className="column-2">
                                    <div style={{ padding: 10, borderRadius: 5 }}>
                                        <Autocomplete
                                            {...this.state.listPeriode}
                                            // debug
                                            clearOnEscape
                                            id="periode"
                                            onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => this.clearMessage())}
                                            style={{ width: 250 }}
                                            renderInput={(params) =>
                                                <TextField {...params} label="Period Year" margin="normal" style={{ marginTop: 7 }}
                                                    InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                                    InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                                    error={this.state.errorPeriode}
                                                    helperText={this.state.msgErrorPeriode}
                                                />}
                                            value={this.state.periode}
                                        />
                                    </div>
                                </div>
                                : true}
491
                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
492 493 494 495 496
                        <div style={{ paddingLeft: 30, paddingRight: 30, paddingTop: 10 }}>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
497
                                acceptedFiles={["xls", "xlsx", "pdf", "PDF", "docx", "doc", "pptx", "ppt", "ods", "odf", "txt", "csv", "zip", "rar"]}
Deni Rinaldi's avatar
Deni Rinaldi committed
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')}
                                sizeUpload={Number(this.state.sizeUpload)}
                            />
Deni Rinaldi's avatar
Deni Rinaldi committed
509
                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
510 511 512 513 514 515 516 517 518 519 520 521
                        <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.decription}
                                inputProps={{
                                    min: 0,
                                    style: {
                                        fontSize: 11
                                    }
                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
522

Deni Rinaldi's avatar
Deni Rinaldi committed
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
                                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}
Deni Rinaldi's avatar
Deni Rinaldi committed
538
                            >
Deni Rinaldi's avatar
Deni Rinaldi committed
539
                            </TextField>
Deni Rinaldi's avatar
Deni Rinaldi committed
540
                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
541 542 543 544 545 546 547 548 549 550 551 552 553 554
                        <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"
555
                                    onClick={() => 
556 557 558 559 560
                                        {this.props.handleLoading(1) 
                                            setTimeout(() => {
                                                this.validasi()
                                            }, 100)
                                        }
561
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
562 563 564 565 566 567
                                >
                                    <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>
Deni Rinaldi's avatar
Deni Rinaldi committed
568 569
                        </div>
                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
570 571 572 573 574
                    <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                        <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                            {this.state.messageAlert}
                        </Alert>
                    </Snackbar>
Deni Rinaldi's avatar
Deni Rinaldi committed
575
                </div>
576
            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
577 578 579
        )
    }
}