refactor: move PortfolioStructure to widgets layer
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
|
||||
import type { Portfolio } from "@/entities/portfolio";
|
||||
|
||||
import { PortfolioStructure } from "./PortfolioStructure";
|
||||
|
||||
const rub: Portfolio["structure"]["currencies"][number] = {
|
||||
categories: [
|
||||
{ sharePercent: "52", type: "STOCK", value: "650000" },
|
||||
{ sharePercent: "30", type: "BOND", value: "375000" },
|
||||
{ sharePercent: "10", type: "OTHER", value: "125000" },
|
||||
{ sharePercent: "8", type: "CASH", value: "100000" },
|
||||
],
|
||||
currency: "RUB",
|
||||
hasNegativeValues: false,
|
||||
totalValue: "1250000",
|
||||
};
|
||||
|
||||
const meta = {
|
||||
args: { structure: { currencies: [rub], unvaluedCategories: [] } },
|
||||
component: PortfolioStructure,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component:
|
||||
"Структура по типам активов, включая доступные деньги. Синтетические серверные суммы и доли, без запросов API и финансовых расчётов на клиенте. При неполной или отрицательной оценке остаётся текстовый список.",
|
||||
},
|
||||
},
|
||||
},
|
||||
tags: ["autodocs"],
|
||||
title: "Widgets/PortfolioStructure",
|
||||
} satisfies Meta<typeof PortfolioStructure>;
|
||||
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Regular: Story = {};
|
||||
export const MultipleCurrencies: Story = {
|
||||
args: {
|
||||
structure: {
|
||||
currencies: [
|
||||
rub,
|
||||
{
|
||||
categories: [{ sharePercent: "100", type: "CASH", value: "500" }],
|
||||
currency: "USD",
|
||||
hasNegativeValues: false,
|
||||
totalValue: "500",
|
||||
},
|
||||
],
|
||||
unvaluedCategories: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
export const CashOnly: Story = {
|
||||
args: {
|
||||
structure: {
|
||||
currencies: [
|
||||
{
|
||||
categories: rub.categories.map(row => ({
|
||||
...row,
|
||||
sharePercent: row.type === "CASH" ? "100" : "0",
|
||||
value: row.type === "CASH" ? "100000" : "0",
|
||||
})),
|
||||
currency: "RUB",
|
||||
hasNegativeValues: false,
|
||||
totalValue: "100000",
|
||||
},
|
||||
],
|
||||
unvaluedCategories: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
export const Empty: Story = {
|
||||
args: { structure: { currencies: [], unvaluedCategories: [] } },
|
||||
};
|
||||
export const Incomplete: Story = {
|
||||
args: {
|
||||
structure: {
|
||||
currencies: [
|
||||
{
|
||||
...rub,
|
||||
categories: rub.categories.map(
|
||||
|
||||
row =>
|
||||
({
|
||||
...row,
|
||||
sharePercent: null,
|
||||
}),
|
||||
),
|
||||
},
|
||||
],
|
||||
unvaluedCategories: [{ count: 2, type: "STOCK" }],
|
||||
},
|
||||
},
|
||||
};
|
||||
export const UnknownOnly: Story = {
|
||||
args: {
|
||||
structure: {
|
||||
currencies: [],
|
||||
unvaluedCategories: [{ count: 1, type: "BOND" }],
|
||||
},
|
||||
},
|
||||
};
|
||||
export const Negative: Story = {
|
||||
args: {
|
||||
structure: {
|
||||
currencies: [
|
||||
{
|
||||
...rub,
|
||||
categories: rub.categories.map(
|
||||
|
||||
row =>
|
||||
({
|
||||
...row,
|
||||
sharePercent: null,
|
||||
value: row.type === "OTHER" ? "25000" : row.value,
|
||||
}),
|
||||
),
|
||||
hasNegativeValues: true,
|
||||
totalValue: "1150000",
|
||||
},
|
||||
],
|
||||
unvaluedCategories: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user