aboutsummaryrefslogtreecommitdiff
path: root/src/components/input/MonthFilter.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/input/MonthFilter.tsx')
-rw-r--r--src/components/input/MonthFilter.tsx18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/components/input/MonthFilter.tsx b/src/components/input/MonthFilter.tsx
new file mode 100644
index 0000000..dec64b0
--- /dev/null
+++ b/src/components/input/MonthFilter.tsx
@@ -0,0 +1,18 @@
+import { useDateRange, useNavigation } from '@/components/hooks';
+import { getMonthDateRangeValue } from '@/lib/date';
+import { MonthSelect } from './MonthSelect';
+
+export function MonthFilter() {
+ const { router, updateParams } = useNavigation();
+ const {
+ dateRange: { startDate },
+ } = useDateRange();
+
+ const handleMonthSelect = (date: Date) => {
+ const range = getMonthDateRangeValue(date);
+
+ router.push(updateParams({ date: range, offset: undefined }));
+ };
+
+ return <MonthSelect date={startDate} onChange={handleMonthSelect} />;
+}