Skip to content

Commit

Permalink
feat: APP-439 display additional info for offchain project too if cus…
Browse files Browse the repository at this point in the history
…tom/unknown fields (#2527)
  • Loading branch information
blushi authored Nov 4, 2024
1 parent 3f61f7c commit 3421b46
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 75 deletions.
Binary file modified bun.lockb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Box, Grid } from '@mui/material';
import InfoTooltipWithIcon from 'web-components/src/components/tooltip/InfoTooltipWithIcon';
import { Body, Label } from 'web-components/src/components/typography';

import { AnchoredProjectMetadataLD } from 'lib/db/types/json-ld';
import { ProjectMetadataLD } from 'lib/db/types/json-ld';
import {
getFieldLabel,
getFieldType,
Expand All @@ -20,7 +20,7 @@ import {
} from './ProjectPageMetadata.constants';

interface MetadataProps {
metadata?: AnchoredProjectMetadataLD;
metadata?: ProjectMetadataLD;
onChainProjectId?: string;
}

Expand All @@ -30,7 +30,7 @@ const ProjectPageMetadata: React.FC<React.PropsWithChildren<MetadataProps>> = ({
}) => {
const { _ } = useLingui();

if (!onChainProjectId && !metadata) return null;
if (!metadata) return null;

// Common
const startDate = metadata?.['regen:projectStartDate'];
Expand Down Expand Up @@ -59,25 +59,27 @@ const ProjectPageMetadata: React.FC<React.PropsWithChildren<MetadataProps>> = ({
borderRadius: '0 0 8px 8px',
}}
>
{metadata && (
{onChainProjectId && (
<Body sx={{ pb: 7 }} size="lg">
{_(PROJECT_PAGE_METADATA_HELPER_TEXT)}
</Body>
)}
<Box>
<Grid container spacing={8}>
<Grid item xs={12} sm={6} sx={{ flexDirection: 'column' }}>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<Label size="xs" sx={{ mr: 1 }}>
<Trans>project id</Trans>
</Label>
<InfoTooltipWithIcon
title={_(PROJECT_PAGE_METADATA_ID_TOOLTIP)}
outlined
/>
</Box>
<Body size="xl">{onChainProjectId}</Body>
</Grid>
{onChainProjectId && (
<Grid item xs={12} sm={6} sx={{ flexDirection: 'column' }}>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<Label size="xs" sx={{ mr: 1 }}>
<Trans>project id</Trans>
</Label>
<InfoTooltipWithIcon
title={_(PROJECT_PAGE_METADATA_ID_TOOLTIP)}
outlined
/>
</Box>
<Body size="xl">{onChainProjectId}</Body>
</Grid>
)}

<MetaDetail
label={_(msg`toucan project token id`)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import {
AnchoredProjectMetadataLD,
CreditClassMetadataLD,
ProjectMetadataLD,
} from 'lib/db/types/json-ld';
import { getBatchesTotal } from 'lib/ecocredit/api';
import { IS_REGEN } from 'lib/env';
Expand Down Expand Up @@ -520,7 +521,7 @@ function ProjectDetails(): JSX.Element {
sortedDocuments={sortedDocuments}
sortCallbacksDocuments={sortCallbacksDocuments}
offChainProject={offChainProject}
projectMetadata={projectMetadata}
projectMetadata={projectMetadata as ProjectMetadataLD}
onChainProjectId={onChainProjectId}
batchData={{
batches: batchesWithSupply,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { msg } from '@lingui/macro';

import { IconTabProps } from 'web-components/src/components/tabs/IconTab';

import { getProjectUnknownFields } from 'lib/rdf/rdf.unknown-fields';

import { ProjectPageMetadata } from 'components/molecules';
import { CreditBatches } from 'components/organisms';
import { isAnchoredProjectMetadata } from 'components/organisms/ProjectTopSection/ProjectTopSection.utils';
Expand Down Expand Up @@ -49,15 +51,14 @@ export const getProjectDetailsTabs = ({
{
label: _(msg`Additional Info`),
content: (
<>
{isAnchoredProjectMetadata(projectMetadata, onChainProjectId) && (
<ProjectPageMetadata
metadata={projectMetadata}
onChainProjectId={onChainProjectId}
/>
)}
</>
<ProjectPageMetadata
metadata={projectMetadata}
onChainProjectId={onChainProjectId}
/>
),
hidden: !isAnchoredProjectMetadata(projectMetadata, onChainProjectId),
hidden:
!isAnchoredProjectMetadata(projectMetadata, onChainProjectId) &&
projectMetadata &&
getProjectUnknownFields(projectMetadata).length === 0,
},
].filter(tab => tab.hidden !== true);
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ import { SortCallbacksType } from 'web-components/src/components/table/ActionsTa
import { Theme } from 'web-components/src/theme/muiTheme';

import { Document } from 'generated/graphql';
import {
AnchoredProjectMetadataLD,
LegacyProjectMetadataLD,
} from 'lib/db/types/json-ld';
import { ProjectMetadataLD } from 'lib/db/types/json-ld';
import { TranslatorType } from 'lib/i18n/i18n.types';

import { ProjectMiddleSectionProps } from 'components/organisms/CreditBatchesSection/CreditBatchesSection.types';

export type ProjectDetailsTableTabsProps = {
sortedDocuments: Document[];
sortCallbacksDocuments?: SortCallbacksType;
projectMetadata?: AnchoredProjectMetadataLD | LegacyProjectMetadataLD;
projectMetadata?: ProjectMetadataLD;
onChainProjectId?: string;
sx?: SxProps<Theme>;
_: TranslatorType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {
AnchoredProjectMetadataBaseLD,
CFCProjectMetadataLD,
ProjectPageMetadataLD,
TerrasosProjectMetadataLD,
ToucanProjectMetadataLD,
VCSProjectMetadataLD,
} from '.';
import { TerrasosProjectMetadataLD } from './terrasos-project-metadata';

/** A combination of existing anchored Project metadata schemas */
export type AnchoredProjectMetadataLD = AnchoredProjectMetadataBaseLD &
Expand Down
15 changes: 9 additions & 6 deletions web-marketplace/src/lib/db/types/json-ld/project-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { ContextDefinition } from 'jsonld';
import { CompactedNameOptionalUrl } from 'lib/rdf/types';

import { Rating } from './rating';
import { MarketType } from './terrasos-project-metadata';
import {
MarketType,
TerrasosProjectMetadataLD,
} from './terrasos-project-metadata';

/** Anchored metadata AKA "Additional Info" - Editable only with a signed Ledger TX. */
export interface AnchoredProjectMetadataBaseLD {
Expand Down Expand Up @@ -38,7 +41,8 @@ export interface AnchoredProjectMetadataBaseLD {
}

/** Un-anchored metadata from our DB. This is editable without a Ledger TX. */
export interface ProjectPageMetadataLD {
export interface ProjectPageMetadataLD
extends Partial<TerrasosProjectMetadataLD> {
'@context': ContextDefinition;
'@type': string; // regen:Project-Page
'@id': string;
Expand All @@ -54,15 +58,14 @@ export interface ProjectPageMetadataLD {
}[];
'schema:creditText'?: string;
'schema:description'?: string;
'regen:marketType'?: MarketType[];
'regen:story'?: string;
'regen:storyTitle'?: string;
'regen:storyMedia'?: ProjectStoryMedia;

// Legacy project fields
'schema:image'?: string;
'regen:glanceText'?: string[];
'regen:landStory'?: string;
'regen:story'?: string;
'regen:storyTitle'?: string;
'regen:storyMedia'?: ProjectStoryMedia;
'regen:projectQuote'?: ProjectQuote;
'regen:boundaries'?: string;
'regen:landManagementActions'?: NameImageDescription[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface TerrasosProjectMetadataLD {
'regen:watershed'?: string;
'regen:subWatershed'?: string;
}

export type IucnStatus =
| 'EXTINCT'
| 'EXTINCT_IN_WILD'
Expand All @@ -27,7 +28,9 @@ export type IucnStatus =
| 'LEAST_CONCERN'
| 'DATA_DEFICIENT'
| 'NOT_EVALUATED';

export type MarketType = 'COMPLIANCE_MARKET' | 'VOLUNTARY_MARKET';

export type QudtValue = {
'qudt:unit': string;
'qudt:numericValue': number;
Expand Down
26 changes: 13 additions & 13 deletions web-marketplace/src/lib/i18n/locales/en.po
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
msgid ""
msgstr ""
"POT-Creation-Date: 2024-11-04 09:28+0100\n"
"POT-Creation-Date: 2024-11-04 09:43+0100\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down Expand Up @@ -330,7 +330,7 @@ msgid "Additional Certifications"
msgstr ""

#: src/components/molecules/BatchMetadata/BatchMetadata.tsx:27
#: src/components/templates/ProjectDetails/tables/ProjectDetails.TableTabs.config.tsx:50
#: src/components/templates/ProjectDetails/tables/ProjectDetails.TableTabs.config.tsx:52
#: src/pages/CreditClassDetails/tables/CreditClassDetails.TableTabs.config.tsx:33
msgid "Additional Info"
msgstr ""
Expand Down Expand Up @@ -1222,7 +1222,7 @@ msgstr ""
msgid "Credit Details"
msgstr ""

#: src/components/templates/ProjectDetails/tables/ProjectDetails.TableTabs.config.tsx:35
#: src/components/templates/ProjectDetails/tables/ProjectDetails.TableTabs.config.tsx:37
#: src/pages/CreditClassDetails/tables/CreditClassDetails.TableTabs.config.tsx:20
msgid "Credit Issuance"
msgstr ""
Expand Down Expand Up @@ -2834,7 +2834,7 @@ msgstr ""
msgid "project benefit"
msgstr ""

#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:110
#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:112
msgid "Project Design Document"
msgstr ""

Expand All @@ -2847,19 +2847,19 @@ msgid "Project Developer"
msgstr ""

#: src/components/templates/ProjectDetails/tables/documentation/ProjectDetails.Documentation.tsx:49
#: src/components/templates/ProjectDetails/tables/ProjectDetails.TableTabs.config.tsx:25
#: src/components/templates/ProjectDetails/tables/ProjectDetails.TableTabs.config.tsx:27
msgid "Project documentation"
msgstr ""

#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:133
#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:135
msgid "project end date"
msgstr ""

#: src/pages/ProjectFinished/ProjectFinished.tsx:58
msgid "Project has been created!"
msgstr ""

#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:72
#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:73
#: src/pages/ProjectFinished/ProjectFinished.tsx:76
msgid "project id"
msgstr ""
Expand Down Expand Up @@ -2913,7 +2913,7 @@ msgstr ""
msgid "Project start and end date"
msgstr ""

#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:125
#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:127
msgid "project start date"
msgstr ""

Expand All @@ -2933,7 +2933,7 @@ msgstr ""
msgid "Project timeline"
msgstr ""

#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:102
#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:104
#: src/lib/constants/shared.constants.tsx:196
msgid "project type"
msgstr ""
Expand Down Expand Up @@ -3027,7 +3027,7 @@ msgstr ""
msgid "Redwood Testnet Faucet"
msgstr ""

#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:116
#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:118
msgid "reference id (cfc project id)"
msgstr ""

Expand Down Expand Up @@ -3899,7 +3899,7 @@ msgstr ""
msgid "total purchase price"
msgstr ""

#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:83
#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:85
msgid "toucan project token id"
msgstr ""

Expand Down Expand Up @@ -4037,7 +4037,7 @@ msgstr ""
msgid "VCS methodology url"
msgstr ""

#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:92
#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:94
msgid "vcs project id"
msgstr ""

Expand All @@ -4049,7 +4049,7 @@ msgstr ""
msgid "VCS project page url"
msgstr ""

#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:102
#: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:104
msgid "vcs project type"
msgstr ""

Expand Down
Loading

0 comments on commit 3421b46

Please sign in to comment.