fix: keep position card stories off the account model data imports (#112)
This commit is contained in:
@@ -93,6 +93,7 @@ describe("account position sections", () => {
|
|||||||
displayName: "Акция",
|
displayName: "Акция",
|
||||||
logoSrc: "https://invest-brands.cdn-tinkoff.ru/akciyax160.png",
|
logoSrc: "https://invest-brands.cdn-tinkoff.ru/akciyax160.png",
|
||||||
returnPercent: null,
|
returnPercent: null,
|
||||||
|
returnPercentText: null,
|
||||||
returnText: "+10 ₽",
|
returnText: "+10 ₽",
|
||||||
returnTone: "positive",
|
returnTone: "positive",
|
||||||
shareText: "66,7 %",
|
shareText: "66,7 %",
|
||||||
@@ -107,6 +108,7 @@ describe("account position sections", () => {
|
|||||||
displayName: "Облигация",
|
displayName: "Облигация",
|
||||||
logoSrc: null,
|
logoSrc: null,
|
||||||
returnPercent: "-11.111111",
|
returnPercent: "-11.111111",
|
||||||
|
returnPercentText: "-11,11 %",
|
||||||
returnText: "-5 ₽",
|
returnText: "-5 ₽",
|
||||||
returnTone: "negative",
|
returnTone: "negative",
|
||||||
shareText: "33,3 %",
|
shareText: "33,3 %",
|
||||||
@@ -120,6 +122,7 @@ describe("account position sections", () => {
|
|||||||
displayName: "Фонд",
|
displayName: "Фонд",
|
||||||
logoSrc: null,
|
logoSrc: null,
|
||||||
returnPercent: null,
|
returnPercent: null,
|
||||||
|
returnPercentText: null,
|
||||||
returnText: null,
|
returnText: null,
|
||||||
returnTone: undefined,
|
returnTone: undefined,
|
||||||
shareText: null,
|
shareText: null,
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { formatShare, type Portfolio } from "@/entities/portfolio";
|
import { formatShare, type Portfolio } from "@/entities/portfolio";
|
||||||
import { formatMoney, instrumentLogoUrl } from "@/shared/lib";
|
import { formatDecimal, formatMoney, instrumentLogoUrl } from "@/shared/lib";
|
||||||
|
|
||||||
type AccountPagePosition = Portfolio["positions"][number] & {
|
type AccountPagePosition = Portfolio["positions"][number] & {
|
||||||
instrumentTo?: string;
|
instrumentTo?: string;
|
||||||
logoSrc: null | string;
|
logoSrc: null | string;
|
||||||
returnPercent: null | string;
|
returnPercent: null | string;
|
||||||
|
returnPercentText: null | string;
|
||||||
returnText: null | string;
|
returnText: null | string;
|
||||||
returnTone?: AccountPageReturnTone;
|
returnTone?: AccountPageReturnTone;
|
||||||
shareText: null | string;
|
shareText: null | string;
|
||||||
@@ -222,6 +223,8 @@ function toPosition(
|
|||||||
const returnPrefix
|
const returnPrefix
|
||||||
= isExpanded && returnValue !== null && returnValue > 0 ? "+" : "";
|
= isExpanded && returnValue !== null && returnValue > 0 ? "+" : "";
|
||||||
|
|
||||||
|
const percent = returnPercent(position);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...position,
|
...position,
|
||||||
instrumentTo:
|
instrumentTo:
|
||||||
@@ -231,7 +234,10 @@ function toPosition(
|
|||||||
logoSrc: isExpanded
|
logoSrc: isExpanded
|
||||||
? instrumentLogoUrl(position.logoName)
|
? instrumentLogoUrl(position.logoName)
|
||||||
: null,
|
: null,
|
||||||
returnPercent: returnPercent(position),
|
returnPercent: percent,
|
||||||
|
returnPercentText: percent
|
||||||
|
? `${formatDecimal(formatPositionReturnPercent(percent))} %`
|
||||||
|
: null,
|
||||||
returnText: position.absoluteReturn
|
returnText: position.absoluteReturn
|
||||||
? `${returnPrefix}${formatMoney(position.absoluteReturn)}`
|
? `${returnPrefix}${formatMoney(position.absoluteReturn)}`
|
||||||
: null,
|
: null,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const syntheticPosition
|
|||||||
logoSrc: null,
|
logoSrc: null,
|
||||||
quantity: "100",
|
quantity: "100",
|
||||||
returnPercent: "25",
|
returnPercent: "25",
|
||||||
|
returnPercentText: "+25,00 %",
|
||||||
returnText: "+5 000 ₽",
|
returnText: "+5 000 ₽",
|
||||||
returnTone: "positive",
|
returnTone: "positive",
|
||||||
shareText: "20%",
|
shareText: "20%",
|
||||||
@@ -75,6 +76,7 @@ export const BondLoss: Story
|
|||||||
isin: "DEMO-BOND-2030",
|
isin: "DEMO-BOND-2030",
|
||||||
quantity: "10",
|
quantity: "10",
|
||||||
returnPercent: "-5",
|
returnPercent: "-5",
|
||||||
|
returnPercentText: "-5,00 %",
|
||||||
returnText: "−500 ₽",
|
returnText: "−500 ₽",
|
||||||
returnTone: "negative",
|
returnTone: "negative",
|
||||||
shareText: "7,6%",
|
shareText: "7,6%",
|
||||||
@@ -126,6 +128,7 @@ export const MissingValuation: Story
|
|||||||
currentValue: null,
|
currentValue: null,
|
||||||
displayName: "Учебная позиция без текущей оценки",
|
displayName: "Учебная позиция без текущей оценки",
|
||||||
returnPercent: null,
|
returnPercent: null,
|
||||||
|
returnPercentText: null,
|
||||||
returnText: null,
|
returnText: null,
|
||||||
returnTone: undefined,
|
returnTone: undefined,
|
||||||
shareText: null,
|
shareText: null,
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import { Anchor, Card, Group, Stack, Text } from "@mantine/core";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link } from "react-router";
|
import { Link } from "react-router";
|
||||||
|
|
||||||
import { formatDecimal, formatMoney } from "@/shared/lib";
|
import { formatMoney } from "@/shared/lib";
|
||||||
|
|
||||||
import {
|
import type {
|
||||||
type AccountPagePosition,
|
AccountPagePosition,
|
||||||
type AccountPagePositionSection,
|
AccountPagePositionSection,
|
||||||
formatPositionReturnPercent,
|
|
||||||
} from "../../../../model/positions";
|
} from "../../../../model/positions";
|
||||||
|
|
||||||
import classes from "../../AccountPage.module.css";
|
import classes from "../../AccountPage.module.css";
|
||||||
import { PositionLogo } from "../PositionLogo.view";
|
import { PositionLogo } from "../PositionLogo.view";
|
||||||
|
|
||||||
@@ -30,8 +30,8 @@ const PositionCard: FC<PositionCardProps> = (props) => {
|
|||||||
|
|
||||||
let returnText = position.returnText;
|
let returnText = position.returnText;
|
||||||
|
|
||||||
if (returnText && position.returnPercent) {
|
if (returnText && position.returnPercentText) {
|
||||||
returnText += ` · ${formatDecimal(formatPositionReturnPercent(position.returnPercent))} %`;
|
returnText += ` · ${position.returnPercentText}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnText && !isExpanded) {
|
if (returnText && !isExpanded) {
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import { Anchor, Card, Group, Stack, Text } from "@mantine/core";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link } from "react-router";
|
import { Link } from "react-router";
|
||||||
|
|
||||||
import { formatDecimal, formatMoney } from "@/shared/lib";
|
import { formatMoney } from "@/shared/lib";
|
||||||
|
|
||||||
import {
|
import type {
|
||||||
type AccountPagePositionGroup,
|
AccountPagePositionGroup,
|
||||||
type AccountPagePositionSection,
|
AccountPagePositionSection,
|
||||||
formatPositionReturnPercent,
|
|
||||||
} from "../../../model/positions";
|
} from "../../../model/positions";
|
||||||
|
|
||||||
import classes from "../AccountPage.module.css";
|
import classes from "../AccountPage.module.css";
|
||||||
import { PositionLogo } from "./PositionLogo.view";
|
import { PositionLogo } from "./PositionLogo.view";
|
||||||
|
|
||||||
@@ -63,8 +63,8 @@ const PositionGroupCard: FC<PositionGroupCardProps> = (props) => {
|
|||||||
? classes[position.returnTone]
|
? classes[position.returnTone]
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const returnPercent = position.returnPercent
|
const returnPercent = position.returnPercentText
|
||||||
? ` · ${formatDecimal(formatPositionReturnPercent(position.returnPercent))} %`
|
? ` · ${position.returnPercentText}`
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
const returnValue = `${position.returnText ?? ""}${returnPercent}`;
|
const returnValue = `${position.returnText ?? ""}${returnPercent}`;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ it("keeps expanded positions vertical while other positions adapt to the viewpor
|
|||||||
logoSrc: null,
|
logoSrc: null,
|
||||||
quantity: "10",
|
quantity: "10",
|
||||||
returnPercent: null,
|
returnPercent: null,
|
||||||
|
returnPercentText: null,
|
||||||
returnText: null,
|
returnText: null,
|
||||||
shareText: null,
|
shareText: null,
|
||||||
ticker: null,
|
ticker: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user