Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier506 committed Dec 8, 2021
2 parents d075571 + b3dae08 commit e915e7b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
20 changes: 17 additions & 3 deletions webapp/src/routes/BlockProducers/BlockProducerProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ const BlockProducerProfile = () => {
bpRated = rate
}
})

setMyRating(bpRated?.ratings)

const userDataSet = getBPRadarData({
colorString: 'myRate',
name: t('myRate'),
Expand Down Expand Up @@ -168,6 +170,12 @@ const BlockProducerProfile = () => {
({ owner }) => owner === account
)

if (!bp) {
await setProducer(account)

return
}

setProducer(bp, true)
setProfileData(bp)

Expand All @@ -181,7 +189,7 @@ const BlockProducerProfile = () => {
}, [account])

useEffect(() => {
if (!state.blockProducer || !state.user) return
if (!state.blockProducer) return

setProfileData(state?.blockProducer)
}, [state.blockProducer, state.user])
Expand Down Expand Up @@ -301,8 +309,14 @@ const BlockProducerProfile = () => {
rows={[
{
rater: t('myRate'),
amount: 1,
average: getMyRatingAverage(myRating)
amount: isRated ? 1 : 0,
average: getMyRatingAverage({
community: myRating?.community,
development: myRating?.development,
infrastructure: myRating?.infrastructure,
transparency: myRating?.transparency,
trustiness: myRating?.trustiness
})
},
{
rater: t('eosRates'),
Expand Down
18 changes: 14 additions & 4 deletions webapp/src/routes/BlockProducers/BlockProducerRate.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ const Alert = forwardRef(function Alert(props, ref) {
return <MuiAlert elevation={6} ref={ref} variant='filled' {...props} />
})

const RadarSection = ({ t, state, myRating, polarChartData, classes }) => (
const RadarSection = ({
t,
state,
myRating,
polarChartData,
classes,
isRated
}) => (
<>
<Grid className={classes.chartWrapperSliderView} item md={12} xs={12}>
<PolarChart data={polarChartData} showLegend />
Expand All @@ -62,7 +69,7 @@ const RadarSection = ({ t, state, myRating, polarChartData, classes }) => (
rows={[
{
rater: t('myRate'),
amount: 1,
amount: isRated ? 1 : 0,
average: getMyRatingAverage({
community: myRating.community,
development: myRating.development,
Expand Down Expand Up @@ -100,7 +107,8 @@ RadarSection.propTypes = {
state: PropTypes.object,
myRating: PropTypes.object,
polarChartData: PropTypes.array,
classes: PropTypes.object
classes: PropTypes.object,
isRated: PropTypes.bool
}

const BlockProducerRate = () => {
Expand All @@ -114,7 +122,7 @@ const BlockProducerRate = () => {
{ setProducer, setLastTransaction, handleMutationInsertUserRating }
] = useSharedState()
const [ratingState, setRatingState] = useState(initialRatingState)
const [isRated, setIsRated] = useState(true)
const [isRated, setIsRated] = useState(false)
const [blockProducerLogo, setBlockProducerLogo] = useState(null)
const [blockProducerTitle, setBlockProducerTitle] = useState('No Title')
const [polarChartData, setPolarChartData] = useState([])
Expand Down Expand Up @@ -476,6 +484,7 @@ const BlockProducerRate = () => {
state={state}
myRating={myRating}
polarChartData={polarChartData}
isRated={isRated}
classes={classes}
/>
</Grid>
Expand Down Expand Up @@ -573,6 +582,7 @@ const BlockProducerRate = () => {
t={t}
myRating={myRating}
state={state}
isRated={isRated}
polarChartData={polarChartData}
/>
<Grid item md={12} />
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/utils/get-my-rating-average.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const getMyRatingAverage = myRating => {
if (!myRating) return 0

const average =
((myRating?.community || 0) +
(myRating?.development || 0) +
(myRating?.infrastructure || 0) +
(myRating?.transparency || 0) +
(myRating?.trustiness || 0)) /
Object.keys(myRating || {}).length

return average
}

Expand Down

0 comments on commit e915e7b

Please sign in to comment.