From 0758d14a9aa106c2db234f5c73666918b5f8e9ce Mon Sep 17 00:00:00 2001 From: AlexSserb Date: Thu, 21 Nov 2024 21:11:26 +0400 Subject: [PATCH] fix: made statistic dates PATRIOTIC --- .../tabs/ProfitTab/components/Filters/Filters.tsx | 1 + .../ProfitTab/components/ProfitChart/ProfitChart.tsx | 9 ++++++++- .../ProfitTab/components/ProfitTable/hooks/columns.tsx | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pages/StatisticsPage/tabs/ProfitTab/components/Filters/Filters.tsx b/src/pages/StatisticsPage/tabs/ProfitTab/components/Filters/Filters.tsx index 0f346d5..c7aa772 100644 --- a/src/pages/StatisticsPage/tabs/ProfitTab/components/Filters/Filters.tsx +++ b/src/pages/StatisticsPage/tabs/ProfitTab/components/Filters/Filters.tsx @@ -60,6 +60,7 @@ export const Filters = (props: FiltersProps) => { type="range" placeholder="Выберите даты" maxDate={new Date()} + valueFormat={"DD.MM.YYYY"} /> } {dealStatusSelectProps && diff --git a/src/pages/StatisticsPage/tabs/ProfitTab/components/ProfitChart/ProfitChart.tsx b/src/pages/StatisticsPage/tabs/ProfitTab/components/ProfitChart/ProfitChart.tsx index 79a61f5..08e9f72 100644 --- a/src/pages/StatisticsPage/tabs/ProfitTab/components/ProfitChart/ProfitChart.tsx +++ b/src/pages/StatisticsPage/tabs/ProfitTab/components/ProfitChart/ProfitChart.tsx @@ -6,6 +6,7 @@ import { Skeleton, Stack } from "@mantine/core"; import { ProfitChartFiltersModal } from "../../modals/ProfitChartFiltersModal.tsx"; import { Total } from "../Total/Total.tsx"; import styles from "../../../../ui/StatisticsPage.module.css"; +import { formatDate } from "../../../../../../types/utils.ts"; export const ProfitChart = () => { @@ -15,6 +16,12 @@ export const ProfitChart = () => { isLoading, } = useProfitChart(); + const formattedProfitData = profitData.map( + value => { + return { ...value, date: formatDate(value.date) }; + }, + ); + const getChartsSeries = [ [ { name: "profit", label: "Прибыль", color: "indigo.6" }, @@ -42,7 +49,7 @@ export const ProfitChart = () => { my={"sm"} w={"98%"} h={"34vh"} - data={profitData} + data={formattedProfitData} dataKey="date" unit={units[idx]} tooltipAnimationDuration={200} diff --git a/src/pages/StatisticsPage/tabs/ProfitTab/components/ProfitTable/hooks/columns.tsx b/src/pages/StatisticsPage/tabs/ProfitTab/components/ProfitTable/hooks/columns.tsx index b223e9e..bbe3aa4 100644 --- a/src/pages/StatisticsPage/tabs/ProfitTab/components/ProfitTable/hooks/columns.tsx +++ b/src/pages/StatisticsPage/tabs/ProfitTab/components/ProfitTable/hooks/columns.tsx @@ -3,6 +3,7 @@ import { MRT_ColumnDef } from "mantine-react-table"; import { ProfitTableDataItem } from "../../../../../../../client"; import { GroupStatisticsTable } from "../../ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx"; import { DealStatus, DealStatusDictionary } from "../../../../../../../shared/enums/DealStatus.ts"; +import { formatDate } from "../../../../../../../types/utils.ts"; type Props = { groupTableBy: GroupStatisticsTable; @@ -29,6 +30,9 @@ export const useProfitTableColumns = ({ groupTableBy }: Props) => { const statusIndex = row.original.groupedValue as DealStatus; return DealStatusDictionary[statusIndex]; } + if (groupTableBy == GroupStatisticsTable.BY_DATES) { + return formatDate(row.original.groupedValue as string); + } return row.original.groupedValue; }, size: 60,