'use client'; import * as React from 'react'; import { format, isSameDay, subDays, subMonths } from 'date-fns'; import type { DateRange } from 'react-day-picker'; import * as Button from '@/components/ui/button'; import * as DatepickerPrimivites from '@/components/ui/datepicker'; import * as Popover from '@/components/ui/popover'; import { cn } from '@/utils/cn'; const presets = [ { label: 'Today', dateRange: { from: new Date(), to: new Date(), }, }, { label: 'Last 7 days', dateRange: { from: subDays(new Date(), 7), to: new Date(), }, }, { label: 'Last 30 days', dateRange: { from: subDays(new Date(), 30), to: new Date(), }, }, { label: 'Last 3 months', dateRange: { from: subMonths(new Date(), 3), to: new Date(), }, }, { label: 'Last 12 months', dateRange: { from: subMonths(new Date(), 12), to: new Date(), }, }, { label: 'Month to date', dateRange: { from: new Date(new Date().setDate(1)), to: new Date(), }, }, { label: 'Year to date', dateRange: { from: new Date(new Date().setFullYear(new Date().getFullYear(), 0, 1)), to: new Date(), }, }, ]; function PresetsContainer({ className, ...rest }: React.HTMLAttributes) { return (
); } const PresetItem = React.forwardRef< HTMLButtonElement, React.ButtonHTMLAttributes & { isActive?: boolean; } >(({ className, isActive, ...rest }, forwardedRef) => { return (