mirror of
https://github.com/documenso/documenso.git
synced 2025-11-22 12:41:36 +10:00
feat: team analytics
This commit is contained in:
24
apps/remix/app/hooks/use-analytics-filter.ts
Normal file
24
apps/remix/app/hooks/use-analytics-filter.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { useSearchParams } from 'react-router';
|
||||
|
||||
import type { DateFilterPeriod } from '~/components/analytics/analytics-date-filter';
|
||||
|
||||
export const useAnalyticsFilter = () => {
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
||||
const period = (searchParams.get('period') as DateFilterPeriod) || 'all';
|
||||
|
||||
const handlePeriodChange = (newPeriod: DateFilterPeriod) => {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
if (newPeriod === 'all') {
|
||||
params.delete('period');
|
||||
} else {
|
||||
params.set('period', newPeriod);
|
||||
}
|
||||
setSearchParams(params);
|
||||
};
|
||||
|
||||
return {
|
||||
period,
|
||||
handlePeriodChange,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user