Added parseDateRangeQuery function.
This commit is contained in:
@@ -62,10 +62,10 @@ export function parseDateRange(value, locale = 'en-US') {
|
||||
}
|
||||
|
||||
if (value?.startsWith?.('range')) {
|
||||
const [, startAt, endAt] = value.split(':');
|
||||
const [, startTime, endTime] = value.split(':');
|
||||
|
||||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
const startDate = new Date(+startTime);
|
||||
const endDate = new Date(+endTime);
|
||||
|
||||
return {
|
||||
...getDateRangeValues(startDate, endDate),
|
||||
|
||||
@@ -10,7 +10,6 @@ export async function parseDateRangeQuery(req: NextApiRequest) {
|
||||
const { min, max } = await getWebsiteDateRange(websiteId as string);
|
||||
|
||||
return {
|
||||
websiteId,
|
||||
startDate: min,
|
||||
endDate: max,
|
||||
unit: getMinimumUnit(min, max),
|
||||
@@ -22,9 +21,8 @@ export async function parseDateRangeQuery(req: NextApiRequest) {
|
||||
const minUnit = getMinimumUnit(startDate, endDate);
|
||||
|
||||
return {
|
||||
websiteId,
|
||||
startDate,
|
||||
endDate,
|
||||
unit: getAllowedUnits(startDate, endDate).includes(unit as string) ? unit : minUnit,
|
||||
unit: (getAllowedUnits(startDate, endDate).includes(unit as string) ? unit : minUnit) as string,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user