Commit 33b53923 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

update didam

See merge request !85
parents f666c1cd 1b49c58d
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -90,6 +90,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getPerusahaan = () => api.get('company/get_all_company')
const createPerusahaan = (body) => api.post('/company/create_company', body)
const updatePerusahaan = (body) => api.post('/company/update_company', body)
const getPerusahaanHierarki = () => api.get('company/get_company_hierarki')
// APPROVAL MATRIX
const getAM = () => api.get('approval_matrix/get_all_approval_matrix')
......@@ -104,10 +105,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getUser = () => api.get('user/get_all_user')
const getDetailUser = (userId) => api.get(`user/get_user_by_id/${userId}`)
const searchUser = (body) => api.post('user/search_user', body)
const createUser = (body) => api.get('user/create_user', body)
const updateUser = (body) => api.get('user/update_user', body)
const createUser = (body) => api.post('user/create_user', body)
const updateUser = (body) => api.post('user/update_user', body)
const deleteUser = (userId) => api.get(`user/delete_user/${userId}`)
const changePassword = (body) => api.post('/user/change_password', body)
//Template
......@@ -161,7 +161,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
downloadTemplate,
checkUploadUnitBisnis,
uploadUnitBisnis,
changePassword
changePassword,
getPerusahaanHierarki
}
}
......
......@@ -70,31 +70,44 @@ export default class VisualisasiAM extends Component {
api.create().searchAM(body).then(response => {
if (response.data.status == 'success') {
let data = response.data.data
console.log(data)
let listVisual = []
data.map((item, index) => {
let indexId = listVisual.findIndex((val) => val.orders == item.orders)
let indexId = listVisual.findIndex((val) => val.orderId == item.orders)
if(indexId == -1){
listVisual.push(item)
listVisual.push({
orderId: item.orders,
data: [item]
})
console.log(listVisual);
} else {
return
listVisual[indexId].data.push(item)
}
})
this.setState({ listApproval: listVisual, typeData: response.data.data })
console.log(data);
this.setState({ listApproval: listVisual })
console.log(listVisual);
} else {
alert(response.data.message)
}
})
}
handleChangeOrder(fromIndex, toIndex, that) {
let listApproval = that.state.listApproval
listApproval[fromIndex].orderId = listApproval[toIndex].orderId
listApproval[toIndex].orderId = listApproval[fromIndex].orderId
console.log(fromIndex, toIndex)
}
render() {
const that = this;
const dragProps = {
onDragEnd(fromIndex, toIndex) {
const data = [...that.state.data];
const data = [...that.state.listApproval];
const item = data.splice(fromIndex, 1)[0];
that.handleChangeOrder(fromIndex, toIndex, that)
data.splice(toIndex, 0, item);
that.setState({ data });
that.setState({ listApproval: data });
},
nodeSelector: 'li',
handleSelector: 'a'
......@@ -125,8 +138,7 @@ export default class VisualisasiAM extends Component {
<ol>
{this.state.listApproval.map((item, index) => (
<li key={index}>
{'urutan: ' + item.orders}
<a href="#">Drag</a>
<a href="#">{`${item.data.map((items, indexs) => {return(items.fullname)})} ${item.data.length == 1? '' : item.data[0].operator_type_name}`}</a>
</li>
))}
</ol>
......
......@@ -39,6 +39,7 @@ import { Avatar } from '@material-ui/core';
import HomeRoutes from '../router/homeRoutes'
import ArraySide from '../library/Array'
import Constant from '../library/Constant';
import api from '../api';
const drawerWidth = 307;
......@@ -126,10 +127,25 @@ export default function MiniDrawer() {
const [selectedIndex, setSelectedIndex] = React.useState([]);
const [selectedIndexs, setSelectedIndexs] = React.useState([]);
const [selectedSubIndex, setSelectSub] = React.useState([]);
const [userFullname, setUserFullname] = React.useState("")
const [userEmail, setUserEmail] = React.useState("")
// React.useEffect(() => {
// //
// })
React.useEffect(() => {
if(userFullname == "" && userEmail == "") {
getUserData()
}
})
const getUserData = () => {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data.status == 'success') {
setUserFullname(response.data.data.fullname == null? 'Anonym' : response.data.data.fullname)
setUserEmail(response.data.data.email == null? 'Anonym@123.xyz' : response.data.data.email)
console.log(userEmail)
}
})
}
const handleDrawerOpen = () => {
setOpen(true);
......
......@@ -172,7 +172,7 @@ export default class UserRole extends Component {
downloadFile = async () => {
let res = await fetch(
"https://trftia.eksad.com/tia-reporting-dev/public/attachment/download_file?fileName=UserTemplate&&fileType=xlsx"
"https://tia.eksad.com/tia-reporting-dev/public/attachment/download_file?fileName=UserTemplate&&fileType=xlsx"
)
res = await res.blob()
console.log(res)
......@@ -186,7 +186,7 @@ export default class UserRole extends Component {
}
downloadDataTables = async () => {
let res = await fetch ("https://trftia.eksad.com/tia-reporting-dev/public/user/export_user")
let res = await fetch ("https://tia.eksad.com/tia-reporting-dev/public/user/export_user")
res = await res.blob()
console.log(res)
if (res.size > 0) {
......@@ -289,7 +289,7 @@ export default class UserRole extends Component {
return (
<div style={{ height: this.props.height }}>
{/* <Row> */}
<div className={"main-color"} style={{ height: 199, width: '100%' }} />
<div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} />
{this.state.visibleUser ? <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ fontFamily: 'nunito', color: 'white', width: '20%', alignSelf: 'center', fontSize: 18}}>Master Data - User</label>
......@@ -424,12 +424,14 @@ export default class UserRole extends Component {
{this.state.add && (
<AddUser
onClickClose={this.closeAdd.bind(this)}
refresh={this.getUser.bind(this)}
data={this.state.indexData}
/>
)}
{this.state.edit && (
<EditUser
onClickClose={this.closeEdit.bind(this)}
refresh={this.getUser.bind(this)}
data={this.state.indexData}
/>
)}
......
import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles } from '@material-ui/core';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core';
import api from '../../../api';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { titleCase } from '../../../library/Utils';
import localeID from "date-fns/locale/id"
import format from "date-fns/format";
import * as R from 'ramda'
import RemoveIcon from '@material-ui/icons/Remove';
import AddIcon from '@material-ui/icons/Add';
import { DatePicker } from '@material-ui/pickers';
const CustomCheckbox = withStyles({
root: {
......@@ -31,8 +35,20 @@ export default class AddUser extends Component {
startDate: null,
endDate: null,
company: [],
listCompany: [],
listRole: null,
selectedIndex: 0,
date: new Date(),
errorFullname: false,
errorEmail: false,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorFN: '',
msgErrorEM: '',
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
}
}
......@@ -42,14 +58,47 @@ export default class AddUser extends Component {
componentDidMount() {
this.getRole()
this.getPerusahaan()
}
handleChange(e) {
handleChange(e, type) {
let data = this.state
this.setState({...data, tempData: {...this.state.tempData, [e.target.name] : e.target.value}})
let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') {
this.setState({ ...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
} else if (isDate && type == 'end_date') {
this.setState({ ...data, endDate: format(e, 'yyyy-MM-dd') ,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
} else {
this.setState({ ...data, [e.target.name]: e.target.value,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
}
}
crateUser() {
validasi() {
this.createUser()
}
createUser() {
let payload = {
"role_id": this.state.role.role_id,
"email": this.state.email,
......@@ -61,6 +110,12 @@ export default class AddUser extends Component {
}
api.create().createUser(payload).then((response) => {
console.log(response)
if (String(response.data.status).toLocaleUpperCase == 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
alert(response.data.message)
}
})
}
......@@ -85,6 +140,30 @@ export default class AddUser extends Component {
})
}
getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => {
if(response.data.status == 'success') {
this.setState({listCompany: response.data.data})
console.log(response.data.data)
}
})
}
handleItemChecked(item) {
let indexID = this.state.company.findIndex((val) => val == item.company_id)
return indexID == -1 ? false : true
}
handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val == item.company_id)
let company = this.state.company
if (indexID == -1) {
company.push(item.company_id)
} else {
company.splice(indexID, 1)
}
this.setState({ company })
}
render() {
return (
......@@ -136,8 +215,8 @@ export default class AddUser extends Component {
id="fullname"
name="fullname"
label="Nama Lengkap"
value={this.state.tempData == null? '' : this.state.tempData.fullname}
onChange={(e) => this.handleChange(e)}
value={this.state.fullname}
onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value"
// helperText="Some important text"
/>
......@@ -153,8 +232,8 @@ export default class AddUser extends Component {
id="email"
name="email"
label="Email"
value={this.state.tempData == null? '' : this.state.tempData.email}
onChange={(e) => this.handleChange(e)}
value={this.state.email}
onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value"
// helperText="Some important text"
/>
......@@ -178,30 +257,41 @@ export default class AddUser extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-bottom-20px">
<TextField
style={{ width: '100%'}}
<DatePicker
margin="normal"
id="startDate"
label="Berlaku Mulai"
name="start_date"
value={this.state.tempData == null? '' : this.state.tempData.start_date}
defaultValue="Default Value"
onChange={(e) => this.handleChange(e)}
// helperText="Some important text"
format="dd MMMM yyyy"
value={this.state.startDate}
error={this.state.errorStartDate}
helperText={this.state.msgErrorSD}
onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
<div className="column-2">
<div className="margin-bottom-20px">
<TextField
style={{ width: '100%'}}
<DatePicker
margin="normal"
id="endDate"
label="Berlaku Hingga"
name="end_date"
value={this.state.tempData == null? '' : this.state.tempData.end_date}
defaultValue="Default Value"
onChange={(e) => this.handleChange(e)}
// helperText="Some important text"
format="dd MMMM yyyy"
value={this.state.endDate}
error={this.state.errorEndDate}
helperText={this.state.msgErrorED}
minDate={this.state.startDate}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
......@@ -256,8 +346,46 @@ export default class AddUser extends Component {
<Divider style={{margin: 20}}/>
<div style={{paddingLeft: 20, paddingRight: 20}}>
<h5>Otorisasi Perusahaan</h5>
<div style={{paddingLeft: 10, overflow:'scroll', height: '25vh'}}>
{this.state.listCompany.map((item,index) => {
return(
<div>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.childCompany.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'} />}
</span>}
<span>
<CustomCheckbox
checked={this.handleItemChecked(item)}
onChange={() => this.handleItemClick(item)}
/>
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div>
{item.childCompany.length > 0 && item.childCompany.map((items,indexs) => {
return (
<Collapse in={index == this.state.selectedIndex} timeout="auto" unmountOnExit>
<div style={{ paddingLeft: 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 }}>
{index == this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>} */}
{/* <RemoveIcon color={'action'} fontSize={'small'} /> */}
<span>
<CustomCheckbox
checked={this.handleItemChecked(items)}
onChange={() => this.handleItemClick(items)}
/>
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(items.company_name)}</Typography>
</div>
</Collapse>
)
})}
</div>
)
})}
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
......
import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles } from '@material-ui/core';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core';
import api from '../../../api';
import { titleCase } from '../../../library/Utils';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { DatePicker } from '@material-ui/pickers';
import format from "date-fns/format";
import * as R from 'ramda'
import RemoveIcon from '@material-ui/icons/Remove';
import AddIcon from '@material-ui/icons/Add';
const CustomCheckbox = withStyles({
root: {
......@@ -26,6 +31,18 @@ export default class EditUser extends Component {
listRole: null,
role: null,
company: [],
listCompany: [],
selectedIndex: 0,
errorFullname: false,
errorEmail: false,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorFN: '',
msgErrorEM: '',
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
}
}
......@@ -36,17 +53,46 @@ export default class EditUser extends Component {
componentDidMount() {
this.getDetailUser()
this.getRole()
this.getPerusahaan()
}
handleChange(e) {
handleChange(e, type) {
let data = this.state
this.setState({...data, tempData: {...this.state.tempData, [e.target.name] : e.target.value}})
let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') {
this.setState({ ...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null },
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
} else if (isDate && type == 'end_date') {
this.setState({ ...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
} else {
this.setState({ ...data, tempData: { ...this.state.tempData, [e.target.name]: e.target.value },
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
}
}
getDetailUser() {
api.create().getDetailUser(this.state.paramsId).then((response) => {
if (response.data.status == 'success') {
this.setState({tempData: response.data.data})
this.setState({tempData: response.data.data, company: response.data.data.company})
console.log(response.data.data)
} else {
alert(response.data.message)
......@@ -55,7 +101,7 @@ export default class EditUser extends Component {
}
validasi() {
this.props.onClickClose()
this.updateUser()
}
updateUser() {
......@@ -68,8 +114,14 @@ export default class EditUser extends Component {
"start_date": this.state.tempData.start_date,
"end_date": this.state.tempData.end_date
}
api.create().updateUser(payload).then((response) => {
console.log(response)
if (response.data.status == 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
alert(response.data.message)
}
})
}
......@@ -89,7 +141,6 @@ export default class EditUser extends Component {
};
let index = roleData.findIndex((val) => val.role_id == this.state.tempData.role_id)
console.log(index)
this.setState({listRole: defaultProps, role: index == -1? roleData[0] : roleData[index]})
} else {
alert(response.data.message)
......@@ -97,6 +148,30 @@ export default class EditUser extends Component {
})
}
getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => {
if(response.data.status == 'success') {
this.setState({listCompany: response.data.data})
console.log(response.data.data)
}
})
}
handleItemChecked(item) {
let indexID = this.state.company.findIndex((val) => val == item.company_id)
return indexID == -1 ? false : true
}
handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val == item.company_id)
let company = this.state.company
if (indexID == -1) {
company.push(item.company_id)
} else {
company.splice(indexID, 1)
}
this.setState({ company })
}
render() {
return (
......@@ -149,7 +224,7 @@ export default class EditUser extends Component {
name="fullname"
label="Nama Lengkap"
value={this.state.tempData == null? '' : this.state.tempData.fullname}
onChange={(e) => this.handleChange(e)}
onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value"
// helperText="Some important text"
/>
......@@ -166,7 +241,7 @@ export default class EditUser extends Component {
name="email"
label="Email"
value={this.state.tempData == null? '' : this.state.tempData.email}
onChange={(e) => this.handleChange(e)}
onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value"
// helperText="Some important text"
/>
......@@ -190,30 +265,41 @@ export default class EditUser extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-bottom-20px">
<TextField
style={{ width: '100%'}}
<DatePicker
margin="normal"
id="startDate"
label="Berlaku Mulai"
name="start_date"
value={this.state.tempData == null? '' : this.state.tempData.start_date}
defaultValue="Default Value"
onChange={(e) => this.handleChange(e)}
// helperText="Some important text"
format="dd MMMM yyyy"
value={this.state.tempData == null ? null : this.state.tempData.start_date}
error={this.state.errorStartDate}
helperText={this.state.msgErrorSD}
onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
<div className="column-2">
<div className="margin-bottom-20px">
<TextField
style={{ width: '100%'}}
<DatePicker
margin="normal"
id="endDate"
label="Berlaku Hingga"
name="end_date"
value={this.state.tempData == null? '' : this.state.tempData.end_date}
defaultValue="Default Value"
onChange={(e) => this.handleChange(e)}
// helperText="Some important text"
format="dd MMMM yyyy"
value={this.state.tempData == null ? null : this.state.tempData.end_date}
error={this.state.errorEndDate}
helperText={this.state.msgErrorED}
minDate={this.state.tempData == null ? null : this.state.tempData.start_date}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
......@@ -268,7 +354,46 @@ export default class EditUser extends Component {
<Divider style={{margin: 20}}/>
<div style={{paddingLeft: 20, paddingRight: 20}}>
<h5>Otorisasi Perusahaan</h5>
<div style={{paddingLeft: 10, overflow:'scroll', height: '25vh'}}>
{this.state.listCompany.map((item,index) => {
return(
<div>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.childCompany.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'} />}
</span>}
<span>
<CustomCheckbox
checked={this.handleItemChecked(item)}
onChange={() => this.handleItemClick(item)}
/>
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div>
{item.childCompany.length > 0 && item.childCompany.map((items,indexs) => {
return (
<Collapse in={index == this.state.selectedIndex} timeout="auto" unmountOnExit>
<div style={{ paddingLeft: 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 }}>
{index == this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>} */}
{/* <RemoveIcon color={'action'} fontSize={'small'} /> */}
<span>
<CustomCheckbox
checked={this.handleItemChecked(items)}
onChange={() => this.handleItemClick(items)}
/>
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(items.company_name)}</Typography>
</div>
</Collapse>
)
})}
</div>
)
})}
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
......
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