-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: Credit Class Page "Additional Info" improvements #1980
Changes from all commits
266d201
77f5de4
87e266c
18312eb
245784f
746ec8c
76054c1
1358b82
cbb7813
806beb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { formatDuration } from 'date-fns'; | ||
|
||
export function fromISO8601(iso8601Duration: string) { | ||
const iso8601DurationRegex = | ||
/(-)?P(-)?(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?(?:T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?)?/; | ||
var matches = iso8601Duration.match(iso8601DurationRegex); | ||
const duration = { | ||
years: matches?.[3] ? Number(matches?.[3]) : 0, | ||
months: matches?.[4] ? Number(matches?.[4]) : 0, | ||
weeks: matches?.[5] ? Number(matches?.[5]) : 0, | ||
days: matches?.[6] ? Number(matches?.[6]) : 0, | ||
hours: matches?.[7] ? Number(matches?.[7]) : 0, | ||
minutes: matches?.[8] ? Number(matches?.[8]) : 0, | ||
seconds: matches?.[9] ? Number(matches?.[9]) : 0, | ||
}; | ||
if (Object.values(duration).findIndex(v => v !== 0) > -1) | ||
return `${ | ||
matches?.[1] === '-' || matches?.[2] === '-' ? 'Previous ' : '' | ||
}${formatDuration(duration)}`; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,22 @@ export interface CreditClassMetadataLD { | |
'regen:carbonOffsetStandard'?: CompactedNameUrl; | ||
'regen:tokenizationSource'?: string; | ||
'regen:certifications'?: Certification[]; | ||
'regen:coBenefits'?: string[]; | ||
'regen:measuredGHGs': string[]; | ||
'regen:bufferPoolAccounts': { | ||
// We probably want to simplify this to be just a @list instead, | ||
// but keeping as is, until C04 class metadata is updated accordingly. | ||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we create a followup task blocked by regen-network/regen-registry-standards#57? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done: #1983 |
||
'@type': 'schema:ItemList'; | ||
'schema:itemListElement': BufferPoolAccount[]; | ||
}; | ||
} | ||
|
||
export type BufferPoolAccount = { | ||
'schema:name': string; | ||
// Keeping both regen:walletAddress and regen:address for now, | ||
// until C04 class metadata gets fixed. | ||
// But ultimately, we should just use regen:address. | ||
Comment on lines
+39
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also relevant to regen-network/regen-registry-standards#57 |
||
'regen:walletAddress'?: string; | ||
'regen:address'?: string; | ||
'regen:poolAllocation': string; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Flex } from 'web-components/lib/components/box'; | ||
import { Body } from 'web-components/lib/components/typography'; | ||
|
||
import { getAccountUrl } from 'lib/block-explorer'; | ||
import { BufferPoolAccount } from 'lib/db/types/json-ld/credit-class-metadata'; | ||
|
||
import { LinkWithArrow } from 'components/atoms'; | ||
import { MetaDetail } from 'components/molecules'; | ||
|
||
type Props = { | ||
bufferPoolAccounts?: BufferPoolAccount[]; | ||
}; | ||
|
||
const BufferPoolAccounts: React.FC<Props> = ({ bufferPoolAccounts }) => { | ||
if (!bufferPoolAccounts) return null; | ||
|
||
const count = bufferPoolAccounts?.length; | ||
|
||
if (!count || count < 1) return null; | ||
|
||
return ( | ||
<MetaDetail | ||
label="buffer pool accounts" | ||
customContent={ | ||
<Flex flexDirection="column"> | ||
{bufferPoolAccounts.map(account => ( | ||
<Body key={account?.['schema:name']} size="xl" styleLinks={false}> | ||
<LinkWithArrow | ||
href={getAccountUrl( | ||
account?.['regen:walletAddress'] || | ||
account?.['regen:address'], | ||
)} | ||
label={account?.['schema:name']} | ||
/> | ||
</Body> | ||
))} | ||
</Flex> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export { BufferPoolAccounts }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently just "Duration" inclusion checking this but ultimately once this: regen-network/regen-registry-standards#57 (comment) is fixed, we should check for
schema:Duration
equality