(analytics) Add time dropdown to filter analytics with a time range

This commit is contained in:
Baptiste Arnaud
2024-01-29 19:41:27 +01:00
parent 07928c743c
commit 515fcafcd8
7 changed files with 139 additions and 15 deletions

View File

@@ -0,0 +1,18 @@
import { timeFilterValues } from '../constants'
export const parseDateFromTimeFilter = (
timeFilter: (typeof timeFilterValues)[number]
): Date | undefined => {
switch (timeFilter) {
case 'today':
return new Date(new Date().setHours(0, 0, 0, 0))
case 'last7Days':
return new Date(Date.now() - 7 * 24 * 60 * 60 * 1000)
case 'last30Days':
return new Date(Date.now() - 30 * 24 * 60 * 60 * 1000)
case 'yearToDate':
return new Date(new Date().getFullYear(), 0, 1)
case 'allTime':
return
}
}