Commit ecf887fd authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-dev(pc)' into 'master'

Toast ++

See merge request !129
parents ab6b1382 b5f16e69
...@@ -19,7 +19,7 @@ export default class CreateParameter extends Component { ...@@ -19,7 +19,7 @@ export default class CreateParameter extends Component {
minValue: null, minValue: null,
maxValue: null, maxValue: null,
startDate: '', startDate: '',
endDate: '', endDate: null,
date: new Date(), date: new Date(),
approvedBy: null, approvedBy: null,
getApprovedBy: null, getApprovedBy: null,
...@@ -40,6 +40,10 @@ export default class CreateParameter extends Component { ...@@ -40,6 +40,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorValue: '', msgErrorValue: '',
...@@ -217,6 +221,10 @@ export default class CreateParameter extends Component { ...@@ -217,6 +221,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorValue: '', msgErrorValue: '',
...@@ -237,6 +245,10 @@ export default class CreateParameter extends Component { ...@@ -237,6 +245,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorValue: '', msgErrorValue: '',
...@@ -258,6 +270,10 @@ export default class CreateParameter extends Component { ...@@ -258,6 +270,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorValue: '', msgErrorValue: '',
...@@ -270,11 +286,36 @@ export default class CreateParameter extends Component { ...@@ -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) { handleChangeCreate(e, type) {
let data = this.state let data = this.state
let isDate = type !== '' ? true : false let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') { 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) console.log(this.state.startDate)
}) })
} else if (isDate && type == 'end_date') { } else if (isDate && type == 'end_date') {
...@@ -282,22 +323,28 @@ export default class CreateParameter extends Component { ...@@ -282,22 +323,28 @@ export default class CreateParameter extends Component {
console.log(this.state.endDate) console.log(this.state.endDate)
}) })
} else { } else {
this.setState({ ...data, [e.target.name]: e.target.value }) this.setState({ ...data, [e.target.name]: e.target.value }, () => this.clearMessage())
} }
} }
validasi() { validasi() {
if (R.isEmpty(this.state.tempData.description)) { if (R.isNil(this.state.getParameter)) {
this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' }) this.setState({ errorParameter: true, msgErrorParameter: 'Parameter tidak boleh kosong' })
} else if (R.isEmpty(this.state.tempData.value)) { } else if (R.isNil(this.state.getTypes)) {
this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' }) this.setState({ errorGroup: true, msgErrorGroup: 'Group tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.min_value)) { } 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' }) this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.start_date)) { } else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' }) this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.order)) { // } else if (R.isNil(this.state.tempData.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' }) // 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.min_value) && R.isNil(this.state.tempData.max_value)) {
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' }) this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.end_date)) { } else if (R.isNil(this.state.tempData.end_date)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' }) this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' })
...@@ -307,17 +354,23 @@ export default class CreateParameter extends Component { ...@@ -307,17 +354,23 @@ export default class CreateParameter extends Component {
} }
validasiCreate() { validasiCreate() {
if (R.isEmpty(this.state.description)) { if (R.isNil(this.state.getTypes)) {
this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' }) this.setState({ errorGroup: true, msgErrorGroup: 'Group tidak boleh kosong' })
} else if (R.isEmpty(this.state.value)) { } else if (R.isNil(this.state.getParameter)) {
this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' }) this.setState({ errorParameter: true, msgErrorParameter: 'Parameter tidak boleh kosong' })
} else if (R.isNil(this.state.minValue)) { } 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' }) this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' })
} else if (R.isNil(this.state.startDate)) { } else if (R.isNil(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' }) this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.order)) { // } else if (R.isNil(this.state.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' }) // this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
} else if (R.isNil(this.state.maxValue)) { } else if (!R.isNil(this.state.minValue) && R.isNil(this.state.maxValue)) {
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' }) this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' })
} else if (R.isNil(this.state.endDate)) { } else if (R.isNil(this.state.endDate)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' }) this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' })
...@@ -382,7 +435,7 @@ export default class CreateParameter extends Component { ...@@ -382,7 +435,7 @@ export default class CreateParameter extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()} onClick={() => this.props.onClickClose()}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -415,8 +468,16 @@ export default class CreateParameter extends Component { ...@@ -415,8 +468,16 @@ export default class CreateParameter extends Component {
{...this.state.parameter} {...this.state.parameter}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue })} 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" />} 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} value={this.state.getParameter}
/> />
</div> </div>
...@@ -439,8 +500,8 @@ export default class CreateParameter extends Component { ...@@ -439,8 +500,8 @@ export default class CreateParameter extends Component {
}} }}
name="description" name="description"
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
error={this.state.errorDeskripsi} // error={this.state.errorDeskripsi}
helperText={this.state.msgErrorDeskripsi} // helperText={this.state.msgErrorDeskripsi}
> >
</TextField> </TextField>
</div> </div>
...@@ -464,8 +525,8 @@ export default class CreateParameter extends Component { ...@@ -464,8 +525,8 @@ export default class CreateParameter extends Component {
}} }}
name="value" name="value"
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
error={this.state.errorValue} // error={this.state.errorValue}
helperText={this.state.msgErrorValue} // helperText={this.state.msgErrorValue}
> >
</TextField> </TextField>
</div> </div>
...@@ -547,11 +608,11 @@ export default class CreateParameter extends Component { ...@@ -547,11 +608,11 @@ export default class CreateParameter extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography> <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>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography> <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> </div>
</div> </div>
...@@ -562,7 +623,7 @@ export default class CreateParameter extends Component { ...@@ -562,7 +623,7 @@ export default class CreateParameter extends Component {
{...this.state.types} {...this.state.types}
debug debug
id="tipe" 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" />} renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Group" />}
value={this.state.getTypes} value={this.state.getTypes}
/> />
...@@ -572,7 +633,7 @@ export default class CreateParameter extends Component { ...@@ -572,7 +633,7 @@ export default class CreateParameter extends Component {
{...this.state.perusahaan} {...this.state.perusahaan}
debug debug
id="tipe" 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" />} renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Perusahaan" />}
value={this.state.getPerusahaan} value={this.state.getPerusahaan}
/> />
...@@ -597,8 +658,8 @@ export default class CreateParameter extends Component { ...@@ -597,8 +658,8 @@ export default class CreateParameter extends Component {
}} }}
name="order" name="order"
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
error={this.state.errorOrder} // error={this.state.errorOrder}
helperText={this.state.msgErrorOrder} // helperText={this.state.msgErrorOrder}
> >
</TextField> </TextField>
</div> </div>
...@@ -702,7 +763,7 @@ export default class CreateParameter extends Component { ...@@ -702,7 +763,7 @@ export default class CreateParameter extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()} onClick={() => this.props.onClickClose()}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -736,8 +797,16 @@ export default class CreateParameter extends Component { ...@@ -736,8 +797,16 @@ export default class CreateParameter extends Component {
debug debug
disabled={!this.state.enableParameter} disabled={!this.state.enableParameter}
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue })} 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" />} 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} value={this.state.getParameter}
/> />
</div> </div>
...@@ -760,8 +829,6 @@ export default class CreateParameter extends Component { ...@@ -760,8 +829,6 @@ export default class CreateParameter extends Component {
}} }}
name="description" name="description"
onChange={(e) => this.handleChangeCreate(e, '')} onChange={(e) => this.handleChangeCreate(e, '')}
error={this.state.errorDeskripsi}
helperText={this.state.msgErrorDeskripsi}
> >
</TextField> </TextField>
</div> </div>
...@@ -785,8 +852,8 @@ export default class CreateParameter extends Component { ...@@ -785,8 +852,8 @@ export default class CreateParameter extends Component {
}} }}
name="value" name="value"
onChange={(e) => this.handleChangeCreate(e, '')} onChange={(e) => this.handleChangeCreate(e, '')}
error={this.state.errorValue} // error={this.state.errorValue}
helperText={this.state.msgErrorValue} // helperText={this.state.msgErrorValue}
> >
</TextField> </TextField>
</div> </div>
...@@ -866,8 +933,8 @@ export default class CreateParameter extends Component { ...@@ -866,8 +933,8 @@ export default class CreateParameter extends Component {
</div> </div>
<div style={{ padding: 10, borderRadius: 5 }}> <div style={{ padding: 10, borderRadius: 5 }}>
<Typography style={{ fontSize: 11 }}>Dibuat : Admin - 21 Jul 2020, 18:45</Typography> <Typography style={{ fontSize: 11 }}>Dibuat : </Typography>
<Typography style={{ fontSize: 11 }}>Diubah : Admin - 21 Jul 2020, 18:45</Typography> <Typography style={{ fontSize: 11 }}>Diubah : </Typography>
</div> </div>
</div> </div>
...@@ -877,8 +944,16 @@ export default class CreateParameter extends Component { ...@@ -877,8 +944,16 @@ export default class CreateParameter extends Component {
{...this.state.types} {...this.state.types}
debug debug
id="tipe" 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" />} 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} value={this.state.getTypes}
/> />
</div> </div>
...@@ -887,8 +962,16 @@ export default class CreateParameter extends Component { ...@@ -887,8 +962,16 @@ export default class CreateParameter extends Component {
{...this.state.perusahaan} {...this.state.perusahaan}
debug debug
id="tipe" 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" />} 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} value={this.state.getPerusahaan}
/> />
</div> </div>
...@@ -912,8 +995,8 @@ export default class CreateParameter extends Component { ...@@ -912,8 +995,8 @@ export default class CreateParameter extends Component {
}} }}
name="order" name="order"
onChange={(e) => this.handleChangeCreate(e, '')} onChange={(e) => this.handleChangeCreate(e, '')}
error={this.state.errorOrder} // error={this.state.errorOrder}
helperText={this.state.msgErrorOrder} // helperText={this.state.msgErrorOrder}
> >
</TextField> </TextField>
</div> </div>
......
...@@ -78,6 +78,7 @@ export default class Parameter extends Component { ...@@ -78,6 +78,7 @@ export default class Parameter extends Component {
api.create().updateParameter(payload).then(response => { api.create().updateParameter(payload).then(response => {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getAllParameter() this.getAllParameter()
alert(response.data.message)
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
...@@ -89,6 +90,7 @@ export default class Parameter extends Component { ...@@ -89,6 +90,7 @@ export default class Parameter extends Component {
api.create().createParameter(payload).then(response => { api.create().createParameter(payload).then(response => {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getAllParameter() this.getAllParameter()
alert(response.data.message)
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
......
...@@ -7,7 +7,8 @@ import UploadFile from "../../library/Upload"; ...@@ -7,7 +7,8 @@ import UploadFile from "../../library/Upload";
import MUIDataTable from "mui-datatables"; import MUIDataTable from "mui-datatables";
import CreateUnitBisnis from "./formUnitBisnis/CreateUnitBisnis"; import CreateUnitBisnis from "./formUnitBisnis/CreateUnitBisnis";
import ReactTooltip from 'react-tooltip'; 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 { ExcelRenderer } from 'react-excel-renderer';
import api from "../../api"; import api from "../../api";
import { isThisSecond } from "date-fns"; import { isThisSecond } from "date-fns";
...@@ -18,6 +19,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable()); ...@@ -18,6 +19,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions(); const options = ct.customOptions();
const options2 = ct.customOptions2(); const options2 = ct.customOptions2();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class UnitBisnis extends Component { export default class UnitBisnis extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -32,7 +36,10 @@ export default class UnitBisnis extends Component { ...@@ -32,7 +36,10 @@ export default class UnitBisnis extends Component {
cols: null, cols: null,
rows: null, rows: null,
dataLoaded: false, dataLoaded: false,
popupError: false popupError: false,
alert: false,
tipeAlert: '',
messageAlert: ''
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -238,10 +245,10 @@ export default class UnitBisnis extends Component { ...@@ -238,10 +245,10 @@ export default class UnitBisnis extends Component {
this.setState({ visibleEdit: false }) this.setState({ visibleEdit: false })
api.create().updateUnitBisnis(payload).then(response => { api.create().updateUnitBisnis(payload).then(response => {
if (response.data.status == 'success') { if (response.data.status == 'success') {
alert(response.data.message)
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } 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 { ...@@ -251,8 +258,9 @@ export default class UnitBisnis extends Component {
api.create().createUnitBisnis(payload).then(response => { api.create().createUnitBisnis(payload).then(response => {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } 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 { ...@@ -290,14 +298,21 @@ export default class UnitBisnis extends Component {
uploadUnitBisnis() { uploadUnitBisnis() {
api.create().uploadUnitBisnis(this.state.payload).then(response => { api.create().uploadUnitBisnis(this.state.payload).then(response => {
console.log(response) console.log(response)
if (response.data.status === "success") { if (response.data) {
alert(response.data.message) if (response.data.status === "success") {
this.getData() this.getData()
this.setState({ visibleUnitBisnis: true }) 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() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -366,6 +381,11 @@ export default class UnitBisnis extends Component { ...@@ -366,6 +381,11 @@ export default class UnitBisnis extends Component {
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
<div style={{ height: 199, width: '100%' }} className={"main-color"} /> <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 ? {this.state.visibleUnitBisnis === true ?
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <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 { ...@@ -298,7 +298,7 @@ export default class UserRole extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[6] === "Aktif" ? {/* {tableMeta.rowData[6] === "Aktif" ? */}
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -310,9 +310,9 @@ export default class UserRole extends Component { ...@@ -310,9 +310,9 @@ export default class UserRole extends Component {
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
: {/* :
null null
} } */}
</div > </div >
); );
} }
......
...@@ -202,8 +202,12 @@ export default class EditUser extends Component { ...@@ -202,8 +202,12 @@ export default class EditUser extends Component {
getPerusahaan() { getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => { api.create().getPerusahaanHierarki().then((response) => {
if (response.data.status === 'success') { if (response.data) {
this.setState({ listCompany: response.data.data }) if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data })
}
} else {
alert(response.problem)
} }
}) })
} }
......
...@@ -113,7 +113,7 @@ class UserRole extends Component { ...@@ -113,7 +113,7 @@ class UserRole extends Component {
onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })} onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })}
> >
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[2] !== "superadmin" && tableMeta.rowData[4] === "Aktif" ? {tableMeta.rowData[2] !== "superadmin" ?
<img src={Images.editCopy} /> : <img src={Images.editCopy} /> :
null 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