feat: total values in statistics page
This commit is contained in:
@@ -4,6 +4,8 @@ import PageBlock from "../../../../../../components/PageBlock/PageBlock.tsx";
|
|||||||
import { useProfitChart } from "./hooks/useProfitChart.tsx";
|
import { useProfitChart } from "./hooks/useProfitChart.tsx";
|
||||||
import { Skeleton, Stack } from "@mantine/core";
|
import { Skeleton, Stack } from "@mantine/core";
|
||||||
import { ProfitChartFiltersModal } from "../../modals/ProfitChartFiltersModal.tsx";
|
import { ProfitChartFiltersModal } from "../../modals/ProfitChartFiltersModal.tsx";
|
||||||
|
import { Total } from "../Total/Total.tsx";
|
||||||
|
import styles from "../../../../ui/StatisticsPage.module.css";
|
||||||
|
|
||||||
|
|
||||||
export const ProfitChart = () => {
|
export const ProfitChart = () => {
|
||||||
@@ -26,30 +28,33 @@ export const ProfitChart = () => {
|
|||||||
const units = ["₽", "шт"];
|
const units = ["₽", "шт"];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageBlock style={{ flex: 3, minWidth: "600px", padding: "25px" }}>
|
<div className={styles["profit-chart-container"]}>
|
||||||
<ProfitChartFiltersModal
|
<Total profitData={profitData} />
|
||||||
form={form}
|
<PageBlock style={{ padding: "25px" }}>
|
||||||
/>
|
<ProfitChartFiltersModal
|
||||||
<Skeleton visible={isLoading}>
|
form={form}
|
||||||
<Stack gap={"xl"}>
|
/>
|
||||||
{getChartsSeries.map((series, idx) => {
|
<Skeleton visible={isLoading}>
|
||||||
return (
|
<Stack gap={"xl"}>
|
||||||
<AreaChart
|
{getChartsSeries.map((series, idx) => {
|
||||||
my={"sm"}
|
return (
|
||||||
w={"98%"}
|
<AreaChart
|
||||||
h={"39vh"}
|
my={"sm"}
|
||||||
data={profitData}
|
w={"98%"}
|
||||||
dataKey="date"
|
h={"34vh"}
|
||||||
unit={units[idx]}
|
data={profitData}
|
||||||
tooltipAnimationDuration={200}
|
dataKey="date"
|
||||||
valueFormatter={(value) => new Intl.NumberFormat("ru-RU").format(value)}
|
unit={units[idx]}
|
||||||
series={series}
|
tooltipAnimationDuration={200}
|
||||||
fillOpacity={0.5}
|
valueFormatter={(value) => new Intl.NumberFormat("ru-RU").format(value)}
|
||||||
/>
|
series={series}
|
||||||
);
|
fillOpacity={0.5}
|
||||||
})}
|
/>
|
||||||
</Stack>
|
);
|
||||||
</Skeleton>
|
})}
|
||||||
</PageBlock>
|
</Stack>
|
||||||
|
</Skeleton>
|
||||||
|
</PageBlock>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { Center, Divider, Group, Text } from "@mantine/core";
|
||||||
|
import { ProfitChartDataItem } from "../../../../../../client";
|
||||||
|
import PageBlock from "../../../../../../components/PageBlock/PageBlock.tsx";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
profitData: ProfitChartDataItem[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Total = ({ profitData }: Props) => {
|
||||||
|
const totalProfit = profitData.reduce(
|
||||||
|
(sum, dataItem) => dataItem.profit + sum,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const totalRevenue = profitData.reduce(
|
||||||
|
(sum, dataItem) => dataItem.revenue + sum,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const totalCount = profitData.reduce(
|
||||||
|
(sum, dataItem) => dataItem.dealsCount + sum,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageBlock style={{ padding: "25px", height: "7vh", flexGrow: 0 }}>
|
||||||
|
<Group gap={2} justify={"space-between"}>
|
||||||
|
<Center w={"30%"}>
|
||||||
|
<Text>Прибыль: {new Intl.NumberFormat("ru-RU").format(totalProfit)} ₽</Text>
|
||||||
|
</Center>
|
||||||
|
<Divider size={"md"} orientation="vertical" />
|
||||||
|
<Center w={"30%"}>
|
||||||
|
<Text>Выручка: {new Intl.NumberFormat("ru-RU").format(totalRevenue)} ₽</Text>
|
||||||
|
</Center>
|
||||||
|
<Divider size={"md"} orientation="vertical" />
|
||||||
|
<Center w={"30%"}>
|
||||||
|
<Text>Сделок: {new Intl.NumberFormat("ru-RU").format(totalCount)} шт</Text>
|
||||||
|
</Center>
|
||||||
|
</Group>
|
||||||
|
</PageBlock>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -13,6 +13,16 @@
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.profit-chart-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: rem(10);
|
||||||
|
height: 96vh;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
flex: 3;
|
||||||
|
min-width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
.top-panel {
|
.top-panel {
|
||||||
padding: rem(5);
|
padding: rem(5);
|
||||||
gap: rem(10);
|
gap: rem(10);
|
||||||
|
|||||||
Reference in New Issue
Block a user