tickera-angular-components 0.0.1-dev.104 → 0.0.1-dev.105

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.
@@ -3047,6 +3047,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
3047
3047
  }]
3048
3048
  }], ctorParameters: () => [{ type: ApiService }] });
3049
3049
 
3050
+ const transformUrlParams = (params) => {
3051
+ const queryParams = new URLSearchParams();
3052
+ Object.entries(params).forEach(([key, value]) => {
3053
+ if (typeof value === 'number') {
3054
+ queryParams.append(key, value.toString());
3055
+ }
3056
+ else if (Array.isArray(value)) {
3057
+ value.forEach((item) => {
3058
+ queryParams.append(key, typeof item === 'number' ? item?.toString() : item);
3059
+ });
3060
+ }
3061
+ else if (typeof value === 'string') {
3062
+ queryParams.append(key, value);
3063
+ }
3064
+ });
3065
+ return queryParams;
3066
+ };
3067
+
3050
3068
  class ProductService {
3051
3069
  apiService;
3052
3070
  productsSubject = new BehaviorSubject([]);
@@ -3054,14 +3072,8 @@ class ProductService {
3054
3072
  constructor(apiService) {
3055
3073
  this.apiService = apiService;
3056
3074
  }
3057
- fetchProducts({ page, search, limit, }) {
3058
- const queryParams = new URLSearchParams();
3059
- if (page)
3060
- queryParams.append('page', page.toString());
3061
- if (search)
3062
- queryParams.append('search', search);
3063
- if (limit)
3064
- queryParams.append('limit', limit.toString());
3075
+ fetchProducts(params) {
3076
+ const queryParams = transformUrlParams(params);
3065
3077
  const queryString = queryParams.toString();
3066
3078
  const apiRoute = `${PRODUCTS_API_ROUTES.FIND_ALL}${queryString ? '?' + queryString : ''}`;
3067
3079
  return this.apiService.get(apiRoute);