@hmcts/rpx-xui-common-lib 2.0.18 → 2.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2129,28 +2129,6 @@ function getValues(options, values) {
2129
2129
  }, []);
2130
2130
  }
2131
2131
 
2132
- const getAllCaseworkersFromServices = (caseworkersByService) => {
2133
- let allCaseworkers = [];
2134
- caseworkersByService.forEach(caseworkerListByService => {
2135
- allCaseworkers = allCaseworkers.concat(caseworkerListByService.caseworkers);
2136
- });
2137
- return allCaseworkers;
2138
- };
2139
- const getSessionStorageKeyForServiceId = (serviceId) => {
2140
- return `${serviceId}-caseworkers`;
2141
- };
2142
- const getCaseworkers = (serviceId, sessionStorageService) => {
2143
- const sessionKey = getSessionStorageKeyForServiceId(serviceId);
2144
- const value = sessionStorageService.getItem(sessionKey);
2145
- if (value) {
2146
- return JSON.parse(value);
2147
- }
2148
- };
2149
- const setCaseworkers = (serviceId, caseworkers, sessionStorageService) => {
2150
- const sessionKey = getSessionStorageKeyForServiceId(serviceId);
2151
- sessionStorageService.setItem(sessionKey, JSON.stringify(caseworkers));
2152
- };
2153
-
2154
2132
  class SessionStorageService {
2155
2133
  /**
2156
2134
  * Get an item from the session storage.
@@ -2216,35 +2194,8 @@ class FindAPersonService {
2216
2194
  }
2217
2195
  this.assignedUser = searchOptions.assignedUser ? searchOptions.assignedUser : null;
2218
2196
  const fullServices = searchOptions.services;
2219
- const storedServices = [];
2220
- const newServices = [];
2221
- const storedCaseworkersByService = [];
2222
- fullServices.forEach(serviceId => {
2223
- const serviceKey = getSessionStorageKeyForServiceId(serviceId);
2224
- if (this.sessionStorageService.getItem(serviceKey)) {
2225
- storedServices.push(serviceId);
2226
- storedCaseworkersByService.push({ service: serviceId, caseworkers: JSON.parse(this.sessionStorageService.getItem(serviceKey)) });
2227
- }
2228
- else {
2229
- newServices.push(serviceId);
2230
- }
2231
- });
2232
- // if all services are stored then return the stored caseworkers by service
2233
- if (storedServices.length === fullServices.length) {
2234
- const storedCaseworkers = getAllCaseworkersFromServices(storedCaseworkersByService);
2235
- return of$1(this.searchInCaseworkers(storedCaseworkers, searchOptions));
2236
- }
2237
- // all serviceIds passed in as node layer getting used anyway and caseworkers also stored there
2238
- return this.http.post('/workallocation/retrieveCaseWorkersForServices', { fullServices }).pipe(tap(caseworkersByService => {
2239
- caseworkersByService.forEach(caseworkerListByService => {
2240
- // for any new service, ensure that they are then stored in the session
2241
- if (newServices.includes(caseworkerListByService.service)) {
2242
- setCaseworkers(caseworkerListByService.service, caseworkerListByService.caseworkers, this.sessionStorageService);
2243
- }
2244
- });
2245
- }), map(caseworkersByService => {
2246
- const givenCaseworkers = getAllCaseworkersFromServices(caseworkersByService);
2247
- return this.searchInCaseworkers(givenCaseworkers, searchOptions);
2197
+ return this.http.post('/workallocation/caseworker/getUsersByServiceName', { services: fullServices, term: searchOptions.searchTerm }).pipe(map(caseworkers => {
2198
+ return this.searchInCaseworkers(caseworkers, searchOptions);
2248
2199
  }));
2249
2200
  }
2250
2201
  mapCaseworkers(caseworkers, roleCategory) {
@@ -2276,11 +2227,9 @@ class FindAPersonService {
2276
2227
  roleCategory = RoleCategory.CTSC;
2277
2228
  }
2278
2229
  }
2279
- const searchTerm = searchOptions && searchOptions.searchTerm ? searchOptions.searchTerm.toLowerCase() : '';
2280
2230
  const people = caseworkers ? this.mapCaseworkers(caseworkers, roleCategory) : [];
2281
- const finalPeopleList = people.filter(person => person && person.name && person.name.toLowerCase().includes(searchTerm));
2282
- return searchOptions.userIncluded ? finalPeopleList.filter(person => person && person.id !== this.assignedUser)
2283
- : finalPeopleList.filter(person => person?.id !== this.assignedUser);
2231
+ return searchOptions.userIncluded ? people.filter(person => person && person.id !== this.assignedUser)
2232
+ : people.filter(person => person && person.id !== this.userId && person.id !== this.assignedUser);
2284
2233
  }
2285
2234
  searchJudicial(value, serviceId) {
2286
2235
  return this.http.post('api/prd/judicial/getJudicialUsersSearch', { searchString: value, serviceCode: serviceId });