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/') =>
const
searchUser
=
(
body
)
=>
api
.
post
(
'user/search_user'
,
body
)
const
createUser
=
(
body
)
=>
api
.
post
(
'user/create_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
checkUploadUser
=
(
body
)
=>
api
.
post
(
'/user/check_import'
,
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 {
}
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
({
errorFullname
:
false
,
errorEmail
:
false
,
...
...
@@ -150,6 +177,9 @@ export default class AddUser extends Component {
msgErrorRN
:
''
,
msgErrorSD
:
''
,
msgErrorED
:
''
,
company
},
()
=>
{
console
.
log
(
this
.
state
.
company
)
})
}
...
...
@@ -262,41 +292,58 @@ export default class AddUser extends Component {
handleItemClick
(
item
)
{
let
indexID
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
let
listCompany
=
this
.
state
.
listCompany
let
company
=
this
.
state
.
company
if
(
indexID
===
-
1
)
{
company
.
push
(
item
.
id
)
if
(
item
.
parent
!==
null
)
{
let
indexIDs
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
parent
)
if
(
indexIDs
===
-
1
)
{
company
.
push
(
item
.
parent
)
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
)
})
}
}
}
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
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
this
.
handleItemClick
(
items
)
item
.
children
.
map
((
items
,
indexs
)
=>
{
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
{
company
.
splice
(
indexID
,
1
)
if
(
item
.
parent
!==
null
)
{
let
indexIDs
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
parent
)
if
(
indexIDs
!==
-
1
)
{
company
.
splice
(
indexIDs
,
1
)
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
this
.
handleItemClick
(
items
)
})
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handleSpliceChild
(
items
)
})
}
}
}
this
.
setState
({
company
})
// console.log(company)
this
.
setState
({
company
})
}
renderChildren
=
(
item
,
pad
)
=>
{
...
...
@@ -570,7 +617,7 @@ export default class AddUser extends Component {
margin
=
"normal"
id
=
"startDate"
label
=
"Valid From"
format
=
"dd
MMMM
yyyy"
format
=
"dd
-MM-
yyyy"
value
=
{
this
.
state
.
startDate
}
error
=
{
this
.
state
.
errorStartDate
}
helperText
=
{
this
.
state
.
msgErrorSD
}
...
...
@@ -603,7 +650,7 @@ export default class AddUser extends Component {
margin
=
"normal"
id
=
"endDate"
label
=
"Valid To"
format
=
"dd
MMMM
yyyy"
format
=
"dd
-MM-
yyyy"
value
=
{
this
.
state
.
endDate
}
error
=
{
this
.
state
.
errorEndDate
}
helperText
=
{
this
.
state
.
msgErrorED
}
...
...
src/container/Otorisasi/User/EditUser.js
View file @
7506ecd9
...
...
@@ -123,6 +123,33 @@ export default class EditUser extends Component {
}
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
({
errorFullname
:
false
,
errorEmail
:
false
,
...
...
@@ -134,6 +161,7 @@ export default class EditUser extends Component {
msgErrorRN
:
''
,
msgErrorSD
:
''
,
msgErrorED
:
''
,
company
})
}
...
...
@@ -251,7 +279,10 @@ export default class EditUser extends Component {
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
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
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Token"
))
{
...
...
@@ -279,40 +310,57 @@ export default class EditUser extends Component {
handleItemClick
(
item
)
{
let
indexID
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
id
)
let
company
=
this
.
state
.
company
if
(
indexID
===
-
1
)
{
company
.
push
(
item
.
id
)
if
(
item
.
parent
!==
null
)
{
let
indexIDs
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
parent
)
if
(
indexIDs
===
-
1
)
{
company
.
push
(
item
.
parent
)
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
)
})
}
}
}
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
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
this
.
handleItemClick
(
items
)
handleSpliceChild
(
items
)
})
}
}
}
else
{
company
.
splice
(
indexID
,
1
)
if
(
item
.
parent
!==
null
)
{
let
indexIDs
=
this
.
state
.
company
.
findIndex
((
val
)
=>
val
===
item
.
parent
)
if
(
indexIDs
!==
-
1
)
{
company
.
splice
(
indexIDs
,
1
)
}
if
(
indexID
===
-
1
)
{
company
.
push
(
item
.
id
)
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
else
{
company
.
splice
(
indexID
,
1
)
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
this
.
handleItemClick
(
items
)
handleSpliceChild
(
items
)
})
}
}
}
this
.
setState
({
company
})
// console.log(company)
this
.
setState
({
company
})
}
renderChildren
=
(
item
,
pad
)
=>
{
...
...
@@ -583,7 +631,7 @@ export default class EditUser extends Component {
margin
=
"normal"
id
=
"startDate"
label
=
"Valid From"
format
=
"dd
MMMM
yyyy"
format
=
"dd
-MM-
yyyy"
value
=
{
this
.
state
.
tempData
===
null
?
null
:
this
.
state
.
tempData
.
start_date
}
error
=
{
this
.
state
.
errorStartDate
}
helperText
=
{
this
.
state
.
msgErrorSD
}
...
...
@@ -615,7 +663,7 @@ export default class EditUser extends Component {
margin
=
"normal"
id
=
"endDate"
label
=
"Valid To"
format
=
"dd
MMMM
yyyy"
format
=
"dd
-MM-
yyyy"
value
=
{
this
.
state
.
tempData
===
null
?
null
:
this
.
state
.
tempData
.
end_date
}
error
=
{
this
.
state
.
errorEndDate
}
helperText
=
{
this
.
state
.
msgErrorED
}
...
...
src/container/Otorisasi/UserRole.js
View file @
7506ecd9
...
...
@@ -161,6 +161,33 @@ class UserRole extends Component {
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
()
{
const
columns
=
[{
name
:
"Action"
,
...
...
@@ -186,9 +213,24 @@ class UserRole extends Component {
null
}
<
/div
>
<
/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
>
);
}
...
...
@@ -317,6 +359,38 @@ class UserRole extends Component {
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
>
);
}
...
...
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