@flusys/ng-auth 6.0.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,6 +46,12 @@ class AuthApiService {
46
46
  switchCompany(data) {
47
47
  return this.http.post(`${this.baseUrl}/switch-company`, data);
48
48
  }
49
+ getCompanies() {
50
+ return this.http.post(`${this.baseUrl}/get-companies`, {});
51
+ }
52
+ getCompanyBranches(companyId) {
53
+ return this.http.post(`${this.baseUrl}/get-company-branches`, { companyId });
54
+ }
49
55
  refresh() {
50
56
  return this.http.post(`${this.baseUrl}/refresh`, {});
51
57
  }
@@ -715,8 +721,6 @@ const AUTH_MESSAGES = {
715
721
  'auth.password.change.current.required': 'Current password is required',
716
722
  'auth.password.reset.email.sent': 'Password reset email sent',
717
723
  'auth.password.reset.success': 'Password reset successfully',
718
- 'auth.token.expired': 'Token has expired',
719
- 'auth.token.revoked': 'Token has been revoked',
720
724
  'auth.token.too.large': 'Refresh token too large (≈{{size}} bytes)',
721
725
  'auth.company.list.success': 'User companies retrieved successfully',
722
726
  'auth.company.not.found': 'Company not found',
@@ -791,8 +795,6 @@ const AUTH_MESSAGES = {
791
795
  'user.permission.already.assigned': 'User already assigned to this {{type}}',
792
796
  'user.permission.not.found': '{{type}} permission not found',
793
797
  // === UI KEYS — AUTH DOMAIN (AUTH_ROUTES: login, register, forgot-password, reset-password, verify-email) ===
794
- // interceptors/token-refresh.interceptor.ts
795
- 'auth.session.expired.title': 'Session Expired',
796
798
  // pages/login/login-page.component.ts
797
799
  'auth.login.welcome': 'Welcome back!',
798
800
  'auth.login.sign.in.to.continue': 'Sign in to continue to your account',
@@ -1251,6 +1253,22 @@ class AuthLayoutApiAdapter {
1251
1253
  slug: permission.branchSlug ?? '',
1252
1254
  }))));
1253
1255
  }
1256
+ getMyCompanies() {
1257
+ return this.authApi.getCompanies().pipe(map$1((response) => (response.data || []).map((company) => ({
1258
+ id: company.id,
1259
+ name: company.name,
1260
+ slug: company.slug ?? '',
1261
+ imageId: company.logoId ?? '',
1262
+ }))));
1263
+ }
1264
+ getMyCompanyBranches(companyId) {
1265
+ return this.authApi.getCompanyBranches(companyId).pipe(map$1((response) => (response.data || []).map((branch) => ({
1266
+ id: branch.id,
1267
+ name: branch.name,
1268
+ slug: branch.slug ?? '',
1269
+ imageId: branch.logoId ?? undefined,
1270
+ }))));
1271
+ }
1254
1272
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthLayoutApiAdapter, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1255
1273
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthLayoutApiAdapter, providedIn: 'root' });
1256
1274
  }
@@ -1297,7 +1315,7 @@ class AuthUserProviderAdapter {
1297
1315
  messageVariables: response.messageVariables,
1298
1316
  data: (response.data ?? []).map((user) => ({
1299
1317
  id: user.id,
1300
- name: user.name ?? user.email,
1318
+ name: user.name || user.email,
1301
1319
  email: user.email,
1302
1320
  })),
1303
1321
  meta: response.meta,
@@ -1349,6 +1367,12 @@ class AuthUserPermissionProviderAdapter {
1349
1367
  getUserBranchPermissions(userId, companyId) {
1350
1368
  return this.userPermissionApi.getUserBranches(userId, companyId);
1351
1369
  }
1370
+ getUserCompanyPermissions(userId) {
1371
+ return this.userPermissionApi.getUserCompanies(userId).pipe(map((response) => ({
1372
+ ...response,
1373
+ data: (response.data ?? []).map((c) => ({ id: c.companyId, name: c.companyName })),
1374
+ })));
1375
+ }
1352
1376
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthUserPermissionProviderAdapter, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1353
1377
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthUserPermissionProviderAdapter });
1354
1378
  }
