27 lines
930 B
JavaScript
27 lines
930 B
JavaScript
import { Box, useTheme } from "@mui/material";
|
|
import Chip from "../../../components/Chip/Chip";
|
|
import { formatNumber } from "../../../helpers";
|
|
import { DecimalBigNumber } from "../../../helpers/DecimalBigNumber";
|
|
|
|
const BondDiscount = ({ discount, textOnly }) => {
|
|
const theme = useTheme();
|
|
const discountString = `${formatNumber(Number(discount.mul(new DecimalBigNumber("100").toString())), 2)}%`;
|
|
|
|
return textOnly ? (
|
|
<Box
|
|
style={{
|
|
color: new DecimalBigNumber("0").gt(discount) ? theme.colors.feedback.error : theme.colors.feedback.pnlGain,
|
|
}}
|
|
>
|
|
{discountString}
|
|
</Box>
|
|
) : (
|
|
<Chip
|
|
label={`${formatNumber(Number(discount.mul(new DecimalBigNumber("100")).toString()), 2)}%`}
|
|
template={new DecimalBigNumber("0").gt(discount) ? "error" : "success"}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default BondDiscount;
|