prevMonth() {
const currentDate = new Date(this.currentMonth);
currentDate.setMonth(currentDate.getMonth() - 1);
this.loadCalendar(currentDate);
}
nextMonth() {
const currentDate = new Date(this.currentMonth);
currentDate.setMonth(currentDate.getMonth() + 1);
this.loadCalendar(currentDate);
}
private loadCalendar(date: Date) {
const year = date.getFullYear();
const month = date.getMonth() + 1;
this.currentMonth = this.datePipe.transform(date, 'MMMM - yyyy');
const daysInMonth = new Date(year, month, 0).getDate();
const firstDayOfWeek = new Date(year, month - 1, 1).getDay();
this.days = [];
for (let i = 0; i < 7; i++) {
const dayIndex = (i + firstDayOfWeek) % 7;
this.days.push(['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][dayIndex]);
}
this.memberTransactionDetails.getIssueCounts(year, month).subscribe((data: IssueDashboard[]) => {
this.boxes = data.map(item => ({
date: item.id,
issueCount: item.issueCount,
}));
});
}