add calendar settings

This commit is contained in:
nessar committed 2025-11-01 03:15:30 +01:00
1 parent d8759eee29
commit d01c93c763
32 files changed
+1290 -1585

No files matched your search

@@ -1,10 +1,11 @@
import { Component, effect, signal } from '@angular/core';
import { UserInputService } from '../../services/user-input-service';
import { MatCard, MatCardContent } from '@angular/material/card';
import { CalendarMonth } from "../calendar-month/calendar-month";
import { CalendarMonth } from '../calendar-month/calendar-month';
import { CalendarService, SelectedDates } from '../../services/calendar-service';
import { CommonModule } from '@angular/common';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
import { CalendarSettingsService } from '../../services/calendar-settings-service';
@Component({
selector: 'app-calendar-year',
@@ -15,15 +16,24 @@ import { MatProgressSpinner } from '@angular/material/progress-spinner';
export class CalendarYear {
protected isLoading = signal(true);
constructor(private userInput: UserInputService, private calendarService: CalendarService) {
constructor(
private userInput: UserInputService,
private calendarService: CalendarService,
private calendarSettingsService: CalendarSettingsService,
) {
effect(() => {
this.selectedDates = this.calendarService.getSelectedDatesForYear();
const vacationData = this.userInput.vacationNumberSignal();
this.calendarSettingsService.samediMalin();
this.isLoading.set(true);
// Simulate server-side calculation with a small delay
setTimeout(() => {
if (this.selectedDates) {
this.selectedDates.optimizeVacations(vacationData);
// Create a copy to avoid mutating the original signal data
this.selectedDates.optimizeVacations(
{ ...vacationData },
this.calendarSettingsService,
);
}
this.isLoading.set(false);
}, 1);
@@ -38,5 +48,8 @@ export class CalendarYear {
}
// months starting from actual date
protected months: number[] = Array.from({ length: 12 }, (_, i) => (new Date().getMonth() + i) % 12);
protected months: number[] = Array.from(
{ length: 12 },
(_, i) => (new Date().getMonth() + i) % 12,
);
}