MaintenanceMode.js 43.4 KB
Newer Older
Riri Novita's avatar
Riri Novita committed
1 2 3 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
import React, { Component, useRef } from 'react';
import { Typography, Paper, TextField, Snackbar, withStyles, Switch, FormControlLabel } from '@material-ui/core';
import Images from '../../assets/Images';
import Constant from '../../library/Constant';
import api from '../../api';
import { PropagateLoader } from 'react-spinners';
import { format } from 'date-fns';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { Alert } from '@material-ui/lab';
import ReactTooltip from "react-tooltip";
import SunEditor, { buttonList } from "suneditor-react";
import 'suneditor/dist/css/suneditor.min.css'; // Import Sun Editor's CSS File


const IOSSwitch = withStyles((theme) => ({
    root: {
        width: 55,
        height: 31,
        padding: 0,
        margin: theme.spacing(1),
    },
    switchBase: {
        padding: 3,
        marginLeft: 1,
        '&$checked': {
            transform: 'translateX(16px)',
            color: theme.palette.common.white,
            paddingLeft: 11,
            '& + $track': {
                backgroundColor: '#52d869',
                opacity: 1,
                border: 'none',
            },
        },
        '&$focusVisible $thumb': {
            color: '#52d869',
            border: '6px solid #fff',
        },
    },
    thumb: {
        width: 25,
        height: 25,
    },
    track: {
        borderRadius: 30 / 2,
        border: `1px solid ${theme.palette.grey[400]}`,
        backgroundColor: 'red',
        opacity: 1,
        transition: theme.transitions.create(['background-color', 'border']),
    },
    checked: {},
    focusVisible: {},
}))(({ classes, ...props }) => {
    return (
        <Switch
            focusVisibleClassName={classes.focusVisible}
            disableRipple
            classes={{
                root: classes.root,
                switchBase: classes.switchBase,
                thumb: classes.thumb,
                track: classes.track,
                checked: classes.checked,
            }}
            {...props}
        />
    );
});


class MaintenanceMode extends Component {
    constructor(props) {
        super(props)
        this.editorRef = React.createRef();
        this.editorRefEmail = React.createRef();
Riri Novita's avatar
Riri Novita committed
76
        this.editorRefContent = React.createRef();
Riri Novita's avatar
Riri Novita committed
77 78
        // this.handleChange = this.handleChange.bind(this)
        this.state = {
Riri Novita's avatar
Riri Novita committed
79 80 81 82 83 84
            load: false,
            loading: false,
            mailcontentModeActive: "",
            mailcontentModeNonActive: "",
            checkedB: true,
            headline: '',
Riri Novita's avatar
Riri Novita committed
85
            maintenanceContent: "",
Riri Novita's avatar
Riri Novita committed
86 87 88 89 90 91 92 93
            subjectMailActive: '',
            subjectMailNonActive: '',
            maintenanceID: null,
            maintenanceStatus: 0,
            mailStatusActive: 0,
            mailStatusNonActive: 0,


Riri Novita's avatar
Riri Novita committed
94 95 96 97 98
        }
    }


    componentDidMount() {
Riri Novita's avatar
Riri Novita committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
        this.getDetailMaintenanceMode()
    }

