-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create pool redesign - feature branch (#2537)
* Fabric changes * Type updates * Add new create pool index * Add pool structure section * Fix sidebar * Add pool details section * Add pool setup section * Minor UI fix * Pool structure - create pool (#2543) * Add pool structure UI changes * Small UI fix * Avoid deletion on entries if less than one * Add logic to single / multi sign * Fix linter errors * Create pool - functionality (#2545) * Fix ts error and change logic for onboarding values * Add create pool existing functionality * Cleanup types * cleanup * Add deposit banner * Fix linter errors * Add metadata values * Cleanup types * Add onboarding functionality and UI fixes * Add proxies functionality * Fix ts errors * Add create pool dialog * Add dialogs * Add review feedback * wip * Add waiting before redirecting to avoid error * Remove default empty pool fee * Create pool bugs and fixes (#2550) * Bug fixes and add proposal link * Fix ratings creating empty value * Update fabric/src/theme/tokens/colors.ts Co-authored-by: Sophia <[email protected]> * Update centrifuge-app/src/pages/IssuerCreatePool/IssuerCategories.tsx Co-authored-by: Sophia <[email protected]> * Update centrifuge-app/src/pages/IssuerCreatePool/PoolSetupSection.tsx Co-authored-by: Sophia <[email protected]> * Add feedback * feedback * Feedback changes * Add feeback * Fix tranches apy APY should be based on junior token * Add feeback * Fix placeholder color * Replace file upload with image upload * Bug fixes * Code review feedback * Add jay's feedback and cleanup * Update centrifuge-app/src/components/Menu/IssuerMenu.tsx Co-authored-by: Onno Visser <[email protected]> * Update centrifuge-app/src/pages/IssuerCreatePool/validate.ts Co-authored-by: Onno Visser <[email protected]> * Update centrifuge-app/src/pages/IssuerCreatePool/validate.ts Co-authored-by: Onno Visser <[email protected]> * Rebase issue --------- Co-authored-by: Sophia <[email protected]> Co-authored-by: Onno Visser <[email protected]>
- Loading branch information
1 parent
6f9b38b
commit df6cf97
Showing
40 changed files
with
2,654 additions
and
953 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
centrifuge-app/src/pages/IssuerCreatePool/FormAddressInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { evmToSubstrateAddress } from '@centrifuge/centrifuge-js' | ||
import { useCentrifugeUtils } from '@centrifuge/centrifuge-react' | ||
import { TextInput } from '@centrifuge/fabric' | ||
import { useField } from 'formik' | ||
import React from 'react' | ||
import { FieldWithErrorMessage } from '../../../src/components/FieldWithErrorMessage' | ||
import { isEvmAddress } from '../../../src/utils/address' | ||
import { truncate } from '../../utils/web3' | ||
|
||
interface FormAddressInputProps { | ||
name: string | ||
chainId?: number | ||
placeholder?: string | ||
} | ||
|
||
export const FormAddressInput = ({ name, chainId, placeholder }: FormAddressInputProps) => { | ||
const [field, meta, helpers] = useField(name) | ||
const utils = useCentrifugeUtils() | ||
|
||
let truncated: string | undefined | ||
try { | ||
truncated = truncate(utils.formatAddress(field.value)) | ||
} catch (e) { | ||
truncated = undefined | ||
} | ||
|
||
function handleBlur() { | ||
helpers.setTouched(true) | ||
|
||
if (!truncated || meta.error) { | ||
helpers.setError('Invalid address') | ||
return | ||
} | ||
|
||
helpers.setValue(isEvmAddress(field.value) ? evmToSubstrateAddress(field.value, chainId ?? 0) : field.value) | ||
} | ||
|
||
return ( | ||
<FieldWithErrorMessage | ||
{...field} | ||
placeholder={placeholder ?? 'Type address...'} | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => helpers.setValue(e.target.value)} | ||
onBlur={handleBlur} | ||
errorMessage={meta.touched && meta.error ? meta.error : undefined} | ||
as={TextInput} | ||
/> | ||
) | ||
} |
113 changes: 113 additions & 0 deletions
113
centrifuge-app/src/pages/IssuerCreatePool/IssuerCategories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { PoolMetadataInput } from '@centrifuge/centrifuge-js' | ||
import { Box, Grid, IconButton, IconTrash, Select, Text, TextInput } from '@centrifuge/fabric' | ||
import { Field, FieldArray, FieldProps, useFormikContext } from 'formik' | ||
import { FieldWithErrorMessage } from '../../../src/components/FieldWithErrorMessage' | ||
import { AddButton } from './PoolDetailsSection' | ||
import { StyledGrid } from './PoolStructureSection' | ||
|
||
const PROVIDERS = [ | ||
{ label: 'Please select...', value: '' }, | ||
{ 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: 'investmentManager' }, | ||
{ label: 'Sub-advisor', value: 'subadvisor' }, | ||
{ label: 'Historical default rate', value: 'historicalDefaultRate' }, | ||
{ label: 'Other', value: 'other' }, | ||
] | ||
|
||
export const LabelWithDeleteButton = ({ | ||
onDelete, | ||
hideButton, | ||
label, | ||
}: { | ||
onDelete: () => void | ||
hideButton: boolean | ||
label: string | ||
}) => { | ||
return ( | ||
<Box display="flex" justifyContent="space-between" alignItems="center"> | ||
<Text variant="heading4">{label}</Text> | ||
{!hideButton && ( | ||
<IconButton onClick={onDelete}> | ||
<IconTrash color="textSecondary" /> | ||
</IconButton> | ||
)} | ||
</Box> | ||
) | ||
} | ||
|
||
export const IssuerCategoriesSection = () => { | ||
const form = useFormikContext<PoolMetadataInput>() | ||
return ( | ||
<Box mt={4} mb={3}> | ||
<Text variant="heading2">Service providers</Text> | ||
<StyledGrid gridTemplateColumns={['1fr', '1fr 1fr']} mt={3}> | ||
<FieldArray name="issuerCategories"> | ||
{({ push, remove }) => ( | ||
<> | ||
{form.values.issuerCategories.map((category, index) => ( | ||
<> | ||
<Grid gridTemplateColumns={['1fr', category.type === 'other' ? '1fr 1fr' : '1fr']} gap={2}> | ||
<Field name={`issuerCategories.${index}.type`}> | ||
{({ field, meta }: FieldProps) => ( | ||
<Select | ||
name={field.name} | ||
label="Type" | ||
onChange={(event) => form.setFieldValue(field.name, event.target.value)} | ||
onBlur={field.onBlur} | ||
value={field.value} | ||
options={PROVIDERS} | ||
errorMessage={meta.touched && meta.error ? meta.error : undefined} | ||
/> | ||
)} | ||
</Field> | ||
{category.type === 'other' && ( | ||
<Field name={`issuerCategories.${index}.description`}> | ||
{({ field, meta }: FieldProps) => ( | ||
<FieldWithErrorMessage | ||
{...field} | ||
label="Description" | ||
placeholder="Type here..." | ||
maxLength={100} | ||
as={TextInput} | ||
errorMessage={meta.touched && meta.error ? meta.error : undefined} | ||
onBlur={field.onBlur} | ||
/> | ||
)} | ||
</Field> | ||
)} | ||
</Grid> | ||
<Field name={`issuerCategories.${index}.value`}> | ||
{({ field, meta }: FieldProps) => ( | ||
<FieldWithErrorMessage | ||
{...field} | ||
label={ | ||
<LabelWithDeleteButton | ||
onDelete={() => remove(index)} | ||
hideButton={form.values.issuerCategories.length === 1} | ||
label="Name of provider" | ||
/> | ||
} | ||
placeholder="Type here..." | ||
maxLength={100} | ||
errorMessage={meta.touched && meta.error ? meta.error : undefined} | ||
onBlur={field.onBlur} | ||
as={TextInput} | ||
/> | ||
)} | ||
</Field> | ||
</> | ||
))} | ||
<Box gridColumn="span 2"> | ||
<AddButton onClick={() => push({ type: '', value: '' })} /> | ||
</Box> | ||
</> | ||
)} | ||
</FieldArray> | ||
</StyledGrid> | ||
</Box> | ||
) | ||
} |
Oops, something went wrong.