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,6 +356,7 @@ export default class UnitBisnis extends Component { ...@@ -336,6 +356,7 @@ export default class UnitBisnis extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{this.state.edit && (
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -347,6 +368,7 @@ export default class UnitBisnis extends Component { ...@@ -347,6 +368,7 @@ export default class UnitBisnis extends Component {
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
)}
</div > </div >
); );
} }
...@@ -430,6 +452,7 @@ export default class UnitBisnis extends Component { ...@@ -430,6 +452,7 @@ 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" />
{this.state.create && (
<a data-tip={'Upload'} data-for="upload"> <a data-tip={'Upload'} data-for="upload">
<button <button
style={{ style={{
...@@ -443,6 +466,7 @@ export default class UnitBisnis extends Component { ...@@ -443,6 +466,7 @@ export default class UnitBisnis extends Component {
<img src={Images.upload} /> <img src={Images.upload} />
</button> </button>
</a> </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,7 +482,8 @@ export default class UnitBisnis extends Component { ...@@ -458,7 +482,8 @@ 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 && (
<a data-tip={'Add New'} data-for="create">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -471,6 +496,7 @@ export default class UnitBisnis extends Component { ...@@ -471,6 +496,7 @@ export default class UnitBisnis extends Component {
<img src={Images.add} /> <img src={Images.add} />
</button> </button>
</a> </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() {
...@@ -64,6 +71,11 @@ export default class CreateUnitBisnis extends Component { ...@@ -64,6 +71,11 @@ export default class CreateUnitBisnis extends Component {
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