Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
PPL Sosial
tbcare
tbcare-web
Commits
34e2a050
Commit
34e2a050
authored
May 30, 2021
by
Sean Zeliq Urian
Browse files
[GREEN] route ActivityLog scene and put it on navbar
parent
d6b893da
Pipeline
#79885
passed with stages
in 4 minutes and 9 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/App/components/Routes/index.tsx
View file @
34e2a050
...
...
@@ -6,7 +6,7 @@ import { Home, AccountManagement, Login, CaseRecapitulation, PositiveCaseInput }
import
{
LocalStorage
}
from
'
services
'
;
import
{
DEFAULT_SECRET_KEY
}
from
'
constant
'
;
import
Layout
from
'
./components/Layout
'
;
import
ActivityLog
from
'
scenes/ActivityLog
/components/ActivityLog
'
;
import
ActivityLog
from
'
scenes/ActivityLog
'
;
export
default
function
Routes
()
{
const
{
user
,
setUser
,
setToken
,
token
,
services
,
alert
}
=
useContext
(
...
...
src/services/hooks/useMainService/index.tsx
View file @
34e2a050
import
{
createEndpoint
,
createDateFilterParam
}
from
'
helper
'
;
import
axios
from
'
axios
'
;
import
{
FilterType
,
StatisticType
,
AgeKeyProps
,
ExportPayload
,
SexKeyProps
,
DistrictKeyProps
,
SubDistrictKeyProps
}
from
'
contexts/AppContext/types
'
;
import
{
DateProps
}
from
'
contexts/AppContext/types
'
;
import
{
createEndpoint
,
createDateFilterParam
}
from
'
helper
'
;
import
{
FilterType
,
StatisticType
,
AgeKeyProps
,
ExportPayload
,
SexKeyProps
,
DistrictKeyProps
,
SubDistrictKeyProps
,
}
from
'
contexts/AppContext/types
'
;
const
API_MAIN_URL
=
process
.
env
.
REACT_APP_API_MAIN_URL
;
...
...
@@ -144,8 +152,8 @@ export default function useMainService(token: string) {
async
function
listInvestigationCases
(
query
:
string
=
''
,
page
:
number
=
1
,
includePositive
:
boolean
=
false
,
page
:
number
=
1
,
includePositive
:
boolean
=
false
)
{
const
endpoint
=
END_POINTS
.
INVESTIGATION_CASES
([
includePositive
...
...
@@ -160,14 +168,18 @@ export default function useMainService(token: string) {
page
:
number
=
1
,
includePositive
:
boolean
=
false
)
{
const
endpoint
=
END_POINTS
.
INVESTIGATION_CASES
(
[
includePositive
?
`?include_positive=true&search=
${
query
}
&page=
${
page
}
`
:
`?search=
${
query
}
&page=
${
page
}
`
]
);
const
endpoint
=
END_POINTS
.
INVESTIGATION_CASES
([
includePositive
?
`?include_positive=true&search=
${
query
}
&page=
${
page
}
`
:
`?search=
${
query
}
&page=
${
page
}
`
,
]);
return
fetchWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
}
async
function
filterInvestigationCases
(
filterType
:
string
,
query
:
string
,
includePositive
:
boolean
=
false
filterType
:
string
,
query
:
string
,
includePositive
:
boolean
=
false
)
{
let
urlQuery
=
''
;
switch
(
filterType
)
{
...
...
@@ -194,9 +206,9 @@ export default function useMainService(token: string) {
break
;
}
const
endpoint
=
END_POINTS
.
INVESTIGATION_CASES
(
[
includePositive
?
`?include_positive=true&
${
urlQuery
}
`
:
`?
${
urlQuery
}
`
]
);
const
endpoint
=
END_POINTS
.
INVESTIGATION_CASES
(
[
includePositive
?
`?include_positive=true&
${
urlQuery
}
`
:
`?
${
urlQuery
}
`
,
]
);
return
fetchWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
}
...
...
@@ -206,21 +218,24 @@ export default function useMainService(token: string) {
}
async
function
createCaseSubject
(
body
:
object
)
{
const
endpoint
=
END_POINTS
.
CASE_SUBJECTS
([
null
])
const
endpoint
=
END_POINTS
.
CASE_SUBJECTS
([
null
])
;
return
fetchWithAuthentication
(
endpoint
,
Method
.
POST
,
body
);
}
async
function
createInvestigationCase
(
body
:
object
)
{
const
endpoint
=
END_POINTS
.
INVESTIGATION_CASES
([
null
])
const
endpoint
=
END_POINTS
.
INVESTIGATION_CASES
([
null
])
;
return
fetchWithAuthentication
(
endpoint
,
Method
.
POST
,
body
);
}
async
function
createMonitoringCase
(
body
:
object
)
{
const
endpoint
=
END_POINTS
.
MONITORING_CASES
([
null
])
const
endpoint
=
END_POINTS
.
MONITORING_CASES
([
null
])
;
return
fetchWithAuthentication
(
endpoint
,
Method
.
POST
,
body
);
}
async
function
listNotCheckedMonitoringCase
(
query
:
string
=
''
,
page
:
number
=
1
)
{
async
function
listNotCheckedMonitoringCase
(
query
:
string
=
''
,
page
:
number
=
1
)
{
const
endpoint
=
END_POINTS
.
MONITORING_CASES
([
`?page=
${
page
}
&search=
${
query
}
&is_checked=false`
,
]);
...
...
@@ -229,24 +244,22 @@ export default function useMainService(token: string) {
async
function
searchNotCheckedMonitoringCase
(
query
:
string
=
''
)
{
const
endpoint
=
END_POINTS
.
MONITORING_CASES
([
`?search=
${
query
}
&is_checked=false`
`?search=
${
query
}
&is_checked=false`
,
]);
return
fetchWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
}
async
function
editInvestigationCase
(
id
:
string
,
body
:
object
)
{
const
endpoint
=
END_POINTS
.
INVESTIGATION_CASES
([
id
]);
return
fetchWithAuthentication
(
endpoint
,
Method
.
PUT
,
body
);
return
fetchWithAuthentication
(
endpoint
,
Method
.
PUT
,
body
);
}
async
function
editMonitoringCase
(
id
:
string
,
body
:
object
)
{
const
endpoint
=
END_POINTS
.
MONITORING_CASES
([
id
]);
return
fetchWithAuthentication
(
endpoint
,
Method
.
PUT
,
body
);
return
fetchWithAuthentication
(
endpoint
,
Method
.
PUT
,
body
);
}
async
function
fetchStatistics
(
filter
:
ExportPayload
)
{
async
function
fetchStatistics
(
filter
:
ExportPayload
)
{
let
urlQuery
=
'
?
'
;
switch
(
filter
?.
filterType
)
{
case
StatisticType
.
Sex
:
...
...
@@ -263,10 +276,11 @@ export default function useMainService(token: string) {
break
;
case
StatisticType
.
Age
:
const
ageKey
=
filter
?.
filters
as
AgeKeyProps
;
urlQuery
=
`?min_age=
${
ageKey
.
minAge
}
&max_age=
${
ageKey
.
maxAge
}
`
;
urlQuery
=
`?min_age=
${
ageKey
.
minAge
}
&max_age=
${
ageKey
.
maxAge
}
`
;
}
urlQuery
+=
"
&
"
+
createDateFilterParam
(
filter
?.
start_date
,
filter
?.
end_date
)
urlQuery
+=
'
&
'
+
createDateFilterParam
(
filter
?.
start_date
,
filter
?.
end_date
);
const
endpoint
=
END_POINTS
.
EXPORTABLES
([
`
${
urlQuery
}
`
]);
return
fetchWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
...
...
@@ -274,17 +288,17 @@ export default function useMainService(token: string) {
async
function
exportCSV
()
{
const
endpoint
=
END_POINTS
.
EXPORTABLES
([
'
investigation-cases-csv
'
]);
return
downloadWithAuthentication
(
endpoint
,
Method
.
GET
);
return
downloadWithAuthentication
(
endpoint
,
Method
.
GET
);
}
async
function
exportXLS
()
{
const
endpoint
=
END_POINTS
.
EXPORTABLES
([
'
investigation-cases-csv?download_as_xls=1
'
]);
return
downloadWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
const
endpoint
=
END_POINTS
.
EXPORTABLES
([
'
investigation-cases-csv?download_as_xls=1
'
,
]);
return
downloadWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
}
async
function
filterExportCSV
(
filter
:
ExportPayload
)
{
async
function
filterExportCSV
(
filter
:
ExportPayload
)
{
let
urlQuery
=
'
?
'
;
switch
(
filter
.
filterType
)
{
case
StatisticType
.
Sex
:
...
...
@@ -301,18 +315,19 @@ export default function useMainService(token: string) {
break
;
case
StatisticType
.
Age
:
const
ageKey
=
filter
.
filters
as
AgeKeyProps
;
urlQuery
=
`?min_age=
${
ageKey
.
minAge
}
&max_age=
${
ageKey
.
maxAge
}
`
;
urlQuery
=
`?min_age=
${
ageKey
.
minAge
}
&max_age=
${
ageKey
.
maxAge
}
`
;
}
urlQuery
+=
"
&
"
+
createDateFilterParam
(
filter
?.
start_date
,
filter
?.
end_date
)
urlQuery
+=
'
&
'
+
createDateFilterParam
(
filter
?.
start_date
,
filter
?.
end_date
);
const
endpoint
=
END_POINTS
.
EXPORTABLES
([
`investigation-cases-csv
${
urlQuery
}
`
]);
return
downloadWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
const
endpoint
=
END_POINTS
.
EXPORTABLES
([
`investigation-cases-csv
${
urlQuery
}
`
,
]);
return
downloadWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
}
async
function
filterExportXLS
(
filter
:
ExportPayload
)
{
async
function
filterExportXLS
(
filter
:
ExportPayload
)
{
let
urlQuery
=
'
?
'
;
switch
(
filter
.
filterType
)
{
case
StatisticType
.
Sex
:
...
...
@@ -329,37 +344,43 @@ export default function useMainService(token: string) {
break
;
case
StatisticType
.
Age
:
const
ageKey
=
filter
.
filters
as
AgeKeyProps
;
urlQuery
=
`?min_age=
${
ageKey
.
minAge
}
&max_age=
${
ageKey
.
maxAge
}
`
;
urlQuery
=
`?min_age=
${
ageKey
.
minAge
}
&max_age=
${
ageKey
.
maxAge
}
`
;
}
urlQuery
+=
"
&
"
+
createDateFilterParam
(
filter
?.
start_date
,
filter
?.
end_date
)
const
endpoint
=
END_POINTS
.
EXPORTABLES
([
`investigation-cases-csv
${
urlQuery
}
&download_as_xls=1`
]);
return
downloadWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
urlQuery
+=
'
&
'
+
createDateFilterParam
(
filter
?.
start_date
,
filter
?.
end_date
);
const
endpoint
=
END_POINTS
.
EXPORTABLES
([
`investigation-cases-csv
${
urlQuery
}
&download_as_xls=1`
,
]);
return
downloadWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
}
async
function
getLog
(
page
:
number
)
{
if
(
page
===
1
)
{
const
endpoint
=
END_POINTS
.
LOGS
([
null
,
])
return
fetchWithAuthentication
(
endpoint
,
Method
.
GET
);
async
function
getLog
(
page
:
number
,
roleFilterQuery
:
String
,
start_date
:
String
,
end_date
:
String
,
ignoreDateFilterQuery
:
boolean
)
{
let
param
=
"
?page=
"
+
page
+
"
&
"
;
if
(
roleFilterQuery
!==
"
Semua Peran
"
)
{
param
+=
"
is_admin=
"
+
(
roleFilterQuery
.
toLowerCase
()
===
"
admin
"
)
+
"
&
"
;
}
if
(
!
ignoreDateFilterQuery
)
{
param
+=
"
start_date=
"
+
start_date
+
"
&
"
;
param
+=
"
end_date=
"
+
end_date
;
}
const
endpointWithPaging
=
END_POINTS
.
LOGS
([
`?page=
${
page
}
`
,
])
return
fetchWithAuthentication
(
endpointWithPaging
.
slice
(
0
,
-
1
),
Method
.
GET
,
);
const
endpointWithPaging
=
END_POINTS
.
LOGS
([
param
]);
console
.
log
(
endpointWithPaging
)
return
fetchWithAuthentication
(
endpointWithPaging
.
slice
(
0
,
-
1
),
Method
.
GET
);
}
async
function
fetchStatisticsByDate
(
start_date
:
string
,
end_date
:
string
)
{
async
function
fetchStatisticsByDate
(
start_date
:
string
,
end_date
:
string
)
{
let
urlQuery
=
`?start_date=
${
start_date
}
&end_date=
${
end_date
}
`
;
const
endpoint
=
END_POINTS
.
EXPORTABLES
([
`
${
urlQuery
}
`
]);
return
fetchWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
return
fetchWithAuthentication
(
endpoint
.
slice
(
0
,
-
1
),
Method
.
GET
);
}
return
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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