diff --git a/HRM.UI/ClientApp/src/app/app.topbar.component.html b/HRM.UI/ClientApp/src/app/app.topbar.component.html index 2833eb5..4e79543 100644 --- a/HRM.UI/ClientApp/src/app/app.topbar.component.html +++ b/HRM.UI/ClientApp/src/app/app.topbar.component.html @@ -98,6 +98,12 @@ } + + @if (payrollTypeName) { +
  • + {{payrollTypeName}} +
  • + } @if (apiService.menuItems !== null) { diff --git a/HRM.UI/ClientApp/src/app/app.topbar.component.scss b/HRM.UI/ClientApp/src/app/app.topbar.component.scss index 6760b0f..ff2701c 100644 --- a/HRM.UI/ClientApp/src/app/app.topbar.component.scss +++ b/HRM.UI/ClientApp/src/app/app.topbar.component.scss @@ -409,3 +409,27 @@ border-left: 1px solid $topbar-accent-purple-light; margin-left: 12px; } + +// Current payroll type label (admin logins), left of the Pending Jobs icon. +// Sits on the dark admin topbar, so it uses the same white as .topbar-icon. +.topbar-payroll-type-item { + display: flex; + align-items: center; + height: 36px; +} +.topbar-payroll-type { + display: inline-block; + max-width: 260px; + padding: 4px 12px; + border: 1px solid rgba($color-white, 0.35); + border-radius: 999px; + background: rgba($color-white, 0.12); + color: $color-white; + font-size: 13px; + font-weight: 600; + line-height: 18px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + cursor: default; +} diff --git a/HRM.UI/ClientApp/src/app/app.topbar.component.ts b/HRM.UI/ClientApp/src/app/app.topbar.component.ts index bec2e2c..3bac07b 100644 --- a/HRM.UI/ClientApp/src/app/app.topbar.component.ts +++ b/HRM.UI/ClientApp/src/app/app.topbar.component.ts @@ -54,6 +54,13 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy { private notifPanelWasOpen = false; private subscriptions: Subscription[] = []; + // Current payroll type's description, shown left of the Pending Jobs icon for admin + // (EnumUserType.User) logins only. Re-read whenever the stored token changes + // (login, user switch, payroll-type switch, logout). + payrollTypeName: string = ''; + private payrollTypeToken: string | null | undefined = undefined; + private payrollTypeSub: Subscription | null = null; + isScrolled: boolean = false; @HostListener('window:scroll', []) onWindowScroll() { @@ -159,6 +166,46 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy { this.onNotificationPanelClosed(); } this.notifPanelWasOpen = isOpen; + + this.syncPayrollTypeName(); + } + + /** + * Shows the current payroll type's description for admin logins. Cheap on every + * change-detection pass: it only does work when the token in localStorage changed. + * The name comes from the server (GetPayrollTypeByLoginID), so it is the payroll + * type the API actually scopes data by. + */ + private syncPayrollTypeName(): void { + const token = localStorage.getItem('token'); + if (token === this.payrollTypeToken) { + return; + } + this.payrollTypeToken = token; + if (this.payrollTypeSub) { + this.payrollTypeSub.unsubscribe(); + this.payrollTypeSub = null; + } + + let user: any = null; + try { + user = token ? new JwtHelperService().decodeToken(token) : null; + } catch { + user = null; + } + if (!user || user.UserType != EnumUserType.User || !user.PayrollTypeID) { + this.payrollTypeName = ''; + return; + } + + this.payrollTypeSub = this.authService.GetPayrollTypeByLoginID().subscribe({ + next: (payrollType) => { + this.payrollTypeName = payrollType?.description ?? ''; + }, + error: () => { + this.payrollTypeName = ''; + }, + }); } /** @@ -176,6 +223,9 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy { ngOnDestroy(): void { this.subscriptions.forEach(s => s.unsubscribe()); + if (this.payrollTypeSub) { + this.payrollTypeSub.unsubscribe(); + } } loadBookmark() { diff --git a/HRM.UI/ClientApp/src/app/reports/discontinue-employee-details/discontinue-employee-details.component.ts b/HRM.UI/ClientApp/src/app/reports/discontinue-employee-details/discontinue-employee-details.component.ts index b12e45a..9e8623d 100644 --- a/HRM.UI/ClientApp/src/app/reports/discontinue-employee-details/discontinue-employee-details.component.ts +++ b/HRM.UI/ClientApp/src/app/reports/discontinue-employee-details/discontinue-employee-details.component.ts @@ -54,6 +54,7 @@ export class DiscontinueEmployeeDetailsComponent implements OnInit { this.notificationService.showWarning('From Date cannot be after To Date.', 'Warning'); return; } + debugger; this.grid.load({ fromDate: this.fromDate, toDate: this.toDate }); }