-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtime-range.tsx
More file actions
54 lines (51 loc) · 1.69 KB
/
time-range.tsx
File metadata and controls
54 lines (51 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
import { DateRange } from 'react-day-picker'
import { DateRangePicker } from '@/components/ui/date-range-picker'
export type TimeRange = 'hourly' | 'daily' | 'weekly' | 'monthly';
interface TimeRangeProps {
timeRange: TimeRange
onTimeRangeChange: (range: TimeRange) => void
dateRange: DateRange | undefined
onDateRangeChange: (range: DateRange | undefined) => void
className?: string
}
export function TimeRange({
timeRange,
onTimeRangeChange,
dateRange,
onDateRangeChange,
className
}: TimeRangeProps) {
return (
<div className={cn("flex items-center gap-2", className)}>
<div className="flex gap-1">
<Button
variant={timeRange == 'hourly' ? 'default' : 'outline'}
size="sm"
onClick={() => onTimeRangeChange('hourly')}
>
Hourly
</Button>
<Button
variant={timeRange === 'daily' ? 'default' : 'outline'}
size="sm"
onClick={() => onTimeRangeChange('daily')}
>
Daily
</Button>
<Button
variant={timeRange === 'monthly' ? 'default' : 'outline'}
size="sm"
onClick={() => onTimeRangeChange('monthly')}
>
Monthly
</Button>
</div>
<DateRangePicker
initialDateRange={dateRange}
onChange={onDateRangeChange}
/>
</div>
)
}