@@ -17,6 +17,8 @@ export class ProjectComponent implements OnInit {
1717 projectInvestments$ : Observable < AngorProjectInvestment [ ] > | null = null ;
1818 isLoading = true ;
1919 error : HttpErrorResponse | null = null ;
20+ investmentPage : number = 1 ;
21+ investmentsPerPage : number = 10 ;
2022
2123 constructor (
2224 private route : ActivatedRoute ,
@@ -42,7 +44,9 @@ export class ProjectComponent implements OnInit {
4244 return this . apiService . getAngorProjectStats$ ( angorId ) . pipe (
4345 switchMap ( stats => {
4446 this . projectStats$ = of ( stats ) ;
45- return this . apiService . getAngorProjectInvestments ( angorId ) ;
47+ const limit = this . investmentsPerPage ;
48+ const offset = ( this . investmentPage - 1 ) * limit ;
49+ return this . apiService . getAngorProjectInvestments ( angorId , offset , limit ) ;
4650 } ) ,
4751 map ( investments => {
4852 this . projectInvestments$ = of ( investments ) ;
@@ -63,4 +67,22 @@ export class ProjectComponent implements OnInit {
6367 )
6468 . subscribe ( ) ;
6569 }
70+
71+ onInvestmentPageChange ( newPage : number ) : void {
72+ this . investmentPage = newPage ;
73+ this . angorId$ . pipe (
74+ switchMap ( angorId => {
75+ if ( ! angorId ) {
76+ throw new Error ( 'Angor ID is missing.' ) ;
77+ }
78+ this . isLoading = true ;
79+ const limit = this . investmentsPerPage ;
80+ const offset = ( this . investmentPage - 1 ) * limit ;
81+ return this . apiService . getAngorProjectInvestments ( angorId , offset , limit ) ;
82+ } )
83+ ) . subscribe ( investments => {
84+ this . projectInvestments$ = of ( investments ) ;
85+ this . isLoading = false ;
86+ } ) ;
87+ }
6688}
0 commit comments