diff --git a/interfaces/Portalicious/src/app/domains/domain-api.service.ts b/interfaces/Portalicious/src/app/domains/domain-api.service.ts index 1b439e0cfa..f6d68d45c7 100644 --- a/interfaces/Portalicious/src/app/domains/domain-api.service.ts +++ b/interfaces/Portalicious/src/app/domains/domain-api.service.ts @@ -30,23 +30,37 @@ export abstract class DomainApiService { >({ path, processResponse, - requestOptions = {}, + params = {}, + responseAsBlob = false, method = 'GET', paginateQuery, ...opts }: { path: Parameters[0]; processResponse?: (data: BackendDataShape) => ProcessedResponseShape; - requestOptions?: Omit< - Perform121ServiceRequestParams, - 'endpoint' | 'method' + params?: Record< + string, + | boolean + | number + | readonly (boolean | number | string)[] + | Signal< + boolean | number | readonly (boolean | number | string)[] | string + > + | string >; + responseAsBlob?: boolean; method?: Perform121ServiceRequestParams['method']; paginateQuery?: Signal; } & Partial>) { return () => { const queryKey = this.pathToQueryKey(path); const endpoint = queryKey.join('/'); + const deSignalizedParams = Object.fromEntries( + Object.entries(params).map(([key, value]) => [ + key, + isSignal(value) ? value() : value, + ]), + ); return queryOptions({ ...opts, @@ -54,13 +68,15 @@ export abstract class DomainApiService { ...queryKey, method, endpoint, - JSON.stringify(requestOptions), + deSignalizedParams, + responseAsBlob, paginateQuery && paginateQuery(), processResponse, ], queryFn: async () => { - // eslint-disable-next-line prefer-const - let { params, ...options } = requestOptions; + let httpParams = { + ...deSignalizedParams, + }; if (paginateQuery) { const paginateQueryParams = @@ -68,8 +84,8 @@ export abstract class DomainApiService { paginateQuery(), ); - params = { - ...params, + httpParams = { + ...httpParams, ...paginateQueryParams, }; } @@ -77,8 +93,8 @@ export abstract class DomainApiService { const response = await this.httpWrapperService.perform121ServiceRequest( { - ...options, - params, + responseAsBlob, + httpParams, method, endpoint, }, diff --git a/interfaces/Portalicious/src/app/domains/event/event.api.service.ts b/interfaces/Portalicious/src/app/domains/event/event.api.service.ts index e3de817ef3..3eac9f73c4 100644 --- a/interfaces/Portalicious/src/app/domains/event/event.api.service.ts +++ b/interfaces/Portalicious/src/app/domains/event/event.api.service.ts @@ -22,10 +22,8 @@ export class EventApiService extends DomainApiService { }) { return this.generateQueryOptions({ path: BASE_ENDPOINT(projectId), - requestOptions: { - params, - responseAsBlob: true, - }, + params, + responseAsBlob: true, }); } diff --git a/interfaces/Portalicious/src/app/domains/metric/metric.api.service.ts b/interfaces/Portalicious/src/app/domains/metric/metric.api.service.ts index 5358fc3a34..85820483ea 100644 --- a/interfaces/Portalicious/src/app/domains/metric/metric.api.service.ts +++ b/interfaces/Portalicious/src/app/domains/metric/metric.api.service.ts @@ -36,10 +36,8 @@ export class MetricApiService extends DomainApiService { }) { return this.generateQueryOptions({ path: [...BASE_ENDPOINT(projectId), 'export-list', type], - requestOptions: { - params, - responseAsBlob: true, - }, + params, + responseAsBlob: true, }); } @@ -53,11 +51,9 @@ export class MetricApiService extends DomainApiService { }) { return this.generateQueryOptions<{ data: PaymentMetricDetails[] }>({ path: [...BASE_ENDPOINT(projectId), 'export-list', ExportType.payment], - requestOptions: { - params: { - minPayment: payment, - maxPayment: payment, - }, + params: { + minPayment: payment, + maxPayment: payment, }, }); } diff --git a/interfaces/Portalicious/src/app/domains/payment/payment.api.service.ts b/interfaces/Portalicious/src/app/domains/payment/payment.api.service.ts index cdd282e521..af664941b5 100644 --- a/interfaces/Portalicious/src/app/domains/payment/payment.api.service.ts +++ b/interfaces/Portalicious/src/app/domains/payment/payment.api.service.ts @@ -63,7 +63,7 @@ export class PaymentApiService extends DomainApiService { method: 'POST', endpoint: this.pathToQueryKey([...BASE_ENDPOINT(projectId)]).join('/'), body: paymentData, - params: { + httpParams: { ...this.paginateQueryService.paginateQueryToHttpParamsObject( paginateQuery, ), diff --git a/interfaces/Portalicious/src/app/domains/project/project.api.service.ts b/interfaces/Portalicious/src/app/domains/project/project.api.service.ts index 504128e6d9..1f81ab37cc 100644 --- a/interfaces/Portalicious/src/app/domains/project/project.api.service.ts +++ b/interfaces/Portalicious/src/app/domains/project/project.api.service.ts @@ -42,7 +42,7 @@ export class ProjectApiService extends DomainApiService { >({ method: 'POST', endpoint: BASE_ENDPOINT, - params: { + httpParams: { importFromKobo: true, koboToken: token, koboAssetId: assetId, @@ -93,12 +93,10 @@ export class ProjectApiService extends DomainApiService { AttributeWithTranslatedLabel[] >({ path: [BASE_ENDPOINT, projectId, 'attributes'], - requestOptions: { - params: { - includeProgramRegistrationAttributes, - includeTemplateDefaultAttributes, - filterShowInPeopleAffectedTable, - }, + params: { + includeProgramRegistrationAttributes, + includeTemplateDefaultAttributes, + filterShowInPeopleAffectedTable, }, processResponse: (attributes) => { return uniqBy(attributes, 'name').map((attribute) => { @@ -210,13 +208,11 @@ export class ProjectApiService extends DomainApiService { projectId, 'financial-service-providers/intersolve-voucher/vouchers', ], - requestOptions: { - params: { - referenceId: voucherReferenceId, - payment: paymentId.toString(), - }, - responseAsBlob: true, + params: { + referenceId: voucherReferenceId, + payment: paymentId.toString(), }, + responseAsBlob: true, }); } @@ -235,11 +231,9 @@ export class ProjectApiService extends DomainApiService { projectId, 'financial-service-providers/intersolve-voucher/vouchers/balance', ], - requestOptions: { - params: { - referenceId: registrationReferenceId, - payment: paymentId, - }, + params: { + referenceId: registrationReferenceId, + payment: paymentId, }, }); } @@ -265,10 +259,8 @@ export class ProjectApiService extends DomainApiService { }) { return this.generateQueryOptions>({ path: [BASE_ENDPOINT, projectId, 'actions'], - requestOptions: { - params: { - actionType, - }, + params: { + actionType, }, }); } diff --git a/interfaces/Portalicious/src/app/domains/registration/registration.api.service.ts b/interfaces/Portalicious/src/app/domains/registration/registration.api.service.ts index 1e80c9e064..1a5def01ea 100644 --- a/interfaces/Portalicious/src/app/domains/registration/registration.api.service.ts +++ b/interfaces/Portalicious/src/app/domains/registration/registration.api.service.ts @@ -105,7 +105,7 @@ export class RegistrationApiService extends DomainApiService { 'message', ]).join('/'), body, - params: + httpParams: this.paginateQueryService.paginateQueryToHttpParamsObject( paginateQuery, ), @@ -161,7 +161,7 @@ export class RegistrationApiService extends DomainApiService { method, endpoint, body, - params, + httpParams: params, }, ); } @@ -213,7 +213,7 @@ export class RegistrationApiService extends DomainApiService { return this.httpWrapperService.perform121ServiceRequest({ method: 'PATCH', endpoint, - params: { + httpParams: { pause: pauseStatus, }, }); diff --git a/interfaces/Portalicious/src/app/pages/project-payment/project-payment.page.ts b/interfaces/Portalicious/src/app/pages/project-payment/project-payment.page.ts index f7c94073e9..ff9fa90b42 100644 --- a/interfaces/Portalicious/src/app/pages/project-payment/project-payment.page.ts +++ b/interfaces/Portalicious/src/app/pages/project-payment/project-payment.page.ts @@ -180,6 +180,7 @@ export class ProjectPaymentPageComponent { { field: 'financialserviceprovider', header: $localize`FSP`, + type: QueryTableColumnType.MULTISELECT, options: this.project .data() .programFinancialServiceProviderConfigurations.map((config) => ({ diff --git a/interfaces/Portalicious/src/app/services/http-wrapper.service.ts b/interfaces/Portalicious/src/app/services/http-wrapper.service.ts index 091ea8d657..ee8e602338 100644 --- a/interfaces/Portalicious/src/app/services/http-wrapper.service.ts +++ b/interfaces/Portalicious/src/app/services/http-wrapper.service.ts @@ -3,9 +3,10 @@ import { HttpErrorResponse, HttpHeaders, HttpParams, + HttpParamsOptions, HttpStatusCode, } from '@angular/common/http'; -import { inject, Injectable, isSignal, Signal } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { get } from 'lodash'; import { lastValueFrom, of } from 'rxjs'; @@ -22,14 +23,7 @@ interface PerformRequestParams { body?: unknown; responseAsBlob?: boolean; isUpload?: boolean; - params?: Record< - string, - | boolean - | number - | readonly (boolean | number | string)[] - | Signal - | string - >; + httpParams?: HttpParamsOptions['fromObject']; } export type Perform121ServiceRequestParams = { endpoint: string } & Omit< @@ -149,17 +143,10 @@ export class HttpWrapperService { body, responseAsBlob = false, isUpload = false, - params, + httpParams: params, }: PerformRequestParams): Promise { console.log(`HttpWrapperService ${method}: ${url}`, body ?? ''); - const deSignalizedParams = Object.fromEntries( - Object.entries(params ?? {}).map(([key, value]) => [ - key, - isSignal(value) ? value() : value, - ]), - ); - try { const response = await lastValueFrom( this.http @@ -167,16 +154,14 @@ export class HttpWrapperService { headers: this.createHeaders(isUpload), responseType: responseAsBlob ? 'blob' : undefined, withCredentials: true, - params: new HttpParams({ fromObject: deSignalizedParams }), + params: new HttpParams({ fromObject: params }), body, }) .pipe( tap((response) => { console.log( `HttpWrapperService ${method}: ${url}${ - params - ? `\nParams ${JSON.stringify(deSignalizedParams, null, 2)}` - : '' + params ? `\nParams ${JSON.stringify(params, null, 2)}` : '' }${body ? `\nBody: ${JSON.stringify(body, null, 2)}` : ''}`, '\nResponse:', response,