Skip to content

Commit 7bbacca

Browse files
authored
chore: remove dead code regarding insights (calcom#19022)
1 parent b7df700 commit 7bbacca

File tree

6 files changed

+14
-407
lines changed

6 files changed

+14
-407
lines changed

packages/features/insights/filters/Download/RoutingDownload.tsx

-88
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export { Download } from "./Download";
2-
export { RoutingDownload } from "./RoutingDownload";
32
export { RoutingFormResponsesDownload } from "./RoutingFormResponsesDownload";

packages/features/insights/filters/FilterType.tsx

+8-57
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useMemo } from "react";
22

33
import { useLocale } from "@calcom/lib/hooks/useLocale";
4-
import { trpc } from "@calcom/trpc";
54
import type { IconName } from "@calcom/ui";
65
import {
76
Dropdown,
@@ -23,31 +22,10 @@ type Option = {
2322
StartIcon: IconName;
2423
};
2524

26-
export const FilterType = ({ showRoutingFilters = false }: { showRoutingFilters?: boolean }) => {
25+
export const FilterType = () => {
2726
const { t } = useLocale();
2827
const { filter, setConfigFilters } = useFilterContext();
29-
const { selectedFilter, selectedUserId, selectedTeamId, selectedRoutingFormId, isAll, initialConfig } =
30-
filter;
31-
const initialConfigIsReady = !!(initialConfig?.teamId || initialConfig?.userId || initialConfig?.isAll);
32-
33-
// Dynamically load filters if showRoutingFilters is set to true
34-
// Query routing form field options when showRoutingFilters is true
35-
const { data: routingFormFieldOptions } = trpc.viewer.insights.getRoutingFormFieldOptions.useQuery(
36-
{
37-
userId: selectedUserId ?? -1,
38-
teamId: selectedTeamId ?? -1,
39-
isAll: !!isAll,
40-
routingFormId: selectedRoutingFormId ?? undefined,
41-
},
42-
{
43-
enabled: showRoutingFilters && initialConfigIsReady,
44-
trpc: {
45-
context: {
46-
skipBatch: true,
47-
},
48-
},
49-
}
50-
);
28+
const { selectedFilter, selectedUserId } = filter;
5129

5230
const filterOptions = useMemo(() => {
5331
let options: Option[] = [
@@ -58,46 +36,19 @@ export const FilterType = ({ showRoutingFilters = false }: { showRoutingFilters?
5836
},
5937
];
6038

61-
// Add routing forms filter options
62-
if (showRoutingFilters) {
63-
options.push({
64-
label: t("routing_forms"),
65-
value: "routing_forms" as FilterType,
66-
StartIcon: "calendar-check-2" as IconName,
67-
});
68-
69-
options.push({
70-
label: t("booking_status"),
71-
value: "booking_status" as FilterType,
72-
StartIcon: "circle" as IconName,
73-
});
74-
75-
// Add dynamic routing form field options
76-
if (routingFormFieldOptions?.length) {
77-
options = [
78-
...options,
79-
...routingFormFieldOptions.map((option) => ({
80-
label: option.label,
81-
value: `rf_${option.id}` as FilterType,
82-
StartIcon: "layers" as IconName,
83-
})),
84-
];
85-
}
86-
} else {
87-
options.push({
88-
label: t("event_type"),
89-
value: "event-type",
90-
StartIcon: "link",
91-
});
92-
}
39+
options.push({
40+
label: t("event_type"),
41+
value: "event-type",
42+
StartIcon: "link",
43+
});
9344

9445
if (selectedUserId) {
9546
// remove user option from filterOptions
9647
options = options.filter((option) => option.value !== "user");
9748
}
9849

9950
return options;
100-
}, [t, showRoutingFilters, routingFormFieldOptions, selectedUserId]);
51+
}, [t, selectedUserId]);
10152

10253
return (
10354
<Dropdown>

packages/features/insights/filters/index.tsx

+5-18
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ import { useFilterContext } from "@calcom/features/insights/context/provider";
22
import { useLocale } from "@calcom/lib/hooks/useLocale";
33
import { Button, Icon, Tooltip } from "@calcom/ui";
44

5-
import { BookingStatusFilter } from "./BookingStatusFilter";
65
import { DateSelect } from "./DateSelect";
7-
import { Download, RoutingDownload } from "./Download";
6+
import { Download } from "./Download";
87
import { EventTypeList } from "./EventTypeList";
98
import { FilterType } from "./FilterType";
10-
import { RoutingFormFieldFilter } from "./RoutingFormFieldFilter";
11-
import { RoutingFormFilterList } from "./RoutingFormFilterList";
129
import { TeamAndSelfList } from "./TeamAndSelfList";
1310
import { UserListInTeam } from "./UserListInTeam";
1411

@@ -37,7 +34,7 @@ const ClearFilters = () => {
3734
);
3835
};
3936

40-
export const Filters = ({ showRoutingFilters = false }: { showRoutingFilters?: boolean }) => {
37+
export const Filters = () => {
4138
const { filter } = useFilterContext();
4239
const { selectedFilter } = filter;
4340

@@ -51,23 +48,13 @@ export const Filters = ({ showRoutingFilters = false }: { showRoutingFilters?: b
5148
return (
5249
<div className="ml-auto mt-6 flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:justify-between">
5350
<div className="flex flex-col gap-2 sm:flex-row sm:flex-nowrap sm:justify-start">
54-
<TeamAndSelfList omitOrg={showRoutingFilters} />
51+
<TeamAndSelfList omitOrg={false} />
5552

5653
<UserListInTeam />
5754

5855
<EventTypeList />
5956

60-
{showRoutingFilters ? (
61-
<>
62-
<RoutingFormFilterList />
63-
<BookingStatusFilter />
64-
{routingFormFieldIds.map((fieldId) => {
65-
if (fieldId) return <RoutingFormFieldFilter fieldId={fieldId} />;
66-
})}
67-
</>
68-
) : null}
69-
70-
<FilterType showRoutingFilters={showRoutingFilters} />
57+
<FilterType />
7158

7259
<ClearFilters />
7360
</div>
@@ -96,7 +83,7 @@ export const Filters = ({ showRoutingFilters = false }: { showRoutingFilters?: b
9683
</Tooltip>
9784
</ButtonGroup> */}
9885
<div className="flex flex-col-reverse sm:flex-row sm:flex-nowrap sm:justify-between">
99-
{showRoutingFilters ? <RoutingDownload /> : <Download />}
86+
<Download />
10087
<DateSelect className="me-2 ms-2" />
10188
</div>
10289
</div>

0 commit comments

Comments
 (0)