feat: render stock logos with signed returns on account page

This commit is contained in:
2026-08-24 23:41:49 +03:00
parent 11be786943
commit a6d3051270
8 changed files with 122 additions and 8 deletions
+12 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { formatMoney, formatShare } from "./display";
import { formatMoney, formatShare, instrumentLogoUrl } from "./display";
describe("portfolio display helpers", () => {
it("formats decimal strings without financial arithmetic", () => {
@@ -33,4 +33,15 @@ describe("portfolio display helpers", () => {
),
).toBeNull();
});
it("builds the brand logo url from an upstream file name", () => {
expect(instrumentLogoUrl("sber3.png")).toBe(
"https://invest-brands.cdn-tinkoff.ru/sber3x160.png",
);
expect(instrumentLogoUrl(" RU000A0JPNM1.png ")).toBe(
"https://invest-brands.cdn-tinkoff.ru/RU000A0JPNM1x160.png",
);
expect(instrumentLogoUrl(null)).toBeNull();
expect(instrumentLogoUrl(" ")).toBeNull();
});
});
+11
View File
@@ -45,3 +45,14 @@ export function portfolioErrorCode(error: unknown): string | undefined {
? String(error.code)
: undefined;
}
const logoSize = 160;
export 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;
}