Commit c2ff51bc authored by Deni Rinaldi's avatar Deni Rinaldi

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

Deni dev(pc)

See merge request !136
parents 84f5d3ae 7c5516c4
......@@ -513,6 +513,7 @@ export default class CreateParameter extends Component {
value={this.state.tempData === null ? '' : this.state.tempData.value}
type={"number"}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -538,6 +539,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.tempData === null ? '' : this.state.tempData.min_value}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -646,6 +648,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.tempData === null ? '' : this.state.tempData.order}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -671,6 +674,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.tempData === null ? '' : this.state.tempData.max_value}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -840,10 +844,12 @@ export default class CreateParameter extends Component {
value={this.state.value === null ? '' : this.state.value}
type={"number"}
inputProps={{
min: 0,
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
......@@ -865,6 +871,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.minValue === null ? '' : this.state.minValue}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -983,6 +990,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.order === null ? '' : this.state.order}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -1008,6 +1016,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.maxValue === null ? '' : this.state.maxValue}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......
......@@ -42,6 +42,7 @@ export default class Parameter extends Component {
getAllParameter() {
api.create().getAllParameter().then(response => {
if (response.data) {
if (response.data.status === "success") {
console.log(response);
let data = response.data.data
......@@ -61,7 +62,10 @@ export default class Parameter extends Component {
})
this.setState({ dataTable: listData, data: response.data.data })
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -83,6 +87,7 @@ export default class Parameter extends Component {
updateParameter = (payload) => {
this.setState({ visibleEdit: false })
api.create().updateParameter(payload).then(response => {
console.log(response);
if (response.data) {
if (response.data.status == 'success') {
this.getAllParameter()
......
import React, { Component } from "react";
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import { createMuiTheme, MuiThemeProvider, withStyles } from '@material-ui/core/styles';
import Images from "../../assets/Images";
import MUIDataTable from "mui-datatables";
import { InputBase } from "@material-ui/core";
import { InputBase, Snackbar } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload";
import MuiAlert from '@material-ui/lab/Alert';
import CreateReportItems from "./formReportItems/CreateReportItems";
import EditReportItems from "./formReportItems/EditReportItems";
import VisualReportItems from "./formReportItems/VisualReportItems";
......@@ -17,6 +18,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 ReportItems extends Component {
constructor(props) {
super(props)
......@@ -32,7 +36,10 @@ export default class ReportItems extends Component {
dataLoaded: false,
cols: null,
rows: null,
popupError: false
popupError: false,
alert: false,
tipeAlert: '',
messageAlert: ''
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -450,6 +457,7 @@ export default class ReportItems extends Component {
getData() {
api.create().getReportItems().then((response) => {
console.log(response)
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => {
......@@ -457,7 +465,10 @@ export default class ReportItems extends Component {
})
this.setState({ dataTable: listData, listData: response.data.data })
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -482,6 +493,7 @@ export default class ReportItems extends Component {
}
api.create().searchReportItems(body).then(response => {
// console.log(response.data);
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
......@@ -489,7 +501,10 @@ export default class ReportItems extends Component {
})
this.setState({ dataTable: listData, listData: response.data.data })
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -497,10 +512,15 @@ export default class ReportItems extends Component {
createReportItems = (payload) => {
this.setState({ add: false })
api.create().createReportItems(payload).then(response => {
if (response.data) {
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' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -538,10 +558,15 @@ export default class ReportItems extends Component {
updateReportItems = (payload) => {
this.setState({ edit: false })
api.create().updateReportItems(payload).then(response => {
if (response.data) {
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' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -550,15 +575,22 @@ export default class ReportItems extends Component {
api.create().uploadReportItems(this.state.payload).then(response => {
if (response.data) {
if (response.data.status === "success") {
console.log(response)
alert(response.data.message)
this.getData()
this.setState({ itemReport: true })
this.setState({ itemReport: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
const columns = [{
name: "Action",
......@@ -716,6 +748,11 @@ export default class ReportItems extends Component {
<div style={{ height: this.props.height }}>
{/* <Row> */}
<div className={"main-color"} style={{ height: 199, width: '100%' }} />
<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.itemReport === true ?
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
......
......@@ -21,7 +21,7 @@ export default class CreateReportItems extends Component {
order: '',
description: '',
uom: '',
weight: null,
weight: '',
formula: '',
realVal: '',
condition: null,
......@@ -36,6 +36,10 @@ export default class CreateReportItems extends Component {
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
......@@ -66,15 +70,20 @@ export default class CreateReportItems extends Component {
handleChange(e, type) {
let data = this.state
let isDate = type !== ''? true : false
let isDate = type !== '' ? true : false
if (isDate && type === 'start_date') {
this.setState({...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
this.setState({
...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
......@@ -83,13 +92,18 @@ export default class CreateReportItems extends Component {
msgErrorED: '',
})
} else if (isDate && type === 'end_date') {
this.setState({...data, endDate : format(e, 'yyyy-MM-dd'),
this.setState({
...data, endDate: format(e, 'yyyy-MM-dd'),
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
......@@ -98,13 +112,18 @@ export default class CreateReportItems extends Component {
msgErrorED: '',
})
} else {
this.setState({...data, [e.target.name]: e.target.value,
this.setState({
...data, [e.target.name]: e.target.value,
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
......@@ -120,24 +139,28 @@ export default class CreateReportItems extends Component {
if (R.isNil(this.state.reportType)) return alert("Jenis Laporan is Required.");
if (R.isNil(this.state.company)) return alert("Perusahaan is Required.");
else if (R.isEmpty(this.state.order)) {
this.setState({errorOrder: true, msgErrorOrder: 'Order Harus Diisi'})
this.setState({ errorOrder: true, msgErrorOrder: 'Order Harus Diisi' })
}
else if (R.isEmpty(this.state.description)) {
this.setState({errorDesc: true, msgErrorDesc: 'Deskripsi Harus Diisi'})
this.setState({ errorDesc: true, msgErrorDesc: 'Deskripsi Harus Diisi' })
}
else if (R.isNil(this.state.InputType)) {
this.setState({ errorTipeData: true, msgErrorTipeData: 'Tipe Data Harus Diisi' })
}
else if (R.isNil(this.state.InputType)) return alert("Tipe Data is Required.")
else if (this.state.disabledFormula === false && R.isEmpty(this.state.formula)) {
this.setState({errorFormula: true, msgErrorFormula: 'Formula Harus Diisi'})
this.setState({ errorFormula: true, msgErrorFormula: 'Formula Harus Diisi' })
}
else if (this.state.disabledValue === false && R.isEmpty(this.state.realVal)) {
this.setState({errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi'})
this.setState({ errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi' })
}
else if (this.state.disabledCondt === false && R.isEmpty(this.state.condition)) {
this.setState({ errorCondition: true, msgErrorCondition: 'Kondisi Jika Salah Harus Diisi' })
}
else if (this.state.disabledCondt === false && R.isEmpty(this.state.condition)) return alert("Kondisi Jika Salah is Required.")
else if (R.isNil(this.state.startDate)) {
this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'})
this.setState({ errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong' })
}
else if (R.isNil(this.state.endDate)) {
this.setState({errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong'})
this.setState({ errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong' })
}
else {
this.addReportItems()
......@@ -162,23 +185,13 @@ export default class CreateReportItems extends Component {
"end_date": this.state.endDate
}
console.log(payload)
api.create().createReportItems(payload).then((response) => {
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
alert(response.data.message)
}
}
})
this.props.createReportItems(payload)
}
getInputType() {
api.create().getInputType().then((response) => {
console.log(response.data)
if(response.data.status === 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let inputData = data.map((item) => {
return {
......@@ -190,7 +203,7 @@ export default class CreateReportItems extends Component {
options: inputData,
getOptionLabel: (option) => titleCase(option.type_report_name),
};
this.setState({listInputType: defaultProps, inputData: response.data.data})
this.setState({ listInputType: defaultProps, inputData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -200,7 +213,7 @@ export default class CreateReportItems extends Component {
getPerusahaan() {
api.create().getPerusahaanActive().then((response) => {
// console.log(response)
if(response.data.status === 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let companyData = data.map((item) => {
return {
......@@ -212,7 +225,7 @@ export default class CreateReportItems extends Component {
options: companyData,
getOptionLabel: (option) => titleCase(option.company_name),
};
this.setState({listCompany: defaultProps, companyData: response.data.data})
this.setState({ listCompany: defaultProps, companyData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -222,7 +235,7 @@ export default class CreateReportItems extends Component {
getReportType() {
api.create().getReportType().then((response) => {
// console.log(response)
if(response.data.status === 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let reportTypeData = data.map((item) => {
return {
......@@ -234,7 +247,7 @@ export default class CreateReportItems extends Component {
options: reportTypeData,
getOptionLabel: (option) => titleCase(option.report_name),
};
this.setState({listReportType: defaultProps, reportTypeData: response.data.data})
this.setState({ listReportType: defaultProps, reportTypeData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -249,7 +262,7 @@ export default class CreateReportItems extends Component {
}
api.create().getReportParent(payload).then((response) => {
console.log(response)
if(response.data.status === 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let parentData = data.map((item) => {
return {
......@@ -261,7 +274,7 @@ export default class CreateReportItems extends Component {
options: parentData,
getOptionLabel: (option) => titleCase(option.description),
};
this.setState({listParent: defaultProps, parentData: response.data.data})
this.setState({ listParent: defaultProps, parentData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -274,6 +287,15 @@ export default class CreateReportItems extends Component {
return value
}
clearMessage() {
this.setState({
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
})
}
render() {
return (
......@@ -291,7 +313,7 @@ export default class CreateReportItems extends Component {
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -322,11 +344,11 @@ export default class CreateReportItems extends Component {
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}}>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listReportType}
id="reportType"
onChange={(event, newInputValue) => this.setState({reportType: newInputValue})}
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue })}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -348,11 +370,11 @@ export default class CreateReportItems extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}} >
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }} >
<Autocomplete
{...this.state.listCompany}
id="company"
onChange={(event, newInputValue) => this.setState({company: newInputValue}, () => this.getParent())}
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => this.getParent())}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -377,11 +399,13 @@ export default class CreateReportItems extends Component {
id="orders"
name="order"
label="Order"
type="number"
onChange={(e) => this.handleChange(e, null)}
value={this.state.order}
error={this.state.errorOrder}
helperText={this.state.msgErrorOrder}
inputProps={{
min: 0,
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
......@@ -431,11 +455,11 @@ export default class CreateReportItems extends Component {
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}} >
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }} >
<Autocomplete
{...this.state.listParent}
id="parentId"
onChange={(event, newInputValue) => this.setState({parent: newInputValue})}
onChange={(event, newInputValue) => this.setState({ parent: newInputValue })}
debug
disabled={this.state.reportType == null || this.state.company == null}
renderInput={(params) =>
......@@ -513,20 +537,45 @@ export default class CreateReportItems extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}}>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listInputType}
id="inputType"
onChange={(event, newInputValue) => this.setState({InputType: newInputValue},
() => newInputValue === null ? this.setState({disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
: newInputValue.type_report_name === 'Formula' ? this.setState({disabledFormula: false, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
: newInputValue.type_report_name === 'Validation' ? this.setState({disabledFormula: false, disabledCondt: false, disabledValue: false, formula: '', condition: '', realVal: ''})
: this.setState({disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
onChange={(event, newInputValue) => this.setState({ InputType: newInputValue },
() => newInputValue === null ? this.setState({ disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: '' })
: newInputValue.type_report_name === 'Formula' ?
this.setState({
disabledFormula: false,
disabledCondt: true,
disabledValue: true,
formula: '',
condition: '',
realVal: ''
}, () => this.clearMessage())
: newInputValue.type_report_name === 'Validation' ?
this.setState({
disabledFormula: false,
disabledCondt: false,
disabledValue: false,
formula: '',
condition: '',
realVal: ''
}, () => this.clearMessage())
: this.setState({
disabledFormula: true,
disabledCondt: true,
disabledValue: true,
formula: '',
condition: '',
realVal: ''
}, () => this.clearMessage())
)}
debug
renderInput={(params) =>
<TextField {...params}
label="Tipe Data"
error={this.state.errorTipeData}
helperText={this.state.msgErrorTipeData}
InputLabelProps={{
style: {
fontSize: 11,
......@@ -573,7 +622,7 @@ export default class CreateReportItems extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}}>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="realVal"
......@@ -601,17 +650,19 @@ export default class CreateReportItems extends Component {
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}}>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.condition}
id="isWrongCondition"
disabled={this.state.disabledCondt}
onChange={(event, newValue) => {
this.setState({condition: newValue});
this.setState({ condition: newValue }, () => this.clearMessage());
}}
options={this.state.options}
renderInput={(params) =>
<TextField {...params}
error={this.state.errorCondition}
helperText={this.state.msgErrorCondition}
label="Kondisi Jika Salah"
InputLabelProps={{
style: {
......@@ -620,7 +671,7 @@ export default class CreateReportItems extends Component {
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11,fontFamily: 'Nunito Sans, sans-serif' } }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
......@@ -656,7 +707,7 @@ export default class CreateReportItems extends Component {
}
}}
style={{padding: 0, margin: 0, width: '100%'}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
......@@ -689,7 +740,7 @@ export default class CreateReportItems extends Component {
}
}}
style={{padding: 0, margin: 0, width: '100%'}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
......@@ -725,11 +776,11 @@ export default class CreateReportItems extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<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 }}>:</Typography>
</div>
<div style={{display: 'flex'}}>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>:</Typography>
</div>
......@@ -748,7 +799,7 @@ export default class CreateReportItems extends Component {
</div>
</button>
</div>
<div className="column-2" style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'center'}}>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.validasi()}
......
import React, { Component } from 'react';
import { TextField, Typography } from '@material-ui/core';
import { TextField, Typography, withStyles, Snackbar } from '@material-ui/core';
import { DatePicker } from '@material-ui/pickers';
import format from "date-fns/format";
import Autocomplete from '@material-ui/lab/Autocomplete';
import MuiAlert from '@material-ui/lab/Alert';
import api from '../../../api';
import * as R from 'ramda'
import { titleCase } from '../../../library/Utils';
import Images from '../../../assets/Images';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class EditReportItems extends Component {
constructor(props) {
......@@ -23,7 +26,7 @@ export default class EditReportItems extends Component {
order: null,
description: '',
uom: '',
weight: null,
weight: "",
formula: '',
realVal: '',
condition: null,
......@@ -51,7 +54,10 @@ export default class EditReportItems extends Component {
disabledFormula: true,
disabledCondt: true,
disabledValue: true,
options: ['WARNING', 'STOPPER']
options: ['WARNING', 'STOPPER'],
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -160,26 +166,20 @@ export default class EditReportItems extends Component {
"end_date": this.state.tempData.end_date
}
console.log(payload)
api.create().updateReportItems(payload).then((response) => {
console.log(response);
if (response.data) {
if (response.data.status === 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
alert(response.data.message)
}
}
})
this.props.updateReportItems(payload)
}
getDetailReportItems() {
api.create().getDetailReportItems(this.props.data[1]).then((response) => {
if (response.data) {
if (response.data.status === 'success') {
this.setState({ tempData: response.data.data }, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),)
console.log(response.data.data)
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -187,6 +187,7 @@ export default class EditReportItems extends Component {
getInputType() {
api.create().getInputType().then((response) => {
// console.log(response)
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let inputData = data.map((item) => {
......@@ -203,7 +204,10 @@ export default class EditReportItems extends Component {
let index = inputData.findIndex((val) => val.type_report_id === this.state.tempData.type_report_id)
this.setState({ listInputType: defaultProps, InputType: index === -1 ? null : inputData[index] })
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -211,6 +215,7 @@ export default class EditReportItems extends Component {
getPerusahaan() {
api.create().getPerusahaanActive().then((response) => {
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let companyData = data.map((item) => {
......@@ -227,7 +232,10 @@ export default class EditReportItems extends Component {
let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id)
this.setState({ listCompany: defaultProps, company: index === -1 ? null : companyData[index] }, () => this.getParent())
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -235,6 +243,7 @@ export default class EditReportItems extends Component {
getReportType() {
api.create().getReportType().then((response) => {
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let reportTypeData = data.map((item) => {
......@@ -251,7 +260,10 @@ export default class EditReportItems extends Component {
let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id)
this.setState({ listReportType: defaultProps, reportType: index === -1 ? null : reportTypeData[index] }, () => this.getParent())
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -264,6 +276,7 @@ export default class EditReportItems extends Component {
}
api.create().getReportParent(payload).then((response) => {
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let parentData = data.map((item) => {
......@@ -279,7 +292,10 @@ export default class EditReportItems extends Component {
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent)
this.setState({ listParent: defaultProps, parent: index == -1 ? null : parentData[index] })
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -294,6 +310,10 @@ export default class EditReportItems extends Component {
})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
return (
......@@ -315,6 +335,11 @@ export default class EditReportItems extends Component {
</button>
</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 className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
......@@ -398,11 +423,13 @@ export default class EditReportItems extends Component {
id="order"
label="Order"
name="order"
type="number"
value={this.state.tempData === null ? '' : this.state.tempData.order}
error={this.state.errorOrder}
helperText={this.state.msgErrorOrder}
onChange={(e) => this.handleChange(e, '')}
inputProps={{
min: 0,
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif'
......
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