Commit 57b432d5 authored by Deni Rinaldi's avatar Deni Rinaldi

button edit

parent 72013a79
...@@ -80,6 +80,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -80,6 +80,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getMenu = () => api.get('menu/get_menu_hierarki') const getMenu = () => api.get('menu/get_menu_hierarki')
const getMenuByRole = () => api.get('menu/get_menu_hierarki_by_role') const getMenuByRole = () => api.get('menu/get_menu_hierarki_by_role')
const getMenuByUser = () => api.get('menu/get_menu') const getMenuByUser = () => api.get('menu/get_menu')
const getPermission = (body) => api.post('permission/get_permission', body)
//UNIT BISNIS //UNIT BISNIS
const getUnitBisnis = () => api.get('business_unit/get_all_business_unit') const getUnitBisnis = () => api.get('business_unit/get_all_business_unit')
...@@ -250,7 +251,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -250,7 +251,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
getMenuByUser, getMenuByUser,
getDetailUnitBisnis, getDetailUnitBisnis,
uploadFoto, uploadFoto,
getReportTypeBody getReportTypeBody,
getPermission
} }
} }
......
...@@ -744,7 +744,7 @@ export default class Parameter extends Component { ...@@ -744,7 +744,7 @@ export default class Parameter extends Component {
</button> </button>
</a> </a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<a data-tip={'Add'} data-for="create"> <a data-tip={'Add New'} data-for="create">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -796,7 +796,7 @@ export default class Parameter extends Component { ...@@ -796,7 +796,7 @@ export default class Parameter extends Component {
style={{ marginRight: 20 }} style={{ marginRight: 20 }}
> >
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <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> <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div> </div>
</button> </button>
<button <button
...@@ -805,7 +805,7 @@ export default class Parameter extends Component { ...@@ -805,7 +805,7 @@ export default class Parameter extends Component {
style={{}} style={{}}
> >
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span> <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
</div> </div>
</button> </button>
</div> </div>
......
...@@ -39,7 +39,9 @@ export default class UnitBisnis extends Component { ...@@ -39,7 +39,9 @@ export default class UnitBisnis extends Component {
popupError: false, popupError: false,
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '' messageAlert: '',
create: false,
edit: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -187,6 +189,24 @@ export default class UnitBisnis extends Component { ...@@ -187,6 +189,24 @@ export default class UnitBisnis extends Component {
componentDidMount() { componentDidMount() {
this.getData() this.getData()
this.getPermission()
}
getPermission() {
let payload = {
menu: "business unit"
}
api.create().getPermission(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
create: response.data.data.create,
edit: response.data.data.edit
})
}
}
})
} }
getData() { getData() {
...@@ -336,17 +356,19 @@ export default class UnitBisnis extends Component { ...@@ -336,17 +356,19 @@ export default class UnitBisnis extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<button {this.state.edit && (
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
}} borderColor: 'transparent',
// onClick={() => console.log(tableMeta)} }}
onClick={() => this.openPopUp(tableMeta.rowData, 'edit')} // onClick={() => console.log(tableMeta)}
> onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
<img src={Images.editCopy} /> >
</button> <img src={Images.editCopy} />
</button>
)}
</div > </div >
); );
} }
...@@ -430,19 +452,21 @@ export default class UnitBisnis extends Component { ...@@ -430,19 +452,21 @@ export default class UnitBisnis extends Component {
</button> </button>
</a> </a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload'} data-for="upload"> {this.state.create && (
<button <a data-tip={'Upload'} data-for="upload">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
margin: 5 borderColor: 'transparent',
}} margin: 5
onClick={() => this.setState({ visibleUpload: true })} }}
> onClick={() => this.setState({ visibleUpload: true })}
<img src={Images.upload} /> >
</button> <img src={Images.upload} />
</a> </button>
</a>
)}
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download"> <a data-tip={'Download'} data-for="download">
<button <button
...@@ -458,19 +482,21 @@ export default class UnitBisnis extends Component { ...@@ -458,19 +482,21 @@ export default class UnitBisnis extends Component {
</button> </button>
</a> </a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<a data-tip={'Add'} data-for="create"> {this.state.create && (
<button <a data-tip={'Add New'} data-for="create">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
margin: 5 borderColor: 'transparent',
}} margin: 5
onClick={() => this.setState({ visibleCreate: true })} }}
> onClick={() => this.setState({ visibleCreate: true })}
<img src={Images.add} /> >
</button> <img src={Images.add} />
</a> </button>
</a>
)}
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div> </div>
</div> </div>
...@@ -510,7 +536,7 @@ export default class UnitBisnis extends Component { ...@@ -510,7 +536,7 @@ export default class UnitBisnis extends Component {
style={{ marginRight: 20 }} style={{ marginRight: 20 }}
> >
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <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> <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div> </div>
</button> </button>
<button <button
...@@ -519,7 +545,7 @@ export default class UnitBisnis extends Component { ...@@ -519,7 +545,7 @@ export default class UnitBisnis extends Component {
style={{}} style={{}}
> >
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span> <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
</div> </div>
</button> </button>
</div> </div>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField, Typography } from '@material-ui/core'; import { TextField, Typography, withStyles, Snackbar } from '@material-ui/core';
import * as R from 'ramda' import * as R from 'ramda'
import { DateTimePicker, KeyboardDatePicker, DatePicker } from "@material-ui/pickers"; import { DateTimePicker, KeyboardDatePicker, DatePicker } from "@material-ui/pickers";
import format from "date-fns/format"; import format from "date-fns/format";
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import api from '../../../api'; import api from '../../../api';
import MuiAlert from '@material-ui/lab/Alert';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class CreateUnitBisnis extends Component { export default class CreateUnitBisnis extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
id: '', id: '',
status:"", status: "",
name: '', name: '',
startDate: '', startDate: '',
endDate: '', endDate: '',
...@@ -20,7 +24,10 @@ export default class CreateUnitBisnis extends Component { ...@@ -20,7 +24,10 @@ export default class CreateUnitBisnis extends Component {
errorEndDate: false, errorEndDate: false,
msgErrorName: "", msgErrorName: "",
msgErrorStartDate: "", msgErrorStartDate: "",
msgErrorEndDate: "" msgErrorEndDate: "",
alert: false,
tipeAlert: '',
messageAlert: '',
} }
} }
render() { render() {
...@@ -61,9 +68,14 @@ export default class CreateUnitBisnis extends Component { ...@@ -61,9 +68,14 @@ export default class CreateUnitBisnis extends Component {
endDate: data.end_date, endDate: data.end_date,
status: data.status, status: data.status,
created: data.created, created: data.created,
updated: data.updated === null ? "" : data.updated updated: data.updated === null ? "" : data.updated
}) })
} }
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -122,7 +134,7 @@ export default class CreateUnitBisnis extends Component { ...@@ -122,7 +134,7 @@ export default class CreateUnitBisnis extends Component {
} else if (R.isNil(this.state.startDate)) { } else if (R.isNil(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Start date is required.' }) this.setState({ errorStartDate: true, msgErrorStartDate: 'Start date is required.' })
} else if (R.isNil(this.state.endDate)) { } else if (R.isNil(this.state.endDate)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'End date is required.'}) this.setState({ errorEndDate: true, msgErrorEndDate: 'End date is required.' })
} else { } else {
let payload = { let payload = {
"business_unit_name": this.state.name, "business_unit_name": this.state.name,
...@@ -133,9 +145,18 @@ export default class CreateUnitBisnis extends Component { ...@@ -133,9 +145,18 @@ export default class CreateUnitBisnis extends Component {
} }
} }
closeAlert() {
this.setState({ alert: false })
}
renderEdit() { renderEdit() {
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show">
<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="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
...@@ -301,7 +322,7 @@ export default class CreateUnitBisnis extends Component { ...@@ -301,7 +322,7 @@ export default class CreateUnitBisnis extends Component {
onClick={() => this.props.onClickClose()} onClick={() => this.props.onClickClose()}
> >
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <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> <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div> </div>
</button> </button>
</div> </div>
...@@ -484,7 +505,7 @@ export default class CreateUnitBisnis extends Component { ...@@ -484,7 +505,7 @@ export default class CreateUnitBisnis extends Component {
onClick={() => this.props.onClickClose()} onClick={() => this.props.onClickClose()}
> >
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <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> <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div> </div>
</button> </button>
</div> </div>
......
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