chore: fetch issues from previous and next month in the calendar view (#2282)

This commit is contained in:
Aaryan Khandelwal 2023-09-28 13:17:46 +05:30 committed by GitHub
parent 6afbd3f1ba
commit 34af666b5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,8 +33,28 @@ const useCalendarIssuesView = () => {
const [activeMonthDate, setActiveMonthDate] = useState(new Date()); const [activeMonthDate, setActiveMonthDate] = useState(new Date());
const firstDayOfMonth = new Date(activeMonthDate.getFullYear(), activeMonthDate.getMonth(), 1); // previous month's first date
const lastDayOfMonth = new Date(activeMonthDate.getFullYear(), activeMonthDate.getMonth() + 1, 0); const previousMonthYear =
activeMonthDate.getMonth() === 0
? activeMonthDate.getFullYear() - 1
: activeMonthDate.getFullYear();
const previousMonthMonth = activeMonthDate.getMonth() === 0 ? 11 : activeMonthDate.getMonth() - 1;
const previousMonthFirstDate = new Date(previousMonthYear, previousMonthMonth, 1);
// next month's last date
const nextMonthYear =
activeMonthDate.getMonth() === 11
? activeMonthDate.getFullYear() + 1
: activeMonthDate.getFullYear();
const nextMonthMonth = (activeMonthDate.getMonth() + 1) % 12;
const nextMonthFirstDate = new Date(nextMonthYear, nextMonthMonth, 1);
const nextMonthLastDate = new Date(
nextMonthFirstDate.getFullYear(),
nextMonthFirstDate.getMonth() + 1,
0
);
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, cycleId, moduleId, viewId } = router.query; const { workspaceSlug, projectId, cycleId, moduleId, viewId } = router.query;
@ -47,8 +67,8 @@ const useCalendarIssuesView = () => {
labels: filters?.labels ? filters?.labels.join(",") : undefined, labels: filters?.labels ? filters?.labels.join(",") : undefined,
created_by: filters?.created_by ? filters?.created_by.join(",") : undefined, created_by: filters?.created_by ? filters?.created_by.join(",") : undefined,
start_date: filters?.start_date ? filters?.start_date.join(",") : undefined, start_date: filters?.start_date ? filters?.start_date.join(",") : undefined,
target_date: `${renderDateFormat(firstDayOfMonth)};after,${renderDateFormat( target_date: `${renderDateFormat(previousMonthFirstDate)};after,${renderDateFormat(
lastDayOfMonth nextMonthLastDate
)};before`, )};before`,
}; };