Chore: Updated resolvers from Class to ResolveFn

This commit is contained in:
2024-05-31 09:58:48 +05:30
parent 6f433ef203
commit 6e3c429db3
255 changed files with 1737 additions and 2155 deletions
@@ -5,7 +5,7 @@ import { ActivatedRouteSnapshot, RouterModule, RouterStateSnapshot, Routes } fro
import { AuthGuard } from '../auth/auth-guard.service';
import { BatchIntegrityReportComponent } from './batch-integrity-report.component';
import { BatchIntegrityResolverService } from './batch-integrity-resolver.service';
import { batchIntegrityResolver } from './batch-integrity.resolver';
const batchIntegrityRoutes: Routes = [
{
@@ -18,7 +18,7 @@ const batchIntegrityRoutes: Routes = [
permission: 'Product Ledger',
},
resolve: {
info: () => inject(BatchIntegrityResolverService).resolve(),
info: batchIntegrityResolver,
},
runGuardsAndResolvers: 'always',
},
@@ -27,6 +27,5 @@ const batchIntegrityRoutes: Routes = [
@NgModule({
imports: [CommonModule, RouterModule.forChild(batchIntegrityRoutes)],
exports: [RouterModule],
providers: [BatchIntegrityResolverService],
})
export class BatchIntegrityReportRoutingModule {}
@@ -1,17 +0,0 @@
import { HttpClientModule } from '@angular/common/http';
import { inject, TestBed } from '@angular/core/testing';
import { BatchIntegrityResolverService } from './batch-integrity-resolver.service';
describe('BatchIntegrityResolverService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule],
providers: [BatchIntegrityResolverService],
});
});
it('should be created', inject([BatchIntegrityResolverService], (service: BatchIntegrityResolverService) => {
expect(service).toBeTruthy();
}));
});
@@ -1,16 +0,0 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
import { BatchIntegrity } from './batch-integrity';
import { BatchIntegrityReportService } from './batch-integrity-report.service';
@Injectable({
providedIn: 'root',
})
export class BatchIntegrityResolverService {
constructor(private ser: BatchIntegrityReportService) {}
resolve(): Observable<BatchIntegrity[]> {
return this.ser.batchIntegrity();
}
}
@@ -0,0 +1,18 @@
import { TestBed } from '@angular/core/testing';
import { ResolveFn } from '@angular/router';
import { BatchIntegrity } from './batch-integrity';
import { batchIntegrityResolver } from './batch-integrity.resolver';
describe('batchIntegrityResolver', () => {
const executeResolver: ResolveFn<BatchIntegrity[]> = (...resolverParameters) =>
TestBed.runInInjectionContext(() => batchIntegrityResolver(...resolverParameters));
beforeEach(() => {
TestBed.configureTestingModule({});
});
it('should be created', () => {
expect(executeResolver).toBeTruthy();
});
});
@@ -0,0 +1,9 @@
import { inject } from '@angular/core';
import { ResolveFn } from '@angular/router';
import { BatchIntegrity } from './batch-integrity';
import { BatchIntegrityReportService } from './batch-integrity-report.service';
export const batchIntegrityResolver: ResolveFn<BatchIntegrity[]> = () => {
return inject(BatchIntegrityReportService).batchIntegrity();
};