feat: filtering and grouping by manager

This commit is contained in:
2024-11-21 18:12:48 +04:00
parent 77aedb514f
commit 9c56ef180f
12 changed files with 38 additions and 4 deletions

View File

@@ -7,5 +7,6 @@ export type GetProfitChartDataRequest = {
clientId: number;
baseMarketplaceKey: string;
dealStatusId: number;
managerId: number;
};

View File

@@ -8,6 +8,7 @@ export type GetProfitTableDataRequest = {
clientId: number;
baseMarketplaceKey: string;
dealStatusId: number;
managerId: number;
groupTableBy: ProfitTableGroupBy;
};

View File

@@ -2,4 +2,4 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type ProfitTableGroupBy = 0 | 1 | 2 | 3 | 4;
export type ProfitTableGroupBy = 0 | 1 | 2 | 3 | 4 | 5;

View File

@@ -1,13 +1,14 @@
import { DatePickerInput, DatePickerInputProps } from "@mantine/dates";
import { Stack, Text } from "@mantine/core";
import ClientSelectNew from "../../../../../../components/Selects/ClientSelectNew/ClientSelectNew.tsx";
import { BaseMarketplaceSchema, ClientSchema } from "../../../../../../client";
import { BaseMarketplaceSchema, ClientSchema, UserSchema } from "../../../../../../client";
import { ObjectSelectProps } from "../../../../../../components/ObjectSelect/ObjectSelect.tsx";
import BaseMarketplaceSelect
from "../../../../../../components/Selects/BaseMarketplaceSelect/BaseMarketplaceSelect.tsx";
import DealStatusSelect from "../../../../../DealsPage/components/DealStatusSelect/DealStatusSelect.tsx";
import { DealStatusType } from "../../../../../../shared/enums/DealStatus.ts";
import { ProfitTableSegmentedControl } from "../ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx";
import ManagerSelect from "../../../../../../components/ManagerSelect/ManagerSelect.tsx";
type FiltersProps = {
@@ -25,6 +26,12 @@ type FiltersProps = {
dealStatusSelectProps?: Omit<ObjectSelectProps<DealStatusType>, "data">;
onDealStatusClear?: () => void;
managerSelectProps?: Omit<
ObjectSelectProps<UserSchema | null>,
"data" | "getValueFn" | "getLabelFn"
>;
onManagerClear?: () => void;
groupTableByProps?: {
value: string,
onChange: (value: string) => void,
@@ -40,6 +47,8 @@ export const Filters = (props: FiltersProps) => {
onBaseMarketplaceClear,
dealStatusSelectProps,
onDealStatusClear,
managerSelectProps,
onManagerClear,
groupTableByProps,
} = props;
@@ -78,6 +87,13 @@ export const Filters = (props: FiltersProps) => {
placeholder={"Выберите маркетплейс"}
/>
}
{managerSelectProps &&
<ManagerSelect
{...managerSelectProps}
onClear={onManagerClear}
placeholder={"Выберите менеджера"}
/>
}
{groupTableByProps &&
<>
<Text>Группировать:</Text>

View File

@@ -13,6 +13,7 @@ export const useProfitChart = () => {
client: null,
marketplace: null,
dealStatus: null,
manager: null,
},
});
const [profitData, setProfitData] = useState<ProfitChartDataItem[]>([]);
@@ -29,6 +30,7 @@ export const useProfitChart = () => {
clientId: form.values.client?.id ?? -1,
baseMarketplaceKey: form.values.marketplace?.key ?? "all",
dealStatusId: form.values.dealStatus?.id ?? -1,
managerId: form.values.manager?.id ?? -1,
};
};

View File

@@ -15,6 +15,7 @@ export const useProfitTableColumns = ({ groupTableBy }: Props) => {
[GroupStatisticsTable.BY_STATUSES]: "Статус",
[GroupStatisticsTable.BY_MARKETPLACES]: "Маркетплейс",
[GroupStatisticsTable.BY_WAREHOUSES]: "Склад отгрузки",
[GroupStatisticsTable.BY_MANAGERS]: "Менеджер",
};
return useMemo<MRT_ColumnDef<ProfitTableDataItem>[]>(

View File

@@ -16,6 +16,7 @@ export const useProfitTable = () => {
client: null,
marketplace: null,
dealStatus: null,
manager: null,
},
});
const [isLoading, setIsLoading] = useState(false);
@@ -39,6 +40,7 @@ export const useProfitTable = () => {
clientId: form.values.client?.id ?? -1,
baseMarketplaceKey: form.values.marketplace?.key ?? "all",
dealStatusId: form.values.dealStatus?.id ?? -1,
managerId: form.values.manager?.id ?? -1,
};
};

View File

@@ -7,6 +7,7 @@ export enum GroupStatisticsTable {
BY_STATUSES,
BY_WAREHOUSES,
BY_MARKETPLACES,
BY_MANAGERS,
}
type Props = Omit<SegmentedControlProps, "data">;
@@ -31,6 +32,10 @@ const data = [
label: "По маркетплейсам",
value: GroupStatisticsTable.BY_MARKETPLACES.toString(),
},
{
label: "По менеджерам",
value: GroupStatisticsTable.BY_MANAGERS.toString(),
},
];
export const ProfitTableSegmentedControl: FC<Props> = props => {

View File

@@ -38,6 +38,8 @@ export const ProfitChartFiltersModal = ({ form }: Props) => {
onBaseMarketplaceClear={() => form.setFieldValue("marketplace", null)}
dealStatusSelectProps={form.getInputProps("dealStatus")}
onDealStatusClear={() => form.setFieldValue("dealStatus", null)}
managerSelectProps={form.getInputProps("manager")}
onManagerClear={() => form.setFieldValue("manager", null)}
/>
</Modal>
</>

View File

@@ -42,6 +42,8 @@ export const ProfitTableFiltersModal = ({ form }: Props) => {
onBaseMarketplaceClear={() => form.setFieldValue("marketplace", null)}
dealStatusSelectProps={form.getInputProps("dealStatus")}
onDealStatusClear={() => form.setFieldValue("dealStatus", null)}
managerSelectProps={form.getInputProps("manager")}
onManagerClear={() => form.setFieldValue("manager", null)}
/>
</Modal>
</>

View File

@@ -1,4 +1,4 @@
import { BaseMarketplaceSchema, ClientSchema } from "../../../client";
import { BaseMarketplaceSchema, ClientSchema, UserSchema } from "../../../client";
import { DealStatusType } from "../../../shared/enums/DealStatus.ts";
export interface ChartFormFilters {
@@ -6,4 +6,5 @@ export interface ChartFormFilters {
client: ClientSchema | null;
marketplace: BaseMarketplaceSchema | null;
dealStatus: DealStatusType | null;
manager: UserSchema | null;
}

View File

@@ -1,7 +1,7 @@
import {
GroupStatisticsTable,
} from "../tabs/ProfitTab/components/ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx";
import { BaseMarketplaceSchema, ClientSchema } from "../../../client";
import { BaseMarketplaceSchema, ClientSchema, UserSchema } from "../../../client";
import { DealStatusType } from "../../../shared/enums/DealStatus.ts";
export interface TableFormFilters {
@@ -10,4 +10,5 @@ export interface TableFormFilters {
client: ClientSchema | null;
marketplace: BaseMarketplaceSchema | null;
dealStatus: DealStatusType | null;
manager: UserSchema | null;
}