feat: card due dates (#271)

* feat: add card due dates to schema

* feat: update repo funcs

* feat: update card router to support due dates

* chore: update migration journal

* feat: add date selector

* feat: display date icon and label on cards

* feat: add due date filters

* feat: add due date to new card form

* feat: light mode tweaks

* feat: improve text eligibility on light mode

* feat: reduce selector font size

* feat: display date updates in card activity

* chore: gen translations
This commit is contained in:
Henry
2025-12-05 21:49:45 +00:00
committed by GitHub
parent 88f1aa0ec4
commit d208952d15
39 changed files with 5224 additions and 722 deletions

View File

@@ -0,0 +1,63 @@
import { addDays, endOfDay, startOfDay } from "date-fns";
type DueDateFilterKey =
| "overdue"
| "today"
| "tomorrow"
| "next-week"
| "next-month"
| "no-due-date";
export interface DueDateFilter {
startDate?: string;
endDate?: string;
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); // 7 days ahead
const nextMonthEnd = addDays(today, 31); // 30 days ahead
return filters.map((filter) => {
switch (filter) {
case "overdue":
return {
endDate: today.toISOString(),
};
case "today":
return {
startDate: today.toISOString(),
endDate: endOfDay(today).toISOString(),
};
case "tomorrow":
return {
startDate: tomorrow.toISOString(),
endDate: endOfDay(tomorrow).toISOString(),
};
case "next-week": {
return {
startDate: today.toISOString(),
endDate: nextWeekEnd.toISOString(),
};
}
case "next-month": {
return {
startDate: nextWeekEnd.toISOString(),
endDate: nextMonthEnd.toISOString(),
};
}
case "no-due-date":
return {
hasNoDueDate: true,
};
default:
return {};
}
});
};