    getDetailMaintenanceMode() {
        this.setState({ loading: true })
        api.create().getDetailMaintenanceMode().then((response) => {
            console.log(response);
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        console.log(data.maintenance_mail.length);
                        let dataModeActive = data.maintenance_mail.length > 0 ? data.maintenance_mail.[0].[0] : null
                        let dataModeNonActive = data.maintenance_mail.length > 0 ? data.maintenance_mail.[0].[1] : null
                        this.setState({
                            maintenanceID: data.maintenance_id,
                            headline: data.maintenance_headline,
                            maintenanceContent: data.maintenance_content,
                            maintenanceStatus: data.maintenance_status === null ? 0 : data.maintenance_status,
                            mailStatusActive: dataModeActive === null ? 0 : dataModeActive.status,
                            subjectMailActive: dataModeActive === null ? null : dataModeActive.mailSubject,
                            mailcontentModeActive: dataModeActive === null ? null : dataModeActive.mailBody,
                            mailStatusNonActive: dataModeNonActive === null ? 0 : dataModeNonActive.status,
                            subjectMailNonActive: dataModeNonActive === null ? null : dataModeNonActive.mailSubject,
                            mailcontentModeNonActive: dataModeNonActive === null ? null : dataModeNonActive.mailBody,

                        }, () => {
                            setTimeout(() => {
                                this.setState({ loading: false })
                            }, 2000);
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

    handleChange(e, type) {
        let data = this.state
        let isDate = type !== '' ? true : false
        if (isDate && type === 'start_date') {
            this.setState({
                ...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null
            })
        } else if (isDate && type === 'end_date') {
            this.setState({
                ...data, endDate: format(e, 'yyyy-MM-dd')
            })
        } else {
            this.setState({
                ...data, [e.target.name]: e.target.value
            })
        }

    }

    handleCreate() {
        let payload = {
            "maintenance_headline": this.state.headline,
            "maintenance_content": this.state.maintenanceContent,
            "maintenance_status": this.state.maintenanceStatus,
173 174 175
            "maintenance_mail": [
                {
                    "mail_type": "MAINTENANCE_MODE_ACTIVE",
Riri Novita's avatar
Riri Novita committed
176 177 178
                    "mail_subject": "TIA 4.0 Is Under Maintenance",
                    "mail_body": "",
                    "mail_status": 0
179 180 181
                },
                {
                    "mail_type": "MAINTENANCE_MODE_INACTIVE",
Riri Novita's avatar
Riri Novita committed
182 183 184
                    "mail_subject": "TIA 4.0 is Back",
                    "mail_body": "",
                    "mail_status": 1
185 186
                }
            ]
Riri Novita's avatar
Riri Novita committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200
            // "maintenance_mail": [
            //     {
            //         "mail_type": "MAINTENANCE_MODE_ACTIVE",
            //         "mail_subject": this.state.subjectMailActive,
            //         "mail_body": this.state.mailcontentModeActive,
            //         "mail_status": this.state.mailStatusActive
            //     },
            //     {
            //         "mail_type": "MAINTENANCE_MODE_INACTIVE",
            //         "mail_subject": this.state.subjectMailNonActive,
            //         "mail_body": this.state.mailcontentModeNonActive,
            //         "mail_status": this.state.mailStatusNonActive
            //     }
            // ]
Riri Novita's avatar
Riri Novita committed
201 202 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 230 231 232 233 234 235 236 237
        }
        console.log(payload);
        api.create().createMaintenanceMode(payload).then((response) => {
            console.log(response)
            this.setState({ loading: true })
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', loading: false }, () => this.getDetailMaintenanceMode())
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
                }
            } else {
                // this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
                alert(response.problem)
                this.setState({ loading: false })
            }
        })

    }

    handleEdit() {
        let payload = {
            "maintenance_id": this.state.maintenanceID,
            "maintenance_headline": this.state.headline,
            "maintenance_content": this.state.maintenanceContent,
            "maintenance_status": this.state.maintenanceStatus,
Riri Novita's avatar
Riri Novita committed
238 239 240
            // "maintenance_mail": [
            //     {
            //         "mail_type": "MAINTENANCE_MODE_ACTIVE",
241 242 243
            //         "mail_subject": "TIA 4.0 Is Under Maintenance",
            //         "mail_body": "",
            //         "mail_status": 0
Riri Novita's avatar
Riri Novita committed
244 245 246
            //     },
            //     {
            //         "mail_type": "MAINTENANCE_MODE_INACTIVE",
247 248
            //         "mail_subject": "TIA 4.0 is Back",
            //         "mail_body": "",
Riri Novita's avatar
Riri Novita committed
249
            //         "mail_status": 1
Riri Novita's avatar
Riri Novita committed
250 251
            //     }
            // ]
252 253 254 255 256 257 258 259 260 261 262 263 264 265
            "maintenance_mail": [
                {
                    "mail_type": "MAINTENANCE_MODE_ACTIVE",
                    "mail_subject": this.state.subjectMailActive,
                    "mail_body": this.state.mailcontentModeActive,
                    "mail_status": this.state.mailStatusActive
                },
                {
                    "mail_type": "MAINTENANCE_MODE_INACTIVE",
                    "mail_subject": this.state.subjectMailNonActive,
                    "mail_body": this.state.mailcontentModeNonActive,
                    "mail_status": this.state.mailStatusNonActive
                }
            ]
Riri Novita's avatar
Riri Novita committed
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
        }
        console.log(payload);
        api.create().updateMaintenanceMode(payload).then((response) => {
            console.log(response)
            this.setState({ loading: true })
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', loading: false }, () => this.getDetailMaintenanceMode())
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
                }
            } else {
                // this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
                alert(response.problem)
                this.setState({ loading: false })
            }
        })
Riri Novita's avatar
Riri Novita committed
294 295 296 297 298 299
    }

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

Riri Novita's avatar
Riri Novita committed
300 301 302
    // handleChange(event) {
    //     this.setState({ ...this.state.checkedB, [event.target.name]: event.target.checked });
    // };
Riri Novita's avatar
Riri Novita committed
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321

    handleImageUploadBefore(files, info, uploadHandler) {
        // uploadHandler is a function
        console.log(files, info, uploadHandler)
        try {
            this.ResizeImage(files, uploadHandler)
        } catch (err) {
            uploadHandler(err.toString())
        }
    }
    handleImageUpload(targetImgElement, index, state, imageInfo, remainingFilesCount) {
        console.log(targetImgElement, index, state, imageInfo, remainingFilesCount)
    }

    handleImageUploadError(errorMessage, result) {
        console.log(errorMessage, result)
    }

    handleEditorChange(value) {
Riri Novita's avatar
Riri Novita committed
322 323
        // console.log(value);
        this.setState({ mailcontentModeActive: value })
Riri Novita's avatar
Riri Novita committed
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403

        // setContent(value)
    }

    handleDrop(event) {
        console.log(event); //Get the drop event
    }

    handleBlur(event, editorContents) {
        console.log(event, editorContents); //Get the blur event
    }

    imageUploadHandler(xmlHttpRequest, info, core) {
        console.log(xmlHttpRequest, info, core)
    }

    ResizeImage(files, uploadHandler) {
        const uploadFile = files[0];
        const img = document.createElement('img');
        const canvas = document.createElement('canvas');
        const reader = new FileReader();

        console.log(uploadFile);

        reader.onload = function (e) {
            img.src = e.target.result
            img.onload = function () {
                let ctx = canvas.getContext("2d");
                ctx.drawImage(img, 0, 0);

                const MAX_WIDTH = 200;
                const MAX_HEIGHT = 100;
                let width = img.width;
                let height = img.height;

                if (width > height) {
                    if (width > MAX_WIDTH) {
                        height *= MAX_WIDTH / width;
                        width = MAX_WIDTH;
                    }
                } else {
                    if (height > MAX_HEIGHT) {
                        width *= MAX_HEIGHT / height;
                        height = MAX_HEIGHT;
                    }
                }

                canvas.width = width;
                canvas.height = height;

                ctx = canvas.getContext("2d");
                ctx.drawImage(img, 0, 0, width, height);

                canvas.toBlob(function (blob) {
                    uploadHandler([new File([blob], uploadFile.name)])
                }, uploadFile.type, 1);
            }
        }

        reader.readAsDataURL(uploadFile);
    }

    handleImageUploadBeforeEmail(files, info, uploadHandler) {
        // uploadHandler is a function
        console.log(files, info, uploadHandler)
        try {
            this.ResizeImageEmail(files, uploadHandler)
        } catch (err) {
            uploadHandler(err.toString())
        }
    }
    handleImageUploadEmail(targetImgElement, index, state, imageInfo, remainingFilesCount) {
        console.log(targetImgElement, index, state, imageInfo, remainingFilesCount)
    }

    handleImageUploadErrorEmail(errorMessage, result) {
        console.log(errorMessage, result)
    }

    handleEditorChangeEmail(value) {
Riri Novita's avatar
Riri Novita committed
404 405
        // console.log(value);
        this.setState({ mailcontentModeNonActive: value })
Riri Novita's avatar
Riri Novita committed
406 407 408 409 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 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467

        // setContent(value)
    }

    handleDropEmail(event) {
        console.log(event); //Get the drop event
    }

    handleBlurEmail(event, editorContents) {
        console.log(event, editorContents); //Get the blur event
    }

    imageUploadHandlerEmail(xmlHttpRequest, info, core) {
        console.log(xmlHttpRequest, info, core)
    }

    ResizeImageEmail(files, uploadHandler) {
        const uploadFile = files[0];
        const img = document.createElement('img');
        const canvas = document.createElement('canvas');
        const reader = new FileReader();

        console.log(uploadFile);

        reader.onload = function (e) {
            img.src = e.target.result
            img.onload = function () {
                let ctx = canvas.getContext("2d");
                ctx.drawImage(img, 0, 0);

                const MAX_WIDTH = 200;
                const MAX_HEIGHT = 100;
                let width = img.width;
                let height = img.height;

                if (width > height) {
                    if (width > MAX_WIDTH) {
                        height *= MAX_WIDTH / width;
                        width = MAX_WIDTH;
                    }
                } else {
                    if (height > MAX_HEIGHT) {
                        width *= MAX_HEIGHT / height;
                        height = MAX_HEIGHT;
                    }
                }

                canvas.width = width;
                canvas.height = height;

                ctx = canvas.getContext("2d");
                ctx.drawImage(img, 0, 0, width, height);

                canvas.toBlob(function (blob) {
                    uploadHandler([new File([blob], uploadFile.name)])
                }, uploadFile.type, 1);
            }
        }

        reader.readAsDataURL(uploadFile);
    }

Riri Novita's avatar
Riri Novita committed
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 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 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
    handleImageUploadBeforeContent(files, info, uploadHandler) {
        // uploadHandler is a function
        console.log(files, info, uploadHandler)
        try {
            this.ResizeImage(files, uploadHandler)
        } catch (err) {
            uploadHandler(err.toString())
        }
    }
    handleImageUploadContent(targetImgElement, index, state, imageInfo, remainingFilesCount) {
        console.log(targetImgElement, index, state, imageInfo, remainingFilesCount)
    }

    handleImageUploadErrorContent(errorMessage, result) {
        console.log(errorMessage, result)
    }

    handleEditorChangeContent(value) {
        // console.log(value);
        this.setState({ maintenanceContent: value })

        // setContent(value)
    }

    handleDropContent(event) {
        console.log(event); //Get the drop event
    }

    handleBlurContent(event, editorContents) {
        console.log(event, editorContents); //Get the blur event
    }

    imageUploadHandlerContent(xmlHttpRequest, info, core) {
        console.log(xmlHttpRequest, info, core)
    }

    ResizeImageContent(files, uploadHandler) {
        const uploadFile = files[0];
        const img = document.createElement('img');
        const canvas = document.createElement('canvas');
        const reader = new FileReader();

        console.log(uploadFile);

        reader.onload = function (e) {
            img.src = e.target.result
            img.onload = function () {
                let ctx = canvas.getContext("2d");
                ctx.drawImage(img, 0, 0);

                const MAX_WIDTH = 200;
                const MAX_HEIGHT = 100;
                let width = img.width;
                let height = img.height;

                if (width > height) {
                    if (width > MAX_WIDTH) {
                        height *= MAX_WIDTH / width;
                        width = MAX_WIDTH;
                    }
                } else {
                    if (height > MAX_HEIGHT) {
                        width *= MAX_HEIGHT / height;
                        height = MAX_HEIGHT;
                    }
                }

                canvas.width = width;
                canvas.height = height;

                ctx = canvas.getContext("2d");
                ctx.drawImage(img, 0, 0, width, height);

                canvas.toBlob(function (blob) {
                    uploadHandler([new File([blob], uploadFile.name)])
                }, uploadFile.type, 1);
            }
        }

        reader.readAsDataURL(uploadFile);
    }

Riri Novita's avatar
Riri Novita committed
550 551 552
    render() {

        const loadingComponent = (
Riri Novita's avatar
Riri Novita committed
553
            <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)' }}>
Riri Novita's avatar
Riri Novita committed
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );

        return (
            <div style={{ flex: 1, backgroundColor: '#f8f8f8', minHeight: this.props.height }}>
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
                <div>
Riri Novita's avatar
Riri Novita committed
571
                    {this.state.loading && loadingComponent}
Riri Novita's avatar
Riri Novita committed
572 573 574 575
                    <div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                        <Typography style={{ fontSize: '16px', color: 'white' }}>Maintenance Mode</Typography>
                    </div>
                    <div style={{ padding: 20, width: '100%' }}>
Riri Novita's avatar
Riri Novita committed
576
                        <Paper style={{ paddingTop: 10, paddingBottom: 50 }}>
Riri Novita's avatar
Riri Novita committed
577
                            <div style={{ display: 'flex', justifyContent: 'space-between', margin: 10, borderBottom: 'solid 2px #00000057', height: '100%' }}>
Riri Novita's avatar
Riri Novita committed
578 579 580 581
                                <div >
                                    <Typography style={{ fontSize: '17px', color: '#4b4b4b', margin: 10 }}>General Setting - Maintenance Mode</Typography>
                                </div>
                                <div style={{ marginTop: 5, marginRight: 30 }}>
Riri Novita's avatar
Riri Novita committed
582
                                    {/* <button
Riri Novita's avatar
Riri Novita committed
583 584
                                        type="button"
                                        style={{ background: 'white' }}
Riri Novita's avatar
Riri Novita committed
585
                                        onClick={() => Alert('Coming Soon !')}
Riri Novita's avatar
Riri Novita committed
586 587 588 589
                                    >
                                        <div style={{ width: 102, height: 30, backgroundColor: '#fff', border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center', marginRight: 15 }}>
                                            <span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
                                        </div>
Riri Novita's avatar
Riri Novita committed
590
                                    </button> */}
Riri Novita's avatar
Riri Novita committed
591 592
                                    <button
                                        type="button"
Riri Novita's avatar
Riri Novita committed
593
                                        onClick={() => this.state.maintenanceID === null ? this.handleCreate() : this.handleEdit()}
Riri Novita's avatar
Riri Novita committed
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
                                    >
                                        <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                            <span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
                                        </div>
                                    </button>
                                </div>
                            </div>
                            <div style={{ margin: 20 }}>
                                <div style={{ display: 'flex', marginTop: 20, width: '100%', justifyContent: 'space-between' }}>
                                    <Typography style={{ marginTop: 13, width: '20%', color: '#656565', fontSize: 14 }}>Maintenance Mode</Typography>
                                    <div style={{ width: '80%', paddingTop: 10 }}>
                                        <div>
                                            {/* <FormControlLabel
                                                control={<IOSSwitch checked={this.state.checkedB} onChange={this.handleChange.bind(this)} name="checkedB" />} /> */}
                                            <button
                                                type="button"
                                                style={{ background: '#fff', marginRight: 15 }}
Riri Novita's avatar
Riri Novita committed
611
                                                onClick={() => this.setState({ maintenanceStatus: 0 })}
Riri Novita's avatar
Riri Novita committed
612
                                            >
Riri Novita's avatar
Riri Novita committed
613 614
                                                <div style={{ width: 102, height: 30, backgroundColor: this.state.maintenanceStatus === 0 ? 'green' : '#fff', border: this.state.maintenanceStatus === 0 ? 'none' : 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                                    <span style={{ color: this.state.maintenanceStatus === 0 ? 'white' : '#354960', fontSize: 11, fontWeight: 'bold' }}>Non Active</span>
Riri Novita's avatar
Riri Novita committed
615 616 617 618
                                                </div>
                                            </button>
                                            <button
                                                type="button"
Riri Novita's avatar
Riri Novita committed
619
                                                onClick={() => this.setState({ maintenanceStatus: 1 })}
Riri Novita's avatar
Riri Novita committed
620
                                            >
Riri Novita's avatar
Riri Novita committed
621 622
                                                <div style={{ width: 102, height: 30, backgroundColor: this.state.maintenanceStatus === 1 ? 'red' : '#fff', border: this.state.maintenanceStatus === 1 ? null : 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                                    <span style={{ color: this.state.maintenanceStatus === 1 ? 'white' : '#354960', fontSize: 11, fontWeight: 'bold' }}>Active</span>
Riri Novita's avatar
Riri Novita committed
623 624 625 626 627 628 629 630 631 632 633 634 635
                                                </div>
                                            </button>
                                        </div>
                                        <Typography style={{ alignSelf: 'center', width: '80%', marginTop: 11, color: '#656565', fontSize: 14 }}>Dengan mengaktifkan, maka user selain admin tidak dapat melakukan akses ke dalam sistem. (Halaman maintenance terbuka)</Typography>
                                    </div>
                                </div>
                                <Typography style={{ marginTop: 20, width: '80%', color: '#656565', fontSize: 15, fontWeight: 'bold' }}>Setting Halaman Maintenance</Typography>
                                <div style={{ display: 'flex', marginTop: 15, width: '100%', justifyContent: 'space-between' }}>
                                    <Typography style={{ marginTop: 13, width: '20%', color: '#656565', fontSize: 14 }}>Headline</Typography>
                                    <div style={{ width: '80%', margin: 0, marginTop: 10 }}>
                                        <div>
                                            <TextField
                                                variant="outlined"
Riri Novita's avatar
Riri Novita committed
636 637 638 639
                                                id="headline"
                                                name="headline"
                                                value={this.state.headline}
                                                onChange={(e) => this.handleChange(e, '')}
Riri Novita's avatar
Riri Novita committed
640 641 642 643 644 645
                                                style={{ width: '80%' }}
                                                inputProps={{ style: { color: '#656565', height: 0 } }}
                                            />
                                        </div>
                                    </div>
                                </div>
Riri Novita's avatar
Riri Novita committed
646
                                <div style={{ display: 'flex', marginTop: 15, width: '100%', justifyContent: 'space-between' }}>
Riri Novita's avatar
Riri Novita committed
647 648
                                    <Typography style={{ marginTop: 13, width: '20%', color: '#656565', fontSize: 14 }}>Content</Typography>
                                    <div style={{ width: '80%', margin: 0, marginTop: 10 }}>
Riri Novita's avatar
Riri Novita committed
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678
                                        <div style={{ marginTop: 20 }}>
                                            <SunEditor
                                                showToolbar={true}
                                                enableToolbar={true}
                                                ref={this.editorRefContent}
                                                width={"100%"}
                                                setOptions={{
                                                    width: '80%',
                                                    height: 300,
                                                    buttonList: [
                                                        // default
                                                        ['undo', 'redo'],
                                                        ['font', 'fontSize', 'formatBlock'],
                                                        ['paragraphStyle', 'blockquote'],
                                                        ['fontColor', 'hiliteColor', 'textStyle'],
                                                        ['bold', 'underline', 'italic', 'list', 'align'],
                                                        ['table', 'link', 'image'],
                                                        ['fullScreen']
                                                    ]
                                                    // buttonList: buttonList.formatting // Or Array of button list, eg. [['font', 'align'], ['image']]
                                                    // Other option
                                                }}
                                                onChange={this.handleEditorChangeContent.bind(this)}
                                                setContents={this.state.maintenanceContent}
                                                onDrop={this.handleDropContent.bind(this)}
                                                imageUploadHandler={this.imageUploadHandlerContent.bind(this)}
                                                onBlur={this.handleBlurContent.bind(this)}
                                                onImageUploadBefore={this.handleImageUploadBeforeContent.bind(this)}
                                                onImageUpload={this.handleImageUploadContent.bind(this)}
                                                onImageUploadError={this.handleImageUploadErrorContent.bind(this)}
Riri Novita's avatar
Riri Novita committed
679 680 681 682
                                            />
                                        </div>
                                    </div>
                                </div>
Riri Novita's avatar
Riri Novita committed
683
                                {/* <Typography style={{ marginTop: 30, width: '80%', color: '#656565', fontSize: 15, fontWeight: 'bold' }}>Setting Notifikasi Email Saat Maintenance Mode Aktif</Typography>
Riri Novita's avatar
Riri Novita committed
684 685 686 687 688 689 690
                                <div style={{ display: 'flex', marginTop: 20, width: '100%', justifyContent: 'space-between' }}>
                                    <Typography style={{ marginTop: 13, width: '20%', color: '#656565', fontSize: 14 }}>Kirim Email Notif</Typography>
                                    <div style={{ width: '80%', margin: 0, marginTop: 10 }}>
                                        <div>
                                            <button
                                                type="button"
                                                style={{ background: '#fff', marginRight: 15 }}
Riri Novita's avatar
Riri Novita committed
691
                                                onClick={() => this.setState({ mailStatusActive: 0 })}
Riri Novita's avatar
Riri Novita committed
692
                                            >
Riri Novita's avatar
Riri Novita committed
693 694
                                                <div style={{ width: 102, height: 30, backgroundColor: this.state.mailStatusActive === 0 ? 'red' : '#fff', border: this.state.mailStatusActive === 0 ? 'none' : 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                                    <span style={{ color: this.state.mailStatusActive === 0 ? 'white' : '#354960', fontSize: 11, fontWeight: 'bold' }}>Tidak</span>
Riri Novita's avatar
Riri Novita committed
695 696 697 698
                                                </div>
                                            </button>
                                            <button
                                                type="button"
Riri Novita's avatar
Riri Novita committed
699
                                                onClick={() => this.setState({ mailStatusActive: 1 })}
Riri Novita's avatar
Riri Novita committed
700
                                            >
Riri Novita's avatar
Riri Novita committed
701 702
                                                <div style={{ width: 102, height: 30, backgroundColor: this.state.mailStatusActive === 1 ? 'green' : '#fff', border: this.state.mailStatusActive === 1 ? null : 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                                    <span style={{ color: this.state.mailStatusActive === 1 ? 'white' : '#354960', fontSize: 11, fontWeight: 'bold' }}>Ya</span>
Riri Novita's avatar
Riri Novita committed
703 704 705 706 707 708 709 710 711 712 713
                                                </div>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <div style={{ display: 'flex', marginTop: 15, width: '100%', justifyContent: 'space-between' }}>
                                    <Typography style={{ marginTop: 13, width: '20%', color: '#656565', fontSize: 14 }}>Subject Email</Typography>
                                    <div style={{ width: '80%', margin: 0, marginTop: 10 }}>
                                        <div>
                                            <TextField
                                                variant="outlined"
Riri Novita's avatar
Riri Novita committed
714 715 716 717
                                                id="subjectMailActive"
                                                name="subjectMailActive"
                                                onChange={(e) => this.handleChange(e, '')}
                                                value={this.state.subjectMailActive}
Riri Novita's avatar
Riri Novita committed
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749
                                                style={{ width: '80%' }}
                                                inputProps={{ style: { color: '#656565', height: 0 } }}
                                            />
                                        </div>
                                    </div>
                                </div>
                                <div style={{ display: 'flex', marginTop: 15, width: '100%', justifyContent: 'space-between' }}>
                                    <Typography style={{ marginTop: 13, width: '20%', color: '#656565', fontSize: 14 }}>Content Email</Typography>
                                    <div style={{ width: '80%', margin: 0, marginTop: 10 }}>
                                        <div style={{ marginTop: 20 }}>
                                            <SunEditor
                                                showToolbar={true}
                                                enableToolbar={true}
                                                ref={this.editorRef}
                                                width={"100%"}
                                                setOptions={{
                                                    width: '80%',
                                                    height: 300,
                                                    buttonList: [
                                                        // default
                                                        ['undo', 'redo'],
                                                        ['font', 'fontSize', 'formatBlock'],
                                                        ['paragraphStyle', 'blockquote'],
                                                        ['fontColor', 'hiliteColor', 'textStyle'],
                                                        ['bold', 'underline', 'italic', 'list', 'align'],
                                                        ['table', 'link', 'image'],
                                                        ['fullScreen']
                                                    ]
                                                    // buttonList: buttonList.formatting // Or Array of button list, eg. [['font', 'align'], ['image']]
                                                    // Other option
                                                }}
                                                onChange={this.handleEditorChange.bind(this)}
Riri Novita's avatar
Riri Novita committed
750
                                                setContents={this.state.mailcontentModeActive}
Riri Novita's avatar
Riri Novita committed
751 752 753 754 755 756 757 758 759
                                                onDrop={this.handleDrop.bind(this)}
                                                imageUploadHandler={this.imageUploadHandler.bind(this)}
                                                onBlur={this.handleBlur.bind(this)}
                                                onImageUploadBefore={this.handleImageUploadBefore.bind(this)}
                                                onImageUpload={this.handleImageUpload.bind(this)}
                                                onImageUploadError={this.handleImageUploadError.bind(this)}
                                            />
                                        </div>
                                    </div>
Riri Novita's avatar
Riri Novita committed
760 761
                                </div> */}
                                {/* <Typography style={{ marginTop: 30, width: '80%', color: '#656565', fontSize: 15, fontWeight: 'bold' }}>Setting Notifikasi Email Saat Maintenance Mode Non Aktif</Typography>
Riri Novita's avatar
Riri Novita committed
762 763 764 765 766 767 768
                                <div style={{ display: 'flex', marginTop: 20, width: '100%', justifyContent: 'space-between' }}>
                                    <Typography style={{ marginTop: 13, width: '20%', color: '#656565', fontSize: 14 }}>Kirim Email Notif</Typography>
                                    <div style={{ width: '80%', margin: 0, marginTop: 10 }}>
                                        <div>
                                            <button
                                                type="button"
                                                style={{ background: '#fff', marginRight: 15 }}
Riri Novita's avatar
Riri Novita committed
769
                                                onClick={() => this.setState({ mailStatusNonActive: 0 })}
Riri Novita's avatar
Riri Novita committed
770
                                            >
Riri Novita's avatar
Riri Novita committed
771 772
                                                <div style={{ width: 102, height: 30, backgroundColor: this.state.mailStatusNonActive === 0 ? 'red' : '#fff', border: this.state.mailStatusNonActive === 0 ? 'none' : 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                                    <span style={{ color: this.state.mailStatusNonActive === 0 ? 'white' : '#354960', fontSize: 11, fontWeight: 'bold' }}>Tidak</span>
Riri Novita's avatar
Riri Novita committed
773 774 775 776
                                                </div>
                                            </button>
                                            <button
                                                type="button"
Riri Novita's avatar
Riri Novita committed
777
                                                onClick={() => this.setState({ mailStatusNonActive: 1 })}
Riri Novita's avatar
Riri Novita committed
778
                                            >
Riri Novita's avatar
Riri Novita committed
779 780
                                                <div style={{ width: 102, height: 30, backgroundColor: this.state.mailStatusNonActive === 1 ? 'green' : '#fff', border: this.state.mailStatusNonActive === 1 ? null : 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                                    <span style={{ color: this.state.mailStatusNonActive === 1 ? 'white' : '#354960', fontSize: 11, fontWeight: 'bold' }}>Ya</span>
Riri Novita's avatar
Riri Novita committed
781 782 783 784 785 786 787 788 789 790 791
                                                </div>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <div style={{ display: 'flex', marginTop: 15, width: '100%', justifyContent: 'space-between' }}>
                                    <Typography style={{ marginTop: 13, width: '20%', color: '#656565', fontSize: 14 }}>Subject Email</Typography>
                                    <div style={{ width: '80%', margin: 0, marginTop: 10 }}>
                                        <div>
                                            <TextField
                                                variant="outlined"
Riri Novita's avatar
Riri Novita committed
792 793 794 795
                                                id="subjectMailNonActive"
                                                name="subjectMailNonActive"
                                                onChange={(e) => this.handleChange(e, '')}
                                                value={this.state.subjectMailNonActive}
Riri Novita's avatar
Riri Novita committed
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
                                                style={{ width: '80%' }}
                                                inputProps={{ style: { color: '#656565', height: 0 } }}
                                            />
                                        </div>
                                    </div>
                                </div>
                                <div style={{ display: 'flex', marginTop: 15, width: '100%', justifyContent: 'space-between' }}>
                                    <Typography style={{ marginTop: 13, width: '20%', color: '#656565', fontSize: 14 }}>Content Email</Typography>
                                    <div style={{ width: '80%', margin: 0, marginTop: 10 }}>
                                        <div style={{ marginTop: 20 }}>
                                            <SunEditor
                                                showToolbar={true}
                                                enableToolbar={true}
                                                ref={this.editorRefEmail}
                                                width={"100%"}
                                                setOptions={{
                                                    width: '80%',
                                                    height: 300,
                                                    buttonList: [
                                                        // default
                                                        ['undo', 'redo'],
                                                        ['font', 'fontSize', 'formatBlock'],
                                                        ['paragraphStyle', 'blockquote'],
                                                        ['fontColor', 'hiliteColor', 'textStyle'],
                                                        ['bold', 'underline', 'italic', 'list', 'align'],
                                                        ['table', 'link', 'image'],
                                                        ['fullScreen']
                                                    ]
                                                    // buttonList: buttonList.formatting // Or Array of button list, eg. [['font', 'align'], ['image']]
                                                    // Other option
                                                }}
                                                onChange={this.handleEditorChangeEmail.bind(this)}
Riri Novita's avatar
Riri Novita committed
828
                                                setContents={this.state.mailcontentModeNonActive}
Riri Novita's avatar
Riri Novita committed
829 830 831 832 833 834 835 836 837
                                                onDrop={this.handleDropEmail.bind(this)}
                                                imageUploadHandler={this.imageUploadHandlerEmail.bind(this)}
                                                onBlur={this.handleBlurEmail.bind(this)}
                                                onImageUploadBefore={this.handleImageUploadBeforeEmail.bind(this)}
                                                onImageUpload={this.handleImageUploadEmail.bind(this)}
                                                onImageUploadError={this.handleImageUploadErrorEmail.bind(this)}
                                            />
                                        </div>
                                    </div>
Riri Novita's avatar
Riri Novita committed
838
                                </div> */}
Riri Novita's avatar
Riri Novita committed
839 840 841 842 843 844 845 846 847 848 849
                            </div>
                        </Paper>
                    </div>
                </div>
            </div>
        );

    }
}

export default MaintenanceMode;