(defaultValue = "24h")
| 4 | export const Durations: Duration[] = ["24h", "6h", "1h", "5m"] |
| 5 | |
| 6 | export function useDuration(defaultValue = "24h") { |
| 7 | const [duration, setDuration] = useState<Duration>(defaultValue as Duration) |
| 8 | |
| 9 | function onChange(value: string) { |
| 10 | setDuration(value as Duration) |
| 11 | } |
| 12 | |
| 13 | return { |
| 14 | duration, |
| 15 | setDuration, |
| 16 | onChange, |
| 17 | } |
| 18 | } |