Commit f6c27c4e authored by faisalhamdi's avatar faisalhamdi

merge conflict

parents 3799d451 d534fd40
...@@ -42,26 +42,30 @@ export default class Parameter extends Component { ...@@ -42,26 +42,30 @@ export default class Parameter extends Component {
getAllParameter() { getAllParameter() {
api.create().getAllParameter().then(response => { api.create().getAllParameter().then(response => {
if (response.data.status === "success") { if (response.data) {
console.log(response); if (response.data.status === "success") {
let data = response.data.data console.log(response);
let listData = data.map((item, index) => { let data = response.data.data
return [ let listData = data.map((item, index) => {
item.setting_id, return [
item.setting_group, item.setting_id,
item.setting_type, item.setting_group,
item.company_name, item.setting_type,
item.description, item.company_name,
item.order, item.description,
item.value, item.order,
item.min_value, item.value,
item.max_value, item.min_value,
item.status item.max_value,
] item.status
}) ]
this.setState({ dataTable: listData, data: response.data.data }) })
this.setState({ dataTable: listData, data: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -83,6 +87,7 @@ export default class Parameter extends Component { ...@@ -83,6 +87,7 @@ export default class Parameter extends Component {
updateParameter = (payload) => { updateParameter = (payload) => {
this.setState({ visibleEdit: false }) this.setState({ visibleEdit: false })
api.create().updateParameter(payload).then(response => { api.create().updateParameter(payload).then(response => {
console.log(response);
if (response.data) { if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getAllParameter() this.getAllParameter()
...@@ -517,8 +522,7 @@ export default class Parameter extends Component { ...@@ -517,8 +522,7 @@ export default class Parameter extends Component {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response) console.log(response)
this.getAllParameter() this.getAllParameter()
this.setState({ visibleParameter: true }) this.setState({ visibleParameter: true, 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' })
} }
......
...@@ -96,7 +96,7 @@ export default class CreatePerusahaan extends Component { ...@@ -96,7 +96,7 @@ export default class CreatePerusahaan extends Component {
options: perusahaanData, options: perusahaanData,
getOptionLabel: (option) => option.company_name, getOptionLabel: (option) => option.company_name,
}; };
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? perusahaanData[0] : perusahaanData[index] }) this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index] })
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
...@@ -120,7 +120,7 @@ export default class CreatePerusahaan extends Component { ...@@ -120,7 +120,7 @@ export default class CreatePerusahaan extends Component {
options: typeData, options: typeData,
getOptionLabel: (option) => option.business_unit_name, getOptionLabel: (option) => option.business_unit_name,
}; };
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] }) this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index] })
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
...@@ -174,19 +174,21 @@ export default class CreatePerusahaan extends Component { ...@@ -174,19 +174,21 @@ export default class CreatePerusahaan extends Component {
errorSD: false, errorSD: false,
errorED: false, errorED: false,
errorJL: false, errorJL: false,
errorUB: false,
msgErrorNP: '', msgErrorNP: '',
msgErrorPC: '', msgErrorPC: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorJL: '', msgErrorJL: '',
msgErrorUB: ''
}) })
} }
validasiEdit() { validasiEdit() {
if (R.isEmpty(this.state.company)) { if (R.isEmpty(this.state.company)) {
this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' }) this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' })
// } else if (R.isEmpty(this.state.totalReport)) { } else if (R.isNil(this.state.getTypes)) {
// this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' }) this.setState({ errorUB: true, msgErrorUB: 'Unit Bisnis harus diisi' })
} else if (R.isNil(this.state.startDate)) { } else if (R.isNil(this.state.startDate)) {
this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' }) this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.endDate)) { } else if (R.isNil(this.state.endDate)) {
...@@ -196,7 +198,7 @@ export default class CreatePerusahaan extends Component { ...@@ -196,7 +198,7 @@ export default class CreatePerusahaan extends Component {
"company_id": this.state.companyID, "company_id": this.state.companyID,
"company_name": this.state.company, "company_name": this.state.company,
"business_unit_id": this.state.getTypes.business_unit_id, "business_unit_id": this.state.getTypes.business_unit_id,
"parent": this.state.getPerusahaan.company_id, "parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
// "total_report": this.state.totalReport, // "total_report": this.state.totalReport,
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate
...@@ -209,7 +211,7 @@ export default class CreatePerusahaan extends Component { ...@@ -209,7 +211,7 @@ export default class CreatePerusahaan extends Component {
validasi() { validasi() {
if (R.isEmpty(this.state.company)) { if (R.isEmpty(this.state.company)) {
this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' }) this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' })
} else if (R.isNil(this.state.types)) { } else if (R.isNil(this.state.getTypes)) {
this.setState({ errorUB: true, msgErrorUB: 'Unit Bisnis harus diisi' }) this.setState({ errorUB: true, msgErrorUB: 'Unit Bisnis harus diisi' })
} else if (R.isNil(this.state.startDate)) { } else if (R.isNil(this.state.startDate)) {
this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' }) this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' })
...@@ -217,12 +219,14 @@ export default class CreatePerusahaan extends Component { ...@@ -217,12 +219,14 @@ export default class CreatePerusahaan extends Component {
this.setState({ errorED: true, msgErrorED: 'End Date tidak boleh kosong' }) this.setState({ errorED: true, msgErrorED: 'End Date tidak boleh kosong' })
} else if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) { } else if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) {
return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai") return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai")
// } else if (R.isEmpty(this.state.totalReport)) { }
// else if (R.isEmpty(this.state.totalReport)) {
// this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' }) // this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' })
} else { // }
else {
let payload = { let payload = {
"company_name": this.state.company, "company_name": this.state.company,
"parent": this.state.getPerusahaan.company_id, "parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
"business_unit_id": this.state.getTypes.business_unit_id, "business_unit_id": this.state.getTypes.business_unit_id,
// "total_report": this.state.totalReport, // "total_report": this.state.totalReport,
"start_date": this.state.startDate, "start_date": this.state.startDate,
...@@ -282,8 +286,17 @@ export default class CreatePerusahaan extends Component { ...@@ -282,8 +286,17 @@ export default class CreatePerusahaan extends Component {
{...this.state.types} {...this.state.types}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue })} onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, ()=> this.clearError())}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Unit Bisnis" />} renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Unit Bisnis"
error={this.state.errorUB}
helperText={this.state.msgErrorUB}
/>
}
value={this.state.getTypes} value={this.state.getTypes}
/> />
</div> </div>
...@@ -510,14 +523,13 @@ export default class CreatePerusahaan extends Component { ...@@ -510,14 +523,13 @@ export default class CreatePerusahaan extends Component {
{...this.state.types} {...this.state.types}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue })} onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, ()=> this.clearError())}
renderInput={(params) => renderInput={(params) =>
<TextField <TextField
{...params} {...params}
label="Unit Bisnis" label="Unit Bisnis"
margin="normal" margin="normal"
style={{marginTop: 7}} style={{marginTop: 7}}
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorUB} error={this.state.errorUB}
helperText={this.state.msgErrorUB} helperText={this.state.msgErrorUB}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
......
...@@ -138,7 +138,7 @@ export default class EditPerusahaan extends Component { ...@@ -138,7 +138,7 @@ export default class EditPerusahaan extends Component {
"company_id": this.state.companyID, "company_id": this.state.companyID,
"company_name": this.state.company, "company_name": this.state.company,
"business_unit_id": this.state.getTypes.business_unit_id, "business_unit_id": this.state.getTypes.business_unit_id,
"parent": this.state.getPerusahaan.company_id, "parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
"total_report": this.state.totalReport, "total_report": this.state.totalReport,
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate
......
...@@ -446,7 +446,7 @@ export default class Perusahaan extends Component { ...@@ -446,7 +446,7 @@ export default class Perusahaan extends Component {
{this.state.visiblePerusahaan === true ? {this.state.visiblePerusahaan === 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 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%' }}>Master Data - Perusahaan</label> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Perusahaan</label>
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}> <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} /> <img src={Images.searchBlack} style={{ marginRight: 10 }} />
<InputBase <InputBase
...@@ -457,62 +457,77 @@ export default class Perusahaan extends Component { ...@@ -457,62 +457,77 @@ export default class Perusahaan extends Component {
inputProps={{ 'aria-label': 'naked' }} inputProps={{ 'aria-label': 'naked' }}
/> />
</div> </div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex', flexFlow: 'wrap' }}> <div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<button <a data-tip={'Download Template'} data-for="template">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
margin: 5 borderColor: 'transparent',
}} margin: 5
onClick={() => this.downloadFile()} }}
> onClick={() => this.downloadFile()}
<img src={Images.template} /> >
</button> <img src={Images.template} />
<button </button>
style={{ </a>
backgroundColor: 'transparent', <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
cursor: 'pointer', <a data-tip={'Upload'} data-for="upload">
borderColor: 'transparent', <button
margin: 5 style={{
}} backgroundColor: 'transparent',
onClick={() => this.setState({ visibleUpload: true })} cursor: 'pointer',
> borderColor: 'transparent',
<img src={Images.upload} /> margin: 5
</button> }}
<button onClick={() => this.setState({ visibleUpload: true })}
style={{ >
backgroundColor: 'transparent', <img src={Images.upload} />
cursor: 'pointer', </button>
borderColor: 'transparent', </a>
margin: 5 <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
}} <a data-tip={'Download'} data-for="download">
onClick={() => this.downloadDataTable()} <button
> style={{
<img src={Images.download} /> backgroundColor: 'transparent',
</button> cursor: 'pointer',
<button borderColor: 'transparent',
style={{ margin: 5
backgroundColor: 'transparent', }}
cursor: 'pointer', onClick={() => this.downloadDataTable()}
borderColor: 'transparent', >
margin: 5 <img src={Images.download} />
}} </button>
onClick={() => null} </a>
> <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<img src={Images.visualisasi} onClick={() => this.setState({ visibleVisual: true, visiblePerusahaan: false })} /> <a data-tip={'Visualisasi'} data-for="visual">
</button> <button
<button style={{
style={{ backgroundColor: 'transparent',
backgroundColor: 'transparent', cursor: 'pointer',
cursor: 'pointer', borderColor: 'transparent',
borderColor: 'transparent', margin: 5
margin: 5 }}
}} onClick={() => null}
onClick={() => this.setState({ visibleCreate: true })} >
> <img src={Images.visualisasi} onClick={() => this.setState({ visibleVisual: true, visiblePerusahaan: false })} />
<img src={Images.add} /> </button>
</button> </a>
<ReactTooltip border={true} id="visual" place="bottom" type="light" effect="solid" />
<a data-tip={'Tambah'} data-for="create">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleCreate: true })}
>
<img src={Images.add} />
</button>
</a>
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div> </div>
</div> </div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
...@@ -626,7 +641,7 @@ export default class Perusahaan extends Component { ...@@ -626,7 +641,7 @@ export default class Perusahaan extends Component {
type={this.state.uploadStatus} type={this.state.uploadStatus}
percentage={this.state.percentage} percentage={this.state.percentage}
result={this.state.result} result={this.state.result}
acceptedFiles={["pdf"]} acceptedFiles={["xsls"]}
onHandle={(dt) => { onHandle={(dt) => {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) this.setState({ uploadStatus: 'idle', percentage: '0' })
......
import React, { Component } from "react"; 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 Images from "../../assets/Images";
import MUIDataTable from "mui-datatables"; 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 { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import MuiAlert from '@material-ui/lab/Alert';
import CreateReportItems from "./formReportItems/CreateReportItems"; import CreateReportItems from "./formReportItems/CreateReportItems";
import EditReportItems from "./formReportItems/EditReportItems"; import EditReportItems from "./formReportItems/EditReportItems";
import VisualReportItems from "./formReportItems/VisualReportItems"; import VisualReportItems from "./formReportItems/VisualReportItems";
...@@ -17,6 +18,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable()); ...@@ -17,6 +18,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 ReportItems extends Component { export default class ReportItems extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -32,7 +36,10 @@ export default class ReportItems extends Component { ...@@ -32,7 +36,10 @@ export default class ReportItems extends Component {
dataLoaded: false, dataLoaded: false,
cols: null, cols: null,
rows: null, rows: null,
popupError: false popupError: false,
alert: false,
tipeAlert: '',
messageAlert: ''
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -450,14 +457,18 @@ export default class ReportItems extends Component { ...@@ -450,14 +457,18 @@ export default class ReportItems extends Component {
getData() { getData() {
api.create().getReportItems().then((response) => { api.create().getReportItems().then((response) => {
console.log(response) console.log(response)
if (response.data.status == 'success') { if (response.data) {
let data = response.data.data if (response.data.status == 'success') {
let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => { let data = response.data.data
return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status] let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => {
}) return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status]
this.setState({ dataTable: listData, listData: response.data.data }) })
this.setState({ dataTable: listData, listData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -482,14 +493,18 @@ export default class ReportItems extends Component { ...@@ -482,14 +493,18 @@ export default class ReportItems extends Component {
} }
api.create().searchReportItems(body).then(response => { api.create().searchReportItems(body).then(response => {
// console.log(response.data); // console.log(response.data);
if (response.data.status == 'success') { if (response.data) {
let data = response.data.data if (response.data.status == 'success') {
let listData = data.map((item, index) => { let data = response.data.data
return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status] let listData = data.map((item, index) => {
}) return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status]
this.setState({ dataTable: listData, listData: response.data.data }) })
this.setState({ dataTable: listData, listData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -497,10 +512,15 @@ export default class ReportItems extends Component { ...@@ -497,10 +512,15 @@ export default class ReportItems extends Component {
createReportItems = (payload) => { createReportItems = (payload) => {
this.setState({ add: false }) this.setState({ add: false })
api.create().createReportItems(payload).then(response => { api.create().createReportItems(payload).then(response => {
if (response.data.status == 'success') { if (response.data) {
this.getData() if (response.data.status == 'success') {
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -538,10 +558,15 @@ export default class ReportItems extends Component { ...@@ -538,10 +558,15 @@ export default class ReportItems extends Component {
updateReportItems = (payload) => { updateReportItems = (payload) => {
this.setState({ edit: false }) this.setState({ edit: false })
api.create().updateReportItems(payload).then(response => { api.create().updateReportItems(payload).then(response => {
if (response.data.status == 'success') { if (response.data) {
this.getData() if (response.data.status == 'success') {
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -550,15 +575,22 @@ export default class ReportItems extends Component { ...@@ -550,15 +575,22 @@ export default class ReportItems extends Component {
api.create().uploadReportItems(this.state.payload).then(response => { api.create().uploadReportItems(this.state.payload).then(response => {
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response)
alert(response.data.message) alert(response.data.message)
this.getData() 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() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -716,10 +748,15 @@ export default class ReportItems extends Component { ...@@ -716,10 +748,15 @@ export default class ReportItems extends Component {
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
<div className={"main-color"} style={{ height: 199, width: '100%' }} /> <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 ? {this.state.itemReport === 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 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Item Report</label> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Item Laporan</label>
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}> <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} /> <img src={Images.searchBlack} style={{ marginRight: 10 }} />
<InputBase <InputBase
......
...@@ -134,6 +134,21 @@ export default class AddUser extends Component { ...@@ -134,6 +134,21 @@ export default class AddUser extends Component {
} }
} }
clearError() {
this.setState({
errorFullname: false,
errorEmail: false,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorFN: '',
msgErrorEM: '',
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
}
isEmail(email) { isEmail(email) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase()); return re.test(String(email).toLowerCase());
...@@ -272,47 +287,51 @@ export default class AddUser extends Component { ...@@ -272,47 +287,51 @@ export default class AddUser extends Component {
padding = 20 padding = 20
} }
return ( return (
<ul> <div>
{item.children.map((data, index) => { {item.children.length > 0 && (
return ( <ul>
// <li> {item.children.map((data, index) => {
<Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}> return (
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}> // <li>
{R.isNil(data.children) ? <Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}>
null <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}>
: {R.isNil(data.children) ?
data.children.length < 1 ? null
null :
: data.children.length < 1 ?
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}> null
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />} :
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>
}
<span>
{this.state.role ? this.state.role.role_id === 1 ?
<CustomCheckboxDisabled
disabled={true}
checked={true}
// onChange={() => this.handleItemClick(item)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/>
}
</span> </span>
} <Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
<span> </div>
{this.state.role ? this.state.role.role_id === 1 ? {!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
<CustomCheckboxDisabled </Collapse>
disabled={true} // </li>
checked={true} )
// onChange={() => this.handleItemClick(item)} })}
/> : </ul>
<CustomCheckbox )}
checked={this.handleItemChecked(data)} </div>
onChange={() => this.handleItemClick(data)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/>
}
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse>
// </li>
)
})}
</ul>
) )
} }
...@@ -498,7 +517,7 @@ export default class AddUser extends Component { ...@@ -498,7 +517,7 @@ export default class AddUser extends Component {
<Autocomplete <Autocomplete
{...this.state.listRole} {...this.state.listRole}
id="role" id="role"
onChange={(event, newInputValue) => this.setState({ role: newInputValue })} onChange={(event, newInputValue) => this.setState({ role: newInputValue }, ()=> this.clearError())}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField <TextField
...@@ -662,8 +681,8 @@ export default class AddUser extends Component { ...@@ -662,8 +681,8 @@ export default class AddUser extends Component {
</div> </div>
</div> </div>
<div style={{ flexDirection: 'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}> <div style={{ flexDirection: 'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{ fontSize: 12 }}>{`Dibuat : ${format(this.state.date, 'dd MMMM yyyy', { locale: localeID })}`}</Typography> <Typography style={{ fontSize: 12 }}>{`Dibuat: `}</Typography>
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData === null? '' : this.state.tempData.updated}`}</Typography> */} <Typography style={{fontSize: 12}}>{`Diubah: `}</Typography>
</div> </div>
<Divider style={{ margin: 20 }} /> <Divider style={{ margin: 20 }} />
<div style={{ paddingLeft: 20, paddingRight: 20 }}> <div style={{ paddingLeft: 20, paddingRight: 20 }}>
......
...@@ -121,6 +121,21 @@ export default class EditUser extends Component { ...@@ -121,6 +121,21 @@ export default class EditUser extends Component {
} }
} }
clearError() {
this.setState({
errorFullname: false,
errorEmail: false,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorFN: '',
msgErrorEM: '',
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
}
getDetailUser() { getDetailUser() {
api.create().getDetailUser(this.state.paramsId).then((response) => { api.create().getDetailUser(this.state.paramsId).then((response) => {
this.getRole() this.getRole()
...@@ -274,47 +289,51 @@ export default class EditUser extends Component { ...@@ -274,47 +289,51 @@ export default class EditUser extends Component {
padding = 20 padding = 20
} }
return ( return (
<ul> <div>
{item.children.map((data, index) => { {item.children.length > 0 && (
return ( <ul>
// <li> {item.children.map((data, index) => {
<Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}> return (
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}> // <li>
{R.isNil(data.children) ? <Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}>
null <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}>
: {R.isNil(data.children) ?
data.children.length < 1 ? null
null :
: data.children.length < 1 ?
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}> null
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />} :
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>
}
<span>
{this.state.role ? this.state.role.role_id === 1 ?
<CustomCheckboxDisabled
disabled={true}
checked={true}
// onChange={() => this.handleItemClick(item)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/>
}
</span> </span>
} <Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
<span> </div>
{this.state.role ? this.state.role.role_id === 1 ? {!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
<CustomCheckboxDisabled </Collapse>
disabled={true} // </li>
checked={true} )
// onChange={() => this.handleItemClick(item)} })}
/> : </ul>
<CustomCheckbox )}
checked={this.handleItemChecked(data)} </div>
onChange={() => this.handleItemClick(data)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/>
}
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse>
// </li>
)
})}
</ul>
) )
} }
...@@ -497,7 +516,7 @@ export default class EditUser extends Component { ...@@ -497,7 +516,7 @@ export default class EditUser extends Component {
<Autocomplete <Autocomplete
{...this.state.listRole} {...this.state.listRole}
id="role" id="role"
onChange={(event, newInputValue) => this.setState({ role: newInputValue })} onChange={(event, newInputValue) => this.setState({ role: newInputValue }, ()=> this.clearError())}
debug debug
renderInput={(params) => <TextField renderInput={(params) => <TextField
......
...@@ -116,7 +116,7 @@ export default class AddRole extends Component { ...@@ -116,7 +116,7 @@ export default class AddRole extends Component {
} else if (R.isNil(this.state.endDate)) { } 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 if (this.state.privileges.length < 1) { } else if (this.state.privileges.length < 1) {
alert('Hak Akses belum di pilih !!') this.setState({ alert: true, messageAlert: 'Hak Akses belum di pilih !!', tipeAlert: 'warning' })
} else { } else {
this.addRole() this.addRole()
} }
...@@ -468,8 +468,8 @@ export default class AddRole extends Component { ...@@ -468,8 +468,8 @@ export default class AddRole extends Component {
</div> </div>
</div> </div>
<div style={{ flexDirection: 'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}> <div style={{ flexDirection: 'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{ fontSize: 12 }}>{`Dibuat : ${format(this.state.date, 'dd MMMM yyyy', { locale: localeID })}`}</Typography> <Typography style={{ fontSize: 12 }}>{`Dibuat: `}</Typography>
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData === null? '' : this.state.tempData.updated}`}</Typography> */} <Typography style={{fontSize: 12}}>{`Diubah: `}</Typography>
</div> </div>
<Divider style={{ margin: 20 }} /> <Divider style={{ margin: 20 }} />
<div style={{ paddingLeft: 20, paddingRight: 20 }}> <div style={{ paddingLeft: 20, paddingRight: 20 }}>
......
...@@ -122,7 +122,7 @@ export default class EditRole extends Component { ...@@ -122,7 +122,7 @@ export default class EditRole extends Component {
} else if (R.isNil(this.state.tempData.end_date)) { } else if (R.isNil(this.state.tempData.end_date)) {
this.setState({ errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong' }) this.setState({ errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong' })
} else if (this.state.privileges.length < 1) { } else if (this.state.privileges.length < 1) {
alert('Hak Akses belum di pilih !!') this.setState({ alert: true, messageAlert: 'Hak Akses belum di pilih !!', tipeAlert: 'warning' })
} else { } else {
this.updateRole() this.updateRole()
} }
......
This diff is collapsed.
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