Commit 1220dd40 authored by Deni Rinaldi's avatar Deni Rinaldi

preview unit bisnis

parent 43482619
...@@ -13,6 +13,7 @@ import api from "../../api"; ...@@ -13,6 +13,7 @@ import api from "../../api";
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions(); const options = ct.customOptions();
const options2 = ct.customOptions2();
export default class UnitBisnis extends Component { export default class UnitBisnis extends Component {
constructor(props) { constructor(props) {
...@@ -22,7 +23,12 @@ export default class UnitBisnis extends Component { ...@@ -22,7 +23,12 @@ export default class UnitBisnis extends Component {
visibleEdit: false, visibleEdit: false,
dataTable: [], dataTable: [],
listData: [], listData: [],
data: [] data: [],
search: "",
visibleUnitBisnis: true,
cols: null,
rows: null,
dataLoaded: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -30,16 +36,24 @@ export default class UnitBisnis extends Component { ...@@ -30,16 +36,24 @@ export default class UnitBisnis extends Component {
fileHandler = (event) => { fileHandler = (event) => {
let fileObj = event let fileObj = event
ExcelRenderer(fileObj, (err, resp) => { ExcelRenderer(fileObj, (err, resp) => {
// console.log(resp); if (err) {
// if (err) { console.log(err);
// console.log(err); }
// } else {
// else { let judul = resp.rows[0]
// this.setState({ let isi = resp.rows.slice(1)
// cols: resp.cols, // let body = isi.map((item) => {
// rows: resp.rows // return {
// }); // item
// } // ]
// })
console.log(JSON.stringify(isi));
this.setState({
dataLoaded: true,
cols: judul,
rows: isi
});
}
}); });
} }
...@@ -74,7 +88,20 @@ export default class UnitBisnis extends Component { ...@@ -74,7 +88,20 @@ export default class UnitBisnis extends Component {
visibleCreate: true visibleCreate: true
}) })
} }
}
handleInputChange = (e) => {
// Immediately update the state
this.setState({
search: e.target.value
})
// Execute the debounced onChange method
this.onChangeDebounced(e)
}
onChangeDebounced = (e) => {
// Delayed logic goes here
} }
render() { render() {
...@@ -143,55 +170,93 @@ export default class UnitBisnis extends Component { ...@@ -143,55 +170,93 @@ export default class UnitBisnis extends Component {
return ( return (
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
<div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} /> <div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} />
<div> {this.state.visibleUnitBisnis === true ?
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Master Data - Unit Bisnis</label> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5 }}> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Master Data - Unit Bisnis</label>
<img src={Images.searchBlack} style={{ marginRight: 10 }} /> <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5 }}>
<InputBase <img src={Images.searchBlack} style={{ marginRight: 10 }} />
style={{ width: '100%' }} <InputBase
placeholder="Search" style={{ width: '100%' }}
inputProps={{ 'aria-label': 'naked' }} placeholder="Search"
/> value={this.state.search}
onChange={(e) => this.handleInputChange(e)}
inputProps={{ 'aria-label': 'naked' }}
/>
</div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex' }}>
<img src={Images.template} />
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
<img src={Images.download} />
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
}}
onClick={() => this.setState({ visibleCreate: true })}
>
<img src={Images.add} />
</button>
</div>
</div> </div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex' }}> <div style={{ padding: 25 }}>
<img src={Images.template} /> <MuiThemeProvider theme={getMuiTheme()}>
<button <MUIDataTable
style={{ theme={getMuiTheme()}
backgroundColor: 'transparent', data={this.state.dataTable}
cursor: 'pointer', columns={columns}
borderColor: 'transparent' options={options}
}} />
onClick={() => this.setState({ visibleUpload: true })} </MuiThemeProvider>
>
<img src={Images.upload} /> </div>
</button> </div>
<img src={Images.download} /> :
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
</div>
<div style={{ padding: 25 }}>
{this.state.dataLoaded && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
data={this.state.rows}
columns={this.state.cols}
options={options2}
/>
</MuiThemeProvider>
)}
</div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button <button
style={{ type="button"
backgroundColor: 'transparent', onClick={() => this.setState({ visibleUnitBisnis: true })}
cursor: 'pointer', style={{ marginRight: 20}}
borderColor: 'transparent'
}}
onClick={() => this.setState({ visibleCreate: true })}
> >
<img src={Images.add} /> <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
</div>
</button> </button>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</div> </div>
</div> </div>
<div style={{ padding: 25 }}> }
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
data={this.state.dataTable}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</div>
</div>
{this.state.visibleCreate && ( {this.state.visibleCreate && (
<CreateUnitBisnis <CreateUnitBisnis
onClickClose={() => this.setState({ visibleCreate: false })} onClickClose={() => this.setState({ visibleCreate: false })}
...@@ -233,7 +298,7 @@ export default class UnitBisnis extends Component { ...@@ -233,7 +298,7 @@ export default class UnitBisnis extends Component {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) this.setState({ uploadStatus: 'idle', percentage: '0' })
}} }}
onUpload={() => this.setState({ visibleUpload: false })} onUpload={() => this.setState({ visibleUpload: false, visibleUnitBisnis: false })}
/> />
</div> </div>
</div> </div>
......
...@@ -320,6 +320,20 @@ exports.customOptions = function () { ...@@ -320,6 +320,20 @@ exports.customOptions = function () {
} }
} }
exports.customOptions2 = function () {
return {
// selectableRows: false,
selectableRows: 'none',
filterType: 'multiselect',
responsive: 'scrollMaxHeight',
rowsPerPage: 5,
rowsPerPageOptions: [5, 10, 20, 50],
print: false,
download: false,
elevation: 5,
}
}
exports.customOptionsFixedColumn = function () { exports.customOptionsFixedColumn = function () {
return { return {
// selectableRows: false, // selectableRows: false,
......
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