-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add drawer accordiong by selected asset type arch
- Loading branch information
Showing
9 changed files
with
165 additions
and
92 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
90 changes: 90 additions & 0 deletions
90
centrifuge-app/src/components/Dashboard/assets/CreateAssetForm.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,90 @@ | ||
import { Accordion, Box, Divider, IconHelpCircle, Text, TextInput } from '@centrifuge/fabric' | ||
import { Field, FieldProps, useFormikContext } from 'formik' | ||
import { tooltipText } from 'src/components/Tooltips' | ||
import { useTheme } from 'styled-components' | ||
import { useSuitableAccounts } from '../../../../src/utils/usePermissions' | ||
import { CheckboxOption } from '../../../pages/IssuerCreatePool/PoolStructureSection' | ||
import { CreateAssetFormValues } from './CreateAssetsDrawer' | ||
import { CustomAssetForm } from './CustomAssetForm' | ||
import { FundSharesForm } from './FundSharesForm' | ||
import { LiquidAssetsForm } from './LiquidAssetsForm' | ||
|
||
const assetTypes = [ | ||
{ label: 'Cash', tooltip: 'cashAsset', id: 'cash' }, | ||
{ label: 'Liquid assets', tooltip: 'liquidAsset', id: 'liquid' }, | ||
{ label: 'Fund shares', tooltip: 'fundShares', id: 'fund' }, | ||
{ label: 'Custom assets', tooltip: 'customAsset', id: 'custom' }, | ||
] | ||
|
||
export function CreateAssetsForm({ hasTemplates }: { hasTemplates: boolean }) { | ||
const form = useFormikContext<CreateAssetFormValues>() | ||
const theme = useTheme() | ||
const canCreateAssets = | ||
useSuitableAccounts({ poolId: form.values.poolId, poolRole: ['Borrower'], proxyType: ['Borrow'] }).length > 0 | ||
|
||
const renderBody = () => { | ||
switch (form.values.assetType) { | ||
case 'liquid': | ||
return <LiquidAssetsForm /> | ||
case 'fund': | ||
return <FundSharesForm /> | ||
case 'custom': | ||
return <CustomAssetForm /> | ||
} | ||
} | ||
|
||
return ( | ||
<Box> | ||
<Box | ||
backgroundColor="backgroundSecondary" | ||
borderRadius={8} | ||
p={2} | ||
mt={3} | ||
border={`1px solid ${theme.colors.borderPrimary}`} | ||
> | ||
<Box> | ||
<Text variant="heading4">Select asset type*</Text> | ||
{assetTypes.map((asset) => ( | ||
<CheckboxOption | ||
height={40} | ||
name="assetType" | ||
label={asset.label} | ||
icon={<IconHelpCircle size="iconSmall" color={theme.colors.textSecondary} />} | ||
onChange={() => form.setFieldValue('assetType', asset.id)} | ||
isChecked={form.values.assetType === asset.id} | ||
id={asset.tooltip as keyof typeof tooltipText} | ||
/> | ||
))} | ||
</Box> | ||
<Box mt={3}> | ||
<Field name="assetName"> | ||
{({ field, form }: FieldProps) => ( | ||
<TextInput | ||
name="assetName" | ||
label="Asset name*" | ||
value={field.value} | ||
onChange={(event) => { | ||
form.setFieldValue('assetName', event.target.value) | ||
}} | ||
/> | ||
)} | ||
</Field> | ||
</Box> | ||
</Box> | ||
{hasTemplates && canCreateAssets && form.values.assetType !== 'cash' && ( | ||
<Box mt={3}> | ||
<Accordion | ||
items={[ | ||
{ | ||
title: 'Pricing', | ||
body: renderBody(), | ||
}, | ||
]} | ||
hideBorder | ||
/> | ||
<Divider color="backgroundSecondary" /> | ||
</Box> | ||
)} | ||
</Box> | ||
) | ||
} |
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
3 changes: 3 additions & 0 deletions
3
centrifuge-app/src/components/Dashboard/assets/CustomAssetForm.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,3 @@ | ||
export const CustomAssetForm = () => { | ||
return <div>CustomAssetForm</div> | ||
} |
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
3 changes: 3 additions & 0 deletions
3
centrifuge-app/src/components/Dashboard/assets/FundSharesForm.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,3 @@ | ||
export const FundSharesForm = () => { | ||
return <div>FundSharesForm</div> | ||
} |
3 changes: 3 additions & 0 deletions
3
centrifuge-app/src/components/Dashboard/assets/LiquidAssetsForm.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,3 @@ | ||
export const LiquidAssetsForm = () => { | ||
return <div>LiquidAssetsForm</div> | ||
} |
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
Oops, something went wrong.