Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Tia-dev
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dida Adams Arizona
Tia-dev
Commits
7506ecd9
Commit
7506ecd9
authored
Sep 07, 2020
by
Dida Adams Arizona
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'didam' into 'master'
Didam See merge request
!254
parents
fefcdcaf
2a53aaeb
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
447 additions
and
91 deletions
+447
-91
index.js
src/api/index.js
+1
-1
User.js
src/container/Otorisasi/User.js
+100
-20
AddUser.js
src/container/Otorisasi/User/AddUser.js
+70
-23
EditUser.js
src/container/Otorisasi/User/EditUser.js
+66
-18
UserRole.js
src/container/Otorisasi/UserRole.js
+75
-1
AddRole.js
src/container/Otorisasi/UserRole/AddRole.js
+94
-15
EditRole.js
src/container/Otorisasi/UserRole/EditRole.js
+41
-13
No files found.
src/api/index.js
View file @
7506ecd9
...
@@ -125,7 +125,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
...
@@ -125,7 +125,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const
searchUser
=
(
body
)
=>
api
.
post
(
'user/search_user'
,
body
)
const
searchUser
=
(
body
)
=>
api
.
post
(
'user/search_user'
,
body
)
const
createUser
=
(
body
)
=>
api
.
post
(
'user/create_user'
,
body
)
const
createUser
=
(
body
)
=>
api
.
post
(
'user/create_user'
,
body
)
const
updateUser
=
(
body
)
=>
api
.
post
(
'user/update_user'
,
body
)
const
updateUser
=
(
body
)
=>
api
.
post
(
'user/update_user'
,
body
)
const
deleteUser
=
(
userId
)
=>
api
.
ge
t
(
`user/delete_user/
${
userId
}
`
)
const
deleteUser
=
(
userId
)
=>
api
.
pos
t
(
`user/delete_user/
${
userId
}
`
)
const
changePassword
=
(
body
)
=>
api
.
post
(
'/user/change_password'
,
body
)
const
changePassword
=
(
body
)
=>
api
.
post
(
'/user/change_password'
,
body
)
const
checkUploadUser
=
(
body
)
=>
api
.
post
(
'/user/check_import'
,
body
)
const
checkUploadUser
=
(
body
)
=>
api
.
post
(
'/user/check_import'
,
body
)
const
uploadUser
=
(
body
)
=>
api
.
post
(
'/user/import_user'
,
body
)
const
uploadUser
=
(
body
)
=>
api
.
post
(
'/user/import_user'
,
body
)
...
...
src/container/Otorisasi/User.js
View file @
7506ecd9
This diff is collapsed.
Click to expand it.
src/container/Otorisasi/User/AddUser.js
View file @
7506ecd9
...
@@ -139,6 +139,33 @@ export default class AddUser extends Component {
...
@@ -139,6 +139,33 @@ export default class AddUser extends Component {
}
}
clearError
()
{
clearError
()
{
let
listCompany
=
this
.
state
.
listCompany
let
company
=
this
.
state
.
company
const
handlePushChild
=
(
item
)
=>
{
let
indexIDzz
=
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
if
(
indexIDzz
===
-
1
)
{
company
.
push
(
item
.
id
)
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
listCompany
.
map
((
item
,
index
)
=>
{
company
.
push
(
item
.
id
)
handlePushChild
(
item
)
})
let
uniqueCompany
=
company
.
filter
((
val
,
id
,
array
)
=>
{
return
array
.
indexOf
(
val
)
==
id
;
});
company
=
this
.
state
.
role
.
role_id
===
1
?
uniqueCompany
:
[]
// console.log(uniqueCompany)
this
.
setState
({
this
.
setState
({
errorFullname
:
false
,
errorFullname
:
false
,
errorEmail
:
false
,
errorEmail
:
false
,
...
@@ -150,6 +177,9 @@ export default class AddUser extends Component {
...
@@ -150,6 +177,9 @@ export default class AddUser extends Component {
msgErrorRN
:
''
,
msgErrorRN
:
''
,
msgErrorSD
:
''
,
msgErrorSD
:
''
,
msgErrorED
:
''
,
msgErrorED
:
''
,
company
},
()
=>
{
console
.
log
(
this
.
state
.
company
)
})
})
}
}
...
@@ -262,41 +292,58 @@ export default class AddUser extends Component {
...
@@ -262,41 +292,58 @@ export default class AddUser extends Component {
handleItemClick
(
item
)
{
handleItemClick
(
item
)
{
let
indexID
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
let
indexID
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
let
listCompany
=
this
.
state
.
listCompany
let
company
=
this
.
state
.
company
let
company
=
this
.
state
.
company
if
(
indexID
===
-
1
)
{
const
handlePushChild
=
(
item
)
=>
{
company
.
push
(
item
.
id
)
let
indexIDzz
=
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
if
(
item
.
parent
!==
null
)
{
if
(
indexIDzz
===
-
1
)
{
let
indexIDs
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
parent
)
company
.
push
(
item
.
id
)
if
(
indexIDs
===
-
1
)
{
}
company
.
push
(
item
.
parent
)
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
}
}
const
handleSpliceChild
=
(
item
)
=>
{
let
indexIDzz
=
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
if
(
indexIDzz
!==
-
1
)
{
company
.
splice
(
indexIDzz
,
1
)
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
this
.
handleItemClick
(
items
)
handleSpliceChild
(
items
)
})
})
}
}
}
}
}
if
(
indexID
===
-
1
)
{
company
.
push
(
item
.
id
)
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
else
{
}
else
{
company
.
splice
(
indexID
,
1
)
company
.
splice
(
indexID
,
1
)
if
(
item
.
parent
!==
null
)
{
if
(
item
.
children
!==
null
)
{
let
indexIDs
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
parent
)
if
(
item
.
children
.
length
>
0
)
{
if
(
indexIDs
!==
-
1
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
company
.
splice
(
indexIDs
,
1
)
handleSpliceChild
(
items
)
}
})
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
this
.
handleItemClick
(
items
)
})
}
}
}
}
}
}
}
this
.
setState
({
company
})
// console.log(company)
this
.
setState
({
company
})
}
}
renderChildren
=
(
item
,
pad
)
=>
{
renderChildren
=
(
item
,
pad
)
=>
{
...
@@ -570,7 +617,7 @@ export default class AddUser extends Component {
...
@@ -570,7 +617,7 @@ export default class AddUser extends Component {
margin
=
"normal"
margin
=
"normal"
id
=
"startDate"
id
=
"startDate"
label
=
"Valid From"
label
=
"Valid From"
format
=
"dd
MMMM
yyyy"
format
=
"dd
-MM-
yyyy"
value
=
{
this
.
state
.
startDate
}
value
=
{
this
.
state
.
startDate
}
error
=
{
this
.
state
.
errorStartDate
}
error
=
{
this
.
state
.
errorStartDate
}
helperText
=
{
this
.
state
.
msgErrorSD
}
helperText
=
{
this
.
state
.
msgErrorSD
}
...
@@ -603,7 +650,7 @@ export default class AddUser extends Component {
...
@@ -603,7 +650,7 @@ export default class AddUser extends Component {
margin
=
"normal"
margin
=
"normal"
id
=
"endDate"
id
=
"endDate"
label
=
"Valid To"
label
=
"Valid To"
format
=
"dd
MMMM
yyyy"
format
=
"dd
-MM-
yyyy"
value
=
{
this
.
state
.
endDate
}
value
=
{
this
.
state
.
endDate
}
error
=
{
this
.
state
.
errorEndDate
}
error
=
{
this
.
state
.
errorEndDate
}
helperText
=
{
this
.
state
.
msgErrorED
}
helperText
=
{
this
.
state
.
msgErrorED
}
...
...
src/container/Otorisasi/User/EditUser.js
View file @
7506ecd9
...
@@ -123,6 +123,33 @@ export default class EditUser extends Component {
...
@@ -123,6 +123,33 @@ export default class EditUser extends Component {
}
}
clearError
()
{
clearError
()
{
let
listCompany
=
this
.
state
.
listCompany
let
company
=
this
.
state
.
company
const
handlePushChild
=
(
item
)
=>
{
let
indexIDzz
=
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
if
(
indexIDzz
===
-
1
)
{
company
.
push
(
item
.
id
)
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
listCompany
.
map
((
item
,
index
)
=>
{
company
.
push
(
item
.
id
)
handlePushChild
(
item
)
})
let
uniqueCompany
=
company
.
filter
((
val
,
id
,
array
)
=>
{
return
array
.
indexOf
(
val
)
==
id
;
});
company
=
this
.
state
.
role
.
role_id
===
1
?
uniqueCompany
:
[]
// console.log(uniqueCompany)
this
.
setState
({
this
.
setState
({
errorFullname
:
false
,
errorFullname
:
false
,
errorEmail
:
false
,
errorEmail
:
false
,
...
@@ -134,6 +161,7 @@ export default class EditUser extends Component {
...
@@ -134,6 +161,7 @@ export default class EditUser extends Component {
msgErrorRN
:
''
,
msgErrorRN
:
''
,
msgErrorSD
:
''
,
msgErrorSD
:
''
,
msgErrorED
:
''
,
msgErrorED
:
''
,
company
})
})
}
}
...
@@ -251,7 +279,10 @@ export default class EditUser extends Component {
...
@@ -251,7 +279,10 @@ export default class EditUser extends Component {
if
(
response
.
data
)
{
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
setState
({
listCompany
:
response
.
data
.
data
})
let
dataBaru
=
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
return
{...
item
,
check
:
false
}
})
this
.
setState
({
listCompany
:
dataBaru
})
}
else
{
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Token"
))
{
if
(
response
.
data
.
message
.
includes
(
"Token"
))
{
...
@@ -279,40 +310,57 @@ export default class EditUser extends Component {
...
@@ -279,40 +310,57 @@ export default class EditUser extends Component {
handleItemClick
(
item
)
{
handleItemClick
(
item
)
{
let
indexID
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
let
indexID
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
let
company
=
this
.
state
.
company
let
company
=
this
.
state
.
company
if
(
indexID
===
-
1
)
{
const
handlePushChild
=
(
item
)
=>
{
company
.
push
(
item
.
id
)
let
indexIDzz
=
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
if
(
item
.
parent
!==
null
)
{
if
(
indexIDzz
===
-
1
)
{
let
indexIDs
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
parent
)
company
.
push
(
item
.
id
)
if
(
indexIDs
===
-
1
)
{
}
company
.
push
(
item
.
parent
)
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
}
}
const
handleSpliceChild
=
(
item
)
=>
{
let
indexIDzz
=
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
if
(
indexIDzz
!==
-
1
)
{
company
.
splice
(
indexIDzz
,
1
)
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
this
.
handleItemClick
(
items
)
handleSpliceChild
(
items
)
})
})
}
}
}
}
}
else
{
}
company
.
splice
(
indexID
,
1
)
if
(
item
.
parent
!==
null
)
{
if
(
indexID
===
-
1
)
{
let
indexIDs
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
parent
)
company
.
push
(
item
.
id
)
if
(
indexIDs
!==
-
1
)
{
if
(
item
.
children
!==
null
)
{
company
.
splice
(
indexIDs
,
1
)
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
}
}
else
{
company
.
splice
(
indexID
,
1
)
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
this
.
handleItemClick
(
items
)
handleSpliceChild
(
items
)
})
})
}
}
}
}
}
}
this
.
setState
({
company
})
// console.log(company)
this
.
setState
({
company
})
}
}
renderChildren
=
(
item
,
pad
)
=>
{
renderChildren
=
(
item
,
pad
)
=>
{
...
@@ -583,7 +631,7 @@ export default class EditUser extends Component {
...
@@ -583,7 +631,7 @@ export default class EditUser extends Component {
margin
=
"normal"
margin
=
"normal"
id
=
"startDate"
id
=
"startDate"
label
=
"Valid From"
label
=
"Valid From"
format
=
"dd
MMMM
yyyy"
format
=
"dd
-MM-
yyyy"
value
=
{
this
.
state
.
tempData
===
null
?
null
:
this
.
state
.
tempData
.
start_date
}
value
=
{
this
.
state
.
tempData
===
null
?
null
:
this
.
state
.
tempData
.
start_date
}
error
=
{
this
.
state
.
errorStartDate
}
error
=
{
this
.
state
.
errorStartDate
}
helperText
=
{
this
.
state
.
msgErrorSD
}
helperText
=
{
this
.
state
.
msgErrorSD
}
...
@@ -615,7 +663,7 @@ export default class EditUser extends Component {
...
@@ -615,7 +663,7 @@ export default class EditUser extends Component {
margin
=
"normal"
margin
=
"normal"
id
=
"endDate"
id
=
"endDate"
label
=
"Valid To"
label
=
"Valid To"
format
=
"dd
MMMM
yyyy"
format
=
"dd
-MM-
yyyy"
value
=
{
this
.
state
.
tempData
===
null
?
null
:
this
.
state
.
tempData
.
end_date
}
value
=
{
this
.
state
.
tempData
===
null
?
null
:
this
.
state
.
tempData
.
end_date
}
error
=
{
this
.
state
.
errorEndDate
}
error
=
{
this
.
state
.
errorEndDate
}
helperText
=
{
this
.
state
.
msgErrorED
}
helperText
=
{
this
.
state
.
msgErrorED
}
...
...
src/container/Otorisasi/UserRole.js
View file @
7506ecd9
...
@@ -161,6 +161,33 @@ class UserRole extends Component {
...
@@ -161,6 +161,33 @@ class UserRole extends Component {
this
.
setState
({
alert
:
false
})
this
.
setState
({
alert
:
false
})
}
}
deleteRole
()
{
let
data
=
this
.
state
.
rowData
api
.
create
().
deleteRole
(
data
[
1
]).
then
((
response
)
=>
{
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
,
popupDel
:
false
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
popupDel
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Token"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
popupDel
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
popupDel
:
false
})
}
this
.
getRole
()
})
}
render
()
{
render
()
{
const
columns
=
[{
const
columns
=
[{
name
:
"Action"
,
name
:
"Action"
,
...
@@ -186,9 +213,24 @@ class UserRole extends Component {
...
@@ -186,9 +213,24 @@ class UserRole extends Component {
null
null
}
}
<
/div
>
<
/div
>
<
/button
>
<
/button
>
)}
)}
{
this
.
state
.
buttonEdit
&&
(
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginLeft
:
10
}}
onClick
=
{()
=>
this
.
setState
({
popupDel
:
true
,
rowData
:
tableMeta
.
rowData
})}
>
{
tableMeta
.
rowData
[
2
]
!==
"superadmin"
?
<
img
src
=
{
Images
.
delete
}
/>
:
null
}
<
/button
>
)}
<
/div
>
<
/div
>
);
);
}
}
...
@@ -317,6 +359,38 @@ class UserRole extends Component {
...
@@ -317,6 +359,38 @@ class UserRole extends Component {
data
=
{
this
.
state
.
indexData
}
data
=
{
this
.
state
.
indexData
}
/
>
/
>
)}
)}
{
this
.
state
.
popupDel
&&
(
<
div
className
=
"test app-popup-show"
>
<
div
className
=
"popup-content background-white border-radius"
style
=
{{
borderRadius
:
8
,
padding
:
50
}}
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'center'
}}
>
<
img
src
=
{
Images
.
failedCopy
}
/
>
<
/div
>
<
div
style
=
{{
display
:
'grid'
,
justifyContent
:
'center'
,
marginTop
:
20
}}
>
<
span
style
=
{{
textAlign
:
'center'
,
fontSize
:
14
,
fontWeight
:
'bold'
}}
>
Delete
{
this
.
state
.
rowData
[
2
]}
?
<
/span
>
{
/* <span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold' }}>
{`Please try again later.`}
</span> */
}
<
/div
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'center'
,
marginTop
:
24
}}
>
<
button
className
=
{
"btn-save"
}
onClick
=
{()
=>
this
.
setState
({
popupDel
:
false
})}
>
<
span
style
=
{{
color
:
'white'
}}
>
Cancel
<
/span
>
<
/button
>
<
button
className
=
{
"btn-save"
}
style
=
{{
marginLeft
:
50
}}
onClick
=
{()
=>
this
.
deleteRole
()}
>
<
span
style
=
{{
color
:
'white'
}}
>
Delete
<
/span
>
<
/button
>
<
/div
>
<
/div
>
<
/div
>
)}
<
/div
>
<
/div
>
);
);
}
}
...
...
src/container/Otorisasi/UserRole/AddRole.js
View file @
7506ecd9
This diff is collapsed.
Click to expand it.
src/container/Otorisasi/UserRole/EditRole.js
View file @
7506ecd9
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment