Skip to content

Commit

Permalink
remove nft section for cent loans
Browse files Browse the repository at this point in the history
  • Loading branch information
JP Angelle committed Sep 11, 2023
1 parent a13396f commit c941889
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 99 deletions.
28 changes: 6 additions & 22 deletions centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CurrencyBalance, findBalance, Loan as LoanType } from '@centrifuge/centrifuge-js'
import { useBalances, useCentrifugeTransaction } from '@centrifuge/centrifuge-react'
import { Box, Button, Card, CurrencyInput, IconInfo, InlineFeedback, Shelf, Stack, Text } from '@centrifuge/fabric'
import { Box, Button, Card, CurrencyInput, Shelf, Stack, Text } from '@centrifuge/fabric'
import BN from 'bn.js'
import Decimal from 'decimal.js-light'
import { Field, FieldProps, Form, FormikProvider, useFormik } from 'formik'
import * as React from 'react'
import { Dec } from '../../utils/Decimal'
import { formatBalance, roundDown } from '../../utils/formatting'
import { formatBalance } from '../../utils/formatting'
import { useFocusInvalidInput } from '../../utils/useFocusInvalidInput'
import { useAvailableFinancing } from '../../utils/useLoans'
import { useBorrower } from '../../utils/usePermissions'
Expand Down Expand Up @@ -157,8 +157,8 @@ export function ExternalFinanceForm({ loan }: { loan: LoanType }) {
</Field>
<Stack gap={1}>
<Shelf justifyContent="space-between">
<Text variant="body3">Total amount</Text>
<Text variant="body3">
<Text variant="emphasized">Total principal</Text>
<Text variant="emphasized">
{financeForm.values.price && !Number.isNaN(financeForm.values.price as number)
? formatBalance(
Dec(financeForm.values.price || 0)
Expand All @@ -171,16 +171,6 @@ export function ExternalFinanceForm({ loan }: { loan: LoanType }) {
</Text>
</Shelf>
</Stack>
{(poolReserve.lessThan(availableFinancing) ||
('valuationMethod' in loan.pricing && !loan.pricing.maxBorrowAmount)) && (
<Shelf alignItems="flex-start" justifyContent="start" gap="4px">
<IconInfo size="iconMedium" />
<Text variant="body3">
The pool&apos;s available reserve ({formatBalance(poolReserve, pool?.currency.symbol)}) is smaller
than the available financing
</Text>
</Shelf>
)}
<Stack px={1}>
<Button type="submit" loading={isFinanceLoading}>
Finance asset
Expand Down Expand Up @@ -261,8 +251,8 @@ export function ExternalFinanceForm({ loan }: { loan: LoanType }) {
</Field>
<Stack gap={1}>
<Shelf justifyContent="space-between">
<Text variant="body3">Total amount</Text>
<Text variant="body3">
<Text variant="emphasized">Total principal</Text>
<Text variant="emphasized">
{repayForm.values.price && !Number.isNaN(repayForm.values.price as number)
? formatBalance(
Dec(repayForm.values.price || 0)
Expand All @@ -275,12 +265,6 @@ export function ExternalFinanceForm({ loan }: { loan: LoanType }) {
</Text>
</Shelf>
</Stack>
{balance.lessThan(debt) && (
<InlineFeedback>
Your wallet balance ({formatBalance(roundDown(balance), pool?.currency.symbol, 2)}) is smaller than
the outstanding balance.
</InlineFeedback>
)}
<Stack gap={1} px={1}>
<Button type="submit" disabled={isRepayLoading} loading={isRepayLoading}>
Repay asset
Expand Down
81 changes: 4 additions & 77 deletions centrifuge-app/src/pages/Loan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
Flex,
IconChevronLeft,
IconExternalLink,
IconNft,
InteractiveCard,
Shelf,
Stack,
Text,
Expand All @@ -18,14 +16,12 @@ import {
} from '@centrifuge/fabric'
import * as React from 'react'
import { useHistory, useParams, useRouteMatch } from 'react-router'
import { Identity } from '../../components/Identity'
import { LabelValueStack } from '../../components/LabelValueStack'
import LoanLabel from '../../components/LoanLabel'
import { PageHeader } from '../../components/PageHeader'
import { PageSection } from '../../components/PageSection'
import { PageSummary } from '../../components/PageSummary'
import { PageWithSideBar } from '../../components/PageWithSideBar'
import { AnchorPillButton } from '../../components/PillButton'
import { PodAuthSection } from '../../components/PodAuthSection'
import { RouterLinkButton } from '../../components/RouterLinkButton'
import { Tooltips } from '../../components/Tooltips'
Expand Down Expand Up @@ -320,8 +316,8 @@ const Loan: React.FC<{ setShowOraclePricing?: () => void }> = ({ setShowOraclePr
)
})}

<PageSection title={<Box>NFT</Box>}>
{isTinlakePool && 'owner' in loan ? (
{isTinlakePool && 'owner' in loan ? (
<PageSection title={<Box>NFT</Box>}>
<Shelf gap={6}>
<LabelValueStack label={<Tooltips variant="secondary" type="id" />} value={assetId} />
<LabelValueStack
Expand All @@ -340,77 +336,8 @@ const Loan: React.FC<{ setShowOraclePricing?: () => void }> = ({ setShowOraclePr
}
/>
</Shelf>
) : (
<InteractiveCard
icon={<Thumbnail label="nft" type="nft" />}
title={<TextWithPlaceholder isLoading={nftMetadataIsLoading}>{nftMetadata?.name}</TextWithPlaceholder>}
variant="button"
onClick={() => history.push(`/nfts/collection/${loan?.asset.collectionId}/object/${loan?.asset.nftId}`)}
secondaryHeader={
<Shelf gap={6}>
<LabelValueStack label={<Tooltips variant="secondary" type="id" />} value={assetId} />
<LabelValueStack
label="Owner"
value={nft?.owner ? <Identity clickToCopy address={nft.owner} /> : ''}
/>
</Shelf>
}
>
{(nftMetadata?.description || imageUrl) && (
<Shelf gap={3} alignItems="flex-start">
<Box
display="flex"
alignItems="center"
justifyContent="center"
flex="0 1 50%"
style={{ aspectRatio: '1 / 1' }}
backgroundColor="backgroundSecondary"
borderRadius="8px"
overflow="hidden"
>
{imageUrl ? (
<Box as="img" maxWidth="100%" maxHeight="100%" src={imageUrl} />
) : (
<IconNft color="white" size="250px" />
)}
</Box>
<Stack gap={2}>
<LabelValueStack
label="Description"
value={
<TextWithPlaceholder
isLoading={nftMetadataIsLoading}
words={2}
width={80}
variance={30}
variant="body2"
style={{ wordBreak: 'break-word' }}
>
{nftMetadata?.description || 'No description'}
</TextWithPlaceholder>
}
/>

{imageUrl && (
<LabelValueStack
label="Image"
value={
<AnchorPillButton
href={imageUrl}
target="_blank"
style={{ wordBreak: 'break-all', whiteSpace: 'initial' }}
>
Source file
</AnchorPillButton>
}
/>
)}
</Stack>
</Shelf>
)}
</InteractiveCard>
)}
</PageSection>
</PageSection>
) : null}
</>
) : null}
</Stack>
Expand Down

0 comments on commit c941889

Please sign in to comment.