EditManagementDoc.js 29 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"
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
77 78 79 80 81
                }
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
82
    getDetailDoc() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
83
        api.create().getDetailDocument(this.props.idoc).then(response => {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
84
            // console.log(response)
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
85 86 87 88 89 90 91 92 93 94
            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
95
                            getMonthName: data.document_month,
96
                            description: data.description,
97
                            filePath: data.document_filepath,
Deni Rinaldi's avatar
Deni Rinaldi committed
98
                            file: data.document_filepath,
Deni Rinaldi's avatar
Deni Rinaldi committed
99 100
                            document_name: data.document_name,
                            document_size: data.document_size,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
101 102
                            // id: data.approval_matrix_id,
                            // status: data.status,
Deni Rinaldi's avatar
Deni Rinaldi committed
103
                            fileType: data.document_type,
104
                            created: data.created,
Deni Rinaldi's avatar
Deni Rinaldi committed
105
                            updated: data.updated === null ? "" : data.updated,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
106
                            loadUpload: true,
107 108
                            name: data.values,
                            disabledPeriode: data.values === 'Manual Book TIA 4.0' ? true : false
Deni Rinaldi's avatar
Deni Rinaldi committed
109 110 111
                        }, () => {
                            this.getDataCompany()
                            this.getDataDocument()
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
112 113 114
                            this.getPeriode()
                            this.getMonth()
                        })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In")) {
                                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
146
                        options: typeData,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
147 148
                        getOptionLabel: (option) => option.company_name,
                    };
Deni Rinaldi's avatar
Deni Rinaldi committed
149
                    let index = typeData.findIndex((val) => val.company_id == this.state.companyId)
Deni Rinaldi's avatar
Deni Rinaldi committed
150
                    this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index === -1 ? typeData[0] : typeData[index] })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
151 152 153 154 155 156 157 158 159 160 161
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
162
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
163 164 165 166 167
            }
        })
    }

    getDataDocument() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
168 169 170 171
        // let payload = {
        //     "setting_group_id": 7,
        //     "setting_type_id": 167,
        //     "company_id": 0
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
172

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
173 174
        // }
        api.create().getDocumentCategory().then(response => {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
175
            // console.log(response);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
176 177 178 179 180 181 182 183 184 185
            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
186
                        options: typeData,
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
187 188
                        getOptionLabel: (option) => option.document_category_name,
                    };
Deni Rinaldi's avatar
Deni Rinaldi committed
189
                    let index = typeData.findIndex((val) => val.document_category_id == this.state.categoryId)
Deni Rinaldi's avatar
Deni Rinaldi committed
190
                    this.setState({ document: typeProps, documentData: response.data.data, getDocument: index === -1 ? typeData[0] : typeData[index] })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
191 192 193 194 195 196 197 198 199 200 201
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
202
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
            }
        })
    }

    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
230
    getMonth() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
        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
255 256 257 258 259 260
    clearMessage() {
        this.setState({
            errorPerusahaan: false,
            msgErrorPerusahaan: '',
            errorDocument: false,
            msgErrorDocument: '',
261 262 263 264
            errorMonth: false,
            msgErrorMonth: '',
            errorPeriode: false,
            msgErrorPeriode: '',
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
265 266 267 268 269 270 271
        })
    }

    fileHandler = (event) => {
        let fileObj = event
        let length = event.name.split(".").length
        let fileType = event.name.split(".")[length - 1]
272 273 274 275 276 277
        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
278
                    // console.log(err);
279 280 281 282 283 284
                }
                else {
                    this.setState({ file: event, fileType: String(fileType) })
                }
            })
        }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
285 286 287
    }

    validasi() {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
288 289 290 291 292 293
        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
294 295 296
            } 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
297
        }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
298
        if (R.isNil(this.state.getDocument)) {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
299 300 301
            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' })
302
        } 
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
303
        
