feat: filtering and grouping by manager
This commit is contained in:
		@@ -7,5 +7,6 @@ export type GetProfitChartDataRequest = {
 | 
				
			|||||||
    clientId: number;
 | 
					    clientId: number;
 | 
				
			||||||
    baseMarketplaceKey: string;
 | 
					    baseMarketplaceKey: string;
 | 
				
			||||||
    dealStatusId: number;
 | 
					    dealStatusId: number;
 | 
				
			||||||
 | 
					    managerId: number;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@ export type GetProfitTableDataRequest = {
 | 
				
			|||||||
    clientId: number;
 | 
					    clientId: number;
 | 
				
			||||||
    baseMarketplaceKey: string;
 | 
					    baseMarketplaceKey: string;
 | 
				
			||||||
    dealStatusId: number;
 | 
					    dealStatusId: number;
 | 
				
			||||||
 | 
					    managerId: number;
 | 
				
			||||||
    groupTableBy: ProfitTableGroupBy;
 | 
					    groupTableBy: ProfitTableGroupBy;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,4 +2,4 @@
 | 
				
			|||||||
/* istanbul ignore file */
 | 
					/* istanbul ignore file */
 | 
				
			||||||
/* tslint:disable */
 | 
					/* tslint:disable */
 | 
				
			||||||
/* eslint-disable */
 | 
					/* eslint-disable */
 | 
				
			||||||
export type ProfitTableGroupBy = 0 | 1 | 2 | 3 | 4;
 | 
					export type ProfitTableGroupBy = 0 | 1 | 2 | 3 | 4 | 5;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,14 @@
 | 
				
			|||||||
import { DatePickerInput, DatePickerInputProps } from "@mantine/dates";
 | 
					import { DatePickerInput, DatePickerInputProps } from "@mantine/dates";
 | 
				
			||||||
import { Stack, Text } from "@mantine/core";
 | 
					import { Stack, Text } from "@mantine/core";
 | 
				
			||||||
import ClientSelectNew from "../../../../../../components/Selects/ClientSelectNew/ClientSelectNew.tsx";
 | 
					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 { ObjectSelectProps } from "../../../../../../components/ObjectSelect/ObjectSelect.tsx";
 | 
				
			||||||
import BaseMarketplaceSelect
 | 
					import BaseMarketplaceSelect
 | 
				
			||||||
    from "../../../../../../components/Selects/BaseMarketplaceSelect/BaseMarketplaceSelect.tsx";
 | 
					    from "../../../../../../components/Selects/BaseMarketplaceSelect/BaseMarketplaceSelect.tsx";
 | 
				
			||||||
import DealStatusSelect from "../../../../../DealsPage/components/DealStatusSelect/DealStatusSelect.tsx";
 | 
					import DealStatusSelect from "../../../../../DealsPage/components/DealStatusSelect/DealStatusSelect.tsx";
 | 
				
			||||||
import { DealStatusType } from "../../../../../../shared/enums/DealStatus.ts";
 | 
					import { DealStatusType } from "../../../../../../shared/enums/DealStatus.ts";
 | 
				
			||||||
import { ProfitTableSegmentedControl } from "../ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx";
 | 
					import { ProfitTableSegmentedControl } from "../ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx";
 | 
				
			||||||
 | 
					import ManagerSelect from "../../../../../../components/ManagerSelect/ManagerSelect.tsx";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type FiltersProps = {
 | 
					type FiltersProps = {
 | 
				
			||||||
@@ -25,6 +26,12 @@ type FiltersProps = {
 | 
				
			|||||||
    dealStatusSelectProps?: Omit<ObjectSelectProps<DealStatusType>, "data">;
 | 
					    dealStatusSelectProps?: Omit<ObjectSelectProps<DealStatusType>, "data">;
 | 
				
			||||||
    onDealStatusClear?: () => void;
 | 
					    onDealStatusClear?: () => void;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    managerSelectProps?: Omit<
 | 
				
			||||||
 | 
					        ObjectSelectProps<UserSchema | null>,
 | 
				
			||||||
 | 
					        "data" | "getValueFn" | "getLabelFn"
 | 
				
			||||||
 | 
					    >;
 | 
				
			||||||
 | 
					    onManagerClear?: () => void;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    groupTableByProps?: {
 | 
					    groupTableByProps?: {
 | 
				
			||||||
        value: string,
 | 
					        value: string,
 | 
				
			||||||
        onChange: (value: string) => void,
 | 
					        onChange: (value: string) => void,
 | 
				
			||||||
@@ -40,6 +47,8 @@ export const Filters = (props: FiltersProps) => {
 | 
				
			|||||||
        onBaseMarketplaceClear,
 | 
					        onBaseMarketplaceClear,
 | 
				
			||||||
        dealStatusSelectProps,
 | 
					        dealStatusSelectProps,
 | 
				
			||||||
        onDealStatusClear,
 | 
					        onDealStatusClear,
 | 
				
			||||||
 | 
					        managerSelectProps,
 | 
				
			||||||
 | 
					        onManagerClear,
 | 
				
			||||||
        groupTableByProps,
 | 
					        groupTableByProps,
 | 
				
			||||||
    } = props;
 | 
					    } = props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -78,6 +87,13 @@ export const Filters = (props: FiltersProps) => {
 | 
				
			|||||||
                    placeholder={"Выберите маркетплейс"}
 | 
					                    placeholder={"Выберите маркетплейс"}
 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            {managerSelectProps &&
 | 
				
			||||||
 | 
					                <ManagerSelect
 | 
				
			||||||
 | 
					                    {...managerSelectProps}
 | 
				
			||||||
 | 
					                    onClear={onManagerClear}
 | 
				
			||||||
 | 
					                    placeholder={"Выберите менеджера"}
 | 
				
			||||||
 | 
					                />
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            {groupTableByProps &&
 | 
					            {groupTableByProps &&
 | 
				
			||||||
                <>
 | 
					                <>
 | 
				
			||||||
                    <Text>Группировать:</Text>
 | 
					                    <Text>Группировать:</Text>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,7 @@ export const useProfitChart = () => {
 | 
				
			|||||||
            client: null,
 | 
					            client: null,
 | 
				
			||||||
            marketplace: null,
 | 
					            marketplace: null,
 | 
				
			||||||
            dealStatus: null,
 | 
					            dealStatus: null,
 | 
				
			||||||
 | 
					            manager: null,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    const [profitData, setProfitData] = useState<ProfitChartDataItem[]>([]);
 | 
					    const [profitData, setProfitData] = useState<ProfitChartDataItem[]>([]);
 | 
				
			||||||
@@ -29,6 +30,7 @@ export const useProfitChart = () => {
 | 
				
			|||||||
            clientId: form.values.client?.id ?? -1,
 | 
					            clientId: form.values.client?.id ?? -1,
 | 
				
			||||||
            baseMarketplaceKey: form.values.marketplace?.key ?? "all",
 | 
					            baseMarketplaceKey: form.values.marketplace?.key ?? "all",
 | 
				
			||||||
            dealStatusId: form.values.dealStatus?.id ?? -1,
 | 
					            dealStatusId: form.values.dealStatus?.id ?? -1,
 | 
				
			||||||
 | 
					            managerId: form.values.manager?.id ?? -1,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,7 @@ export const useProfitTableColumns = ({ groupTableBy }: Props) => {
 | 
				
			|||||||
        [GroupStatisticsTable.BY_STATUSES]: "Статус",
 | 
					        [GroupStatisticsTable.BY_STATUSES]: "Статус",
 | 
				
			||||||
        [GroupStatisticsTable.BY_MARKETPLACES]: "Маркетплейс",
 | 
					        [GroupStatisticsTable.BY_MARKETPLACES]: "Маркетплейс",
 | 
				
			||||||
        [GroupStatisticsTable.BY_WAREHOUSES]: "Склад отгрузки",
 | 
					        [GroupStatisticsTable.BY_WAREHOUSES]: "Склад отгрузки",
 | 
				
			||||||
 | 
					        [GroupStatisticsTable.BY_MANAGERS]: "Менеджер",
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return useMemo<MRT_ColumnDef<ProfitTableDataItem>[]>(
 | 
					    return useMemo<MRT_ColumnDef<ProfitTableDataItem>[]>(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,7 @@ export const useProfitTable = () => {
 | 
				
			|||||||
            client: null,
 | 
					            client: null,
 | 
				
			||||||
            marketplace: null,
 | 
					            marketplace: null,
 | 
				
			||||||
            dealStatus: null,
 | 
					            dealStatus: null,
 | 
				
			||||||
 | 
					            manager: null,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    const [isLoading, setIsLoading] = useState(false);
 | 
					    const [isLoading, setIsLoading] = useState(false);
 | 
				
			||||||
@@ -39,6 +40,7 @@ export const useProfitTable = () => {
 | 
				
			|||||||
            clientId: form.values.client?.id ?? -1,
 | 
					            clientId: form.values.client?.id ?? -1,
 | 
				
			||||||
            baseMarketplaceKey: form.values.marketplace?.key ?? "all",
 | 
					            baseMarketplaceKey: form.values.marketplace?.key ?? "all",
 | 
				
			||||||
            dealStatusId: form.values.dealStatus?.id ?? -1,
 | 
					            dealStatusId: form.values.dealStatus?.id ?? -1,
 | 
				
			||||||
 | 
					            managerId: form.values.manager?.id ?? -1,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ export enum GroupStatisticsTable {
 | 
				
			|||||||
    BY_STATUSES,
 | 
					    BY_STATUSES,
 | 
				
			||||||
    BY_WAREHOUSES,
 | 
					    BY_WAREHOUSES,
 | 
				
			||||||
    BY_MARKETPLACES,
 | 
					    BY_MARKETPLACES,
 | 
				
			||||||
 | 
					    BY_MANAGERS,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Props = Omit<SegmentedControlProps, "data">;
 | 
					type Props = Omit<SegmentedControlProps, "data">;
 | 
				
			||||||
@@ -31,6 +32,10 @@ const data = [
 | 
				
			|||||||
        label: "По маркетплейсам",
 | 
					        label: "По маркетплейсам",
 | 
				
			||||||
        value: GroupStatisticsTable.BY_MARKETPLACES.toString(),
 | 
					        value: GroupStatisticsTable.BY_MARKETPLACES.toString(),
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        label: "По менеджерам",
 | 
				
			||||||
 | 
					        value: GroupStatisticsTable.BY_MANAGERS.toString(),
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const ProfitTableSegmentedControl: FC<Props> = props => {
 | 
					export const ProfitTableSegmentedControl: FC<Props> = props => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,8 @@ export const ProfitChartFiltersModal = ({ form }: Props) => {
 | 
				
			|||||||
                    onBaseMarketplaceClear={() => form.setFieldValue("marketplace", null)}
 | 
					                    onBaseMarketplaceClear={() => form.setFieldValue("marketplace", null)}
 | 
				
			||||||
                    dealStatusSelectProps={form.getInputProps("dealStatus")}
 | 
					                    dealStatusSelectProps={form.getInputProps("dealStatus")}
 | 
				
			||||||
                    onDealStatusClear={() => form.setFieldValue("dealStatus", null)}
 | 
					                    onDealStatusClear={() => form.setFieldValue("dealStatus", null)}
 | 
				
			||||||
 | 
					                    managerSelectProps={form.getInputProps("manager")}
 | 
				
			||||||
 | 
					                    onManagerClear={() => form.setFieldValue("manager", null)}
 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
            </Modal>
 | 
					            </Modal>
 | 
				
			||||||
        </>
 | 
					        </>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,8 @@ export const ProfitTableFiltersModal = ({ form }: Props) => {
 | 
				
			|||||||
                    onBaseMarketplaceClear={() => form.setFieldValue("marketplace", null)}
 | 
					                    onBaseMarketplaceClear={() => form.setFieldValue("marketplace", null)}
 | 
				
			||||||
                    dealStatusSelectProps={form.getInputProps("dealStatus")}
 | 
					                    dealStatusSelectProps={form.getInputProps("dealStatus")}
 | 
				
			||||||
                    onDealStatusClear={() => form.setFieldValue("dealStatus", null)}
 | 
					                    onDealStatusClear={() => form.setFieldValue("dealStatus", null)}
 | 
				
			||||||
 | 
					                    managerSelectProps={form.getInputProps("manager")}
 | 
				
			||||||
 | 
					                    onManagerClear={() => form.setFieldValue("manager", null)}
 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
            </Modal>
 | 
					            </Modal>
 | 
				
			||||||
        </>
 | 
					        </>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
import { BaseMarketplaceSchema, ClientSchema } from "../../../client";
 | 
					import { BaseMarketplaceSchema, ClientSchema, UserSchema } from "../../../client";
 | 
				
			||||||
import { DealStatusType } from "../../../shared/enums/DealStatus.ts";
 | 
					import { DealStatusType } from "../../../shared/enums/DealStatus.ts";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface ChartFormFilters {
 | 
					export interface ChartFormFilters {
 | 
				
			||||||
@@ -6,4 +6,5 @@ export interface ChartFormFilters {
 | 
				
			|||||||
    client: ClientSchema | null;
 | 
					    client: ClientSchema | null;
 | 
				
			||||||
    marketplace: BaseMarketplaceSchema | null;
 | 
					    marketplace: BaseMarketplaceSchema | null;
 | 
				
			||||||
    dealStatus: DealStatusType | null;
 | 
					    dealStatus: DealStatusType | null;
 | 
				
			||||||
 | 
					    manager: UserSchema | null;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
    GroupStatisticsTable,
 | 
					    GroupStatisticsTable,
 | 
				
			||||||
} from "../tabs/ProfitTab/components/ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx";
 | 
					} 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";
 | 
					import { DealStatusType } from "../../../shared/enums/DealStatus.ts";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface TableFormFilters {
 | 
					export interface TableFormFilters {
 | 
				
			||||||
@@ -10,4 +10,5 @@ export interface TableFormFilters {
 | 
				
			|||||||
    client: ClientSchema | null;
 | 
					    client: ClientSchema | null;
 | 
				
			||||||
    marketplace: BaseMarketplaceSchema | null;
 | 
					    marketplace: BaseMarketplaceSchema | null;
 | 
				
			||||||
    dealStatus: DealStatusType | null;
 | 
					    dealStatus: DealStatusType | null;
 | 
				
			||||||
 | 
					    manager: UserSchema | null;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user