feat: filters for profit statistics table

This commit is contained in:
2024-11-21 17:25:09 +04:00
parent c81ee2fdb8
commit 77aedb514f
4 changed files with 23 additions and 1 deletions

View File

@@ -5,6 +5,9 @@
import type { ProfitTableGroupBy } from './ProfitTableGroupBy'; import type { ProfitTableGroupBy } from './ProfitTableGroupBy';
export type GetProfitTableDataRequest = { export type GetProfitTableDataRequest = {
dateRange: any[]; dateRange: any[];
clientId: number;
baseMarketplaceKey: string;
dealStatusId: number;
groupTableBy: ProfitTableGroupBy; groupTableBy: ProfitTableGroupBy;
}; };

View File

@@ -13,6 +13,9 @@ export const useProfitTable = () => {
initialValues: { initialValues: {
dateRange: getDefaultDates(), dateRange: getDefaultDates(),
groupTableBy: GroupStatisticsTable.BY_DATES, groupTableBy: GroupStatisticsTable.BY_DATES,
client: null,
marketplace: null,
dealStatus: null,
}, },
}); });
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
@@ -33,6 +36,9 @@ export const useProfitTable = () => {
dateToString(dateRange[1]), dateToString(dateRange[1]),
], ],
groupTableBy: form.values.groupTableBy, groupTableBy: form.values.groupTableBy,
clientId: form.values.client?.id ?? -1,
baseMarketplaceKey: form.values.marketplace?.key ?? "all",
dealStatusId: form.values.dealStatus?.id ?? -1,
}; };
}; };

View File

@@ -36,6 +36,12 @@ export const ProfitTableFiltersModal = ({ form }: Props) => {
value: form.values.groupTableBy.toString(), value: form.values.groupTableBy.toString(),
onChange: (value: string) => form.setFieldValue("groupTableBy", parseInt(value)), onChange: (value: string) => form.setFieldValue("groupTableBy", parseInt(value)),
}} }}
clientSelectProps={form.getInputProps("client")}
onClientClear={() => form.setFieldValue("client", null)}
baseMarketplaceSelectProps={form.getInputProps("marketplace")}
onBaseMarketplaceClear={() => form.setFieldValue("marketplace", null)}
dealStatusSelectProps={form.getInputProps("dealStatus")}
onDealStatusClear={() => form.setFieldValue("dealStatus", null)}
/> />
</Modal> </Modal>
</> </>

View File

@@ -1,6 +1,13 @@
import { GroupStatisticsTable } from "../tabs/ProfitTab/components/ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx"; import {
GroupStatisticsTable,
} from "../tabs/ProfitTab/components/ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx";
import { BaseMarketplaceSchema, ClientSchema } from "../../../client";
import { DealStatusType } from "../../../shared/enums/DealStatus.ts";
export interface TableFormFilters { export interface TableFormFilters {
dateRange: [Date | null, Date | null]; dateRange: [Date | null, Date | null];
groupTableBy: GroupStatisticsTable; groupTableBy: GroupStatisticsTable;
client: ClientSchema | null;
marketplace: BaseMarketplaceSchema | null;
dealStatus: DealStatusType | null;
} }