@@ -2122,7 +2146,7 @@ class BranchListComponent {
2122
2146
  try {
2123
2147
  const response = await this.branchService.delete({
2124
2148
  id: branch.id,
2125
- type: 'delete',
2149
+ type: 'permanent',
2126
2150
  });
2127
2151
  this.messageService.add({
2128
2152
  severity: 'success',
@@ -2173,7 +2197,9 @@ class BranchListComponent {
2173
2197
  (click)="onCreate()"
2174
2198
  >
2175
2199
  <ui-icon pButtonIcon name="plus"></ui-icon>
2176
- <span pButtonLabel>{{ 'administrative.branch.add' | translate }}</span>
2200
+ <span pButtonLabel>{{
2201
+ 'administrative.branch.add' | translate
2202
+ }}</span>
2177
2203
  </button>
2178
2204
  </div>
2179
2205
  </ng-template>
@@ -2266,12 +2292,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
2266
2292
  type: Component,
2267
2293
  args: [{
2268
2294
  selector: 'lib-branch-list',
2269
- imports: [
2270
- AngularModule,
2271
- UiModule,
2272
- HasPermissionDirective,
2273
- TranslatePipe,
2274
- ],
2295
+ imports: [AngularModule, UiModule, HasPermissionDirective, TranslatePipe],
2275
2296
  template: `
2276
2297
  <f-card>
2277
2298
  <ng-template #header>
@@ -2305,7 +2326,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
2305
2326
  (click)="onCreate()"
2306
2327
  >
2307
2328
  <ui-icon pButtonIcon name="plus"></ui-icon>
2308
- <span pButtonLabel>{{ 'administrative.branch.add' | translate }}</span>
2329
+ <span pButtonLabel>{{
2330
+ 'administrative.branch.add' | translate
2331
+ }}</span>
2309
2332
  </button>
2310
2333
  </div>
2311
2334
  </ng-template>
@@ -2537,14 +2560,18 @@ var companyForm_component = /*#__PURE__*/Object.freeze({
2537
2560
 
2538
2561
  class CompanyListComponent {
2539
2562
  permissionValidator = inject(PermissionValidatorService);
2540
- translateAdapter = inject(TranslateService, { optional: true });
2563
+ translateAdapter = inject(TranslateService, {
2564
+ optional: true,
2565
+ });
2541
2566
  router = inject(Router);
2542
2567
  companyService = inject(CompanyApiService);
2543
2568
  canCreate = computed(() => this.permissionValidator.hasPermission(COMPANY_PERMISSIONS.CREATE), /* @ts-ignore */
2544
2569
  ...(ngDevMode ? [{ debugName: "canCreate" }] : /* istanbul ignore next */ []));
2545
2570
  canEditFn = (_item) => this.permissionValidator.hasPermission(COMPANY_PERMISSIONS.UPDATE);
2546
- canDeleteFn = (item) => !item.readOnly && this.permissionValidator.hasPermission(COMPANY_PERMISSIONS.DELETE);
2547
- viewBranchesAction = [{
2571
+ canDeleteFn = (item) => !item.readOnly &&
2572
+ this.permissionValidator.hasPermission(COMPANY_PERMISSIONS.DELETE);
2573
+ viewBranchesAction = [
2574
+ {
2548
2575
  icon: 'building',
2549
2576
  tooltip: 'administrative.branch.view.branches',
2550
2577
  severity: 'secondary',
@@ -2552,12 +2579,29 @@ class CompanyListComponent {
2552
2579
  handler: (c) => this.router.navigate(['/administration/branch'], {
2553
2580
  queryParams: { companyId: c.id },
2554
2581
  }),
2555
- }];
2582
+ },
2583
+ ];
2556
2584
  columns = [
2557
- { field: 'name', header: this.t('administrative.company.name'), type: 'text' },
2558
- { field: 'slug', header: this.t('administrative.company.slug'), type: 'text' },
2559
- { field: 'email', header: this.t('administrative.email.label'), type: 'text' },
2560
- { field: 'phone', header: this.t('administrative.phone.label'), type: 'text' },
2585
+ {
2586
+ field: 'name',
2587
+ header: this.t('administrative.company.name'),
2588
+ type: 'text',
2589
+ },
2590
+ {
2591
+ field: 'slug',
2592
+ header: this.t('administrative.company.slug'),
2593
+ type: 'text',
2594
+ },
2595
+ {
2596
+ field: 'email',
2597
+ header: this.t('administrative.email.label'),
2598
+ type: 'text',
2599
+ },
2600
+ {
2601
+ field: 'phone',
2602
+ header: this.t('administrative.phone.label'),
2603
+ type: 'text',
2604
+ },
2561
2605
  { field: 'isActive', header: this.t('shared.status'), type: 'custom' },
2562
2606
  ];
2563
2607
  asCompany(item) {
@@ -2578,23 +2622,33 @@ class CompanyListComponent {
2578
2622
  [createRoute]="'/administration/company/new'"
2579
2623
  [editRoute]="'/administration/company'"
2580
2624
  [deleteConfirmField]="'name'"
2625
+ [deleteType]="'permanent'"
2581
2626
  [canEdit]="canEditFn"
2582
2627
  [canDelete]="canDeleteFn"
2583
2628
  >
2584
2629
  <ng-template baseListTemplate="isActive" let-item>
2585
2630
  <f-tag
2586
- [value]="asCompany(item).isActive ? ('shared.active' | translate) : ('shared.inactive' | translate)"
2631
+ [value]="
2632
+ asCompany(item).isActive
2633
+ ? ('shared.active' | translate)
2634
+ : ('shared.inactive' | translate)
2635
+ "
2587
2636
  [severity]="asCompany(item).isActive ? 'success' : 'danger'"
2588
2637
  />
2589
2638
  </ng-template>
2590
2639
  </lib-base-list>
2591
- `, isInline: true, dependencies: [{ kind: "component", type: BaseListComponent, selector: "lib-base-list", inputs: ["columns", "actions", "title", "showCreateButton", "searchable", "pageSize", "scrollHeight", "emptyMessage", "createButtonLabel", "createButtonIcon", "data", "total", "isLoading", "service", "filter", "createRoute", "editRoute", "deleteConfirmField", "idField", "canEdit", "canDelete"], outputs: ["onCreate", "onLazyLoad", "onSearch"] }, { kind: "directive", type: BaseListTemplateDirective, selector: "ng-template[baseListTemplate]", inputs: ["baseListTemplate"] }, { kind: "ngmodule", type: UiModule }, { kind: "component", type: i1$1.TagComponent, selector: "f-tag", inputs: ["value", "severity", "icon", "rounded", "color", "styleClass", "style"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
2640
+ `, isInline: true, dependencies: [{ kind: "component", type: BaseListComponent, selector: "lib-base-list", inputs: ["columns", "actions", "title", "showCreateButton", "searchable", "pageSize", "scrollHeight", "emptyMessage", "createButtonLabel", "createButtonIcon", "data", "total", "isLoading", "service", "filter", "createRoute", "editRoute", "deleteConfirmField", "deleteType", "idField", "canEdit", "canDelete"], outputs: ["onCreate", "onLazyLoad", "onSearch"] }, { kind: "directive", type: BaseListTemplateDirective, selector: "ng-template[baseListTemplate]", inputs: ["baseListTemplate"] }, { kind: "ngmodule", type: UiModule }, { kind: "component", type: i1$1.TagComponent, selector: "f-tag", inputs: ["value", "severity", "icon", "rounded", "color", "styleClass", "style"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
2592
2641
  }
2593
2642
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CompanyListComponent, decorators: [{
2594
2643
  type: Component,
2595
2644
  args: [{
2596
2645
  selector: 'lib-company-list',
2597
- imports: [BaseListComponent, BaseListTemplateDirective, UiModule, TranslatePipe],
2646
+ imports: [
2647
+ BaseListComponent,
2648
+ BaseListTemplateDirective,
2649
+ UiModule,
2650
+ TranslatePipe,
2651
+ ],
2598
2652
  template: `
2599
2653
  <lib-base-list
2600
2654
  [columns]="columns"
@@ -2606,12 +2660,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
2606
2660
  [createRoute]="'/administration/company/new'"
2607
2661
  [editRoute]="'/administration/company'"
2608
2662
  [deleteConfirmField]="'name'"
2663
+ [deleteType]="'permanent'"
2609
2664
  [canEdit]="canEditFn"
2610
2665
  [canDelete]="canDeleteFn"
2611
2666
  >
2612
2667
  <ng-template baseListTemplate="isActive" let-item>
2613
2668
  <f-tag
2614
- [value]="asCompany(item).isActive ? ('shared.active' | translate) : ('shared.inactive' | translate)"
2669
+ [value]="
2670
+ asCompany(item).isActive
2671
+ ? ('shared.active' | translate)
2672
+ : ('shared.inactive' | translate)
2673
+ "
2615
2674
  [severity]="asCompany(item).isActive ? 'success' : 'danger'"
2616
2675
  />
2617
2676
  </ng-template>
@@ -2669,9 +2728,8 @@ class ForgotPasswordPageComponent {
2669
2728
  .forgotPassword(email)
2670
2729
  .pipe(takeUntilDestroyed(this.destroyRef), tap({
2671
2730
  next: () => this.showEmailSent(email),
2672
- error: () => { },
2673
2731
  }), finalize(() => this.isLoading.set(false)))
2674
- .subscribe();
2732
+ .subscribe({ error: () => { } });
2675
2733
  }
2676
2734
  showEmailSent(email) {
2677
2735
  this.submittedEmail.set(email);
@@ -7312,7 +7370,7 @@ class UserFormComponent {
7312
7370
  this.userFormExtension
7313
7371
  .saveExtraFieldValues(userId, extraFields)
7314
7372
  .pipe(takeUntilDestroyed(this.destroyRef))
7315
- .subscribe();
7373
+ .subscribe({ error: () => { } });
7316
7374
  }
7317
7375
  onSaveSuccess(message) {
7318
7376
  this.messageService.add({
@@ -7336,9 +7394,10 @@ class UserFormComponent {
7336
7394
  this.permissionService
7337
7395
  .assignUserToBranch(userId, branch.id)
7338
7396
  .pipe(takeUntilDestroyed(this.destroyRef))
7339
- .subscribe();
7397
+ .subscribe({ error: () => { } });
7340
7398
  }
7341
7399
  },
7400
+ error: () => { },
7342
7401
  });
7343
7402
  }
7344
7403
  onCancel() {