Commit ef751e91 authored by d.arizona's avatar d.arizona

update didam

parent 586128e4
......@@ -95,7 +95,16 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
const createAM = (body) => api.post('/approval_matrix/create_approval_matrix', body)
const updateAM = (body) => api.post('/approval_matrix/update_approval_matrix', body)
//User
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 deleteUser = (userId) => api.get(`user/delete_user/${userId}`)
//Template
const downloadTemplate = (fileName,fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
// ------
// STEP 3
// ------
......@@ -132,7 +141,14 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
updatePerusahaan,
getApprovedByAM,
createAM,
updateAM
updateAM,
getUser,
getDetailUser,
searchUser,
createUser,
updateUser,
deleteUser,
downloadTemplate
}
}
......
......@@ -57,6 +57,8 @@ export default class CreateApprovalMatrix extends Component {
// operator: '',
startDate: '',
endDate: '',
userData: [],
value: null
}
}
......@@ -80,7 +82,7 @@ export default class CreateApprovalMatrix extends Component {
options: userData,
getOptionLabel: (option) => option.fullname,
};
this.setState({ approvedBy: defaultProps, userData: response.data.data })
this.setState({ approvedBy: defaultProps, userData: response.data.data, value: userData[0] })
} else {
alert(response.data.message)
}
......@@ -205,6 +207,7 @@ export default class CreateApprovalMatrix extends Component {
onChange={(event, newInputValue) => this.setState({userId:newInputValue.user_id}, () => console.log(this.state.userId))}
debug
renderInput={(params) => <TextField {...params} label="debug" margin="normal" />}
value={this.state.value}
/>
</div>
</div>
......
......@@ -4,8 +4,8 @@ import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/
import SearchIcon from '@material-ui/icons/Search';
import Images from "../../assets/Images";
import MUIDataTable from "mui-datatables";
import AddRole from './UserRole/AddRole';
import EditRole from './UserRole/EditRole'
import AddUser from './User/AddUser';
import EditUser from './User/EditUser'
import api from "../../api";
import { titleCase } from "../../library/Utils";
import { InputAdornment, TextField } from "@material-ui/core";
......@@ -18,7 +18,7 @@ export default class UserRole extends Component {
constructor(props) {
super(props)
this.state = {
listRole: [],
listUser: [],
indexData: {},
add: false,
edit: false
......@@ -26,7 +26,7 @@ export default class UserRole extends Component {
}
componentDidMount() {
this.getRole()
this.getUser()
}
closeEdit() {
......@@ -37,27 +37,54 @@ export default class UserRole extends Component {
this.setState({add: false})
}
getRole() {
api.create().getRole().then((response) => {
getUser() {
api.create().getUser().then((response) => {
// console.log(response)
if (response.data.status == 'success') {
// console.log(response.data.data)
let data = response.data.data
let listData = data.map((item,index) => {
return [index, item.role_id, item.role_name, item.access, item.status]
return [index, item.user_id, item.fullname, item.email, item.role_name, item.company, item.status]
})
console.log(listData)
this.setState({listRole: listData})
// this.setState({listRole: response.data.data}, () => {
// console.log(this.state.listRole)
// console.log(listData)
this.setState({listUser: listData})
// this.setState({listUser: response.data.data}, () => {
// console.log(this.state.listUser)
// })
} else {
alert(response.data.message)
}
// console.log(response.data.data)
})
}
searchUser() {
let payload = {
"keyword": this.state.search
}
api.create().searchUser(payload).then((response) => {
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item,index) => {
return [index, item.user_id, item.fullname, item.email, item.role_name, item.company, item.status]
})
this.setState({listUser: listData})
} else {
alert(response.data.message)
}
console.log(response.data.data)
})
}
_handleKeyDown(e) {
if (e.key === 'Enter') {
if (this.state.search.length > 0) {
this.searchUser()
} else {
this.getRole()
}
}
}
render() {
const columns = [{
name: "Action",
......@@ -160,9 +187,9 @@ export default class UserRole extends Component {
onChange={(e) => {
this.setState({ search: e.target.value }, () => {
if (this.state.search.length > 0) {
this.searchRole()
this.searchUser()
} else {
this.getRole()
this.getUser()
}
});
}}
......@@ -190,7 +217,7 @@ export default class UserRole extends Component {
<div style={{ padding: 25 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={data}
data={this.state.listUser}
columns={columns}
options={options}
/>
......@@ -198,13 +225,13 @@ export default class UserRole extends Component {
</div>
</div>
{this.state.add && (
<AddRole
<AddUser
onClickClose={this.closeAdd.bind(this)}
data={this.state.indexData}
/>
)}
{this.state.edit && (
<EditRole
<EditUser
onClickClose={this.closeEdit.bind(this)}
data={this.state.indexData}
/>
......
This diff is collapsed.
This diff is collapsed.
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