Skip to content

Commit

Permalink
verbiage, date format, settlement price
Browse files Browse the repository at this point in the history
  • Loading branch information
JP Angelle committed Sep 12, 2023
1 parent 9455db9 commit 6bf1d19
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function ExternalFinanceForm({ loan }: { loan: LoanType }) {
<Stack as={Card} gap={2} p={2}>
<Box paddingY={1}>
<Text variant="heading4">
To finance the asset, enter face value and settlement price of the treasury bill.
To finance the asset, enter face value and settlement price of the transaction.
</Text>
</Box>
{availableFinancing.greaterThan(0) && !maturityDatePassed && (
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/pages/Loan/PricingValues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function PricingValues({ loan: { pricing }, pool }: Props) {
<>
<LabelValueStack label="ISIN" value={pricing.Isin} />
<LabelValueStack
label="Current price"
label="Latest price"
value={`${formatBalance(
new CurrencyBalance(pricing.oracle.value.toString(), 18).toDecimal(),
pool.currency.symbol,
Expand Down
6 changes: 4 additions & 2 deletions centrifuge-app/src/pages/Loan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Tooltips } from '../../components/Tooltips'
import { nftMetadataSchema } from '../../schemas'
import { LoanTemplate } from '../../types'
import { copyToClipboard } from '../../utils/copyToClipboard'
import { daysBetween, formatDate } from '../../utils/date'
import { daysBetween, formatDate, isValidDate } from '../../utils/date'
import { formatBalance, truncateText } from '../../utils/formatting'
import { useAddress } from '../../utils/useAddress'
import { useLoan, useNftDocumentId } from '../../utils/useLoans'
Expand Down Expand Up @@ -181,7 +181,9 @@ const Loan: React.FC<{ setShowOraclePricing?: () => void }> = ({ setShowOraclePr
?.filter((key) => templateMetadata?.attributes?.[key].public)
.map((key) => ({
label: templateMetadata?.attributes?.[key].label,
value: nftMetadata?.properties[key],
value: isValidDate(nftMetadata?.properties[key])
? formatDate(nftMetadata?.properties[key])
: nftMetadata?.properties[key],
})) || []),
{
label: 'Maturity date',
Expand Down
5 changes: 5 additions & 0 deletions centrifuge-app/src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ export function millisecondsToDays(milliseconds: number): number {
const days = milliseconds / (1000 * 60 * 60 * 24)
return Math.round(days)
}

export function isValidDate(value: string) {
const date = new Date(value)
return !isNaN(date.getTime())
}
6 changes: 5 additions & 1 deletion centrifuge-app/src/utils/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export const positiveNumber = (err?: CustomError) => (val?: any) => {
}

export const settlementPrice = (err?: CustomError) => (val?: any) => {
if (val < 1) {
return getError('Value must be equal to or larger than 1', err, val)
}

const regex = new RegExp(/^\d{1,3}(?:\.\d{1,6})?$/)
return regex.test(val) ? '' : getError(`Value must be in the format of (1-3).(0-6) digits`, err, val)
return regex.test(val) ? '' : getError('Value must be in the format of (1-3).(0-6) digits', err, val)
}

export const maxDecimals = (decimals: number, err?: CustomError) => (val?: any) => {
Expand Down

0 comments on commit 6bf1d19

Please sign in to comment.