Commit b5f16e69 authored by Deni Rinaldi's avatar Deni Rinaldi

Toast ++

parent ab6b1382
......@@ -78,6 +78,7 @@ export default class Parameter extends Component {
api.create().updateParameter(payload).then(response => {
if (response.data.status == 'success') {
this.getAllParameter()
alert(response.data.message)
} else {
alert(response.data.message)
}
......@@ -89,6 +90,7 @@ export default class Parameter extends Component {
api.create().createParameter(payload).then(response => {
if (response.data.status == 'success') {
this.getAllParameter()
alert(response.data.message)
} else {
alert(response.data.message)
}
......
......@@ -7,7 +7,8 @@ import UploadFile from "../../library/Upload";
import MUIDataTable from "mui-datatables";
import CreateUnitBisnis from "./formUnitBisnis/CreateUnitBisnis";
import ReactTooltip from 'react-tooltip';
import { TextField, InputBase } from "@material-ui/core";
import MuiAlert from '@material-ui/lab/Alert';
import { TextField, InputBase, Snackbar, withStyles } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer';
import api from "../../api";
import { isThisSecond } from "date-fns";
......@@ -18,6 +19,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
const options2 = ct.customOptions2();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class UnitBisnis extends Component {
constructor(props) {
super(props)
......@@ -32,7 +36,10 @@ export default class UnitBisnis extends Component {
cols: null,
rows: null,
dataLoaded: false,
popupError: false
popupError: false,
alert: false,
tipeAlert: '',
messageAlert: ''
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -238,10 +245,10 @@ export default class UnitBisnis extends Component {
this.setState({ visibleEdit: false })
api.create().updateUnitBisnis(payload).then(response => {
if (response.data.status == 'success') {
alert(response.data.message)
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
})
}
......@@ -251,8 +258,9 @@ export default class UnitBisnis extends Component {
api.create().createUnitBisnis(payload).then(response => {
if (response.data.status == 'success') {
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
})
}
......@@ -290,14 +298,21 @@ export default class UnitBisnis extends Component {
uploadUnitBisnis() {
api.create().uploadUnitBisnis(this.state.payload).then(response => {
console.log(response)
if (response.data.status === "success") {
alert(response.data.message)
this.getData()
this.setState({ visibleUnitBisnis: true })
if (response.data) {
if (response.data.status === "success") {
this.getData()
this.setState({ visibleUnitBisnis: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
}
})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
const columns = [{
name: "Action",
......@@ -366,6 +381,11 @@ export default class UnitBisnis extends Component {
<div style={{ height: this.props.height }}>
{/* <Row> */}
<div style={{ height: 199, width: '100%' }} className={"main-color"} />
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.visibleUnitBisnis === true ?
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
......
......@@ -298,7 +298,7 @@ export default class UserRole extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
{tableMeta.rowData[6] === "Aktif" ?
{/* {tableMeta.rowData[6] === "Aktif" ? */}
<button
style={{
backgroundColor: 'transparent',
......@@ -310,9 +310,9 @@ export default class UserRole extends Component {
>
<img src={Images.editCopy} />
</button>
:
{/* :
null
}
} */}
</div >
);
}
......
......@@ -202,8 +202,12 @@ export default class EditUser extends Component {
getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => {
if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data })
if (response.data) {
if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data })
}
} else {
alert(response.problem)
}
})
}
......
......@@ -113,7 +113,7 @@ class UserRole extends Component {
onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })}
>
<div style={{ display: 'flex' }}>
{tableMeta.rowData[2] !== "superadmin" && tableMeta.rowData[4] === "Aktif" ?
{tableMeta.rowData[2] !== "superadmin" ?
<img src={Images.editCopy} /> :
null
}
......
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