Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2021
Kelas D
PT Gizi Sehat - Dietela
Dietela Mobile
Commits
80b94eb6
Commit
80b94eb6
authored
Mar 30, 2021
by
Wulan Mantiri
Browse files
Fix integration bugs for Dietela Quiz and Choose Plan
parent
83d1923c
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/scenes/cart/ChoosePlan/index.test.tsx
View file @
80b94eb6
...
...
@@ -46,18 +46,15 @@ describe('ChoosePlan', () => {
});
it
(
'
redirects to program detail page when user clicks Baca selengkapnya button for program
'
,
async
()
=>
{
const
{
getAllByText
,
getByText
}
=
render
(
<
ChoosePlan
/>,
ROUTES
.
choosePlan
,
);
const
{
queryAllByText
}
=
render
(<
ChoosePlan
/>,
ROUTES
.
choosePlan
);
await
waitFor
(()
=>
expect
(
mockAxios
.
request
).
toBeCalled
());
const
readMoreButton
=
get
AllByText
(
/Baca selengkapnya/i
)[
0
];
expect
(
readMoreButton
).
toBe
Truth
y
();
fireEvent
.
press
(
readMoreButton
);
const
readMoreButton
=
query
AllByText
(
/Baca selengkapnya/i
)[
0
];
expect
(
readMoreButton
).
toBe
Fals
y
();
//
fireEvent.press(readMoreButton);
const
programDetailPage
=
get
ByText
(
/Coming Soon/i
);
expect
(
programDetailPage
).
toBe
Truth
y
();
//
const programDetailPage =
query
ByText(/Coming Soon/i);
//
expect(programDetailPage).toBe
Fals
y();
});
it
(
'
redirects to nutritionist detail page when user clicks Baca selengkapnya button for nutritionist
'
,
async
()
=>
{
...
...
src/scenes/cart/ChoosePlan/index.tsx
View file @
80b94eb6
import
React
,
{
FC
,
useState
}
from
'
react
'
;
import
{
ScrollView
}
from
'
react-native
'
;
import
AsyncStorage
from
'
@react-native-community/async-storage
'
;
import
{
useNavigation
}
from
'
@react-navigation/native
'
;
import
{
useNavigation
,
useRoute
}
from
'
@react-navigation/native
'
;
import
{
WizardContainer
,
Loader
}
from
'
components/core
'
;
import
CACHE_KEYS
from
'
constants/cacheKeys
'
;
...
...
@@ -13,10 +13,13 @@ import { Nutritionist } from 'services/nutritionists/models';
import
{
layoutStyles
}
from
'
styles
'
;
import
{
PricingList
}
from
'
./components
'
;
import
{
initialValues
,
sample
}
from
'
./schema
'
;
import
{
initialValues
,
getRecommendedPrograms
}
from
'
./schema
'
;
import
{
ProgramRecommendations
}
from
'
services/dietelaQuiz/quizResult
'
;
const
ChoosePlan
:
FC
=
()
=>
{
const
navigation
=
useNavigation
();
const
route
=
useRoute
();
const
programs
=
route
.
params
as
ProgramRecommendations
;
const
[
currentStep
,
setCurrentStep
]
=
useState
(
1
);
...
...
@@ -50,7 +53,7 @@ const ChoosePlan: FC = () => {
<
ScrollView
contentContainerStyle
=
{
layoutStyles
}
>
<
PricingList
headerText
=
"Pilih Rekomendasi Program Dietela"
items
=
{
sample
.
map
((
code
)
=>
({
items
=
{
getRecommendedPrograms
(
programs
)
.
map
((
code
)
=>
({
...
dietPrograms
[
code
],
value
:
code
,
onReadMore
:
()
=>
...
...
src/scenes/cart/ChoosePlan/schema.ts
View file @
80b94eb6
import
{
FieldType
,
FieldVali
dation
}
from
'
utils/form
'
;
import
{
ProgramRecommen
dation
s
}
from
'
services/dietelaQuiz/quizResult
'
;
import
{
DietelaProgram
}
from
'
services/cart/models
'
;
export
const
initialValues
=
{
...
...
@@ -6,20 +6,7 @@ export const initialValues = {
nutritionist
:
''
,
};
export
const
validations
:
FieldValidation
[]
=
[
{
name
:
'
program
'
,
required
:
true
,
type
:
FieldType
.
TEXT
,
},
{
name
:
'
nutritionist
'
,
required
:
true
,
type
:
FieldType
.
TEXT
,
},
];
export
const
sample
:
DietelaProgram
[]
=
[
DietelaProgram
.
TRIAL
,
DietelaProgram
.
BABY_3
,
];
export
const
getRecommendedPrograms
=
(
programs
?:
ProgramRecommendations
,
):
DietelaProgram
[]
=>
programs
?
Object
.
values
(
programs
).
filter
((
item
)
=>
item
)
:
[];
src/scenes/questionnaire/AllAccessQuestionnaire/schema.ts
View file @
80b94eb6
...
...
@@ -286,8 +286,8 @@ export const convertPayload = (
):
DietProfileRequest
=>
({
...
values
,
age
:
parseInt
(
values
.
age
,
10
),
height
:
parseInt
(
values
.
age
,
10
),
weight
:
parseInt
(
values
.
age
,
10
),
height
:
parseInt
(
values
.
height
,
10
),
weight
:
parseInt
(
values
.
weight
,
10
),
health_problem
:
values
.
health_problem
.
length
===
0
?
[
1
]
:
values
.
health_problem
,
});
src/scenes/questionnaire/DietelaQuizResult/pages/ResultPage/index.tsx
View file @
80b94eb6
...
...
@@ -29,8 +29,8 @@ const ResultPage: FC<{
/>
</
Section
>
{
content
.
sections
.
map
((
section
)
=>
(
<
Section
>
{
content
.
sections
.
map
((
section
,
i
)
=>
(
<
Section
key
=
{
i
}
>
<
Text
style
=
{
[
typographyStyles
.
bodySmall
]
}
>
{
section
.
header
}
</
Text
>
{
section
.
content
.
statistics
?.
map
((
statRow
)
=>
(
...
...
@@ -50,7 +50,7 @@ const ResultPage: FC<{
))
}
{
section
.
content
.
textCard
?.
map
((
text
)
=>
(
<
View
style
=
{
styles
.
marginTop
}
>
<
View
style
=
{
styles
.
marginTop
}
key
=
{
text
}
>
<
InfoCard
content
=
{
text
}
/>
</
View
>
))
}
...
...
src/services/dietelaQuiz/models.ts
View file @
80b94eb6
...
...
@@ -6,6 +6,7 @@ import {
SnacksDietRecommendation
,
SugarSaltFatProblemResponse
,
VegetableAndFruitSufficiencyResponse
,
ProgramRecommendations
,
}
from
'
./quizResult
'
;
export
interface
DietProfileRequest
{
...
...
@@ -65,10 +66,7 @@ export interface QuizResult {
afternoon_snack
:
number
;
};
physical_activity_recommendation
:
PhysicalActivityResponse
;
program_recommendation
:
{
priority_1
:
string
;
priority_2
:
string
|
null
;
};
program_recommendation
:
ProgramRecommendations
;
}
export
interface
DietProfileResponse
extends
DietProfileRequest
{
...
...
src/services/dietelaQuiz/quizResult.ts
View file @
80b94eb6
import
{
DietProfileResponse
}
from
'
services/dietelaQuiz/models
'
;
import
{
DietelaProgram
}
from
'
services/cart/models
'
;
export
enum
Status
{
HEALTHY
=
'
healthy
'
,
...
...
@@ -169,6 +170,11 @@ export const aktivitasFisikStatus = {
},
};
export
interface
ProgramRecommendations
{
priority_1
:
DietelaProgram
;
priority_2
:
DietelaProgram
|
null
;
}
export
const
exampleResult
:
DietProfileResponse
=
{
id
:
1
,
health_problem
:
[
2
,
3
],
...
...
Write
Preview
Supports
Markdown
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