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 KI Ganjil 2021 2022
Clicks - Ecosystem Business
clicks-frontend
Commits
0029cee5
Commit
0029cee5
authored
Dec 05, 2021
by
Abraham Rudolf Brahmana
Browse files
feat: Add visual feedback to rate ecosystem
parent
7f1462a2
Pipeline
#89052
passed with stage
in 10 minutes and 51 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/components/RatingForm.tsx
View file @
0029cee5
import
React
from
"
react
"
;
import
{
View
,
StyleSheet
}
from
"
react-native
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
View
,
StyleSheet
,
ActivityIndicator
}
from
"
react-native
"
;
import
{
Rating
}
from
"
react-native-ratings
"
;
import
Colors
from
"
../constants/Colors
"
;
import
SmallButton
from
"
./button/SmallButton
"
;
import
Spacer
from
"
./Spacer/Spacer
"
;
type
props
=
{
rating
:
number
;
setRating
:
React
.
Dispatch
<
React
.
SetStateAction
<
number
>>
;
onSubmit
:
()
=>
void
;
onSubmit
:
()
=>
Promise
<
void
>
;
setIsRating
:
React
.
Dispatch
<
React
.
SetStateAction
<
boolean
>>
;
};
const
RatingForm
=
({
rating
,
setRating
,
onSubmit
}:
props
)
=>
{
const
RatingForm
=
({
rating
,
setRating
,
onSubmit
,
setIsRating
}:
props
)
=>
{
const
[
isSubmitting
,
setIsSubmitting
]
=
useState
(
false
);
const
onPressHandler
=
async
()
=>
{
setIsSubmitting
(
true
);
await
onSubmit
();
setIsSubmitting
(
false
);
setIsRating
(
false
);
};
return
(
<
View
style
=
{
styles
.
container
}
>
<
Rating
...
...
@@ -19,11 +30,19 @@ const RatingForm = ({ rating, setRating, onSubmit }: props) => {
style
=
{
{
paddingVertical
:
10
}
}
/>
<
Spacer
variant
=
{
"
l
"
}
/>
<
SmallButton
text
=
{
"
Submit Rating
"
}
onPress
=
{
onSubmit
}
colors
=
{
"
primary
"
}
/>
{
!
isSubmitting
?
(
<
SmallButton
text
=
{
"
Submit Rating
"
}
onPress
=
{
()
=>
onPressHandler
()
}
colors
=
{
"
primary
"
}
/>
)
:
(
<
ActivityIndicator
size
=
{
"
large
"
}
animating
=
{
true
}
color
=
{
Colors
.
button
.
primary
.
bg
}
/>
)
}
</
View
>
);
};
...
...
src/screens/ecosystem/EcosystemDetailScreen.tsx
View file @
0029cee5
...
...
@@ -179,8 +179,9 @@ const EcosystemDetailScreen = ({
<
RatingForm
rating
=
{
currentRating
}
setRating
=
{
setCurrentRating
}
onSubmit
=
{
()
=>
{
rateEcosystem
(
id
,
user
.
id
,
currentRating
);
setIsRating
=
{
setIsRating
}
onSubmit
=
{
async
()
=>
{
await
rateEcosystem
(
id
,
user
.
id
,
currentRating
);
}
}
/>
)
}
...
...
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