Commit 9a5ff868 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

update didam

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