Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 18 additions & 0 deletions components/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const LABELS = {
registry: {
'american-carbon-registry': 'ACR',
'art-trees': 'ART',
cercarbono: 'CCB',
'climate-action-reserve': 'CAR',
'gold-standard': 'GLD',
verra: 'VCS',
Expand Down Expand Up @@ -46,7 +47,10 @@ export const COLORS = {

export const ALL_CATEGORIES = [
'agriculture',
'air-capture',
'alkalinity-cdr',
'biochar',
'biomass-cdr',
'cookstove',
'energy-efficiency',
'forest',
Expand All @@ -73,14 +77,17 @@ export const COUNTRIES = [
'Bahamas',
'Bahrain',
'Bangladesh',
'Belgium',
'Belize',
'Benin',
'Bhutan',
'Bolivia',
'Botswana',
'Brazil',
'Bulgaria',
'Burkina Faso',
'Burundi',
'Cabo Verde',
'Cambodia',
'Cameroon',
'Canada',
Expand All @@ -93,7 +100,9 @@ export const COUNTRIES = [
'Congo Republic',
'Costa Rica',
"Cote d'Ivoire",
'Croatia',
'Cyprus',
'Czech Republic',
'DR Congo',
'Denmark',
'Djibouti',
Expand All @@ -112,19 +121,23 @@ export const COUNTRIES = [
'Germany',
'Ghana',
'Greece',
'Guam',
'Guatemala',
'Guinea',
'Guinea-Bissau',
'Guyana',
'Haiti',
'Honduras',
'Hungary',
'Hong Kong',
'Iceland',
'India',
'Indonesia',
'Iraq',
'Ireland',
'Israel',
'Italy',
'Jamaica',
'Japan',
'Jordan',
'Kazakhstan',
Expand Down Expand Up @@ -156,6 +169,7 @@ export const COUNTRIES = [
'Niger',
'Nigeria',
'North Macedonia',
'Norway',
'Oman',
'Pakistan',
'Palestine',
Expand All @@ -165,6 +179,8 @@ export const COUNTRIES = [
'Peru',
'Philippines',
'Qatar',
'Poland',
'Portugal',
'Romania',
'Russia',
'Rwanda',
Expand All @@ -180,6 +196,7 @@ export const COUNTRIES = [
'Sri Lanka',
'Sudan',
'Suriname',
'Sweden',
'Switzerland',
'Syria',
'Taiwan',
Expand All @@ -199,6 +216,7 @@ export const COUNTRIES = [
'Uruguay',
'Uzbekistan',
'Vietnam',
'Yemen',
'Zambia',
'Zimbabwe',
]
Expand Down
67 changes: 54 additions & 13 deletions components/credit-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const CreditRow = ({ color, event, projectView, ...props }) => {
retirement_beneficiary,
retirement_note,
retirement_reason,
transaction_url,
} = event

const columns = projectView ? [6, 6, 7, 7] : [6, 8, 8, 8]
Expand Down Expand Up @@ -73,6 +74,12 @@ const CreditRow = ({ color, event, projectView, ...props }) => {
retirement_note ??
retirement_reason
)
let userSummary = userInfo
if (transaction_type === 'issuance') {
userSummary = 'N/A'
} else if (!userInfo) {
userSummary = 'Data missing'
}

return (
<>
Expand All @@ -96,7 +103,7 @@ const CreditRow = ({ color, event, projectView, ...props }) => {
},
}}
>
{transaction_type === 'retirement' && (
{transaction_type === 'retirement' || transaction_url ? (
<Expander
id='expander'
value={expanded}
Expand All @@ -112,7 +119,7 @@ const CreditRow = ({ color, event, projectView, ...props }) => {
}}
onClick={() => setExpanded((prev) => !prev)}
/>
)}
) : null}
<ProjectBadge project={projects[0]} link />
</Box>
),
Expand Down Expand Up @@ -181,7 +188,7 @@ const CreditRow = ({ color, event, projectView, ...props }) => {
key: 'beneficiary',
label: (
<Text>
{hasBeneficiaryInfo ? (
{hasBeneficiaryInfo || transaction_url ? (
<Box
onClick={() => setExpanded((prev) => !prev)}
sx={{
Expand Down Expand Up @@ -214,7 +221,7 @@ const CreditRow = ({ color, event, projectView, ...props }) => {
}}
>
{userInfo ?? (
<Text sx={{ opacity: 0.5 }}>Data missing</Text>
<Text sx={{ opacity: 0.5 }}>{userSummary}</Text>
)}
</Box>
</Column>
Expand All @@ -234,9 +241,7 @@ const CreditRow = ({ color, event, projectView, ...props }) => {
/>
</Box>
) : (
<Text sx={{ opacity: 0.5 }}>
{transaction_type === 'issuance' ? 'N/A' : 'Data missing'}
</Text>
<Text sx={{ opacity: 0.5 }}>{userSummary}</Text>
)}
</Text>
),
Expand Down Expand Up @@ -272,13 +277,49 @@ const CreditRow = ({ color, event, projectView, ...props }) => {
height: 'fit-content',
}}
>
<BeneficiaryOverview
event={event}
color={eventColor}
columns={projectView ? 4 : 6}
/>
{hasBeneficiaryInfo && (
<BeneficiaryOverview
event={event}
color={eventColor}
columns={projectView ? 4 : 6}
/>
)}

{transaction_url && (
<Column
start={projectView ? [1, 5, 5, 5] : [1, 3, 3, 3]}
width={projectView ? [6, 6, 3, 3] : [1, 3, 3, 3]}
>
<Button
href={transaction_url}
onClick={(e) => e.stopPropagation()}
sx={{
color: eventColor,
fontFamily: 'mono',
letterSpacing: 'mono',
textTransform: 'uppercase',
fontSize: 1,
}}
suffix={
<RotatingArrow
sx={{
width: 14,
height: 14,
mt: -1,
}}
/>
}
>
View transaction
</Button>
</Column>
)}

{!projectView && (
<Column start={[1, 3, 3, 3]} width={3}>
<Column
start={transaction_url ? [4, 6, 6, 6] : [1, 3, 3, 3]}
width={3}
>
<Button
href={`/projects/${projects[0].project_id}`}
onClick={(e) => e.stopPropagation()}
Expand Down
43 changes: 31 additions & 12 deletions components/project-overview.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Button, Column } from '@carbonplan/components'
import { RotatingArrow } from '@carbonplan/icons'
import { Button, Column, Expander } from '@carbonplan/components'
import { QuestionCircle, RotatingArrow } from '@carbonplan/icons'
import { Box, Flex } from 'theme-ui'

import { COLORS, LABELS } from './constants'
import TooltipWrapper from './tooltip-wrapper'
import { getProjectCategory } from './utils'

const Empty = ({ label = 'N/A' }) => {
const Empty = ({ label = 'Unknown' }) => {
return <Box>{label}</Box>
}

Expand All @@ -16,6 +16,7 @@ const ProjectOverview = ({ project, columns = 4 }) => {
country,
status,
protocol,
protocol_unassigned,
is_compliance,
proponent,
project_url,
Expand Down Expand Up @@ -59,7 +60,7 @@ const ProjectOverview = ({ project, columns = 4 }) => {
>
<Box sx={sx.label}>Country</Box>
</TooltipWrapper>
<Box sx={sx.value}>{country}</Box>
<Box sx={sx.value}>{country ?? <Empty />}</Box>
</Column>

<Column start={[4, 3, 3, 3]} width={[3, 2, 2, 2]}>
Expand All @@ -71,7 +72,9 @@ const ProjectOverview = ({ project, columns = 4 }) => {
>
<Box sx={sx.label}>Status</Box>
</TooltipWrapper>
<Box sx={{ ...sx.value, textTransform: 'capitalize' }}>{status}</Box>
<Box sx={{ ...sx.value, textTransform: 'capitalize' }}>
{status ?? <Empty />}
</Box>
</Column>

<Column
Expand All @@ -89,7 +92,7 @@ const ProjectOverview = ({ project, columns = 4 }) => {
<Box sx={sx.value}>
{(Array.isArray(category) ? category : [category]).map((c) => (
<Box key={c} sx={{ width: 'fit-content' }}>
{LABELS.category[c]}
{LABELS.category[c] ?? <Empty />}
</Box>
))}
</Box>
Expand All @@ -110,7 +113,7 @@ const ProjectOverview = ({ project, columns = 4 }) => {
>
<Box sx={sx.label}>Project type</Box>
</TooltipWrapper>
<Box sx={sx.value}>{project_type ?? <Empty />}</Box>
<Box sx={sx.value}>{project_type ?? <Empty label='N/A' />}</Box>
</Column>

<Column
Expand All @@ -125,15 +128,31 @@ const ProjectOverview = ({ project, columns = 4 }) => {
>
<Box sx={sx.label}>Protocol</Box>
</TooltipWrapper>
<Box sx={{ ...sx.value, textTransform: 'uppercase' }}>
{protocol.length > 0 ? (
<Box sx={sx.value}>
{protocol?.length > 0 ? (
<Flex sx={{ flexDirection: 'column', gap: 2 }}>
{protocol.map((d) => (
<Box key={d}>{d}</Box>
<Box key={d} sx={{ textTransform: 'uppercase' }}>
{d}
</Box>
))}
</Flex>
) : (
<Empty />
<TooltipWrapper
color={'primary'}
Icon={QuestionCircle}
tooltip={
protocol_unassigned?.length > 0
? `Reported as ${protocol_unassigned.join(', ')}`
: 'No information reported'
}
sx={{
...sx.tooltipWrapper,
'& svg': { stroke: 'primary' },
}}
>
<Empty />
</TooltipWrapper>
)}
</Box>
</Column>
Expand All @@ -151,7 +170,7 @@ const ProjectOverview = ({ project, columns = 4 }) => {
<Box sx={sx.label}>Proponent</Box>
</TooltipWrapper>
<Box sx={{ ...sx.value, mr: columns === 4 ? [0, 0, 2, 2] : 0 }}>
{proponent ?? <Empty />}
{proponent ?? <Empty label='N/A' />}
</Box>
</Column>

Expand Down
1 change: 1 addition & 0 deletions components/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const QueryProvider = ({ children }) => {
const [registry, setRegistry] = useState({
'american-carbon-registry': true,
'art-trees': true,
cercarbono: true,
'climate-action-reserve': true,
'gold-standard': true,
verra: true,
Expand Down
4 changes: 2 additions & 2 deletions components/tooltip-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Box } from 'theme-ui'
import { Info } from '@carbonplan/icons'
import IconWrapper from './icon-wrapper'

const TooltipWrapper = ({ children, tooltip, color, sx, top }) => {
const TooltipWrapper = ({ Icon = Info, children, tooltip, color, sx, top }) => {
return (
<IconWrapper
Icon={Info}
Icon={Icon}
content={
<Box sx={{ my: 1, fontSize: [1, 1, 1, 2], color }}>{tooltip}</Box>
}
Expand Down
Loading