Skip to content

Commit

Permalink
chore: remove dead code regarding insights (calcom#19022)
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjae-lee authored Jan 31, 2025
1 parent b7df700 commit 7bbacca
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 407 deletions.
88 changes: 0 additions & 88 deletions packages/features/insights/filters/Download/RoutingDownload.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/features/insights/filters/Download/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export { Download } from "./Download";
export { RoutingDownload } from "./RoutingDownload";
export { RoutingFormResponsesDownload } from "./RoutingFormResponsesDownload";
65 changes: 8 additions & 57 deletions packages/features/insights/filters/FilterType.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMemo } from "react";

import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc";
import type { IconName } from "@calcom/ui";
import {
Dropdown,
Expand All @@ -23,31 +22,10 @@ type Option = {
StartIcon: IconName;
};

export const FilterType = ({ showRoutingFilters = false }: { showRoutingFilters?: boolean }) => {
export const FilterType = () => {
const { t } = useLocale();
const { filter, setConfigFilters } = useFilterContext();
const { selectedFilter, selectedUserId, selectedTeamId, selectedRoutingFormId, isAll, initialConfig } =
filter;
const initialConfigIsReady = !!(initialConfig?.teamId || initialConfig?.userId || initialConfig?.isAll);

// Dynamically load filters if showRoutingFilters is set to true
// Query routing form field options when showRoutingFilters is true
const { data: routingFormFieldOptions } = trpc.viewer.insights.getRoutingFormFieldOptions.useQuery(
{
userId: selectedUserId ?? -1,
teamId: selectedTeamId ?? -1,
isAll: !!isAll,
routingFormId: selectedRoutingFormId ?? undefined,
},
{
enabled: showRoutingFilters && initialConfigIsReady,
trpc: {
context: {
skipBatch: true,
},
},
}
);
const { selectedFilter, selectedUserId } = filter;

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

// Add routing forms filter options
if (showRoutingFilters) {
options.push({
label: t("routing_forms"),
value: "routing_forms" as FilterType,
StartIcon: "calendar-check-2" as IconName,
});

options.push({
label: t("booking_status"),
value: "booking_status" as FilterType,
StartIcon: "circle" as IconName,
});

// Add dynamic routing form field options
if (routingFormFieldOptions?.length) {
options = [
...options,
...routingFormFieldOptions.map((option) => ({
label: option.label,
value: `rf_${option.id}` as FilterType,
StartIcon: "layers" as IconName,
})),
];
}
} else {
options.push({
label: t("event_type"),
value: "event-type",
StartIcon: "link",
});
}
options.push({
label: t("event_type"),
value: "event-type",
StartIcon: "link",
});

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

return options;
}, [t, showRoutingFilters, routingFormFieldOptions, selectedUserId]);
}, [t, selectedUserId]);

return (
<Dropdown>
Expand Down
23 changes: 5 additions & 18 deletions packages/features/insights/filters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import { useFilterContext } from "@calcom/features/insights/context/provider";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, Icon, Tooltip } from "@calcom/ui";

import { BookingStatusFilter } from "./BookingStatusFilter";
import { DateSelect } from "./DateSelect";
import { Download, RoutingDownload } from "./Download";
import { Download } from "./Download";
import { EventTypeList } from "./EventTypeList";
import { FilterType } from "./FilterType";
import { RoutingFormFieldFilter } from "./RoutingFormFieldFilter";
import { RoutingFormFilterList } from "./RoutingFormFilterList";
import { TeamAndSelfList } from "./TeamAndSelfList";
import { UserListInTeam } from "./UserListInTeam";

Expand Down Expand Up @@ -37,7 +34,7 @@ const ClearFilters = () => {
);
};

export const Filters = ({ showRoutingFilters = false }: { showRoutingFilters?: boolean }) => {
export const Filters = () => {
const { filter } = useFilterContext();
const { selectedFilter } = filter;

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

<UserListInTeam />

<EventTypeList />

{showRoutingFilters ? (
<>
<RoutingFormFilterList />
<BookingStatusFilter />
{routingFormFieldIds.map((fieldId) => {
if (fieldId) return <RoutingFormFieldFilter fieldId={fieldId} />;
})}
</>
) : null}

<FilterType showRoutingFilters={showRoutingFilters} />
<FilterType />

<ClearFilters />
</div>
Expand Down Expand Up @@ -96,7 +83,7 @@ export const Filters = ({ showRoutingFilters = false }: { showRoutingFilters?: b
</Tooltip>
</ButtonGroup> */}
<div className="flex flex-col-reverse sm:flex-row sm:flex-nowrap sm:justify-between">
{showRoutingFilters ? <RoutingDownload /> : <Download />}
<Download />
<DateSelect className="me-2 ms-2" />
</div>
</div>
Expand Down
Loading

0 comments on commit 7bbacca

Please sign in to comment.