chore: codify React component style

This commit is contained in:
2026-08-25 15:33:20 +03:00
parent 268acdf2e1
commit d10e1dd182
65 changed files with 711 additions and 365 deletions
+13 -7
View File
@@ -12,12 +12,12 @@ function formatDecimal(value: string): string {
return `${sign}${grouped}${fraction ? `,${fraction}` : ""}`;
}
export function formatMoney(money: Money | null): string {
function formatMoney(money: Money | null): string {
if (!money) return "—";
return `${formatDecimal(money.value)} ${money.currency === "RUB" ? "₽" : money.currency}`;
}
export function formatShare(
function formatShare(
numerator: Money | null,
denominator: Money | null,
): string | null {
@@ -32,7 +32,7 @@ export function formatShare(
return `${rounded} %`;
}
export function formatSnapshotTime(value: string): string {
function formatSnapshotTime(value: string): string {
return new Intl.DateTimeFormat("ru-RU", {
dateStyle: "medium",
timeStyle: "short",
@@ -40,7 +40,7 @@ export function formatSnapshotTime(value: string): string {
}).format(new Date(value));
}
export function portfolioErrorCode(error: unknown): string | undefined {
function portfolioErrorCode(error: unknown): string | undefined {
return typeof error === "object" && error !== null && "code" in error
? String(error.code)
: undefined;
@@ -48,11 +48,17 @@ export function portfolioErrorCode(error: unknown): string | undefined {
const logoSize = 160;
export function instrumentLogoUrl(
logoName: string | null | undefined,
): string | null {
function instrumentLogoUrl(logoName: string | null | undefined): string | null {
const stem = logoName?.trim().replace(/\.png$/i, "");
return stem
? `https://invest-brands.cdn-tinkoff.ru/${stem}x${logoSize}.png`
: null;
}
export {
formatMoney,
formatShare,
formatSnapshotTime,
instrumentLogoUrl,
portfolioErrorCode,
};