From 4d6c4282475a2664c73efb06ab6f90fe987abce2 Mon Sep 17 00:00:00 2001 From: katty barroso Date: Thu, 14 Nov 2024 17:29:06 +0100 Subject: [PATCH] Add pool details section UI --- .../IssuerCreatePool/PoolDetailsSection.tsx | 418 ++++++++++++++++++ .../IssuerCreatePool/PoolStructureSection.tsx | 49 +- .../src/pages/IssuerCreatePool/index.tsx | 40 +- .../IssuerCreatePool/{types.tsx => types.ts} | 10 +- .../src/pages/IssuerCreatePool/validate.ts | 28 +- fabric/src/components/FileUpload/index.tsx | 158 ++++--- fabric/src/components/Stepper/index.tsx | 61 +-- fabric/src/components/TextInput/index.tsx | 6 +- fabric/src/icon-svg/icon-upload.svg | 11 +- fabric/src/theme/tokens/colors.ts | 2 +- 10 files changed, 646 insertions(+), 137 deletions(-) create mode 100644 centrifuge-app/src/pages/IssuerCreatePool/PoolDetailsSection.tsx rename centrifuge-app/src/pages/IssuerCreatePool/{types.tsx => types.ts} (95%) diff --git a/centrifuge-app/src/pages/IssuerCreatePool/PoolDetailsSection.tsx b/centrifuge-app/src/pages/IssuerCreatePool/PoolDetailsSection.tsx new file mode 100644 index 0000000000..de9bd5251d --- /dev/null +++ b/centrifuge-app/src/pages/IssuerCreatePool/PoolDetailsSection.tsx @@ -0,0 +1,418 @@ +import { PoolMetadataInput } from '@centrifuge/centrifuge-js' +import { + Box, + Button, + CurrencyInput, + FileUpload, + Grid, + Select, + Text, + TextAreaInput, + TextInput, +} from '@centrifuge/fabric' +import { Field, FieldProps, useFormikContext } from 'formik' +import { useTheme } from 'styled-components' +import { FieldWithErrorMessage } from '../../../src/components/FieldWithErrorMessage' +import { Tooltips } from '../../../src/components/Tooltips' +import { isTestEnv } from '../../../src/config' +import { StyledGrid } from './PoolStructureSection' +import { validate } from './validate' + +const PROVIDERS = [ + { label: 'Fund admin', value: 'fundAdmin' }, + { label: 'Trustee', value: 'trustee' }, + { label: 'Pricing oracle provider', value: 'pricingOracleProvider' }, + { label: 'Auditor', value: 'auditor' }, + { label: 'Custodian', value: 'custodian' }, + { label: 'Investment manager', value: 'Investment manager' }, + { label: 'Sub-advisor', value: 'subadvisor' }, + { label: 'Historical default rate', value: 'historicalDefaultRate' }, + { label: 'Other', value: 'other' }, +] + +export const Line = () => { + const theme = useTheme() + return +} + +export const PoolDetailsSection = () => { + const theme = useTheme() + const form = useFormikContext() + const createLabel = (label: string) => `${label}${isTestEnv ? '' : '*'}` + + return ( + + + Pool Details + + + + + {({ field, meta, form }: FieldProps) => ( + + )} + + + {({ field, meta, form }: FieldProps) => ( + { + form.setFieldTouched('poolIcon', true, false) + form.setFieldValue('poolIcon', file) + }} + label="Pool icon*" + errorMessage={meta.touched && meta.error ? meta.error : undefined} + accept="image/svg+xml" + fileTypeText="SVG (in square size)" + /> + )} + + + + + {({ field, meta, form }: FieldProps) => ( + Investor type*} size="sm" /> + } + onChange={(event: any) => form.setFieldValue('investorType', event.target.value)} + onBlur={field.onBlur} + errorMessage={meta.touched && meta.error ? meta.error : undefined} + value={field.value} + as={TextInput} + placeholder="Type here..." + /> + )} + + + {({ field, form }: FieldProps) => ( + form.setFieldValue('maxReserve', value)} + /> + )} + + + {({ field, form, meta }: FieldProps) => ( + { + form.setFieldValue('assetClass', event.target.value) + form.setFieldValue('subAssetClass', '', false) + }} + onBlur={field.onBlur} + errorMessage={meta.touched && meta.error ? meta.error : undefined} + value={field.value} + options={PROVIDERS} + placeholder="Please select..." + /> + )} + + + {({ field, meta, form }: FieldProps) => ( + + )} + + + + + + + + Pool rating + + + {({ field, meta, form }: FieldProps) => ( + + )} + + + {({ field, meta, form }: FieldProps) => ( + + )} + + + {({ field, meta, form }: FieldProps) => ( + + )} + + + {({ field, meta, form }: FieldProps) => ( + { + form.setFieldTouched('executiveSummary', true, false) + form.setFieldValue('executiveSummary', file) + }} + accept="application/pdf" + label={createLabel('Executive summary PDF')} + placeholder="Choose file" + small + /> + )} + + + + + + + + Pool analysis + + + {({ field, meta, form }: FieldProps) => ( + + )} + + + {({ field, meta, form }: FieldProps) => ( + + )} + + + {({ field, meta, form }: FieldProps) => ( + + )} + + + {({ field, meta, form }: FieldProps) => ( + { + form.setFieldTouched('executiveSummary', true, false) + form.setFieldValue('executiveSummary', file) + }} + accept="application/pdf" + label="Reviewer avatar" + placeholder="Choose file" + small + /> + )} + + + + + ) +} diff --git a/centrifuge-app/src/pages/IssuerCreatePool/PoolStructureSection.tsx b/centrifuge-app/src/pages/IssuerCreatePool/PoolStructureSection.tsx index 03aa26a592..73bb434a43 100644 --- a/centrifuge-app/src/pages/IssuerCreatePool/PoolStructureSection.tsx +++ b/centrifuge-app/src/pages/IssuerCreatePool/PoolStructureSection.tsx @@ -1,7 +1,6 @@ import { PoolMetadataInput } from '@centrifuge/centrifuge-js' import { Box, - Button, Checkbox, CurrencyInput, Grid, @@ -12,6 +11,7 @@ import { TextInput, } from '@centrifuge/fabric' import { Field, FieldProps, useFormikContext } from 'formik' +import * as React from 'react' import styled, { useTheme } from 'styled-components' import { FieldWithErrorMessage } from '../../../src/components/FieldWithErrorMessage' import { Tooltips, tooltipText } from '../../../src/components/Tooltips' @@ -32,16 +32,15 @@ export const StyledGrid = styled(Grid)` padding: 40px; border: ${({ theme }) => `1px solid ${theme.colors.borderPrimary}`}; border-radius: 8px; + gap: 24px; @media (max-width: ${({ theme }) => theme.breakpoints.S}) { padding: 12px; } ` -export const StyledBox = styled(StyledGrid)`` - -const Line = () => { +export const Line = () => { const theme = useTheme() - return + return } const ASSET_CLASSES = Object.keys(config.assetClasses).map((key) => ({ @@ -57,6 +56,7 @@ const CheckboxOption = ({ icon, sublabel, id, + height, }: { name: string label: string @@ -65,8 +65,10 @@ const CheckboxOption = ({ disabled?: boolean icon?: React.ReactNode id?: keyof typeof tooltipText + height?: number }) => { const theme = useTheme() + return ( @@ -109,8 +111,6 @@ export const PoolStructureSection = () => { const form = useFormikContext() const { values } = form - console.log(values) - const subAssetClasses = config.assetClasses[form.values.assetClass]?.map((label) => ({ label, @@ -142,16 +142,18 @@ export const PoolStructureSection = () => { Pool Structure - + Pool type * { Tranches {Array.from({ length: values.trancheStructure }).map((_, index) => ( - + Tranche {index + 1} @@ -292,6 +294,7 @@ export const PoolStructureSection = () => { + {({ field, form, meta }: FieldProps) => ( @@ -303,18 +306,18 @@ export const PoolStructureSection = () => { placeholder="4-12 characters" minLength={4} maxLength={12} - // disabled={isUpdating} /> )} + {index === 0 ? ( - + {({ field, meta, form }: FieldProps) => (