diff --git a/centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx b/centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx index 66d1527441..b0c3a5c00e 100644 --- a/centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx +++ b/centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx @@ -118,7 +118,7 @@ export function ExternalFinanceForm({ loan }: { loan: LoanType }) { - 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. {availableFinancing.greaterThan(0) && !maturityDatePassed && ( diff --git a/centrifuge-app/src/pages/Loan/PricingValues.tsx b/centrifuge-app/src/pages/Loan/PricingValues.tsx index 17599b3a75..881ed2e62a 100644 --- a/centrifuge-app/src/pages/Loan/PricingValues.tsx +++ b/centrifuge-app/src/pages/Loan/PricingValues.tsx @@ -24,7 +24,7 @@ export function PricingValues({ loan: { pricing }, pool }: Props) { <> 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', diff --git a/centrifuge-app/src/utils/date.ts b/centrifuge-app/src/utils/date.ts index aa726ae9a0..ff949fe89f 100644 --- a/centrifuge-app/src/utils/date.ts +++ b/centrifuge-app/src/utils/date.ts @@ -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()) +} diff --git a/centrifuge-app/src/utils/validation/index.ts b/centrifuge-app/src/utils/validation/index.ts index 0e56786cbf..cce8fd1459 100644 --- a/centrifuge-app/src/utils/validation/index.ts +++ b/centrifuge-app/src/utils/validation/index.ts @@ -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) => {