feat: render stock logos with signed returns on account page
This commit is contained in:
@@ -4,5 +4,6 @@ export {
|
||||
formatMoney,
|
||||
formatShare,
|
||||
formatSnapshotTime,
|
||||
instrumentLogoUrl,
|
||||
portfolioErrorCode,
|
||||
} from "./model/display";
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user