"use client"; import { format, subDays, subYears } from "date-fns"; import { Calendar as CalendarIcon } from "lucide-react"; import type { FC } from "react"; import { Button } from "@/components/ui/button"; import { Calendar } from "@/components/ui/calendar"; import { Label } from "@/components/ui/label"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { cn } from "@/lib/utils"; interface DateRangeSelectorProps { startDate: Date | undefined; endDate: Date | undefined; onStartDateChange: (date: Date | undefined) => void; onEndDateChange: (date: Date | undefined) => void; } export const DateRangeSelector: FC = ({ startDate, endDate, onStartDateChange, onEndDateChange, }) => { const handleLast30Days = () => { const today = new Date(); onStartDateChange(subDays(today, 30)); onEndDateChange(today); }; const handleLastYear = () => { const today = new Date(); onStartDateChange(subYears(today, 1)); onEndDateChange(today); }; const handleClearDates = () => { onStartDateChange(undefined); onEndDateChange(undefined); }; return (

Select Date Range

Choose how far back you want to sync your data. You can always re-index later with different dates.

{/* Start Date */}
date > new Date()} />
{/* End Date */}
date > new Date() || (startDate ? date < startDate : false)} />
{/* Quick date range buttons */}
); };