Commit aa7168d4 authored by Riri Novita's avatar Riri Novita

Merge branch 'dev/riri' into 'ENV-DEV'

issue

See merge request !1740
parents 3b1e01cf 4af1ea70
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Typography, Paper, TextField, Snackbar} from '@material-ui/core'; import { Typography, Paper, TextField, Snackbar, withStyles} from '@material-ui/core';
import Images from '../../assets/Images'; import Images from '../../assets/Images';
import Constant from '../../library/Constant'; import Constant from '../../library/Constant';
import api from '../../api'; import api from '../../api';
...@@ -7,8 +7,11 @@ import { PropagateLoader } from 'react-spinners'; ...@@ -7,8 +7,11 @@ import { PropagateLoader } from 'react-spinners';
import { format } from 'date-fns'; import { format } from 'date-fns';
import Autocomplete from '@material-ui/lab/Autocomplete'; import Autocomplete from '@material-ui/lab/Autocomplete';
import TableProgressReport from './TableProgressReport' import TableProgressReport from './TableProgressReport'
import { Alert } from '@material-ui/lab';
import ReactTooltip from "react-tooltip"; import ReactTooltip from "react-tooltip";
import MuiAlert from '@material-ui/lab/Alert';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class ReportProgress extends Component { class ReportProgress extends Component {
constructor(props) { constructor(props) {
...@@ -35,7 +38,10 @@ class ReportProgress extends Component { ...@@ -35,7 +38,10 @@ class ReportProgress extends Component {
month: null, month: null,
periodeMB: null, periodeMB: null,
reportType: null, reportType: null,
dataTable: [] dataTable: [],
alert: false,
tipeAlert: '',
messageAlert: '',
} }
} }
......
import React, { Component } from "react"; import React, { Component } from "react";
import { createMuiTheme, FormControlLabel, Input, MuiThemeProvider, TableCell, Typography } from "@material-ui/core"; import { createMuiTheme, FormControlLabel, Input, MuiThemeProvider, Snackbar, TableCell, Typography, withStyles } from "@material-ui/core";
import MUIDataTable from "mui-datatables"; import MUIDataTable from "mui-datatables";
import api from '../../api'; import api from '../../api';
import Constant from '../../library/Constant'; import Constant from '../../library/Constant';
import { PropagateLoader } from "react-spinners"; import { PropagateLoader } from "react-spinners";
import Images from "../../assets/Images"; import Images from "../../assets/Images";
import MuiAlert from '@material-ui/lab/Alert';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3()); const getMuiTheme = () => createMuiTheme(ct.customTable3());
...@@ -31,12 +34,14 @@ export default class TableProgressReport extends Component { ...@@ -31,12 +34,14 @@ export default class TableProgressReport extends Component {
idCompany: null, idCompany: null,
companyName: "", companyName: "",
month: "", month: "",
alert: false,
tipeAlert: '',
messageAlert: '',
} }
} }
handleShowPopup(id, data) { handleShowPopup(id, data) {
let item = this.props let item = this.props
console.log(item);
let bulan = item.month == 1 ? "Jan" : item.month == 2 ? "Feb" : item.month == 3 ? "Mar" : item.month == 4 ? "Apr" : item.month == 5 ? "May" : item.month == 6 ? "Jun" : item.month == 7 ? "Jul" : item.month == 8 ? "Aug" : item.month == 9 ? "Sep" : item.month == 10 ? "Oct" : item.month == 11 ? "Nov" : item.month == 12 ? "Dec" : null let bulan = item.month == 1 ? "Jan" : item.month == 2 ? "Feb" : item.month == 3 ? "Mar" : item.month == 4 ? "Apr" : item.month == 5 ? "May" : item.month == 6 ? "Jun" : item.month == 7 ? "Jul" : item.month == 8 ? "Aug" : item.month == 9 ? "Sep" : item.month == 10 ? "Oct" : item.month == 11 ? "Nov" : item.month == 12 ? "Dec" : null
this.setState({ visiblePopup: true, idCompany: id, companyName: data[0], month: bulan }) this.setState({ visiblePopup: true, idCompany: id, companyName: data[0], month: bulan })
} }
...@@ -60,15 +65,10 @@ export default class TableProgressReport extends Component { ...@@ -60,15 +65,10 @@ export default class TableProgressReport extends Component {
if (response.ok) { if (response.ok) {
this.setState({ loading: false }) this.setState({ loading: false })
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }, () => { this.setState({ loading: false, visiblePopup: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
setTimeout(() => {
this.setState({ loading: false })
this.getData()
}, 2000);
})
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) // this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false}, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) { if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => { setTimeout(() => {
localStorage.removeItem(Constant.TOKEN) localStorage.removeItem(Constant.TOKEN)
...@@ -78,14 +78,18 @@ export default class TableProgressReport extends Component { ...@@ -78,14 +78,18 @@ export default class TableProgressReport extends Component {
}) })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
} }
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
let dataTable2 = this.props.dataTable; let dataTable2 = this.props.dataTable;
...@@ -717,6 +721,11 @@ export default class TableProgressReport extends Component { ...@@ -717,6 +721,11 @@ export default class TableProgressReport extends Component {
return ( return (
<div> <div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{ padding: "0px 20px 20px 20px", width: this.props.width - (this.props.open === true ? 350 : 100) }}> <div style={{ padding: "0px 20px 20px 20px", width: this.props.width - (this.props.open === true ? 350 : 100) }}>
{this.state.loading && loadingComponent} {this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment