[WEB-5255] fix: calendar layout weekly view (#8018)
* fix: calendar layout weekly view * chore: code refactor
This commit is contained in:
parent
b7aa25f2c6
commit
ec6e682044
1 changed files with 23 additions and 3 deletions
|
|
@ -116,10 +116,30 @@ export class CalendarStore implements ICalendarStore {
|
||||||
if (!this.calendarPayload) return undefined;
|
if (!this.calendarPayload) return undefined;
|
||||||
|
|
||||||
const { activeWeekDate } = this.calendarFilters;
|
const { activeWeekDate } = this.calendarFilters;
|
||||||
|
const year = activeWeekDate.getFullYear();
|
||||||
|
const month = activeWeekDate.getMonth();
|
||||||
|
const dayOfMonth = activeWeekDate.getDate();
|
||||||
|
|
||||||
return this.calendarPayload[`y-${activeWeekDate.getFullYear()}`][`m-${activeWeekDate.getMonth()}`][
|
// Check if calendar data exists for this year and month
|
||||||
`w-${this.activeWeekNumber - 1}`
|
const yearData = this.calendarPayload[`y-${year}`];
|
||||||
];
|
if (!yearData) return undefined;
|
||||||
|
|
||||||
|
const monthData = yearData[`m-${month}`];
|
||||||
|
if (!monthData) return undefined;
|
||||||
|
|
||||||
|
// Calculate firstDayOfMonth offset (same logic as calendar generation)
|
||||||
|
const startOfWeek = this.rootStore?.rootStore?.user?.userProfile?.data?.start_of_the_week ?? EStartOfTheWeek.SUNDAY;
|
||||||
|
const firstDayOfMonthRaw = new Date(year, month, 1).getDay();
|
||||||
|
const firstDayOfMonth = (firstDayOfMonthRaw - startOfWeek + 7) % 7;
|
||||||
|
|
||||||
|
// Calculate which sequential week this date falls into
|
||||||
|
const weekIndex = Math.floor((dayOfMonth - 1 + firstDayOfMonth) / 7);
|
||||||
|
|
||||||
|
const weekKey = `w-${weekIndex}`;
|
||||||
|
if (!(weekKey in monthData)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return monthData[weekKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
getStartAndEndDate = computedFn((layout: "week" | "month") => {
|
getStartAndEndDate = computedFn((layout: "week" | "month") => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue