diff --git a/src/app/features/moderation/store/preprint-moderation/preprint-moderation.state.ts b/src/app/features/moderation/store/preprint-moderation/preprint-moderation.state.ts index b02da84e9..a8189c0fc 100644 --- a/src/app/features/moderation/store/preprint-moderation/preprint-moderation.state.ts +++ b/src/app/features/moderation/store/preprint-moderation/preprint-moderation.state.ts @@ -182,7 +182,7 @@ export class PreprintModerationState { ); return this.contributorsService - .getAllContributors(ResourceType.Preprint, preprintId, 1, DEFAULT_TABLE_PARAMS.rows) + .getBibliographicContributors(ResourceType.Preprint, preprintId, 1, DEFAULT_TABLE_PARAMS.rows) .pipe( tap((res) => { ctx.setState( @@ -241,7 +241,7 @@ export class PreprintModerationState { ); return this.contributorsService - .getAllContributors(ResourceType.Preprint, preprintId, 1, DEFAULT_TABLE_PARAMS.rows) + .getBibliographicContributors(ResourceType.Preprint, preprintId, 1, DEFAULT_TABLE_PARAMS.rows) .pipe( tap((res) => { ctx.setState( diff --git a/src/app/shared/services/contributors.service.ts b/src/app/shared/services/contributors.service.ts index 62c178759..16d525413 100644 --- a/src/app/shared/services/contributors.service.ts +++ b/src/app/shared/services/contributors.service.ts @@ -37,14 +37,16 @@ export class ContributorsService { [ResourceType.DraftRegistration, 'draft_registrations'], ]); - private getBaseUrl(resourceType: ResourceType, resourceId: string): string { + private getBaseUrl(resourceType: ResourceType, resourceId: string, isBibliographic = false): string { const resourcePath = this.urlMap.get(resourceType); if (!resourcePath) { throw new Error(`Unsupported resource type: ${resourceType}`); } - return `${this.apiUrl}/${resourcePath}/${resourceId}/contributors`; + const contributorsUrl = isBibliographic ? 'bibliographic_contributors' : 'contributors'; + + return `${this.apiUrl}/${resourcePath}/${resourceId}/${contributorsUrl}`; } getAllContributors( @@ -69,14 +71,26 @@ export class ContributorsService { ); } - getRequestAccessContributors(resourceType: ResourceType, resourceId: string): Observable { - const resourcePath = this.urlMap.get(resourceType); - const baseUrl = `${this.apiUrl}/${resourcePath}/${resourceId}/requests/`; - const params = { 'embed[]': ['creator'] }; + getBibliographicContributors( + resourceType: ResourceType, + resourceId: string, + page: number, + pageSize: number + ): Observable> { + const baseUrl = this.getBaseUrl(resourceType, resourceId, true); - return this.jsonApiService - .get(baseUrl, params) - .pipe(map((response) => ContributorsMapper.getContributors(response.data))); + const params = { + page: page, + 'page[size]': pageSize, + }; + + return this.jsonApiService.get(`${baseUrl}/`, params).pipe( + map((response) => ({ + data: ContributorsMapper.getContributors(response.data), + totalCount: response.meta.total, + pageSize: response.meta.per_page, + })) + ); } searchUsers(value: string, page = 1): Observable> {