Skip to content

Commit

Permalink
feat: review
Browse files Browse the repository at this point in the history
  • Loading branch information
euharrison committed Nov 8, 2024
1 parent 43e0835 commit e630ae8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TransparentTokensTable = ({
<img src={icon} />
: <div className="rounded-full h-full border border-white" />}
</div>
{display.toUpperCase()}
{asset.symbol}
</div>,
<div
key={`balance-${display}`}
Expand Down Expand Up @@ -185,9 +185,7 @@ export const TransparentOverviewPanel = (): JSX.Element => {
containerProps={{ className: "pb-16" }}
>
{transparentTokensQuery.data?.length ?
<>
<PanelContent data={transparentTokensQuery.data} />
</>
<PanelContent data={transparentTokensQuery.data} />
: <div className="bg-neutral-900 p-6 rounded-sm text-center font-medium my-14">
You currently hold no assets in your unshielded account
</div>
Expand Down
11 changes: 9 additions & 2 deletions apps/namadillo/src/App/Common/FiatCurrency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ import BigNumber from "bignumber.js";
type FiatCurrencyProps = Omit<CurrencyProps, "currency">;

export const FiatCurrency = (props: FiatCurrencyProps): JSX.Element => {
const formattedAmount = new BigNumber(props.amount.toPrecision(2));
let amount = new BigNumber(props.amount);
if (amount.lt(0.01)) {
amount = new BigNumber(amount.toPrecision(2));
} else {
amount = amount.decimalPlaces(2);
}

return (
<Currency
{...props}
currency={{ symbol: "$", fraction: "cents" }}
amount={formattedAmount}
amount={amount}
decimalPlaces={amount.decimalPlaces() === 1 ? 2 : undefined}
/>
);
};
2 changes: 1 addition & 1 deletion apps/namadillo/src/App/Masp/ShieldedFungibleTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ShieldedFungibleTable = ({
<img src={icon} />
: <div className="rounded-full h-full border border-white" />}
</div>
{display.toUpperCase()}
{asset.symbol}
</div>,
<div
key={`balance-${display}`}
Expand Down
4 changes: 3 additions & 1 deletion packages/components/src/Currency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type CurrencyObject = {

export type CurrencyProps = {
amount: number | BigNumber;
decimalPlaces?: number;
hideBalances?: boolean;
currency: CurrencyObject;
separator?: "." | "," | "";
Expand All @@ -21,6 +22,7 @@ export type CurrencyProps = {

export const Currency = ({
amount,
decimalPlaces,
currency,
hideBalances = false,
currencyPosition = "left",
Expand All @@ -32,7 +34,7 @@ export const Currency = ({
fractionClassName = "",
...containerRest
}: CurrencyProps): JSX.Element => {
const amountParts = BigNumber(amount).toFormat().split(".");
const amountParts = BigNumber(amount).toFormat(decimalPlaces).split(".");
const baseAmount = hideBalances ? "✳✳✳✳" : amountParts[0] || "0";
const fraction =
amountParts.length > 1 && !hideBalances ? amountParts[1] : "";
Expand Down

0 comments on commit e630ae8

Please sign in to comment.