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';
export type GetProfitTableDataRequest = {
dateRange: any[];
clientId: number;
baseMarketplaceKey: string;
dealStatusId: number;
groupTableBy: ProfitTableGroupBy;
};

View File

@@ -13,6 +13,9 @@ export const useProfitTable = () => {
initialValues: {
dateRange: getDefaultDates(),
groupTableBy: GroupStatisticsTable.BY_DATES,
client: null,
marketplace: null,
dealStatus: null,
},
});
const [isLoading, setIsLoading] = useState(false);
@@ -33,6 +36,9 @@ export const useProfitTable = () => {
dateToString(dateRange[1]),
],
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(),
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>
</>

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 {
dateRange: [Date | null, Date | null];
groupTableBy: GroupStatisticsTable;
client: ClientSchema | null;
marketplace: BaseMarketplaceSchema | null;
dealStatus: DealStatusType | null;
}