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
32145370
Commit
32145370
authored
Jul 14, 2022
by
Arfin Syadziy
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'env/ridwan' into 'ENV-DEV-CR-CAFRM'
bug fixing and using one component See merge request
!1580
parents
c4a2ad1c
9f9ad787
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
741 deletions
+60
-741
CarfmDocument.js
src/container/CRFM/CarfmDocument.js
+37
-10
CreateCarfmDoc.js
src/container/CRFM/CreateCarfmDoc.js
+19
-11
InternalAudit.js
src/container/CRFM/InternalAudit.js
+0
-357
RiskManagement.js
src/container/CRFM/RiskManagement.js
+0
-357
homeRoutes.js
src/router/homeRoutes.js
+4
-6
No files found.
src/container/CRFM/
AntiFraud
.js
→
src/container/CRFM/
CarfmDocument
.js
View file @
32145370
...
...
@@ -9,11 +9,11 @@ import api from '../../api';
import
PropagateLoader
from
"react-spinners/PropagateLoader"
import
TableDocument
from
"./TableDocument"
;
import
PopUpKonfirmasi
from
"../DocumentManagement/PopUpKonfirmasi"
;
import
CreateC
rafmDoc
from
"./CreateCra
fmDoc"
;
import
CreateC
arfmDoc
from
"./CreateCar
fmDoc"
;
const
Alert
=
withStyles
({})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
RiskManage
ment
extends
Component
{
export
default
class
CarfmDocu
ment
extends
Component
{
constructor
(
props
)
{
super
(
props
);
...
...
@@ -27,21 +27,48 @@ export default class RiskManagement extends Component {
name
:
''
,
userCompActive
:
[],
isHasAccessDocument
:
false
,
submenu_id
:
27
,
submenu_name
:
"
anti-fraud
"
,
menu_title
:
"
Anti-Fraud
"
submenu_id
:
0
,
submenu_name
:
""
,
menu_title
:
""
}
}
componentDidMount
()
{
async
componentDidMount
()
{
// this.getPermission()
await
this
.
getMenuName
();
this
.
getDataCarfm
();
this
.
getDetailUser
();
}
getDataCarfm
(){
async
getMenuName
(){
await
api
.
create
().
getMenuByUser
().
then
(
response
=>
{
if
(
response
.
data
){
if
(
response
.
data
.
status
===
'success'
){
response
.
data
.
data
.
map
(
(
item
)
=>
{
let
arr
=
window
.
location
.
href
.
split
(
'/'
);
if
(
item
.
class_id
==
arr
.
slice
(
-
1
)[
0
]){
this
.
setState
({
submenu_id
:
item
.
menu_id
,
submenu_name
:
item
.
menu_name
.
toLowerCase
(),
menu_title
:
item
.
menu_name
.
replace
(
/
\b\w
/g
,
c
=>
c
.
toUpperCase
())
})
}
}
)
}
}
}
)
}
getDataCarfm
(
create
){
let
payload
=
{
submenu_id
:
this
.
state
.
submenu_id
}
...
...
@@ -63,7 +90,7 @@ export default class RiskManagement extends Component {
isHasAccessDocument
:
dataList
.
length
==
0
?
false
:
true
,
listData
:
dataList
,
loadTable
:
true
,
refresh
:
''
refresh
:
create
==
undefined
?
''
:
create
},
()
=>
{
this
.
getPermission
(
this
.
state
.
submenu_name
)
})
...
...
@@ -213,7 +240,7 @@ export default class RiskManagement extends Component {
this
.
setState
({
konfirmasi
:
true
,
formData
:
payload
,
docId
:
response
.
data
.
data
.
document_id
,
loading
:
false
})
}
else
if
(
response
.
data
.
message
===
"Data was Saved Successfully"
)
{
this
.
getDataCarfm
()
this
.
getDataCarfm
(
'create'
)
this
.
setState
({
visibleCreate
:
false
,
loading
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
})
}
else
{
...
...
@@ -339,7 +366,7 @@ export default class RiskManagement extends Component {
/>
)}
{this.state.visibleCreate && (
<CreateC
ra
fmDoc
<CreateC
ar
fmDoc
onClickClose={() => this.setState({ visibleCreate: false })}
// getDataDocument={this.getDataDocument.bind(this)}
createDocument={this.createDocument.bind(this)}
...
...
src/container/CRFM/CreateC
ra
fmDoc.js
→
src/container/CRFM/CreateC
ar
fmDoc.js
View file @
32145370
...
...
@@ -14,7 +14,7 @@ import PropagateLoader from "react-spinners/PropagateLoader"
const
Alert
=
withStyles
({
})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
CreateC
ra
fmDoc
extends
Component
{
export
default
class
CreateC
ar
fmDoc
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
...
...
@@ -48,7 +48,8 @@ export default class CreateCrafmDoc extends Component {
docId
:
''
,
sizeUpload
:
"1"
,
disabledPeriode
:
false
,
menuName
:
null
menuName
:
null
,
saveDisable
:
false
}
}
...
...
@@ -253,7 +254,7 @@ export default class CreateCrafmDoc extends Component {
validasi
()
{
if
(
this
.
state
.
disabledPeriode
===
true
)
{
if
(
R
.
isNil
(
this
.
state
.
file
))
{
this
.
setState
({
alert
:
true
,
messageAlert
:
'File Cannot be Empty'
,
tipeAlert
:
'warning'
})
this
.
setState
({
alert
:
true
,
messageAlert
:
'File Cannot be Empty'
,
tipeAlert
:
'warning'
,
saveDisable
:
false
})
}
else
{
const
formData
=
new
FormData
();
formData
.
append
(
"file"
,
this
.
state
.
file
);
...
...
@@ -276,14 +277,14 @@ export default class CreateCrafmDoc extends Component {
}
else
{
if
(
R
.
isNil
(
this
.
state
.
getPerusahaan
))
{
this
.
setState
({
errorPerusahaan
:
true
,
msgErrorPerusahaan
:
'Company Cannot be Empty'
})
this
.
setState
({
errorPerusahaan
:
true
,
msgErrorPerusahaan
:
'Company Cannot be Empty'
,
saveDisable
:
false
})
}
else
if
(
R
.
isNil
(
this
.
state
.
periode
))
{
this
.
setState
({
errorPeriode
:
true
,
msgErrorPeriode
:
'Period Cannot be Empty'
})
this
.
setState
({
errorPeriode
:
true
,
msgErrorPeriode
:
'Period Cannot be Empty'
,
saveDisable
:
false
})
}
else
if
(
R
.
isNil
(
this
.
state
.
monthId
))
{
this
.
setState
({
errorMonth
:
true
,
msgErrorMonth
:
'Month Cannot be Empty'
})
this
.
setState
({
errorMonth
:
true
,
msgErrorMonth
:
'Month Cannot be Empty'
,
saveDisable
:
false
})
}
else
if
(
R
.
isNil
(
this
.
state
.
file
))
{
this
.
setState
({
alert
:
true
,
messageAlert
:
'File Cannot be Empty'
,
tipeAlert
:
'warning'
})
this
.
setState
({
alert
:
true
,
messageAlert
:
'File Cannot be Empty'
,
tipeAlert
:
'warning'
,
saveDisable
:
false
})
}
else
{
const
formData
=
new
FormData
();
formData
.
append
(
"file"
,
this
.
state
.
file
);
...
...
@@ -484,13 +485,19 @@ export default class CreateCrafmDoc extends Component {
<
/button
>
<
/div
>
<
div
className
=
"column-2"
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
alignItems
:
'center'
}}
>
<
button
{
!
this
.
state
.
saveDisable
&&
<
button
disabled
=
{
this
.
state
.
saveDisable
}
type
=
"button"
onClick
=
{()
=>
{
this
.
props
.
handleLoading
(
1
)
{
this
.
setState
({
saveDisable
:
true
});
this
.
props
.
handleLoading
(
1
);
setTimeout
(()
=>
{
this
.
validasi
()
console
.
log
(
this
.
validasi
());
console
.
log
(
"vlidasi "
+
this
.
validasi
());
},
100
)
}
}
...
...
@@ -498,7 +505,8 @@ export default class CreateCrafmDoc extends Component {
<
div
style
=
{{
width
:
102
,
height
:
30
,
backgroundColor
:
'#354960'
,
borderRadius
:
5
,
alignItems
:
'center'
,
display
:
'flex'
,
justifyContent
:
'center'
}}
>
<
span
style
=
{{
color
:
'#fff'
,
fontSize
:
11
}}
>
Save
<
/span
>
<
/div
>
<
/button
>
<
/button>
}
<
/div
>
<
/div
>
<
/div
>
...
...
src/container/CRFM/InternalAudit.js
deleted
100644 → 0
View file @
c4a2ad1c
import
React
,
{
Component
}
from
'react'
import
{
withStyles
}
from
'@material-ui/core/styles'
;
import
{
createMuiTheme
,
MuiThemeProvider
,
Paper
,
Snackbar
,
Tab
,
Tabs
,
Typography
}
from
'@material-ui/core'
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
Constant
from
'../../library/Constant'
;
import
Images
from
'../../assets/Images'
;
import
ReactTooltip
from
'react-tooltip'
;
import
api
from
'../../api'
;
import
PropagateLoader
from
"react-spinners/PropagateLoader"
import
TableDocument
from
"./TableDocument"
;
import
PopUpKonfirmasi
from
"../DocumentManagement/PopUpKonfirmasi"
;
import
CreateCrafmDoc
from
"./CreateCrafmDoc"
;
const
Alert
=
withStyles
({})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
RiskManagement
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
alert
:
false
,
listData
:
[],
id
:
0
,
btncreate
:
false
,
btnview
:
false
,
load
:
false
,
name
:
''
,
userCompActive
:
[],
isHasAccessDocument
:
false
,
submenu_id
:
26
,
submenu_name
:
"internal audit"
,
menu_title
:
"Internal Audit"
}
}
componentDidMount
()
{
// this.getPermission()
this
.
getDataCarfm
();
this
.
getDetailUser
();
}
getDataCarfm
(){
let
payload
=
{
submenu_id
:
this
.
state
.
submenu_id
}
api
.
create
().
getCarfmDocumentBySubmenu
(
payload
).
then
(
response
=>
{
if
(
response
){
if
(
response
.
data
.
status
===
'success'
){
let
dataList
=
[]
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
// if (item.value == "Manual Book TIA 4.0sss") {
dataList
.
push
(
item
)
// }
})
if
(
dataList
.
length
==
0
)
{
this
.
setState
({
isHasAccessDocument
:
dataList
.
length
==
0
?
false
:
true
})
}
else
{
this
.
setState
({
isHasAccessDocument
:
dataList
.
length
==
0
?
false
:
true
,
listData
:
dataList
,
loadTable
:
true
,
refresh
:
''
},
()
=>
{
this
.
getPermission
(
this
.
state
.
submenu_name
)
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
)
}
getPermission
(
subMenu
)
{
let
payload
=
{
menu
:
subMenu
}
api
.
create
().
getPermission
(
payload
).
then
(
response
=>
{
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
setState
({
btncreate
:
response
.
data
.
data
.
create
,
btnview
:
response
.
data
.
data
.
view
,
btndownload
:
response
.
data
.
data
.
download
,
load
:
true
})
console
.
log
(
"btn create "
+
this
.
state
.
btncreate
);
}
else
{
this
.
setState
({
load
:
true
})
}
}
else
{
this
.
setState
({
load
:
true
})
}
})
}
getDetailUser
()
{
let
userId
=
localStorage
.
getItem
(
Constant
.
USER
)
api
.
create
().
getDetailUser
(
userId
).
then
((
response
)
=>
{
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
setState
({
userCompany
:
response
.
data
.
data
.
company
,
visibleTrue
:
false
},
()
=>
{
this
.
getCompanyActive
()
console
.
log
(
this
.
state
.
userCompany
);
})
}
}
}
})
}
getCompanyActive
()
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
console
.
log
(
"getcompanyactive start"
);
console
.
log
(
response
);
console
.
log
(
"getcompanyactive stop"
);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
compActive
=
[]
let
userCompActive
=
[]
this
.
state
.
userCompany
.
map
((
item
,
index
)
=>
{
let
indeks
=
data
.
findIndex
((
val
)
=>
val
.
company_id
==
item
)
if
(
indeks
!==
-
1
&&
String
(
data
[
indeks
].
status
).
toLocaleLowerCase
()
==
'active'
){
userCompActive
.
push
(
item
)
}
})
data
.
map
((
item
,
index
)
=>
{
if
(
String
(
item
.
status
).
toLocaleLowerCase
()
==
'active'
)
{
compActive
.
push
(
item
)
}
})
if
(
compActive
.
length
==
userCompActive
.
length
){
this
.
setState
({
btnadd
:
true
})
}
else
{
this
.
setState
({
btnadd
:
false
})
}
this
.
setState
({
userCompActive
,
visibleTrue
:
true
})
// console.log(userCompActive)
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
visibleTrue
:
true
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
console
.
log
(
"error di getcompany active"
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
listCompany
:
null
,
company
:
null
,
visibleTrue
:
true
})
}
})
}
createUploadDocument
()
{
this
.
setState
({
visibleCreate
:
false
,
konfirmasi
:
false
})
const
formData
=
this
.
state
.
formData
formData
.
append
(
"documentId"
,
this
.
state
.
docId
)
formData
.
append
(
"updated"
,
1
)
this
.
setState
({
loading
:
true
})
api
.
create
().
updateDocument
(
formData
).
then
(
response
=>
{
// console.log(response)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getDataDocument
(
this
.
state
.
settingID
,
this
.
state
.
menuName
)
this
.
setState
({
konfirmasi
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
,
visibleCreate
:
false
,
loading
:
false
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
createDocument
(
payload
)
{
//upload apinya disini
this
.
setState
({
loading
:
true
})
api
.
create
().
uploadCarfmDocument
(
payload
).
then
(
response
=>
{
// console.log(response)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
message
===
"The Document Already Exists in The System, Do You Want to Overwrite It?"
)
{
this
.
setState
({
konfirmasi
:
true
,
formData
:
payload
,
docId
:
response
.
data
.
data
.
document_id
,
loading
:
false
})
}
else
if
(
response
.
data
.
message
===
"Data was Saved Successfully"
)
{
this
.
getDataCarfm
()
this
.
setState
({
visibleCreate
:
false
,
loading
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
handleLoading
(
tipe
)
{
this
.
setState
({
loading
:
tipe
==
0
?
false
:
true
})
}
render
()
{
const
loadingComponent
=
(
<
div
style
=
{{
position
:
'absolute'
,
zIndex
:
1500
,
top
:
0
,
left
:
0
,
width
:
'100%'
,
height
:
'100%'
,
display
:
'flex'
,
justifyContent
:
'center'
,
alignItems
:
'center'
,
background
:
'rgba(255,255,255,0.8)'
}}
>
<
PropagateLoader
// css={override}
size
=
{
20
}
color
=
{
"#274B80"
}
loading
=
{
this
.
state
.
loading
}
/
>
<
/div
>
);
return
(
<
div
style
=
{{
height
:
this
.
props
.
height
,
backgroundColor
:
'#f8f8f8'
}}
>
{
/* {this.props.load && ()} */
}
<
Snackbar
open
=
{
this
.
state
.
alert
}
autoHideDuration
=
{
6000
}
onClose
=
{()
=>
this
.
closeAlert
()}
>
<
Alert
onClose
=
{()
=>
this
.
closeAlert
()}
severity
=
{
this
.
state
.
tipeAlert
}
>
{
this
.
state
.
messageAlert
}
<
/Alert
>
<
/Snackbar
>
<
div
className
=
{
"main-color"
}
style
=
{{
height
:
78
,
display
:
'flex'
,
alignItems
:
'center'
,
paddingLeft
:
20
}}
>
<
Typography
style
=
{{
fontSize
:
'16px'
,
color
:
'white'
}}
>
{
this
.
state
.
menu_title
}
<
/Typography
>
<
/div
>
<
div
style
=
{{
padding
:
20
}}
>
{
this
.
state
.
loading
&&
loadingComponent
&&
this
.
state
.
isHasAccessDocument
}
<
Paper
style
=
{{
padding
:
20
}}
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
}}
>
{(
this
.
state
.
btncreate
)
&&
<
span
>
<
a
data
-
tip
=
{
'Add'
}
data
-
for
=
"add"
>
<
div
style
=
{{
display
:
'grid'
,
justifyContent
:
'flex-end'
}}
>
<
button
type
=
"button"
onClick
=
{()
=>
this
.
setState
({
visibleCreate
:
true
,
refresh
:
''
})}
style
=
{{
marginRight
:
25
,
background
:
'transparent'
}}
>
<
img
src
=
{
Images
.
add
}
/
>
<
/button
>
<
/div
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"add"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
<
/div
>
<
div
style
=
{{
display
:
'flex'
}}
>
{
this
.
state
.
visibleTrue
&&
(
<
TableDocument
data
=
{
this
.
state
.
listData
}
refresh
=
{
this
.
state
.
refresh
}
load
=
{
true
}
userCompActive
=
{
this
.
state
.
userCompActive
}
handleLoading
=
{
this
.
handleLoading
.
bind
(
this
)}
name
=
{
this
.
state
.
name
}
submenu_id
=
{
this
.
state
.
submenu_id
}
btndownload
=
{
this
.
state
.
btndownload
}
/
>
)}
<
/div
>
<
/Paper
>
{
!
this
.
state
.
isHasAccessDocument
&&
(
<
Paper
style
=
{{
padding
:
20
}}
>
<
label
>
You
Don
't Have Any Access in Document Management</label>
</Paper>
)}
</div>
{this.state.konfirmasi && (
<PopUpKonfirmasi
onClickClosePopUp={() => this.setState({ konfirmasi: false })}
uploadDocId={this.createUploadDocument.bind(this)}
/>
)}
{this.state.visibleCreate && (
<CreateCrafmDoc
onClickClose={() => this.setState({ visibleCreate: false })}
// getDataDocument={this.getDataDocument.bind(this)}
createDocument={this.createDocument.bind(this)}
handleLoading={this.handleLoading.bind(this)}
allsubcoCreate={this.state.btnadd}
submenu_id={this.state.submenu_id}
/>
)}
</div>
);
}
}
src/container/CRFM/RiskManagement.js
deleted
100644 → 0
View file @
c4a2ad1c
import
React
,
{
Component
}
from
'react'
import
{
withStyles
}
from
'@material-ui/core/styles'
;
import
{
createMuiTheme
,
MuiThemeProvider
,
Paper
,
Snackbar
,
Tab
,
Tabs
,
Typography
}
from
'@material-ui/core'
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
Constant
from
'../../library/Constant'
;
import
Images
from
'../../assets/Images'
;
import
ReactTooltip
from
'react-tooltip'
;
import
api
from
'../../api'
;
import
PropagateLoader
from
"react-spinners/PropagateLoader"
import
TableDocument
from
"./TableDocument"
;
import
PopUpKonfirmasi
from
"../DocumentManagement/PopUpKonfirmasi"
;
import
CreateCrafmDoc
from
"./CreateCrafmDoc"
;
const
Alert
=
withStyles
({})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
RiskManagement
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
alert
:
false
,
listData
:
[],
id
:
0
,
btncreate
:
false
,
btnview
:
false
,
load
:
false
,
name
:
''
,
userCompActive
:
[],
isHasAccessDocument
:
false
,
submenu_id
:
28
,
submenu_name
:
"risk management"
,
menu_title
:
"Risk Management"
}
}
componentDidMount
()
{
// this.getPermission()
this
.
getDataCarfm
();
this
.
getDetailUser
();
}
getDataCarfm
(){
let
payload
=
{
submenu_id
:
this
.
state
.
submenu_id
}
api
.
create
().
getCarfmDocumentBySubmenu
(
payload
).
then
(
response
=>
{
if
(
response
){
if
(
response
.
data
.
status
===
'success'
){
let
dataList
=
[]
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
// if (item.value == "Manual Book TIA 4.0sss") {
dataList
.
push
(
item
)
// }
})
if
(
dataList
.
length
==
0
)
{
this
.
setState
({
isHasAccessDocument
:
dataList
.
length
==
0
?
false
:
true
})
}
else
{
this
.
setState
({
isHasAccessDocument
:
dataList
.
length
==
0
?
false
:
true
,
listData
:
dataList
,
loadTable
:
true
,
refresh
:
''
},
()
=>
{
this
.
getPermission
(
this
.
state
.
submenu_name
)
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
)
}
getPermission
(
subMenu
)
{
let
payload
=
{
menu
:
subMenu
}
api
.
create
().
getPermission
(
payload
).
then
(
response
=>
{
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
setState
({
btncreate
:
response
.
data
.
data
.
create
,
btnview
:
response
.
data
.
data
.
view
,
btndownload
:
response
.
data
.
data
.
download
,
load
:
true
})
console
.
log
(
"btn create "
+
this
.
state
.
btncreate
);
}
else
{
this
.
setState
({
load
:
true
})
}
}
else
{
this
.
setState
({
load
:
true
})
}
})
}
getDetailUser
()
{
let
userId
=
localStorage
.
getItem
(
Constant
.
USER
)
api
.
create
().
getDetailUser
(
userId
).
then
((
response
)
=>
{
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
setState
({
userCompany
:
response
.
data
.
data
.
company
,
visibleTrue
:
false
},
()
=>
{
this
.
getCompanyActive
()
console
.
log
(
this
.
state
.
userCompany
);
})
}
}
}
})
}
getCompanyActive
()
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
console
.
log
(
"getcompanyactive start"
);
console
.
log
(
response
);
console
.
log
(
"getcompanyactive stop"
);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
compActive
=
[]
let
userCompActive
=
[]
this
.
state
.
userCompany
.
map
((
item
,
index
)
=>
{
let
indeks
=
data
.
findIndex
((
val
)
=>
val
.
company_id
==
item
)
if
(
indeks
!==
-
1
&&
String
(
data
[
indeks
].
status
).
toLocaleLowerCase
()
==
'active'
){
userCompActive
.
push
(
item
)
}
})
data
.
map
((
item
,
index
)
=>
{
if
(
String
(
item
.
status
).
toLocaleLowerCase
()
==
'active'
)
{
compActive
.
push
(
item
)
}
})
if
(
compActive
.
length
==
userCompActive
.
length
){
this
.
setState
({
btnadd
:
true
})
}
else
{
this
.
setState
({
btnadd
:
false
})
}
this
.
setState
({
userCompActive
,
visibleTrue
:
true
})
// console.log(userCompActive)
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
visibleTrue
:
true
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
console
.
log
(
"error di getcompany active"
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
listCompany
:
null
,
company
:
null
,
visibleTrue
:
true
})
}
})
}
createUploadDocument
()
{
this
.
setState
({
visibleCreate
:
false
,
konfirmasi
:
false
})
const
formData
=
this
.
state
.
formData
formData
.
append
(
"documentId"
,
this
.
state
.
docId
)
formData
.
append
(
"updated"
,
1
)
this
.
setState
({
loading
:
true
})
api
.
create
().
updateDocument
(
formData
).
then
(
response
=>
{
// console.log(response)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getDataDocument
(
this
.
state
.
settingID
,
this
.
state
.
menuName
)
this
.
setState
({
konfirmasi
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
,
visibleCreate
:
false
,
loading
:
false
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
createDocument
(
payload
)
{
//upload apinya disini
this
.
setState
({
loading
:
true
})
api
.
create
().
uploadCarfmDocument
(
payload
).
then
(
response
=>
{
// console.log(response)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
message
===
"The Document Already Exists in The System, Do You Want to Overwrite It?"
)
{
this
.
setState
({
konfirmasi
:
true
,
formData
:
payload
,
docId
:
response
.
data
.
data
.
document_id
,
loading
:
false
})
}
else
if
(
response
.
data
.
message
===
"Data was Saved Successfully"
)
{
this
.
getDataCarfm
()
this
.
setState
({
visibleCreate
:
false
,
loading
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
handleLoading
(
tipe
)
{
this
.
setState
({
loading
:
tipe
==
0
?
false
:
true
})
}
render
()
{
const
loadingComponent
=
(
<
div
style
=
{{
position
:
'absolute'
,
zIndex
:
1500
,
top
:
0
,
left
:
0
,
width
:
'100%'
,
height
:
'100%'
,
display
:
'flex'
,
justifyContent
:
'center'
,
alignItems
:
'center'
,
background
:
'rgba(255,255,255,0.8)'
}}
>
<
PropagateLoader
// css={override}
size
=
{
20
}
color
=
{
"#274B80"
}
loading
=
{
this
.
state
.
loading
}
/
>
<
/div
>
);
return
(
<
div
style
=
{{
height
:
this
.
props
.
height
,
backgroundColor
:
'#f8f8f8'
}}
>
{
/* {this.props.load && ()} */
}
<
Snackbar
open
=
{
this
.
state
.
alert
}
autoHideDuration
=
{
6000
}
onClose
=
{()
=>
this
.
closeAlert
()}
>
<
Alert
onClose
=
{()
=>
this
.
closeAlert
()}
severity
=
{
this
.
state
.
tipeAlert
}
>
{
this
.
state
.
messageAlert
}
<
/Alert
>
<
/Snackbar
>
<
div
className
=
{
"main-color"
}
style
=
{{
height
:
78
,
display
:
'flex'
,
alignItems
:
'center'
,
paddingLeft
:
20
}}
>
<
Typography
style
=
{{
fontSize
:
'16px'
,
color
:
'white'
}}
>
{
this
.
state
.
menu_title
}
<
/Typography
>
<
/div
>
<
div
style
=
{{
padding
:
20
}}
>
{
this
.
state
.
loading
&&
loadingComponent
&&
this
.
state
.
isHasAccessDocument
}
<
Paper
style
=
{{
padding
:
20
}}
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
}}
>
{(
this
.
state
.
btncreate
)
&&
<
span
>
<
a
data
-
tip
=
{
'Add'
}
data
-
for
=
"add"
>
<
div
style
=
{{
display
:
'grid'
,
justifyContent
:
'flex-end'
}}
>
<
button
type
=
"button"
onClick
=
{()
=>
this
.
setState
({
visibleCreate
:
true
,
refresh
:
''
})}
style
=
{{
marginRight
:
25
,
background
:
'transparent'
}}
>
<
img
src
=
{
Images
.
add
}
/
>
<
/button
>
<
/div
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"add"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
<
/div
>
<
div
style
=
{{
display
:
'flex'
}}
>
{
this
.
state
.
visibleTrue
&&
(
<
TableDocument
data
=
{
this
.
state
.
listData
}
refresh
=
{
this
.
state
.
refresh
}
load
=
{
true
}
userCompActive
=
{
this
.
state
.
userCompActive
}
handleLoading
=
{
this
.
handleLoading
.
bind
(
this
)}
name
=
{
this
.
state
.
name
}
submenu_id
=
{
this
.
state
.
submenu_id
}
btndownload
=
{
this
.
state
.
btndownload
}
/
>
)}
<
/div
>
<
/Paper
>
{
!
this
.
state
.
isHasAccessDocument
&&
(
<
Paper
style
=
{{
padding
:
20
}}
>
<
label
>
You
Don
't Have Any Access in Document Management</label>
</Paper>
)}
</div>
{this.state.konfirmasi && (
<PopUpKonfirmasi
onClickClosePopUp={() => this.setState({ konfirmasi: false })}
uploadDocId={this.createUploadDocument.bind(this)}
/>
)}
{this.state.visibleCreate && (
<CreateCrafmDoc
onClickClose={() => this.setState({ visibleCreate: false })}
// getDataDocument={this.getDataDocument.bind(this)}
createDocument={this.createDocument.bind(this)}
handleLoading={this.handleLoading.bind(this)}
allsubcoCreate={this.state.btnadd}
submenu_id={this.state.submenu_id}
/>
)}
</div>
);
}
}
src/router/homeRoutes.js
View file @
32145370
...
...
@@ -20,9 +20,7 @@ import SubHolding from '../container/Reports/SubHolding';
import
SummaryTriputra
from
'../container/SummaryTriputra/SummaryOfTriputra'
;
import
MasterDataCAT
from
'../container/MasterData/MasterDataCAT/MasterDataCAT'
;
import
ProgressReport
from
'../container/ProgressReport/ProgressReport'
;
import
InternalAudit
from
"../container/CRFM/InternalAudit"
;
import
AntiFraud
from
"../container/CRFM/AntiFraud"
;
import
RiskManagement
from
"../container/CRFM/RiskManagement"
;
import
CarfmDocument
from
"../container/CRFM/CarfmDocument"
;
const
routes
=
[
{
...
...
@@ -115,15 +113,15 @@ const routes = [
},
{
path
:
"/home/internal-audit"
,
main
:
InternalAudi
t
main
:
CarfmDocumen
t
},
{
path
:
"/home/anti-fraud"
,
main
:
AntiFraud
main
:
CarfmDocument
},
{
path
:
"/home/risk-management"
,
main
:
RiskManage
ment
main
:
CarfmDocu
ment
},
{
path
:
"*"
,
...
...
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