Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier506 committed Aug 25, 2022
2 parents c04c558 + 5839c49 commit e0b0abd
Show file tree
Hide file tree
Showing 37 changed files with 396 additions and 400 deletions.
5 changes: 3 additions & 2 deletions contracts/rateproducer/include/rateproducer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,10 @@ namespace eoscostarica {
*
* @param rating_id - Id of the rating,
* @param comment - Commentary
* @param is_eden - is eden member true/false
*
*/
void logcomment (uint64_t rating_id, std::string comment);
void logcomment (uint64_t rating_id, std::string comment, bool is_eden);

/**
*
Expand Down Expand Up @@ -614,7 +615,7 @@ namespace eoscostarica {
action(rminactive, ricardian_contract(rminactive_ricardian)),
action(rmrate, user, bp, ricardian_contract(rmrate_ricardian)),
action(migrate, ricardian_contract(migrate_ricardian)),
action(logcomment, rating_id, comment, ricardian_contract(logcomment_ricardian)),
action(logcomment, rating_id, comment, is_eden, ricardian_contract(logcomment_ricardian)),
action(loglike, rating_id, user, like, ricardian_contract(loglike_ricardian)))

} // namespace eoscostarica
14 changes: 7 additions & 7 deletions contracts/rateproducer/src/rateproducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ namespace eoscostarica {
check( (MINVAL <= development && development <= MAXVAL), "Error development value out of range" );
check( (MINVAL <= community && community <= MAXVAL), "Error community value out of range" );

bool isEden = scope.value == eden_scope.value;
name stats_ram_payer = isEden ? _self : user;
bool is_eden = scope.value == eden_scope.value;
name stats_ram_payer = is_eden ? _self : user;

check( is_blockproducer(bp), "votes are allowed only for registered block producers" );

name proxy_name = get_proxy(user);
if(proxy_name.length()) {
check(is_active_proxy(proxy_name), "votes are allowed only for active proxies" );
if(!isEden) check( MIN_VOTERS <= get_voters(proxy_name), "delegated proxy does not have enough voters" );
if(!is_eden) check( MIN_VOTERS <= get_voters(proxy_name), "delegated proxy does not have enough voters" );
} else {
if(!isEden) check( MIN_VOTERS <= get_voters(user), "account does not have enough voters" );
if(!is_eden) check( MIN_VOTERS <= get_voters(user), "account does not have enough voters" );
}

ratings_table_v2 _ratings(_self, scope.value);
Expand Down Expand Up @@ -75,7 +75,7 @@ namespace eoscostarica {
development);

if(!comment.empty()) {
SEND_INLINE_ACTION(*this, logcomment, { {get_self(), name("active")} }, { rating_id, comment });
SEND_INLINE_ACTION(*this, logcomment, { {get_self(), name("active")} }, { rating_id, comment, is_eden });
}

} else {
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace eoscostarica {
&bp_average);

if(!comment.empty()) {
SEND_INLINE_ACTION(*this, logcomment, { {get_self(), name("active")} }, { existing_rating->id, comment });
SEND_INLINE_ACTION(*this, logcomment, { {get_self(), name("active")} }, { existing_rating->id, comment, is_eden });
}
}
}
Expand Down Expand Up @@ -503,7 +503,7 @@ namespace eoscostarica {
cfg.set(c, c.owner);
}

void rateproducer::logcomment(uint64_t rating_id, std::string comment) {
void rateproducer::logcomment(uint64_t rating_id, std::string comment, bool is_eden) {
require_auth(_self);
check( comment.length() <= 500, "comment must be less or equal than 500 characters" );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
const { eosConfig } = require('../../../config')
const {
eosConfig,
generalContractScope,
edenContractScope
} = require('../../../config')
const { save, updateUserRating } = require('../../comment.service')
const EosApi = require('eosjs-api')

Expand All @@ -17,36 +21,22 @@ module.exports = {
try {
const {
transaction_id,
data: {
data: { rating_id: ratingId, comment }
}
data: { rating_id: ratingId, comment, is_eden: isEden }
} = action
let userRatings

userRatings = await eosApi.getTableRows({
if (isEden === null) return

const userRatings = await eosApi.getTableRows({
json: true,
code: eosConfig.baseAccount,
scope: 'eden',
scope: isEden ? edenContractScope : generalContractScope,
table: 'rating',
reverse: false,
limit: 1,
lower_bound: ratingId,
upper_bound: ratingId
})

if (!userRatings) {
userRatings = await eosApi.getTableRows({
json: true,
code: eosConfig.baseAccount,
scope: 'rateproducer',
table: 'rating',
reverse: false,
limit: 1,
lower_bound: ratingId,
upper_bound: ratingId
})
}

const [blockProducer] = userRatings.rows.filter(
({ id }) => id == ratingId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ module.exports = {
const {
transaction_id,
actors,
data: {
data: { rating_id: ratingId, like }
}
data: { rating_id: ratingId, like }
} = action

await saveOrUpdate({
Expand Down
5 changes: 1 addition & 4 deletions hasura/metadata/actions.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
type Mutation {
rateProducer(
ratingInput: RatingInput!
): RatingOutput
rateProducer(ratingInput: RatingInput!): RatingOutput
}

input RatingInput {
Expand All @@ -27,4 +25,3 @@ type deleteUserRateOutput {
type AddCommentOutput {
success: Boolean!
}

37 changes: 18 additions & 19 deletions webapp/src/components/Card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useTheme } from '@mui/material/styles'
import { useTranslation } from 'react-i18next'
import useMediaQuery from '@mui/material/useMediaQuery'
import Card from '@mui/material/Card'
import Box from '@mui/material/Box'
import CardHeader from '@mui/material/CardHeader'
import Typography from '@mui/material/Typography'
import CardActions from '@mui/material/CardActions'
Expand Down Expand Up @@ -97,31 +96,31 @@ const CardData = ({
</Avatar>
}
title={
<Box className={classes.warningBox}>
<Box className={classes.boxTitle}>
<div className={classes.warningBox}>
<div className={classes.boxTitle}>
<Typography className={classes.noWrap} variant='h6'>
{title || owner}
</Typography>
</Box>
</Box>
</div>
</div>
}
subheader={
<Box className={classes.warningBox}>
<div className={classes.warningBox}>
<Typography className={classes.subTitleHeader}>
{owner}
</Typography>
<Box className={classes.moreWrapper}>
<div className={classes.moreWrapper}>
<Typography style={{ margin: 'auto' }} variant='subtitle2'>
{t('view')}
</Typography>
<KeyboardArrowRightIcon />
</Box>
</Box>
</div>
</div>
}
/>
</Link>
<Box className={classes.radar}>
<Box className={classes.blockIcons}>
<div className={classes.radar}>
<div className={classes.blockIcons}>
{!title && (
<TooltipWrapper
open={open}
Expand All @@ -131,8 +130,8 @@ const CardData = ({
classes={classes}
/>
)}
</Box>
<Box className={classes.chartWrapper}>
</div>
<div className={classes.chartWrapper}>
<PolarChart
data={[
{
Expand All @@ -149,11 +148,11 @@ const CardData = ({
}
]}
/>
</Box>
</div>
{showOptions && (
<Grid container justifyContent='center'>
<Grid item md={4} xs={4}>
<Box className={classes.boxValueRates}>
<div className={classes.boxValueRates}>
<Typography
variant='subtitle2'
className={clsx(classes.avgText, classes.marginRightElem)}
Expand All @@ -163,10 +162,10 @@ const CardData = ({
<Typography className={classes.avgValue} variant='body2'>
{rate || 0}
</Typography>
</Box>
</div>
</Grid>
<Grid item md={4} xs={5}>
<Box className={classes.boxValueRates}>
<div className={classes.boxValueRates}>
<Typography
variant='subtitle2'
className={clsx(classes.avgText, classes.marginRightElem)}
Expand All @@ -176,11 +175,11 @@ const CardData = ({
<Typography className={classes.avgValue} variant='body2'>
{average}
</Typography>
</Box>
</div>
</Grid>
</Grid>
)}
</Box>
</div>
<CardActions className={classes.actions}>
{useRateButton && (
<>
Expand Down
28 changes: 14 additions & 14 deletions webapp/src/components/CommentCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ const CommentCard = ({ producer = {} }) => {
return (
<Grid pt={6} container justifyContent='center' md={12}>
<Grid className={classes.sectionContent} item md={12} xs={12}>
<Box className={classes.cardContainer}>
<Box display='flex' justifyContent='end' alignItems='center'>
<div className={classes.cardContainer}>
<div className={classes.container}>
<Typography flex={1} mt='28px' mb='44px' variant='h6'>
{t('userComments')} ({comments.length})
</Typography>
Expand Down Expand Up @@ -191,11 +191,11 @@ const CommentCard = ({ producer = {} }) => {
</MenuItem>
))}
</Menu>
</Box>
<Box pl={2}>
</div>
<div className={classes.commentContainer}>
{comments.map((comment, index) => (
<Box pt='12px' pb='12px' key={index}>
<Box display='flex'>
<div className={classes.divComment} key={index}>
<div className={classes.divUser}>
<Typography variant='body2' display='flex' flex={1} mb={2}>
{comment.user}
</Typography>
Expand All @@ -208,14 +208,14 @@ const CommentCard = ({ producer = {} }) => {
>
<Moment fromNow>{comment.created_at}</Moment>
</Typography>
</Box>
</div>
<Typography>{comment.content}</Typography>
<Grid container>
<Grid item md={8} className={classes.center}>
<Box pt={1} display={isMobile ? 'block' : 'flex'}>
{Object.entries(comment.user_ratings[0].ratings).map(
(param, index) => (
<Box key={index}>
<div key={index}>
<Box
width={isMobile ? '90px' : 'auto'}
display='inline-block'
Expand All @@ -231,13 +231,13 @@ const CommentCard = ({ producer = {} }) => {
<Typography variant='body4' mr={2}>
{param[1]}
</Typography>
</Box>
</div>
)
)}
</Box>
</Grid>
<Grid item md={4} className={classes.box}>
<Box pt={1}>
<div className={classes.divLikes}>
<Typography
variant='body3'
textTransform='uppercase'
Expand All @@ -264,13 +264,13 @@ const CommentCard = ({ producer = {} }) => {
<ThumbDownIcon className={classes.thumb} />
</IconButton>
</Typography>
</Box>
</div>
</Grid>
</Grid>
</Box>
</div>
))}
</Box>
</Box>
</div>
</div>
</Grid>
<Snackbar
anchorOrigin={{
Expand Down
21 changes: 20 additions & 1 deletion webapp/src/components/CommentCard/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ export default theme => ({
cardContainer: {
width: '95%'
},
container: {
display: 'flex !important',
justifyContent: 'end !important',
alignItems: 'center !important'
},
commentContainer: {
paddingLeft: 20
},
divComment: {
paddingTop: '12px',
paddingBottom: '12px'
},
divUser: {
display: 'flex'
},
divLikes: {
paddingTop: '20px'
},
box: {
display: 'flex',
alignItems: 'center',
Expand All @@ -26,7 +44,8 @@ export default theme => ({
},
btnFilter: {
color: 'inherit !important',
borderRadius: '2px !important'
borderRadius: '2px !important',
content: ''
},
center: {
margin: 'auto !important',
Expand Down
Loading

0 comments on commit e0b0abd

Please sign in to comment.