This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactoring token logo logic * New component InvestmentSummaryRow semi complete * Also filtering free claims to show them on summary page * Dynamically loading claims on investment summary page * Refactored calculatePercentage function into utils * Refactored new utils calculateInvestmentAmounts * Upgradring EnhancedUserClaimData into ClaimWithInvestmentData * Adding vCowAmount, cost and percentage to InvestmentSummaryRow * Renamed paidClaims to selectedClaims as they are a subset only * Refactored free and selected claims * Fixed typo * Further refactoring stuff on InvesmentFlow component Co-authored-by: Leandro <[email protected]>
- Loading branch information
1 parent
e8dbe09
commit a116ab5
Showing
6 changed files
with
199 additions
and
96 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
73 changes: 73 additions & 0 deletions
73
src/custom/pages/Claim/InvestmentFlow/InvestSummaryRow.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,73 @@ | ||
import { ClaimType } from 'state/claim/hooks' | ||
import { calculatePercentage } from 'state/claim/hooks/utils' | ||
import { TokenLogo } from 'pages/Claim/styled' | ||
import { ClaimWithInvestmentData } from 'pages/Claim/types' | ||
import CowProtocolLogo from 'components/CowProtocolLogo' | ||
import { formatSmart } from 'utils/format' | ||
import { AMOUNT_PRECISION } from 'constants/index' | ||
|
||
export type Props = { claim: ClaimWithInvestmentData } | ||
|
||
export function InvestSummaryRow(props: Props): JSX.Element | null { | ||
const { claim } = props | ||
|
||
const { isFree, type, price, currencyAmount, vCowAmount, cost, investmentCost } = claim | ||
|
||
const symbol = isFree ? '' : (currencyAmount?.currency?.symbol as string) | ||
|
||
const formattedCost = | ||
formatSmart(investmentCost, AMOUNT_PRECISION, { thousandSeparator: true, isLocaleAware: true }) || '0' | ||
const percentage = investmentCost && cost && calculatePercentage(investmentCost, cost) | ||
|
||
return ( | ||
<tr> | ||
<td> | ||
{isFree ? ( | ||
<b>{ClaimType[type]}</b> | ||
) : ( | ||
<> | ||
<TokenLogo symbol={symbol} size={32} /> | ||
<CowProtocolLogo size={32} /> | ||
<span> | ||
<b>Buy vCOW</b> | ||
<i>with {symbol}</i> | ||
</span> | ||
</> | ||
)} | ||
</td> | ||
|
||
<td> | ||
{!isFree && ( | ||
<span> | ||
<b>Investment amount:</b>{' '} | ||
<i> | ||
{formattedCost} {symbol} ({percentage}% of available investing opportunity) | ||
</i> | ||
</span> | ||
)} | ||
<span> | ||
<b>Amount to receive:</b> | ||
<i>{formatSmart(vCowAmount) || '0'} vCOW</i> | ||
</span> | ||
</td> | ||
|
||
<td> | ||
{!isFree && ( | ||
<span> | ||
<b>Price:</b>{' '} | ||
<i> | ||
{formatSmart(price) || '0'} vCoW per {symbol} | ||
</i> | ||
</span> | ||
)} | ||
<span> | ||
<b>Cost:</b> <i>{isFree ? 'Free!' : `${formattedCost} ${symbol}`}</i> | ||
</span> | ||
<span> | ||
<b>Vesting:</b> | ||
<i>{type === ClaimType.Airdrop ? 'No' : '4 years (linear)'}</i> | ||
</span> | ||
</td> | ||
</tr> | ||
) | ||
} |
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
Oops, something went wrong.