fix: enable sessions for API keys (#283)

* fix: enable sessions for API keys

* chore: remove old due date filters

* chore: update lockfile

* fix: temp ignore eslint errors on build
This commit is contained in:
Henry
2025-12-13 22:19:16 +00:00
committed by GitHub
parent bcd20b58c6
commit 86ecdca7f1
19 changed files with 220 additions and 93 deletions

View File

@@ -0,0 +1,63 @@
import { addDays, endOfDay, startOfDay } from "date-fns";
export type DueDateFilterKey =
| "overdue"
| "today"
| "tomorrow"
| "next-week"
| "next-month"
| "no-due-date";
export interface DueDateFilter {
startDate?: Date;
endDate?: Date;
hasNoDueDate?: boolean;
}
export const convertDueDateFiltersToRanges = (
filters: DueDateFilterKey[],
): DueDateFilter[] => {
if (!filters.length) return [];
const today = startOfDay(new Date());
const tomorrow = addDays(today, 1);
const nextWeekEnd = addDays(today, 8);
const nextMonthEnd = addDays(today, 31);
return filters.map((filter) => {
switch (filter) {
case "overdue":
return {
endDate: today,
};
case "today":
return {
startDate: today,
endDate: endOfDay(today),
};
case "tomorrow":
return {
startDate: tomorrow,
endDate: endOfDay(tomorrow),
};
case "next-week": {
return {
startDate: today,
endDate: nextWeekEnd,
};
}
case "next-month": {
return {
startDate: nextWeekEnd,
endDate: nextMonthEnd,
};
}
case "no-due-date":
return {
hasNoDueDate: true,
};
default:
return {};
}
});
};

View File

@@ -2,3 +2,4 @@ export * from "./generateUID";
export * from "./generateSlug";
export * from "./subscriptions";
export * from "./email";
export * from "./dueDateFilters";