diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts index 3969f39..42511ce 100644 --- a/src/app/components/login/login.component.ts +++ b/src/app/components/login/login.component.ts @@ -52,7 +52,6 @@ export class LoginComponent implements OnInit, OnDestroy { ) {} ngOnInit(): void { - this.routeParams(); this.deleteTokens(); } @@ -61,17 +60,6 @@ export class LoginComponent implements OnInit, OnDestroy { this.destroy$.complete(); } - routeParams() { - this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params) => { - if (params['id'] && params['id'] === 'pw-send') { - this.overlayService.setOverlayData('dialog', 'pw-send'); - } - if (params['id'] && params['id'] === 'pw-change') { - this.overlayService.setOverlayData('dialog', 'pw-change'); - } - }); - } - isButtonDisabled() { return this.buttonStateService.isButtonDisabled; } diff --git a/src/app/components/summary/summary.component.html b/src/app/components/summary/summary.component.html index 88d588e..d803776 100644 --- a/src/app/components/summary/summary.component.html +++ b/src/app/components/summary/summary.component.html @@ -43,7 +43,7 @@
{{ "summary.upcomingDeadline" | translate }}
diff --git a/src/app/components/summary/summary.component.ts b/src/app/components/summary/summary.component.ts index 42e4c3c..a32b925 100644 --- a/src/app/components/summary/summary.component.ts +++ b/src/app/components/summary/summary.component.ts @@ -16,11 +16,13 @@ import { PRIORITIES, PRIORITY_LABELS, } from '../../constants/task-priority.constants'; +import { CommonModule } from '@angular/common'; @Component({ selector: 'app-summary', standalone: true, imports: [ + CommonModule, RouterModule, TranslateModule, LoadingSpinnerComponent, @@ -49,9 +51,8 @@ export class SummaryComponent implements OnInit, OnDestroy { ) {} /** - * This method performs the following actions: - * - Calls the loadAllTasks method to load all tasks. - * - Calls the loadCurrentUser method to load the current user. + * Loads all tasks and the current user. Initializes the component + * by fetching necessary data from the TaskService and UserService. */ ngOnInit(): void { this.loadAllTasks(); @@ -132,31 +133,12 @@ export class SummaryComponent implements OnInit, OnDestroy { * Retrieves the date of the next urgent task. * @returns {string | null} The date of the next urgent task formatted as a string, or null if no urgent tasks exist. */ - get nextUrgentTask(): string | null { - if (this.urgentTasks.length === 0) return null; - - const nextTask = this.urgentTasks.reduce((earliest, current) => { - return Date.parse(current.date) < Date.parse(earliest.date) - ? current - : earliest; - }); - - return this.timeConverter(nextTask.date); - } - - /** - * Converts a date string to a human-readable format. - * @param dateString - The date string to convert. - * @returns A string representing the date in the format "MMM. DD, YYYY". - */ - timeConverter(dateString: string): string { - const date = new Date(dateString); - return date.toLocaleDateString('en-US', { - month: 'short', - day: 'numeric', - year: 'numeric', - }); + return this.urgentTasks.length + ? this.urgentTasks.reduce((a, b) => + Date.parse(a.date) < Date.parse(b.date) ? a : b + ).date + : null; } /** @@ -164,14 +146,9 @@ export class SummaryComponent implements OnInit, OnDestroy { * @returns a localized greeting string. */ get greeting(): string { - const currentHour = new Date().getHours(); - - if (currentHour >= 5 && currentHour < 12) { - return this.translateService.instant('summary.morning'); - } - if (currentHour >= 12 && currentHour < 18) { - return this.translateService.instant('summary.afternoon'); - } - return this.translateService.instant('summary.evening'); + const hour = new Date().getHours(); + const key = + hour < 5 || hour >= 18 ? 'evening' : hour < 12 ? 'morning' : 'afternoon'; + return this.translateService.instant(`summary.${key}`); } } diff --git a/src/app/shared/components/overlay/dialog-overlay/dialog-overlay.component.html b/src/app/shared/components/overlay/dialog-overlay/dialog-overlay.component.html deleted file mode 100644 index b67ed1c..0000000 --- a/src/app/shared/components/overlay/dialog-overlay/dialog-overlay.component.html +++ /dev/null @@ -1,12 +0,0 @@ -- @if (overlayData === "pw-send") { {{ "msgDialog.pwSend" | translate }} } -
-- @if (overlayData === "pw-change") { {{ "msgDialog.pwChange" | translate }} } -
-