304
        else {
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
305
            const formData = new FormData();
306 307
            if (this.state.file == this.state.filePath){
                formData.append("updated", 0);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
308 309 310 311
                formData.append("file", null);
            } else {
                formData.append("updated", 1);
                formData.append("file", this.state.file);
312
            }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
313 314 315
            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
316 317
                formData.append("companyId", 1);

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
318 319 320
            } 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
321
                formData.append("companyId", this.state.getPerusahaan.company_id);
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
322
            }
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
323 324 325
            formData.append("settingId", this.state.getDocument.document_category_id);
            formData.append("description", this.state.description);
            formData.append("extension", this.state.fileType);
326
            formData.append("documentId", this.props.idoc);
Deni Rinaldi's avatar
Deni Rinaldi committed
327
            this.setState({ formData }, () => {
328
                this.props.updateDocument(this.state.formData)
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
329 330 331 332
            })
        }
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
333 334
    deleteFile(e) {
        this.setState({ file: null })
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
335 336 337 338 339 340 341 342 343
    }

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

    render() {
        return (
            <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
                <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
360 361 362
                            </div>
                        </div>

Deni Rinaldi's avatar
Deni Rinaldi committed
363
                        <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
364
                            {this.state.disabledPeriode === false ?
Deni Rinaldi's avatar
Deni Rinaldi committed
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
                            <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
383
                            </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
384 385
                            :true}
                            {this.state.disabledPeriode === false ?
Deni Rinaldi's avatar
Deni Rinaldi committed
386 387 388 389 390 391 392
                            <div className="column-2">
                                <div style={{ padding: 10, borderRadius: 5 }}>
                                    <Autocomplete
                                        {...this.state.document}
                                        // debug
                                        clearOnEscape
                                        id="tipe"
393 394 395 396 397 398
                                        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
399 400 401 402 403 404 405 406 407 408
                                        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>
409
                            </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
                            :
                            <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>
                            }
436
                            {this.state.disabledPeriode === false ?
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
                            <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>
457 458
                            : true }
                            {this.state.disabledPeriode === false ?
459 460
                            <div className="column-2">
                                <div style={{ padding: 10, borderRadius: 5 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
461 462 463 464 465
                                    <Autocomplete
                                        {...this.state.listPeriode}
                                        // debug
                                        clearOnEscape
                                        id="periode"
466
                                        onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => this.clearMessage())}
Deni Rinaldi's avatar
Deni Rinaldi committed
467 468
                                        style={{ width: 250 }}
                                        renderInput={(params) =>
469
                                            <TextField {...params} label="Period Year" margin="normal" style={{ marginTop: 7 }}
Deni Rinaldi's avatar
Deni Rinaldi committed
470 471
                                                InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                                InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
472 473
                                                error={this.state.errorPeriode}
                                                helperText={this.state.msgErrorPeriode}
Deni Rinaldi's avatar
Deni Rinaldi committed
474 475 476 477
                                            />}
                                        value={this.state.periode}
                                    />
                                </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
478
                            </div>
479
                            : true}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
480
                        </div>
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
481
                        <div style={{ paddingLeft: 30, paddingRight: 30, paddingTop: 10 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
482 483 484 485 486
                            {this.state.loadUpload && (
                                <UploadFile
                                    type={this.state.uploadStatus}
                                    percentage={this.state.percentage}
                                    result={this.state.result}
487
                                    acceptedFiles={["xls", "xlsx", "pdf", "PDF", "docx", "doc", "pptx", "ppt", "ods", "odf" ]}
Deni Rinaldi's avatar
Deni Rinaldi committed
488 489 490 491 492 493 494 495 496 497 498 499
                                    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
500
                                    sizeUpload={Number(this.state.sizeUpload)}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
501
                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
502
                            )}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
503
                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
                        <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
532
                            >
Deni Rinaldi's avatar
Deni Rinaldi committed
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
                            </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"
559 560 561 562 563 564 565
                                    onClick={() => 
                                        this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.validasi()
                                            }, 100);
                                        })
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
566 567 568 569 570 571
                                >
                                    <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
572 573
                        </div>
                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
574 575 576 577 578
                    <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
579 580 581 582 583
                </div>
            </div>
        )
    }
}