Skip to content

Commit

Permalink
Merge pull request #1092 from edenia/feat/empty-state-1066
Browse files Browse the repository at this point in the history
Feat/empty state 1066
  • Loading branch information
xavier506 authored Dec 9, 2022
2 parents 87c466b + 8a596bb commit 1dfee43
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 12 deletions.
6 changes: 3 additions & 3 deletions hapi/src/services/eosio.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,15 @@ const getChains = async producerUrl => {
}

const getProducerHealthStatus = bpJson => {
if (!bpJson || !Object.keys(bpJson).length) return []

const healthStatus = []

healthStatus.push({
name: 'bpJson',
valid: !!bpJson && !!Object.keys(bpJson).length
valid: true
})

if (!healthStatus[0].valid) return healthStatus

healthStatus.push({
name: 'organization_name',
valid: !!bpJson.org?.candidate_name
Expand Down
4 changes: 2 additions & 2 deletions hapi/src/services/producer.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const statsService = require('./stats.service')
const updateBPJSONs = async (producers = []) => {
const upsertMutation = `
mutation ($producers: [producer_insert_input!]!) {
insert_producer(objects: $producers, on_conflict: {constraint: producer_owner_key, update_columns: [ bp_json ]}) {
insert_producer(objects: $producers, on_conflict: {constraint: producer_owner_key, update_columns: [ bp_json, health_status ]}) {
affected_rows,
}
}
Expand All @@ -21,7 +21,7 @@ const updateBPJSONs = async (producers = []) => {
const updateProducers = async (producers = []) => {
const upsertMutation = `
mutation ($producers: [producer_insert_input!]!) {
insert_producer(objects: $producers, on_conflict: {constraint: producer_owner_key, update_columns: [ producer_key, unpaid_blocks,last_claim_time, url, location, producer_authority, is_active, total_votes, total_votes_percent, total_votes_eos, vote_rewards,block_rewards, total_rewards, health_status, endpoints, rank]}) {
insert_producer(objects: $producers, on_conflict: {constraint: producer_owner_key, update_columns: [ producer_key, unpaid_blocks,last_claim_time, url, location, producer_authority, is_active, total_votes, total_votes_percent, total_votes_eos, vote_rewards,block_rewards, total_rewards, endpoints, rank]}) {
affected_rows,
returning {
id,
Expand Down
Binary file added webapp/public/empty-states/Error.webp
Binary file not shown.
30 changes: 30 additions & 0 deletions webapp/src/components/InformationCard/EmptyState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { memo } from 'react'
import PropTypes from 'prop-types'

const EmptyState = ({ classes, t }) => {
return (
<div className={`${classes.centerWrapper} ${classes.borderLine}`}>
<div className={classes.emptyState}>
<div class={classes.horizontalLine}></div>
<img
className={classes.imgError}
src="/empty-states/Error.webp"
loading="lazy"
alt=""
/>
<span>{t('emptyState')}</span>
</div>
</div>
)
}

EmptyState.propTypes = {
classes: PropTypes.object,
t: PropTypes.func,
}

EmptyState.defaultProps = {
classes: {},
}

export default memo(EmptyState)
6 changes: 5 additions & 1 deletion webapp/src/components/InformationCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { eosConfig } from '../../config'
import ProducerHealthIndicators from '../ProducerHealthIndicators'
import NodesCard from '../NodeCard/NodesCard'

import EmptyState from './EmptyState'
import ProducerInformation from './ProducerInformation'
import Nodes from './Nodes'
import Social from './Social'
Expand Down Expand Up @@ -59,6 +60,9 @@ const InformationCard = ({ producer, rank, type }) => {
}

const BlockProducerInfo = () => {
if (producerOrg.healthStatus?.length <= 1)
return <EmptyState classes={classes} t={t}/>

return (
<div className="bodyWrapper">
<div className={clsx(classes.info, classes[type])}>
Expand Down Expand Up @@ -136,7 +140,7 @@ const InformationCard = ({ producer, rank, type }) => {
// eslint-disable-next-line
}, [producer])

if(!producerOrg || !Object.keys(producerOrg)?.length) return <></>
if (!producerOrg || !Object.keys(producerOrg)?.length) return <></>

return (
<Card className={classes.root}>
Expand Down
47 changes: 44 additions & 3 deletions webapp/src/components/InformationCard/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default (theme) => ({
flexDirection: 'row',
'& .bodyWrapper': {
flexDirection: 'row',
justifyContent: 'space-evenly',
justifyContent: 'space-between',
width: '100%',
},
'& .MuiTypography-overline': {
Expand Down Expand Up @@ -75,8 +75,8 @@ export default (theme) => ({
},
[theme.breakpoints.up('lg')]: {
padding: theme.spacing(0, 6),
width: 300,
maxWidth: 300,
width: 250,
minWidth: 250,
justifyContent: 'center',
},
},
Expand Down Expand Up @@ -323,4 +323,45 @@ export default (theme) => ({
marginLeft: theme.spacing(1),
},
},
centerWrapper: {
width: '100%',
display: 'flex',
justifyContent: 'center',
},
emptyState: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
'& span': {
width: '16em',
height: '45px',
fontSize: '1.2em',
fontWeight: 'bold',
fontStretch: 'normal',
fontStyle: 'normal',
lineHeight: '1.12',
letterSpacing: '-0.22px',
textAlign: 'center',
color: '#3d3d3dde',
},
},
horizontalLine: {
[theme.breakpoints.down('lg')]: {
width: '270px',
height: '1px',
margin: '15.2px 32px 40px 33px',
backgroundColor: '#e0e0e0',
},
},
imgError: {
[theme.breakpoints.down('lg')]: {
width: '200px',
height: '120px',
},
[theme.breakpoints.up('lg')]: {
width: '260px',
height: '160px',
},
objectFit: 'contain',
},
})
3 changes: 2 additions & 1 deletion webapp/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@
"noData": "No Data",
"peer_keys": "Peer Key",
"account_key": "Account Key",
"hs_bpJson": "BP Json"
"hs_bpJson": "BP Json",
"emptyState": "This block producer does not provide any information."
},
"nodeCardComponent": {
"features": "Features",
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@
"noData": "No hay Datos",
"peer_keys": "Peer",
"account_key": "Cuenta",
"hs_bpJson": "BP Json"
"hs_bpJson": "BP Json",
"emptyState": "Este productor de bloques no proporciona ninguna información."
},
"nodeCardComponent": {
"features": "Características",
Expand Down
1 change: 0 additions & 1 deletion webapp/src/routes/BlockProducers/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default (theme) => ({
display: 'flex',
[theme.breakpoints.up('sm')]: {
justifyContent: 'center',
flex: 'content',
},
[theme.breakpoints.down('sm')]: {
flex: 'auto',
Expand Down

0 comments on commit 1dfee43

Please sign in to comment.