From bdad087afdad528cfc4d8e04be14d116bd79fd11 Mon Sep 17 00:00:00 2001 From: sophian Date: Fri, 11 Oct 2024 13:44:57 -0400 Subject: [PATCH 1/7] Update inputs, UI, and types to support multiple ratings --- .../src/components/IssuerSection.tsx | 42 +++++++----- .../components/PoolOverview/KeyMetrics.tsx | 52 ++++++--------- .../IssuerCreatePool/PoolRatingInput.tsx | 64 +++++++++++++++---- .../src/pages/IssuerCreatePool/index.tsx | 32 +++++----- .../pages/IssuerPool/Configuration/Issuer.tsx | 20 +++--- centrifuge-js/src/modules/pools.ts | 30 ++++----- 6 files changed, 132 insertions(+), 108 deletions(-) diff --git a/centrifuge-app/src/components/IssuerSection.tsx b/centrifuge-app/src/components/IssuerSection.tsx index 8ba196b26..29a8570e5 100644 --- a/centrifuge-app/src/components/IssuerSection.tsx +++ b/centrifuge-app/src/components/IssuerSection.tsx @@ -207,27 +207,35 @@ const Links = ({ links }: { links: { label: string; href?: string; show: boolean } export function RatingDetails({ metadata }: IssuerSectionProps) { - const rating = metadata?.pool?.rating + const ratings = metadata?.pool?.poolRatings - return rating?.ratingAgency || rating?.ratingValue || rating?.ratingReportUrl ? ( + return ratings?.length ? ( Pool rating - - {rating.ratingAgency && ( - {rating.ratingAgency}} /> - )} - {rating.ratingValue && ( - {rating.ratingValue}} /> - )} - - - - {rating?.ratingReportUrl && ( - - View full report - - )} + {ratings?.map((rating) => { + return ( + + + + {rating.agency && ( + {rating.agency}} /> + )} + {rating.value && ( + {rating.value}} /> + )} + + + + {rating?.reportUrl && ( + + View full report + + )} + + + ) + })} ) : null diff --git a/centrifuge-app/src/components/PoolOverview/KeyMetrics.tsx b/centrifuge-app/src/components/PoolOverview/KeyMetrics.tsx index ed169d950..bd25addf7 100644 --- a/centrifuge-app/src/components/PoolOverview/KeyMetrics.tsx +++ b/centrifuge-app/src/components/PoolOverview/KeyMetrics.tsx @@ -144,39 +144,27 @@ export const KeyMetrics = ({ poolId }: Props) => { metric: 'Pool structure', value: metadata?.pool?.poolStructure ? metadata?.pool?.poolStructure : '-', }, - ...(metadata?.pool?.rating?.ratingValue - ? [ - { - metric: 'Rating', - value: ( - - } + ...(metadata?.pool?.poolRatings?.length + ? metadata?.pool?.poolRatings.map((rating) => ({ + metric: 'Rating', + value: ( + } + > + - - {metadata?.pool?.rating?.ratingAgency?.includes('moody') ? ( - - ) : ( - - )} - {metadata?.pool?.rating?.ratingValue} - - - ), - }, - ] + {rating.agency?.includes('moody') ? : } + {rating.value} + + + ), + })) : []), { diff --git a/centrifuge-app/src/pages/IssuerCreatePool/PoolRatingInput.tsx b/centrifuge-app/src/pages/IssuerCreatePool/PoolRatingInput.tsx index c46c6c94d..94948a00b 100644 --- a/centrifuge-app/src/pages/IssuerCreatePool/PoolRatingInput.tsx +++ b/centrifuge-app/src/pages/IssuerCreatePool/PoolRatingInput.tsx @@ -1,20 +1,56 @@ -import { Grid, Stack, Text, TextInput } from '@centrifuge/fabric' +import { PoolMetadataInput } from '@centrifuge/centrifuge-js' +import { Box, Button, Grid, IconMinusCircle, Shelf, Stack, Text, TextInput } from '@centrifuge/fabric' +import { FieldArray, useFormikContext } from 'formik' import { FieldWithErrorMessage } from '../../components/FieldWithErrorMessage' export function PoolRatingInput() { + const form = useFormikContext() + console.log('🚀 ~ form:', form.values.poolRatings) return ( - - Pool rating - - - - - - + + {({ push, remove }) => ( + + + Pool rating + + + + {form.values.poolRatings.length + ? form.values.poolRatings.map((rating, index) => ( + + <> + + + + + + + +