Commit 70b55e0b authored by Deni Rinaldi's avatar Deni Rinaldi

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

upload parameter

See merge request !100
parents 39b359a0 784f249d
...@@ -128,9 +128,11 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -128,9 +128,11 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getParameterByGroup = (groupID) => api.get(`/setting_type/get_all_setting_type_by_group/${groupID}`) const getParameterByGroup = (groupID) => api.get(`/setting_type/get_all_setting_type_by_group/${groupID}`)
const createParameter = (body) => api.post('setting/create_setting', body) const createParameter = (body) => api.post('setting/create_setting', body)
const updateParameter = (body) => api.post('setting/update_setting', body) const updateParameter = (body) => api.post('setting/update_setting', body)
const checkUploadParameter = (body) => api.post('setting/check_import', body)
const uploadParameter = (body) => api.post('/setting/import_setting', body)
//Template //Template
const downloadTemplate = (fileName,fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`) const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
// ------ // ------
// STEP 3 // STEP 3
// ------ // ------
...@@ -196,7 +198,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -196,7 +198,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
updateParameter, updateParameter,
createParameter, createParameter,
getPerusahaanActive, getPerusahaanActive,
getRoleActive getRoleActive,
checkUploadParameter,
uploadParameter
} }
} }
......
...@@ -104,7 +104,7 @@ export default class Parameter extends Component { ...@@ -104,7 +104,7 @@ export default class Parameter extends Component {
let url = window.URL.createObjectURL(res); let url = window.URL.createObjectURL(res);
let a = document.createElement('a'); let a = document.createElement('a');
a.href = url; a.href = url;
a.download = 'Template Parameter Unit.xlsx'; a.download = 'Template Parameter.xlsx';
a.click(); a.click();
} }
} }
...@@ -119,7 +119,7 @@ export default class Parameter extends Component { ...@@ -119,7 +119,7 @@ export default class Parameter extends Component {
let url = window.URL.createObjectURL(res); let url = window.URL.createObjectURL(res);
let a = document.createElement('a'); let a = document.createElement('a');
a.href = url; a.href = url;
a.download = 'Parameter Unit.xlsx'; a.download = 'Parameter.xlsx';
a.click(); a.click();
} }
} }
...@@ -141,9 +141,9 @@ export default class Parameter extends Component { ...@@ -141,9 +141,9 @@ export default class Parameter extends Component {
id: index + 1, id: index + 1,
group: item[0], group: item[0],
parameter: item[1], parameter: item[1],
perusahaan: item[2], company: item[2],
description: item[3], description: item[3],
order: item[4], orders: item[4],
value: item[5], value: item[5],
min_value: item[6], min_value: item[6],
max_value: item[7], max_value: item[7],
...@@ -153,24 +153,27 @@ export default class Parameter extends Component { ...@@ -153,24 +153,27 @@ export default class Parameter extends Component {
} }
}) })
let body = { let body = {
business_unit: payload setting: payload
} }
this.setState({ payload: body }) this.setState({ payload: body })
api.create().checkUploadUnitBisnis(body).then(response => { api.create().checkUploadParameter(body).then(response => {
console.log(response);
if (response.data !== null) {
if (response.data.status === "success") { if (response.data.status === "success") {
let dataRow = response.data.data.map((item, index) => { let dataRow = response.data.data.map((item, index) => {
return [ return [
index + 1, index + 1,
item.group, item.group,
item.paramter, item.parameter,
item.perusahaan, item.company,
item.description, item.description,
item.order, item.orders,
item.value, item.value,
item.min_value, item.min_value,
item.max_value, item.max_value,
item.start_date, item.start_date,
item.end_date, item.end_date,
item.error,
] ]
}) })
let columns = [ let columns = [
...@@ -180,21 +183,21 @@ export default class Parameter extends Component { ...@@ -180,21 +183,21 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('business_unit_name')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('group'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="unitbisnis"> <a data-tip={tableMeta.rowData[11][check].message} data-for="group">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
} }
<ReactTooltip border={true} id="unitbisnis" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="group" place="bottom" type="light" effect="solid" />
</div > </div >
); );
} }
...@@ -205,21 +208,21 @@ export default class Parameter extends Component { ...@@ -205,21 +208,21 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('start_date')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('parameter'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="startdate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="parameter">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
} }
<ReactTooltip border={true} id="startdate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="parameter" place="bottom" type="light" effect="solid" />
</div > </div >
); );
} }
...@@ -230,21 +233,21 @@ export default class Parameter extends Component { ...@@ -230,21 +233,21 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('company'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="company">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
} }
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="company" place="bottom" type="light" effect="solid" />
</div > </div >
); );
} }
...@@ -255,21 +258,21 @@ export default class Parameter extends Component { ...@@ -255,21 +258,21 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('description'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="description">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
} }
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="description" place="bottom" type="light" effect="solid" />
</div > </div >
); );
} }
...@@ -280,21 +283,21 @@ export default class Parameter extends Component { ...@@ -280,21 +283,21 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('order'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="order">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
} }
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="order" place="bottom" type="light" effect="solid" />
</div > </div >
); );
} }
...@@ -305,21 +308,21 @@ export default class Parameter extends Component { ...@@ -305,21 +308,21 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('value'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="value">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
} }
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="value" place="bottom" type="light" effect="solid" />
</div > </div >
); );
} }
...@@ -330,21 +333,21 @@ export default class Parameter extends Component { ...@@ -330,21 +333,21 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('min_value'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="min_value">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
} }
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="min_value" place="bottom" type="light" effect="solid" />
</div > </div >
); );
} }
...@@ -355,21 +358,21 @@ export default class Parameter extends Component { ...@@ -355,21 +358,21 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('max_value'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="max_value">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
} }
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="max_value" place="bottom" type="light" effect="solid" />
</div > </div >
); );
} }
...@@ -380,21 +383,21 @@ export default class Parameter extends Component { ...@@ -380,21 +383,21 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('start_date'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="start_date">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
} }
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="start_date" place="bottom" type="light" effect="solid" />
</div > </div >
); );
} }
...@@ -405,16 +408,16 @@ export default class Parameter extends Component { ...@@ -405,16 +408,16 @@ export default class Parameter extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
let check = null let check = null
if (tableMeta.rowData[4] != null) { if (tableMeta.rowData[11] != null) {
check = tableMeta.rowData[4].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[11].findIndex((val) => val.field.includes('end_date'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
} }
} }
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[4] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[4][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="enddate">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
...@@ -439,10 +442,20 @@ export default class Parameter extends Component { ...@@ -439,10 +442,20 @@ export default class Parameter extends Component {
cols: columns, cols: columns,
rows: dataRow rows: dataRow
}); });
} else {
this.setState({
dataLoaded: true,
cols: [],
rows: []
});
}
} else {
this.setState({
dataLoaded: true,
cols: [],
rows: []
});
} }
console.log(response);
}) })
...@@ -450,6 +463,14 @@ export default class Parameter extends Component { ...@@ -450,6 +463,14 @@ export default class Parameter extends Component {
}); });
} }
uploadParameter() {
api.create().uploadParameter(this.state.payload).then(response => {
console.log(response)
this.getAllParameter()
this.setState({ visibleParameter: true })
})
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -658,7 +679,7 @@ export default class Parameter extends Component { ...@@ -658,7 +679,7 @@ export default class Parameter extends Component {
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
</div> </div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
{/* {this.state.dataLoaded && ( {this.state.dataLoaded && (
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
theme={getMuiTheme()} theme={getMuiTheme()}
...@@ -667,7 +688,7 @@ export default class Parameter extends Component { ...@@ -667,7 +688,7 @@ export default class Parameter extends Component {
options={options2} options={options2}
/> />
</MuiThemeProvider> </MuiThemeProvider>
)} */} )}
</div> </div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}> <div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button <button
...@@ -707,7 +728,7 @@ export default class Parameter extends Component { ...@@ -707,7 +728,7 @@ export default class Parameter extends Component {
/> />
)} )}
{this.state.popupError && ( {this.state.popupError && (
<PopUpFailedSave onClickClose={()=> this.setState({ popupError: false })} /> <PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
)} )}
{this.state.visibleUpload && ( {this.state.visibleUpload && (
<div className="test app-popup-show"> <div className="test app-popup-show">
......
...@@ -261,7 +261,7 @@ export default class CreateUnitBisnis extends Component { ...@@ -261,7 +261,7 @@ export default class CreateUnitBisnis extends Component {
return ( return (
<div className="test app-popup-show" style={{ paddingTop: 100 }}> <div className="test app-popup-show" style={{ paddingTop: 100 }}>
<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" style={{ backgroundColor: '#51c6ea', 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' }}>
<div className="popup-title"> <div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Create Data</span> <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Create Data</span>
......
...@@ -17,7 +17,7 @@ const CustomCheckbox = withStyles({ ...@@ -17,7 +17,7 @@ const CustomCheckbox = withStyles({
}, },
}, },
checked: {}, checked: {},
})((props) => <Checkbox color="default" {...props} />); })((props) => <Checkbox color="default" {...props} />);
export default class EditUser extends Component { export default class EditUser extends Component {
...@@ -47,7 +47,7 @@ export default class EditUser extends Component { ...@@ -47,7 +47,7 @@ export default class EditUser extends Component {
} }
handleChecked() { handleChecked() {
this.setState({checked: !this.state.checked}) this.setState({ checked: !this.state.checked })
} }
componentDidMount() { componentDidMount() {
...@@ -59,7 +59,8 @@ export default class EditUser extends Component { ...@@ -59,7 +59,8 @@ export default class EditUser extends Component {
let data = this.state let data = this.state
let isDate = type !== '' ? true : false let isDate = type !== '' ? true : false
if (isDate && type === 'start_date') { if (isDate && type === 'start_date') {
this.setState({ ...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null }, this.setState({
...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null },
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
errorRoleName: false, errorRoleName: false,
...@@ -72,7 +73,8 @@ export default class EditUser extends Component { ...@@ -72,7 +73,8 @@ export default class EditUser extends Component {
msgErrorED: '', msgErrorED: '',
}) })
} else if (isDate && type === 'end_date') { } else if (isDate && type === 'end_date') {
this.setState({ ...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') }, this.setState({
...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
errorRoleName: false, errorRoleName: false,
...@@ -85,7 +87,8 @@ export default class EditUser extends Component { ...@@ -85,7 +87,8 @@ export default class EditUser extends Component {
msgErrorED: '', msgErrorED: '',
}) })
} else { } else {
this.setState({ ...data, tempData: { ...this.state.tempData, [e.target.name]: e.target.value }, this.setState({
...data, tempData: { ...this.state.tempData, [e.target.name]: e.target.value },
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
errorRoleName: false, errorRoleName: false,
...@@ -104,7 +107,7 @@ export default class EditUser extends Component { ...@@ -104,7 +107,7 @@ export default class EditUser extends Component {
api.create().getDetailUser(this.state.paramsId).then((response) => { api.create().getDetailUser(this.state.paramsId).then((response) => {
this.getRole() this.getRole()
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({tempData: response.data.data, company: response.data.data.company}) this.setState({ tempData: response.data.data, company: response.data.data.company })
console.log(response.data.data) console.log(response.data.data)
} else { } else {
alert(response.data.message) alert(response.data.message)
...@@ -114,15 +117,15 @@ export default class EditUser extends Component { ...@@ -114,15 +117,15 @@ export default class EditUser extends Component {
validasi() { validasi() {
if (R.isEmpty(this.state.tempData.fullname)) { if (R.isEmpty(this.state.tempData.fullname)) {
this.setState({errorFullname: true, msgErrorFN: 'Nama Lengkap tidak boleh kosong'}) this.setState({ errorFullname: true, msgErrorFN: 'Nama Lengkap tidak boleh kosong' })
} else if (R.isEmpty(this.state.tempData.email)) { } else if (R.isEmpty(this.state.tempData.email)) {
this.setState({errorEmail: true, msgErrorEM: 'Email tidak boleh kosong'}) this.setState({ errorEmail: true, msgErrorEM: 'Email tidak boleh kosong' })
} else if (R.isEmpty(this.state.tempData.role_name)) { } else if (R.isEmpty(this.state.tempData.role_name)) {
this.setState({errorRoleName: true, msgErrorRN: 'Role Name tidak boleh kosong'}) this.setState({ errorRoleName: true, msgErrorRN: 'Role Name tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.start_date)) { } else if (R.isNil(this.state.tempData.start_date)) {
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.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 !!') // alert('Hak Akses belum di pilih !!')
...@@ -155,7 +158,7 @@ export default class EditUser extends Component { ...@@ -155,7 +158,7 @@ export default class EditUser extends Component {
getRole() { getRole() {
api.create().getRoleActive().then((response) => { api.create().getRoleActive().then((response) => {
if(response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let roleData = data.map((item) => { let roleData = data.map((item) => {
return { return {
...@@ -169,7 +172,7 @@ export default class EditUser extends Component { ...@@ -169,7 +172,7 @@ export default class EditUser extends Component {
}; };
let index = roleData.findIndex((val) => val.role_id === this.state.tempData.role_id) let index = roleData.findIndex((val) => val.role_id === this.state.tempData.role_id)
this.setState({listRole: defaultProps, role: index === -1? roleData[0] : roleData[index]}) this.setState({ listRole: defaultProps, role: index === -1 ? roleData[0] : roleData[index] })
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
...@@ -178,8 +181,8 @@ export default class EditUser extends Component { ...@@ -178,8 +181,8 @@ export default class EditUser extends Component {
getPerusahaan() { getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => { api.create().getPerusahaanHierarki().then((response) => {
if(response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({listCompany: response.data.data}) this.setState({ listCompany: response.data.data })
console.log(response.data.data) console.log(response.data.data)
} }
}) })
...@@ -201,15 +204,22 @@ export default class EditUser extends Component { ...@@ -201,15 +204,22 @@ export default class EditUser extends Component {
this.setState({ company }) this.setState({ company })
} }
renderChildren = (item) => { renderChildren = (item, pad) => {
let padding = null
if (pad !== undefined) {
padding = pad
} else {
padding = 20
}
return ( return (
<ul> <ul>
{item.child.map((data, index) => { {item.child.map((data, index) => {
return ( return (
<li> <li>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}> {/* <Collapse timeout="auto" unmountOnExit in={data.company_id === this.state.selectedIndex}> */}
{!R.isNil(data.child) && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}> <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.child) ? (padding + 20) : padding }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />} {!R.isNil(data.child) && <span onClick={() => this.setState({ selectedIndex: data.company_id === this.state.selectedIndex ? 0 : data.company_id })} style={{ marginLeft: 7, marginRight: 2 }}>
{data.company_id === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>} </span>}
<span> <span>
<CustomCheckbox <CustomCheckbox
...@@ -219,7 +229,8 @@ export default class EditUser extends Component { ...@@ -219,7 +229,8 @@ export default class EditUser extends Component {
</span> </span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography> <Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div> </div>
{!R.isNil(data.child) && this.renderChildren(data)} {!R.isNil(data.child) && this.renderChildren(data, padding + 20)}
{/* </Collapse> */}
</li> </li>
) )
})} })}
...@@ -227,12 +238,12 @@ export default class EditUser extends Component { ...@@ -227,12 +238,12 @@ export default class EditUser extends Component {
) )
} }
renderChild(item,index){ renderChild(item, index) {
return ( return (
item.child.map((items,indexs, paddingLeft) => { item.child.map((items, indexs, paddingLeft) => {
return ( return (
<div> <div>
<div style={{ paddingLeft: R.isNil(items.child)? 120 : 60, display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}> <div style={{ paddingLeft: R.isNil(items.child) ? 120 : 60, display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{/* {item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}> {/* {item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />} {index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>} */} </span>} */}
...@@ -245,7 +256,7 @@ export default class EditUser extends Component { ...@@ -245,7 +256,7 @@ export default class EditUser extends Component {
</span> </span>
<Typography style={{ fontSize: 12 }}>{titleCase(items.company_name)}</Typography> <Typography style={{ fontSize: 12 }}>{titleCase(items.company_name)}</Typography>
</div> </div>
{!R.isNil(items.child) && this.renderChild(items,indexs)} {!R.isNil(items.child) && this.renderChild(items, indexs)}
</div> </div>
) )
}) })
...@@ -282,7 +293,7 @@ export default class EditUser extends Component { ...@@ -282,7 +293,7 @@ export default class EditUser extends Component {
disabled disabled
// id="outlined-read-only-input" // id="outlined-read-only-input"
variant="filled" variant="filled"
value={this.state.tempData === null? '' : this.state.tempData.user_id} value={this.state.tempData === null ? '' : this.state.tempData.user_id}
onChange={(e) => null} onChange={(e) => null}
> >
{/* {periode.map((option) => ( {/* {periode.map((option) => (
...@@ -297,11 +308,11 @@ export default class EditUser extends Component { ...@@ -297,11 +308,11 @@ export default class EditUser extends Component {
<div className="column-2"> <div className="column-2">
<div className=""> <div className="">
<TextField <TextField
style={{ width: '100%' , marginTop: 7}} style={{ width: '100%', marginTop: 7 }}
id="fullname" id="fullname"
name="fullname" name="fullname"
label="Nama Lengkap" label="Nama Lengkap"
value={this.state.tempData === null? '' : this.state.tempData.fullname} value={this.state.tempData === null ? '' : this.state.tempData.fullname}
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value" // defaultValue="Default Value"
error={this.state.errorFullname} error={this.state.errorFullname}
...@@ -315,11 +326,11 @@ export default class EditUser extends Component { ...@@ -315,11 +326,11 @@ export default class EditUser extends Component {
<div className="column-1"> <div className="column-1">
<div className="margin-bottom-20px"> <div className="margin-bottom-20px">
<TextField <TextField
style={{ width: '100%' , marginTop: 7}} style={{ width: '100%', marginTop: 7 }}
id="email" id="email"
name="email" name="email"
label="Email" label="Email"
value={this.state.tempData === null? '' : this.state.tempData.email} value={this.state.tempData === null ? '' : this.state.tempData.email}
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
error={this.state.errorEmail} error={this.state.errorEmail}
helperText={this.state.msgErrorEM} helperText={this.state.msgErrorEM}
...@@ -332,10 +343,10 @@ export default class EditUser extends Component { ...@@ -332,10 +343,10 @@ 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 })}
debug debug
renderInput={(params) => <TextField {...params} label="Role" margin="normal" style={{marginTop: 7}}/>} renderInput={(params) => <TextField {...params} label="Role" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.role} value={this.state.role}
/> />
</div> </div>
...@@ -394,7 +405,7 @@ export default class EditUser extends Component { ...@@ -394,7 +405,7 @@ export default class EditUser extends Component {
disabled disabled
// id="outlined-read-only-input" // id="outlined-read-only-input"
variant="filled" variant="filled"
value={this.state.tempData === null? '' : this.state.tempData.status} value={this.state.tempData === null ? '' : this.state.tempData.status}
> >
{/* {periode.map((option) => ( {/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}> <MenuItem key={option.value} value={option.value}>
...@@ -415,7 +426,7 @@ export default class EditUser extends Component { ...@@ -415,7 +426,7 @@ export default class EditUser extends Component {
disabled disabled
// id="outlined-read-only-input" // id="outlined-read-only-input"
variant="filled" variant="filled"
value={this.state.tempData === null? '' : this.state.tempData.is_expired} value={this.state.tempData === null ? '' : this.state.tempData.is_expired}
> >
{/* {periode.map((option) => ( {/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}> <MenuItem key={option.value} value={option.value}>
...@@ -426,16 +437,16 @@ export default class EditUser extends Component { ...@@ -426,16 +437,16 @@ export default class EditUser extends Component {
</div> </div>
</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 : ${this.state.tempData === null? '' : this.state.tempData.created}`}</Typography> <Typography style={{ fontSize: 12 }}>{`Dibuat : ${this.state.tempData === null ? '' : this.state.tempData.created}`}</Typography>
<Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData === null? '' : this.state.tempData.updated}`}</Typography> <Typography style={{ fontSize: 12 }}>{`Diubah: ${this.state.tempData === null ? '' : this.state.tempData.updated}`}</Typography>
</div> </div>
<Divider style={{margin: 20}}/> <Divider style={{ margin: 20 }} />
<div style={{paddingLeft: 20, paddingRight: 20}}> <div style={{ paddingLeft: 20, paddingRight: 20 }}>
<h5>Otorisasi Perusahaan</h5> <h5>Otorisasi Perusahaan</h5>
<div style={{paddingLeft: 10, overflow:'scroll', height: '25vh'}}> <div style={{ paddingLeft: 10, overflow: 'scroll', height: '25vh' }}>
{this.state.listCompany.map((item,index) => { {this.state.listCompany.map((item, index) => {
return( return (
<div> <div>
<ul> <ul>
<li> <li>
...@@ -451,7 +462,7 @@ export default class EditUser extends Component { ...@@ -451,7 +462,7 @@ export default class EditUser extends Component {
</span> </span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography> <Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div> </div>
{!R.isNil(item.child) && this.renderChildren(item, semriwing)} {!R.isNil(item.child) && this.renderChildren(item)}
</li> </li>
</ul> </ul>
{/* <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}> {/* <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
...@@ -481,7 +492,7 @@ export default class EditUser extends Component { ...@@ -481,7 +492,7 @@ export default class EditUser extends Component {
</div> </div>
</button> </button>
</div> </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 onClick={() => this.validasi()}> <button onClick={() => this.validasi()}>
<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 }}>Simpan</span>
......
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