Skip to content

Commit ae364c2

Browse files
authored
SBX DEV2, fix to strip extra character from search URLS (#253)
* SBX DEV2 Added size to search provider's request, cleaned branch * SBX DEV2, fix to strip ?size from the called URL * Addedd comment
1 parent b1537f1 commit ae364c2

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

src/app/services/provider.service.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Injectable, inject } from '@angular/core';
21
import { HttpClient, HttpParams } from '@angular/common/http';
3-
import { Observable, map, catchError, of, forkJoin } from 'rxjs';
2+
import { Injectable, inject } from '@angular/core';
3+
import { Observable, catchError, forkJoin, map, of } from 'rxjs';
44
import { environment } from '../../environments/environment';
55
import { FilterOptions } from '../models/filter-options.model';
66
import { SearchOrganizationsFilters } from '../models/search-organizations-filters.model';
@@ -33,9 +33,9 @@ export class ProviderService {
3333
if (params.limit !== undefined) {
3434
httpParams = httpParams.set('limit', params.limit.toString());
3535
}
36-
36+
3737
const url = `${this.endpoint}${httpParams.toString() ? '?' + httpParams.toString() : ''}`;
38-
38+
3939
return this.http.get<Provider[]>(url).pipe(
4040
map(response => {
4141
return Array.isArray(response) ? response : [];
@@ -49,11 +49,11 @@ export class ProviderService {
4949

5050
getProviderById(id: string): Observable<Provider> {
5151
const targetUrl = `${this.endpoint}/${id}`;
52-
52+
5353
// Use CORS proxy if calling external DOME API directly
5454
const isExternalUrl = targetUrl.startsWith('https://');
5555
const url = isExternalUrl ? `https://api.allorigins.win/get?url=${encodeURIComponent(targetUrl)}` : targetUrl;
56-
56+
5757
return this.http.get<any>(url).pipe(
5858
map(response => {
5959
// Parse CORS proxy response if used
@@ -68,11 +68,11 @@ export class ProviderService {
6868

6969
getProvidersForTender(): Observable<Provider[]> {
7070
const targetUrl = this.endpoint;
71-
71+
7272
// Use CORS proxy if calling external DOME API directly
7373
const isExternalUrl = targetUrl.startsWith('https://');
7474
const url = isExternalUrl ? `https://api.allorigins.win/get?url=${encodeURIComponent(targetUrl)}` : targetUrl;
75-
75+
7676
return this.http.get<any>(url).pipe(
7777
map(response => {
7878
// Parse CORS proxy response if used
@@ -86,7 +86,7 @@ export class ProviderService {
8686
);
8787
}
8888

89-
89+
9090
getProvidersForTenderNew(filters: SearchOrganizationsFilters): Observable<Provider[]> {
9191
const url = environment.searchOrganizationsEndpoint;
9292

@@ -102,32 +102,33 @@ export class ProviderService {
102102
}
103103

104104
//Methods for the search engine
105+
//TODO: Check if this is still necessary after we change the main endpoint
105106
getFilterOptions(): Observable<FilterOptions> {
106-
const base = environment.searchOrganizationsEndpoint.replace(/\/searchOrganizations$/, '');
107+
const base = environment.searchOrganizationsEndpoint.replace(/\/searchOrganizations.*$/, '');
107108
const categories$ = this.http.get<any>(`${base}/categories`).pipe(
108109
map(res => (Array.isArray(res) ? res : Array.isArray(res?.data) ? res.data : [])),
109110
catchError(err => {
110111
console.warn('Categories API failed:', err);
111112
return of<string[]>([]);
112113
})
113114
);
114-
115+
115116
const countries$ = this.http.get<any>(`${base}/countries`).pipe(
116117
map(res => (Array.isArray(res) ? res : Array.isArray(res?.data) ? res.data : [])),
117118
catchError(err => {
118119
console.warn('Countries API failed:', err);
119120
return of<string[]>([]);
120121
})
121122
);
122-
123+
123124
const complianceLevels$ = this.http.get<any>(`${base}/complianceLevels`).pipe(
124125
map(res => (Array.isArray(res) ? res : Array.isArray(res?.data) ? res.data : [])),
125126
catchError(err => {
126127
console.warn('ComplianceLevels API failed:', err);
127128
return of<string[]>([]);
128129
})
129130
);
130-
131+
131132
return forkJoin({
132133
categories: categories$,
133134
countries: countries$,

0 commit comments

Comments
 (0)