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-mobile
Commits
2a5e0eb3
Commit
2a5e0eb3
authored
Jun 04, 2020
by
Nandhika Prayoga
Committed by
Irwanto
Jun 04, 2020
Browse files
Form and log fixes
parent
0f7bca7e
Changes
21
Hide whitespace changes
Inline
Side-by-side
android/app/build.gradle
View file @
2a5e0eb3
...
...
@@ -144,8 +144,8 @@ android {
applicationId
"com.tbcare"
minSdkVersion
rootProject
.
ext
.
minSdkVersion
targetSdkVersion
rootProject
.
ext
.
targetSdkVersion
versionCode
2
versionName
"1.
0.1
"
versionCode
3
versionName
"1.
1.0
"
}
splits
{
abi
{
...
...
src/components/CheckList/index.tsx
View file @
2a5e0eb3
...
...
@@ -43,7 +43,6 @@ export default function CheckList({
}
useEffect
(()
=>
{
console
.
log
(
flags
)
updateValue
(
list
.
reduce
((
currentList
:
Array
<
Item
>
,
item
:
Array
<
Item
>
,
index
:
number
)
=>
{
if
(
flags
[
index
])
{
return
[
...
...
src/components/DatePicker/__snapshots__/index.test.tsx.snap
View file @
2a5e0eb3
...
...
@@ -163,7 +163,7 @@ exports[`DatePicker tests renders correctly 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
src/components/Field/index.tsx
View file @
2a5e0eb3
...
...
@@ -77,6 +77,10 @@ function Field({
}
},
[])
const
trimLeadingSpace
=
(
value
:
string
)
=>
{
return
value
.
replace
(
/^
\s
+/g
,
''
)
}
return
(
<
Box
axis
=
{
Box
.
Axis
.
Vertical
}
...
...
@@ -107,7 +111,7 @@ function Field({
<
StyledPicker
mode
=
"dropdown"
selectedValue
=
{
innerValue
}
onValueChange
=
{
(
itemValue
)
=>
setInnerValue
(
itemValue
)
}
onValueChange
=
{
(
itemValue
)
=>
setInnerValue
(
trimLeadingSpace
(
itemValue
)
)
}
>
{
values
.
map
((
pair
,
index
)
=>
{
return
(
...
...
@@ -122,7 +126,7 @@ function Field({
)
:
(
<
StyledField
value
=
{
innerValue
}
onChangeText
=
{
newValue
=>
setInnerValue
(
newValue
)
}
onChangeText
=
{
newValue
=>
setInnerValue
(
trimLeadingSpace
(
newValue
)
)
}
numberOfLines
=
{
numberOfLines
}
multiline
=
{
type
===
Type
.
TextArea
}
secureTextEntry
=
{
shouldSecure
}
...
...
src/helpers/hooks/useFormState/index.tsx
View file @
2a5e0eb3
...
...
@@ -81,7 +81,9 @@ function formManipulator(form: FormProps, action: ActionType) {
const
type
=
newForm
.
fields
[
action
.
field
.
name
].
type
;
const
priorityPattern
=
newForm
.
fields
[
action
.
field
.
name
].
pattern
;
newForm
.
fields
[
action
.
field
.
name
].
value
=
action
.
field
.
value
;
newForm
.
fields
[
action
.
field
.
name
].
value
=
typeof
action
.
field
.
value
===
'
string
'
?
action
.
field
.
value
.
replace
(
/^
\s
+/
,
''
).
replace
(
/
\s
+$/
,
''
)
:
action
.
field
.
value
newForm
.
fields
[
action
.
field
.
name
].
isValid
=
selectFieldPattern
(
type
,
priorityPattern
).
test
(
action
.
field
.
value
)
newForm
.
isValid
=
validateForm
(
newForm
.
fields
);
...
...
src/scenes/ContactInvestigationFormStep2/index.tsx
View file @
2a5e0eb3
...
...
@@ -97,8 +97,8 @@ const ContactInvestigationFormStep2 = () => {
setField
(
"
sub_district
"
,
case_subject
.
sub_district
)
setField
(
"
case_relation
"
,
case_relation
)
}
else
{
setField
(
"
district
"
,
KELURAHAN_VALUES
[
0
].
value
)
setField
(
"
sub_
district
"
,
KECAMATAN_VALUES
[
0
].
value
)
setField
(
"
sub_
district
"
,
KELURAHAN_VALUES
[
0
].
value
)
setField
(
"
district
"
,
KECAMATAN_VALUES
[
0
].
value
)
setField
(
"
case_relation
"
,
JENIS_KONTAK_VALUES
[
0
].
value
)
}
},
[])
...
...
@@ -158,19 +158,19 @@ const ContactInvestigationFormStep2 = () => {
<
Gap
axis
=
{
2
}
gap
=
{
15
}
/>
<
Field
name
=
"Kelurahan"
value
=
{
form
.
fields
.
district
.
value
||
KELURAHAN_VALUES
[
0
].
value
}
value
=
{
form
.
fields
.
sub_
district
.
value
||
KELURAHAN_VALUES
[
0
].
value
}
type
=
{
Field
.
Type
.
Dropdown
}
isRequired
values
=
{
KELURAHAN_VALUES
}
updateValue
=
{
val
=>
onFormChange
(
'
district
'
,
val
)
}
updateValue
=
{
val
=>
onFormChange
(
'
sub_
district
'
,
val
)
}
/>
<
Field
name
=
"Kecamatan"
isRequired
value
=
{
form
.
fields
.
sub_
district
.
value
||
KECAMATAN_VALUES
[
0
].
value
}
value
=
{
form
.
fields
.
district
.
value
||
KECAMATAN_VALUES
[
0
].
value
}
type
=
{
Field
.
Type
.
Dropdown
}
values
=
{
KECAMATAN_VALUES
}
updateValue
=
{
val
=>
onFormChange
(
'
sub_
district
'
,
val
)
}
updateValue
=
{
val
=>
onFormChange
(
'
district
'
,
val
)
}
/>
<
Field
name
=
"Jenis Kontak"
...
...
src/scenes/ContactInvestigationFormStep3/index.test.tsx
View file @
2a5e0eb3
...
...
@@ -162,7 +162,6 @@ it('success insert data, update field, and insert data to cache', () => {
const
riskField
=
instance
.
root
.
find
(
elem
=>
elem
.
props
.
name
===
"
Faktor Risiko
"
);
expect
(
riskField
).
toBeTruthy
();
console
.
log
(
symptomsField
.
props
.
values
)
expect
(
symptomsField
.
props
.
values
).
toStrictEqual
([
false
]);
expect
(
riskField
.
props
.
values
).
toStrictEqual
([
false
]);
...
...
src/scenes/ContactInvestigationFormStep3/index.tsx
View file @
2a5e0eb3
...
...
@@ -45,7 +45,6 @@ const ContactInvestigationFormStep3 = () => {
risk_factors
,
},
}
=
global
.
cache
console
.
log
(
medical_symptoms
)
setField
(
"
medical_symptoms
"
,
JSON
.
stringify
(
medical_symptoms
))
setField
(
"
risk_factors
"
,
JSON
.
stringify
(
risk_factors
))
}
...
...
src/scenes/Home/components/Log/index.tsx
View file @
2a5e0eb3
...
...
@@ -73,40 +73,43 @@ const Log = () => {
useEffect
(()
=>
{
setIsLoaded
(
false
);
const
getLog
=
main
.
getLog
(
page
);
getLog
.
then
(
async
logRes
=>
{
logRes
.
data
.
previous
===
null
?
setIsMin
(
true
)
:
setIsMin
(
false
);
logRes
.
data
.
next
===
null
?
setIsMax
(
true
)
:
setIsMax
(
false
);
const
tempLogList
=
logRes
.
data
.
results
.
filter
((
log
:
LogType
)
=>
{
return
log
.
model_name
===
'
Investigation Case
'
;
});
let
latestObjects
:
LogType
[]
=
[];
for
(
let
log
of
tempLogList
)
{
setModalLatest
(
prevArray
=>
[...
prevArray
,
false
]);
let
currentObj
=
latestObjects
.
find
(
obj
=>
obj
.
object_id
===
log
.
object_id
,
);
if
(
currentObj
)
{
if
(
new
Date
(
currentObj
.
recorded_at
)
<
new
Date
(
log
.
recorded_at
))
{
latestObjects
=
latestObjects
.
filter
(
item
=>
item
!==
currentObj
);
tempLogList
.
find
(
item
=>
item
===
currentObj
).
latest
=
false
;
const
fetchLogs
=
async
()
=>
{
const
logsRes
=
await
main
.
getLog
(
page
,
"
Investigation Case
"
);
if
(
logsRes
.
status
===
200
)
{
logsRes
.
data
.
previous
===
null
?
setIsMin
(
true
)
:
setIsMin
(
false
);
logsRes
.
data
.
next
===
null
?
setIsMax
(
true
)
:
setIsMax
(
false
);
const
tempLogList
=
logsRes
.
data
.
results
.
filter
((
log
:
LogType
)
=>
{
return
log
.
model_name
===
'
Investigation Case
'
;
});
let
latestObjects
:
LogType
[]
=
[];
for
(
let
log
of
tempLogList
)
{
setModalLatest
(
prevArray
=>
[...
prevArray
,
false
]);
let
currentObj
=
latestObjects
.
find
(
obj
=>
obj
.
object_id
===
log
.
object_id
,
);
if
(
currentObj
)
{
if
(
new
Date
(
currentObj
.
recorded_at
)
<
new
Date
(
log
.
recorded_at
))
{
latestObjects
=
latestObjects
.
filter
(
item
=>
item
!==
currentObj
);
tempLogList
.
find
(
item
=>
item
===
currentObj
).
latest
=
false
;
}
}
else
{
latestObjects
.
push
(
log
);
log
.
latest
=
true
;
}
}
else
{
latestObjects
.
push
(
log
);
log
.
latest
=
true
;
}
for
(
let
log
of
tempLogList
)
{
const
caseResponse
=
await
main
.
getInvestigationCase
(
log
.
object_id
);
log
.
case_object
=
caseResponse
.
data
;
}
setLogList
(
tempLogList
);
}
for
(
let
log
of
tempLogList
)
{
const
caseResponse
=
await
main
.
getInvestigationCase
(
log
.
object_id
);
log
.
case_object
=
caseResponse
.
data
;
}
setLogList
(
tempLogList
);
setIsLoaded
(
true
);
});
}
fetchLogs
()
},
[
page
]);
if
(
!
isLoaded
)
{
...
...
@@ -204,15 +207,15 @@ const Log = () => {
})
}
</
Box
>
<
Box
width
=
"100%"
>
{
!
isM
ax
?
(
<
Button
id
=
"prev"
onPress
=
{
()
=>
setPage
(
page
+
1
)
}
>
<
Sebelumnya
{
!
isM
in
?
(
<
Button
width
=
"100%"
id
=
"prev"
onPress
=
{
()
=>
setPage
(
page
+
1
)
}
>
Sebelumnya
</
Button
>
)
:
null
}
<
Gap
axis
=
{
Gap
.
Axis
.
Horizontal
}
gap
=
{
5
}
/>
{
!
isM
in
?
(
<
Button
id
=
"next"
onPress
=
{
()
=>
setPage
(
page
-
1
)
}
>
Selanjutnya
>
{
!
isM
ax
?
(
<
Button
width
=
"100%"
id
=
"next"
onPress
=
{
()
=>
setPage
(
page
-
1
)
}
>
Selanjutnya
</
Button
>
)
:
null
}
</
Box
>
...
...
src/scenes/LoginPage/__snapshots__/index.test.tsx.snap
View file @
2a5e0eb3
...
...
@@ -953,10 +953,10 @@ exports[`insert invalid username and password 1`] = `
style={
Object {
"alignItems": "center",
"backgroundColor": "
#42c41d
",
"borderColor": "
transparent
",
"backgroundColor": "
transparent
",
"borderColor": "
#42c41d
",
"borderRadius": 3,
"borderWidth": 0,
"borderWidth": 0
.8
,
"flexBasis": "auto",
"flexGrow": 1,
"flexShrink": 0,
...
...
@@ -1977,10 +1977,10 @@ exports[`insert username and password correctly 1`] = `
style={
Object {
"alignItems": "center",
"backgroundColor": "
#42c41d
",
"borderColor": "
transparent
",
"backgroundColor": "
transparent
",
"borderColor": "
#42c41d
",
"borderRadius": 3,
"borderWidth": 0,
"borderWidth": 0
.8
,
"flexBasis": "auto",
"flexGrow": 1,
"flexShrink": 0,
...
...
@@ -3001,10 +3001,10 @@ exports[`inserts invalid (length<8) password 1`] = `
style={
Object {
"alignItems": "center",
"backgroundColor": "
#42c41d
",
"borderColor": "
transparent
",
"backgroundColor": "
transparent
",
"borderColor": "
#42c41d
",
"borderRadius": 3,
"borderWidth": 0,
"borderWidth": 0
.8
,
"flexBasis": "auto",
"flexGrow": 1,
"flexShrink": 0,
...
...
@@ -4025,10 +4025,10 @@ exports[`press signup button 1`] = `
style={
Object {
"alignItems": "center",
"backgroundColor": "
#42c41d
",
"borderColor": "
transparent
",
"backgroundColor": "
transparent
",
"borderColor": "
#42c41d
",
"borderRadius": 3,
"borderWidth": 0,
"borderWidth": 0
.8
,
"flexBasis": "auto",
"flexGrow": 1,
"flexShrink": 0,
...
...
@@ -5049,10 +5049,10 @@ exports[`renders correctly 1`] = `
style={
Object {
"alignItems": "center",
"backgroundColor": "
#42c41d
",
"borderColor": "
transparent
",
"backgroundColor": "
transparent
",
"borderColor": "
#42c41d
",
"borderRadius": 3,
"borderWidth": 0,
"borderWidth": 0
.8
,
"flexBasis": "auto",
"flexGrow": 1,
"flexShrink": 0,
...
...
src/scenes/LoginPage/index.test.tsx
View file @
2a5e0eb3
...
...
@@ -21,7 +21,6 @@ const testProps = {
},
setAlert
:
(
alert
:
string
)
=>
testProps
.
alert
=
alert
,
setToken
:
(
newToken
:
string
)
=>
{
console
.
log
(
newToken
)
testProps
.
token
=
newToken
},
shouldLoading
:
false
,
...
...
src/scenes/LoginPage/index.tsx
View file @
2a5e0eb3
...
...
@@ -106,7 +106,6 @@ const LoginPage = () => {
});
setShouldLoading
(
false
)
console
.
log
(
loginRes
)
if
(
loginRes
===
undefined
)
{
setAlert
({
...
...
@@ -139,7 +138,7 @@ const LoginPage = () => {
<
Button
id
=
"signup"
clickable
=
{
!
shouldLoading
}
type
=
{
Button
.
Type
.
Filled
}
type
=
{
Button
.
Type
.
Outline
}
onPress
=
{
()
=>
navigation
.
navigate
(
'
officer-signup-form
'
)
}
>
Ajukan Akun Kader
</
Button
>
...
...
src/scenes/MonitoringMedicalCheck/__snapshots__/index.test.tsx.snap
View file @
2a5e0eb3
...
...
@@ -909,7 +909,7 @@ exports[`can press previous button 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -2365,7 +2365,7 @@ exports[`renders correctly 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -3821,7 +3821,7 @@ exports[`renders form with correct fields 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -5277,7 +5277,7 @@ exports[`submit data succesfully 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
src/scenes/MonitoringMedicalResume/__snapshots__/index.test.tsx.snap
View file @
2a5e0eb3
...
...
@@ -663,7 +663,7 @@ exports[`can press previous button 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -881,7 +881,7 @@ exports[`can press previous button 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -2070,7 +2070,7 @@ exports[`renders correctly 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -2288,7 +2288,7 @@ exports[`renders correctly 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -3477,7 +3477,7 @@ exports[`renders form with correct fields 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -3695,7 +3695,7 @@ exports[`renders form with correct fields 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -4884,7 +4884,7 @@ exports[`submit data succesfully 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
@@ -5102,7 +5102,7 @@ exports[`submit data succesfully 1`] = `
]
}
>
5/8
/2020
6/4
/2020
</Text>
</View>
<View
...
...
src/scenes/MonitoringSelection/__snapshots__/index.test.tsx.snap
View file @
2a5e0eb3
...
...
@@ -910,6 +910,7 @@ exports[`changes pages correctly 1`] = `
Array [
Object {
"alignItems": "flex-end",
"width": "100%",
},
]
}
...
...
@@ -941,7 +942,7 @@ exports[`changes pages correctly 1`] = `
"paddingLeft": 24,
"paddingRight": 24,
"paddingTop": 8,
"width": "
auto
",
"width": "
100%
",
}
}
>
...
...
@@ -961,7 +962,7 @@ exports[`changes pages correctly 1`] = `
]
}
>
Pantau Kasus
>
Pantau Kasus
</Text>
</View>
</View>
...
...
@@ -1910,6 +1911,7 @@ exports[`determines state_1 correctly 1`] = `
Array [
Object {
"alignItems": "flex-end",
"width": "100%",
},
]
}
...
...
@@ -1941,7 +1943,7 @@ exports[`determines state_1 correctly 1`] = `
"paddingLeft": 24,
"paddingRight": 24,
"paddingTop": 8,
"width": "
auto
",
"width": "
100%
",
}
}
>
...
...
@@ -1961,7 +1963,7 @@ exports[`determines state_1 correctly 1`] = `
]
}
>
Pantau Kasus
>
Pantau Kasus
</Text>
</View>
</View>
...
...
@@ -2910,6 +2912,7 @@ exports[`determines state_2 correctly 1`] = `
Array [
Object {
"alignItems": "flex-end",
"width": "100%",
},
]
}
...
...
@@ -2941,7 +2944,7 @@ exports[`determines state_2 correctly 1`] = `
"paddingLeft": 24,
"paddingRight": 24,
"paddingTop": 8,
"width": "
auto
",
"width": "
100%
",
}
}
>
...
...
@@ -2961,7 +2964,7 @@ exports[`determines state_2 correctly 1`] = `
]
}
>
Pantau Kasus
>
Pantau Kasus
</Text>
</View>
</View>
...
...
@@ -3910,6 +3913,7 @@ exports[`determines state_3 correctly 1`] = `
Array [
Object {
"alignItems": "flex-end",
"width": "100%",
},
]
}
...
...
@@ -3941,7 +3945,7 @@ exports[`determines state_3 correctly 1`] = `
"paddingLeft": 24,
"paddingRight": 24,
"paddingTop": 8,
"width": "
auto
",
"width": "
100%
",
}
}
>
...
...
@@ -3961,7 +3965,7 @@ exports[`determines state_3 correctly 1`] = `
]
}
>
Pantau Kasus
>
Pantau Kasus
</Text>
</View>
</View>
...
...
@@ -4910,6 +4914,7 @@ exports[`determines state_4 correctly 1`] = `
Array [
Object {
"alignItems": "flex-end",
"width": "100%",
},
]
}
...
...
@@ -4941,7 +4946,7 @@ exports[`determines state_4 correctly 1`] = `
"paddingLeft": 24,
"paddingRight": 24,
"paddingTop": 8,
"width": "
auto
",
"width": "
100%
",
}
}
>
...
...
@@ -4961,7 +4966,7 @@ exports[`determines state_4 correctly 1`] = `
]
}
>
Pantau Kasus
>
Pantau Kasus
</Text>
</View>
</View>
...
...
@@ -5910,6 +5915,7 @@ exports[`renders correctly 1`] = `
Array [
Object {
"alignItems": "flex-end",
"width": "100%",
},
]
}
...
...
@@ -5941,7 +5947,7 @@ exports[`renders correctly 1`] = `
"paddingLeft": 24,
"paddingRight": 24,
"paddingTop": 8,
"width": "
auto
",
"width": "
100%
",
}
}
>
...
...
@@ -5961,7 +5967,7 @@ exports[`renders correctly 1`] = `
]
}
>
Pantau Kasus
>
Pantau Kasus
</Text>
</View>
</View>
...
...
@@ -6910,6 +6916,7 @@ exports[`succesfully searches monitoring case 1`] = `
Array [
Object {
"alignItems": "flex-end",
"width": "100%",
},
]
}
...
...
@@ -6941,7 +6948,7 @@ exports[`succesfully searches monitoring case 1`] = `
"paddingLeft": 24,
"paddingRight": 24,
"paddingTop": 8,
"width": "
auto
",
"width": "
100%
",
}
}
>
...
...
@@ -6961,7 +6968,7 @@ exports[`succesfully searches monitoring case 1`] = `
]
}
>
Pantau Kasus
>
Pantau Kasus
</Text>
</View>
</View>
...
...
@@ -7910,6 +7917,7 @@ exports[`successfully fetches monitoring cases 1`] = `
Array [
Object {
"alignItems": "flex-end",
"width": "100%",
},
]
}
...
...
@@ -7941,7 +7949,7 @@ exports[`successfully fetches monitoring cases 1`] = `
"paddingLeft": 24,