Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(webapp): apply new format to card component #977

Merged
merged 2 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#GLOBAL
APP_NAME=EOS-RATE
STAGE=dev

# POSTGRES
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
Expand All @@ -10,50 +9,41 @@ POSTGRES_PASSWORD=password
POSTGRES_DB=eosrate
POSTGRES_SCHEMA=public
POSTGRES_DATA=./db_data

# HAPI
HAPI_POSTGRES_HOST=eosrate_postgres
HAPI_POSTGRES_HOST=postgres
HAPI_POSTGRES_PORT=5432
HAPI_POSTGRES_USER=user
HAPI_POSTGRES_PASSWORD=password
HAPI_POSTGRES_DB=eosrate
HAPI_POSTGRES_SCHEMA=public
HAPI_SERVER_PORT=9090
HAPI_SERVER_ADDRESS=0.0.0.0
HAPI_EOS_API_ENDPOINT=https://jungle.edenia.cloud
HAPI_EOS_API_ENDPOINT=https://jungle3.cryptolions.io
HAPI_EOS_CHAIN_ID=aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906
HAPI_PROXY_CONTRACT=proxyaccount
HAPI_RATING_CONTRACT=rateproducer
HAPI_HYPERION_API=https://jungle3history.cryptolions.io
HAPI_HYPERION_START_AT=2022-03-01T00:00:00.000+00:00
HAPI_HASURA_URL=http://hasura:8080/v1/graphql
HAPI_HASURA_ADMIN_SECRET=myadminsecretkey

# HASURA
HASURA_GRAPHQL_DATABASE_URL=postgres://user:password@eosrate_postgres:5432/eosrate
HASURA_GRAPHQL_ADMIN_SECRET=hasurasecret
HASURA_GRAPHQL_UNAUTHORIZED_ROLE=anonymous
HASURA_GRAPHQL_ACTION_BASE_URL=http://hapi:9090

# WEBAPP
REACT_APP_VERSION=$npm_package_version
REACT_APP_RATING_CONTRACT=rateproducer
REACT_APP_MAINNET_VERSION=true
REACT_APP_EDEN_CONTRACT=genesis.eden
REACT_APP_GRAPHQL_HTTP_URL=http://localhost:8080/v1/graphql
REACT_APP_API_URL=https://jungle3.cryptolions.io
REACT_APP_GRAPHQL_WS_URL=ws://localhost:8080/v1/graphql
REACT_APP_EOS_API_URL=https://jungle.edenia.cloud
REACT_APP_EOS_API_HOST=jungle.edenia.cloud
REACT_APP_EOS_API_URL=https://jungle3.cryptolions.io
REACT_APP_EOS_API_HOST=jungle3.cryptolions.io
REACT_APP_EOS_API_PORT=443
REACT_APP_EOS_API_PROTOCOL=https
REACT_APP_EOS_CHAIN_ID=2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840
REACT_APP_BLOCK_EXPLORER=https://jungle3.bloks.io
REACT_APP_NETWORK_MONITOR_URL=https://jungle.eosio.online/
REACT_APP_VERSION=v1.4.21
REACT_APP_MAINNET_VERSION=v1.4.21
REACT_APP_MAINNET_VERSION= v1.4.21
REACT_APP_EDEN_CONTRACT=genesisdeden
REACT_APP_UAL_APP_NAME=EOSRate

# CONTRACT
CONTRACT_ENDPOINT='<endpoint>'
CONTRACT_ACCOUNT='<account>'
REACT_APP_UAL_APP_NAME=EOSRate
43 changes: 22 additions & 21 deletions webapp/src/components/Card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,32 @@ const CardData = ({
rate,
showOptions,
isNewRate,
disable
disable,
isProxy
}) => {
const { t } = useTranslation('translations')
const [open, setOpen] = useState(false)
const classes = useStyles()
const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.only('xs'))

const handleTooltip = e => {
setOpen(!open)
e.preventDefault()
}
console.log(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, delete this console.log

const formatRadarData = info => {
if (isProxy) return info.data

const formatRadarData = rateData => [
parseFloat(formatNumber(rateData?.community || 0, 1)),
parseFloat(formatNumber(rateData?.development || 0, 1)),
parseFloat(formatNumber(rateData?.development || 0, 1)),
parseFloat(formatNumber(rateData?.transparency || 0, 1)),
parseFloat(formatNumber(rateData?.trustiness || 0, 1))
]
return {
...info.data,
data: [
parseFloat(formatNumber(info.total_community || 0, 1)),
parseFloat(formatNumber(info.total_development || 0, 1)),
parseFloat(formatNumber(info.total_transparency || 0, 1)),
parseFloat(formatNumber(info.total_trustiness || 0, 1))
]
}
}

return (
<Card className={classes.card}>
Expand Down Expand Up @@ -135,16 +141,9 @@ const CardData = ({
<PolarChart
data={[
{
...data.data,
data: formatRadarData({
average: data.total_average,
community: data.total_community,
development: data.total_development,
infrastructure: data.total_infrastructure,
ratings_cntr: data.total_ratings_cntr,
transparency: data.total_transparency,
trustiness: data.total_trustiness
})
// ...data.data,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

// data: formatRadarData(data)
...formatRadarData(data)
}
]}
/>
Expand Down Expand Up @@ -245,14 +244,16 @@ CardData.propTypes = {
rate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
showOptions: PropTypes.bool,
isNewRate: PropTypes.bool,
disable: PropTypes.bool
disable: PropTypes.bool,
isProxy: PropTypes.bool
}

CardData.defaultProps = {
useRateButton: true,
average: '0',
rate: '0',
showOptions: true
showOptions: true,
isProxy: false
}

TooltipWrapper.propTypes = {
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/routes/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ const Home = () => {
pathLink='block-producers'
buttonLabel={t('addToVote')}
average={getAverageValue(
_get(blockProducer, 'totalStats.average', 0)
_get(blockProducer, 'total_average', 0)
)}
rate={_get(blockProducer, 'totalStats.ratings_cntr', 0)}
rate={_get(blockProducer, 'ratings_cntr', 0)}
isNewRate={
state.user &&
state.user.userData.userRates.some(
Expand Down
1 change: 1 addition & 0 deletions webapp/src/routes/Proxies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const AllProxies = ({ ual = {} }) => {
useRateButton={false}
pathLink='proxies'
showOptions={false}
isProxy
/>
</div>
))}
Expand Down