From 4650a14b98e2d9750f6c9c8d530da9b2409c143a Mon Sep 17 00:00:00 2001 From: "use-tusk[bot]" <144006087+use-tusk[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 06:46:39 +0000 Subject: [PATCH] fix: Tusk automated feedback for automated check failure --- .../shared/themed/table/themedTableHeader.tsx | 3 +++ .../shared/themed/themedTimeFilter.tsx | 3 +++ .../templates/dashboard/dashboardPage.tsx | 20 +------------------ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/web/components/shared/themed/table/themedTableHeader.tsx b/web/components/shared/themed/table/themedTableHeader.tsx index 0030ec8e5..e1448dda4 100644 --- a/web/components/shared/themed/table/themedTableHeader.tsx +++ b/web/components/shared/themed/table/themedTableHeader.tsx @@ -17,6 +17,7 @@ import FiltersButton from "./filtersButton"; import { DragColumnItem } from "./columns/DragList"; import { UIFilterRowTree } from "../../../../services/lib/filters/uiFilterRowTree"; import { Button } from "@/components/ui/button"; +import { DateRange } from "react-day-picker"; interface ThemedTableHeaderProps { rows?: T[]; @@ -39,6 +40,7 @@ interface ThemedTableHeaderProps { currentTimeFilter: TimeFilter; defaultValue: "24h" | "7d" | "1m" | "3m" | "all"; onTimeSelectHandler: (key: TimeInterval, value: string) => void; + onDateChange: (date: DateRange | undefined) => void; // Add this line }; // define this if you want a table and view toggle @@ -112,6 +114,7 @@ export default function ThemedTableHeader(props: ThemedTableHeaderProps) { isFetching={false} defaultValue={getDefaultValue()} custom={true} + onDateChange={timeFilter.onDateChange} // Add this line /> ) : (
diff --git a/web/components/shared/themed/themedTimeFilter.tsx b/web/components/shared/themed/themedTimeFilter.tsx index e458e304c..f9995f4b0 100644 --- a/web/components/shared/themed/themedTimeFilter.tsx +++ b/web/components/shared/themed/themedTimeFilter.tsx @@ -6,6 +6,7 @@ import useSearchParams from "../utils/useSearchParams"; import { TimeFilter } from "../../templates/dashboard/dashboardPage"; import { ProFeatureWrapper } from "../ProBlockerComponents/ProFeatureWrapper"; import { ThemedTimeFilterShadCN } from "./themedTimeFilterShadCN"; +import { DateRange } from "react-day-picker"; interface ThemedTimeFilterProps { timeFilterOptions: { key: string; value: string }[]; @@ -14,6 +15,7 @@ interface ThemedTimeFilterProps { defaultValue: string; currentTimeFilter: TimeFilter; custom?: boolean; + onDateChange: (date: DateRange | undefined) => void; // Add this line } function formatDateToInputString(date: Date): string { @@ -99,6 +101,7 @@ const ThemedTimeFilter = (props: ThemedTimeFilterProps) => { ); setActive("custom"); onSelect("custom", `${start.toISOString()}_${end.toISOString()}`); + props.onDateChange(newDate); // Add this line } }} initialDateRange={{ diff --git a/web/components/templates/dashboard/dashboardPage.tsx b/web/components/templates/dashboard/dashboardPage.tsx index 14cdee4fe..fef032dec 100644 --- a/web/components/templates/dashboard/dashboardPage.tsx +++ b/web/components/templates/dashboard/dashboardPage.tsx @@ -582,25 +582,7 @@ const DashboardPage = (props: DashboardPageProps) => { customTimeFilter: true, timeFilterOptions: [], defaultTimeFilter: interval, - onTimeSelectHandler: (key: TimeInterval, value: string) => { - if ((key as string) === "custom") { - value = value.replace("custom:", ""); - const start = new Date(value.split("_")[0]); - const end = new Date(value.split("_")[1]); - setInterval(key); - setTimeFilter({ - start, - end, - }); - } else { - setInterval(key); - setTimeFilter({ - start: getTimeIntervalAgo(key), - end: new Date(), - }); - } - }, - onDateChange: onTimeSelectHandler, + onTimeSelectHandler: onTimeSelectHandler, }} advancedFilter={{ filterMap,