Commit b5f16e69 authored by Deni Rinaldi's avatar Deni Rinaldi

Toast ++

parent ab6b1382
......@@ -19,7 +19,7 @@ export default class CreateParameter extends Component {
minValue: null,
maxValue: null,
startDate: '',
endDate: '',
endDate: null,
date: new Date(),
approvedBy: null,
getApprovedBy: null,
......@@ -40,6 +40,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false,
errorStartDate: false,
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorValue: '',
......@@ -217,6 +221,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false,
errorStartDate: false,
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorValue: '',
......@@ -237,6 +245,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false,
errorStartDate: false,
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorValue: '',
......@@ -258,6 +270,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false,
errorStartDate: false,
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorValue: '',
......@@ -270,11 +286,36 @@ export default class CreateParameter extends Component {
}
}
clearMessage() {
this.setState({
errorParameter: false,
errorDeskripsi: false,
errorValue: false,
errorMinValue: false,
errorOrder: false,
errorMaxValue: false,
errorStartDate: false,
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorValue: '',
msgErrorMinValue: '',
msgErrorOrder: '',
msgErrorMaxValue: '',
msgErrorStartDate: '',
msgErrorEndDate: ''
})
}
handleChangeCreate(e, type) {
let data = this.state
let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') {
this.setState({ startDate: format(e, 'yyyy-MM-dd') }, () => {
this.setState({ startDate: format(e, 'yyyy-MM-dd'), endDate: null }, () => {
console.log(this.state.startDate)
})
} else if (isDate && type == 'end_date') {
......@@ -282,22 +323,28 @@ export default class CreateParameter extends Component {
console.log(this.state.endDate)
})
} else {
this.setState({ ...data, [e.target.name]: e.target.value })
this.setState({ ...data, [e.target.name]: e.target.value }, () => this.clearMessage())
}
}
validasi() {
if (R.isEmpty(this.state.tempData.description)) {
this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
} else if (R.isEmpty(this.state.tempData.value)) {
this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.min_value)) {
if (R.isNil(this.state.getParameter)) {
this.setState({ errorParameter: true, msgErrorParameter: 'Parameter tidak boleh kosong' })
} else if (R.isNil(this.state.getTypes)) {
this.setState({ errorGroup: true, msgErrorGroup: 'Group tidak boleh kosong' })
} else if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Perusahaan tidak boleh kosong' })
// } else if (R.isEmpty(this.state.tempData.description)) {
// this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
// } else if (R.isEmpty(this.state.tempData.value)) {
// this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if (!R.isNil(this.state.tempData.max_value) && R.isNil(this.state.tempData.min_value)) {
this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.max_value)) {
// } else if (R.isNil(this.state.tempData.order)) {
// this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
} else if (!R.isNil(this.state.tempData.min_value) && R.isNil(this.state.tempData.max_value)) {
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.end_date)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' })
......@@ -307,17 +354,23 @@ export default class CreateParameter extends Component {
}
validasiCreate() {
if (R.isEmpty(this.state.description)) {
this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
} else if (R.isEmpty(this.state.value)) {
this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if (R.isNil(this.state.minValue)) {
if (R.isNil(this.state.getTypes)) {
this.setState({ errorGroup: true, msgErrorGroup: 'Group tidak boleh kosong' })
} else if (R.isNil(this.state.getParameter)) {
this.setState({ errorParameter: true, msgErrorParameter: 'Parameter tidak boleh kosong' })
} else if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Perusahaan tidak boleh kosong' })
// } else if (R.isEmpty(this.state.description)) {
// this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
// } else if (R.isNil(this.state.value)) {
// this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if (!R.isNil(this.state.maxValue) && R.isNil(this.state.minValue)) {
this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' })
} else if (R.isNil(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
} else if (R.isNil(this.state.maxValue)) {
// } else if (R.isNil(this.state.order)) {
// this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
} else if (!R.isNil(this.state.minValue) && R.isNil(this.state.maxValue)) {
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' })
} else if (R.isNil(this.state.endDate)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' })
......@@ -382,7 +435,7 @@ export default class CreateParameter extends Component {
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -415,8 +468,16 @@ export default class CreateParameter extends Component {
{...this.state.parameter}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue })}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parameter" />}
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, ()=> this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Parameter"
error={this.state.errorParameter}
helperText={this.state.msgErrorParameter}
/>}
value={this.state.getParameter}
/>
</div>
......@@ -439,8 +500,8 @@ export default class CreateParameter extends Component {
}}
name="description"
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorDeskripsi}
helperText={this.state.msgErrorDeskripsi}
// error={this.state.errorDeskripsi}
// helperText={this.state.msgErrorDeskripsi}
>
</TextField>
</div>
......@@ -464,8 +525,8 @@ export default class CreateParameter extends Component {
}}
name="value"
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorValue}
helperText={this.state.msgErrorValue}
// error={this.state.errorValue}
// helperText={this.state.msgErrorValue}
>
</TextField>
</div>
......@@ -547,11 +608,11 @@ export default class CreateParameter extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.created}</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.created}</Typography>
</div>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.updated == - null ? "" : this.props.data.updated}</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.updated === null ? "" : this.state.tempData.updated}</Typography>
</div>
</div>
</div>
......@@ -562,7 +623,7 @@ export default class CreateParameter extends Component {
{...this.state.types}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }) : this.getParameterByGroup(newInputValue.setting_group_id))}
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }, ()=> this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id), this.clearMessage() )}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Group" />}
value={this.state.getTypes}
/>
......@@ -572,7 +633,7 @@ export default class CreateParameter extends Component {
{...this.state.perusahaan}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })}
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, ()=> this.clearMessage())}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Perusahaan" />}
value={this.state.getPerusahaan}
/>
......@@ -597,8 +658,8 @@ export default class CreateParameter extends Component {
}}
name="order"
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorOrder}
helperText={this.state.msgErrorOrder}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
>
</TextField>
</div>
......@@ -702,7 +763,7 @@ export default class CreateParameter extends Component {
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -736,8 +797,16 @@ export default class CreateParameter extends Component {
debug
disabled={!this.state.enableParameter}
id="tipe"
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue })}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parameter" />}
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, ()=> this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Parameter"
error={this.state.errorParameter}
helperText={this.state.msgErrorParameter}
/>}
value={this.state.getParameter}
/>
</div>
......@@ -760,8 +829,6 @@ export default class CreateParameter extends Component {
}}
name="description"
onChange={(e) => this.handleChangeCreate(e, '')}
error={this.state.errorDeskripsi}
helperText={this.state.msgErrorDeskripsi}
>
</TextField>
</div>
......@@ -785,8 +852,8 @@ export default class CreateParameter extends Component {
}}
name="value"
onChange={(e) => this.handleChangeCreate(e, '')}
error={this.state.errorValue}
helperText={this.state.msgErrorValue}
// error={this.state.errorValue}
// helperText={this.state.msgErrorValue}
>
</TextField>
</div>
......@@ -866,8 +933,8 @@ export default class CreateParameter extends Component {
</div>
<div style={{ padding: 10, borderRadius: 5 }}>
<Typography style={{ fontSize: 11 }}>Dibuat : Admin - 21 Jul 2020, 18:45</Typography>
<Typography style={{ fontSize: 11 }}>Diubah : Admin - 21 Jul 2020, 18:45</Typography>
<Typography style={{ fontSize: 11 }}>Dibuat : </Typography>
<Typography style={{ fontSize: 11 }}>Diubah : </Typography>
</div>
</div>
......@@ -877,8 +944,16 @@ export default class CreateParameter extends Component {
{...this.state.types}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }) : this.getParameterByGroup(newInputValue.setting_group_id))}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Group" />}
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }, ()=> this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id), this.clearMessage() )}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Group"
error={this.state.errorGroup}
helperText={this.state.msgErrorGroup}
/>}
value={this.state.getTypes}
/>
</div>
......@@ -887,8 +962,16 @@ export default class CreateParameter extends Component {
{...this.state.perusahaan}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Perusahaan" />}
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, ()=> this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Perusahaan"
error={this.state.errorPerusahaan}
helperText={this.state.msgErrorPerusahaan}
/>}
value={this.state.getPerusahaan}
/>
</div>
......@@ -912,8 +995,8 @@ export default class CreateParameter extends Component {
}}
name="order"
onChange={(e) => this.handleChangeCreate(e, '')}
error={this.state.errorOrder}
helperText={this.state.msgErrorOrder}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
>
</TextField>
</div>
......
......@@ -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