@rolatech/angular-services 20.0.2-beta.3 → 20.0.4-beta.1

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.
@@ -5,7 +5,7 @@ import * as i1 from '@angular/material/button';
5
5
  import { MatButtonModule } from '@angular/material/button';
6
6
  import { switchMap, map, take, BehaviorSubject, Observable, Subject, firstValueFrom } from 'rxjs';
7
7
  import _ from 'lodash';
8
- import { HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
8
+ import { HttpClient, HttpParams, HTTP_INTERCEPTORS } from '@angular/common/http';
9
9
  import { APP_CONFIG } from '@rolatech/angular-common';
10
10
  import { Location, isPlatformBrowser } from '@angular/common';
11
11
  import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
@@ -126,11 +126,6 @@ class BaseService {
126
126
  withCredentials: true,
127
127
  });
128
128
  }
129
- search(word, withCredentials = true) {
130
- return this.http.get(`${this.actionUrl}?search=${word}`, {
131
- withCredentials,
132
- });
133
- }
134
129
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: BaseService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
135
130
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: BaseService, providedIn: 'root' });
136
131
  }
@@ -3009,9 +3004,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0", ngImpor
3009
3004
 
3010
3005
  class PropertySearchService extends BaseService {
3011
3006
  init() {
3012
- this.endpoint = 'properties/search';
3007
+ this.endpoint = 'properties';
3013
3008
  super.init();
3014
3009
  }
3010
+ search1(options) {
3011
+ return this.http.get(`${this.actionUrl}/search`, {
3012
+ params: options,
3013
+ });
3014
+ }
3015
+ search(rawParams) {
3016
+ const params = this.stripUndefined(rawParams);
3017
+ // Decide route: empty filter → DB list; else → Elasticsearch-backed search
3018
+ const isEmpty = this.isEmptyFilter(params);
3019
+ let httpParams = new HttpParams();
3020
+ for (const [k, v] of Object.entries(params)) {
3021
+ if (Array.isArray(v)) {
3022
+ v.forEach((item) => (httpParams = httpParams.append(k, String(item))));
3023
+ }
3024
+ else {
3025
+ httpParams = httpParams.set(k, String(v));
3026
+ }
3027
+ }
3028
+ return isEmpty
3029
+ ? this.http.get(`${this.actionUrl}`, { params: httpParams }) // DB list
3030
+ : this.http.get(`${this.actionUrl}/search`, { params: httpParams }); // ES search
3031
+ }
3032
+ stripUndefined(obj) {
3033
+ const out = {};
3034
+ for (const [k, v] of Object.entries(obj)) {
3035
+ if (v !== undefined && v !== null && !(Array.isArray(v) && v.length === 0) && v !== '') {
3036
+ out[k] = v;
3037
+ }
3038
+ }
3039
+ return out;
3040
+ }
3041
+ isEmptyFilter(params, ignoreKeys = ['page', 'limit', 'sort']) {
3042
+ return Object.entries(params).every(([k, v]) => ignoreKeys.includes(k) || v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0));
3043
+ }
3015
3044
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: PropertySearchService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
3016
3045
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: PropertySearchService, providedIn: 'root' });
3017
3046
  }
@@ -3022,6 +3051,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0", ngImpor
3022
3051
  }]
3023
3052
  }] });
3024
3053
 
3054
+ class TimeZoneService {
3055
+ platformId = inject(PLATFORM_ID);
3056
+ isBrowser = isPlatformBrowser(this.platformId);
3057
+ http = inject(HttpClient);
3058
+ getBrowserTimeZone() {
3059
+ // Europe/London
3060
+ // Asia/Shanghai
3061
+ if (!this.isBrowser)
3062
+ return null; // SSR-safe
3063
+ return Intl.DateTimeFormat().resolvedOptions().timeZone ?? null;
3064
+ }
3065
+ /** minutes east of UTC (e.g. -420 for PDT) */
3066
+ getUtcOffsetMinutes() {
3067
+ if (!this.isBrowser)
3068
+ return null;
3069
+ return -new Date().getTimezoneOffset();
3070
+ }
3071
+ getTimeZoneFromApi() {
3072
+ // proxy /worldtime/api/ip
3073
+ return this.http.get(`/worldtime/api/ip`).pipe(map((r) => r.timezone));
3074
+ }
3075
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: TimeZoneService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
3076
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: TimeZoneService, providedIn: 'root' });
3077
+ }
3078
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: TimeZoneService, decorators: [{
3079
+ type: Injectable,
3080
+ args: [{
3081
+ providedIn: 'root',
3082
+ }]
3083
+ }] });
3084
+
3025
3085
  class LoadingInterceptor {
3026
3086
  loadingService;
3027
3087
  activeRequests = 0;
@@ -3116,5 +3176,5 @@ function provideAngularServices() {
3116
3176
  * Generated bundle index. Do not edit.
3117
3177
  */
3118
3178
 
3119
- export { AmenityService, BackButtonDirective, BaseService, BookingService, BreadcrumbService, CartEventType, CartService, CategoryService, ConversationInitService, ConversationService, DialogComponent, DialogService, FacilityService, FeatureService, FulfillmentService, HideFooterDirective, InventoryService, LayoutService, LoadingInterceptor, LoadingService, MediaService, MembershipService, NavigationService, NotificationService, NotificationStore, NotificationTemplateService, OfferingService, OrderPayoutService, OrderService, PaymentService, PostService, ProductCategoryService, ProductService, PropertySearchService, PropertyService, ResourceCategoryService, ResourceService, SERVICE_DIRECTIVES, SidenavService, SnackBarService, SupportService, ThemeService, TitleService, provideAngularServices };
3179
+ export { AmenityService, BackButtonDirective, BaseService, BookingService, BreadcrumbService, CartEventType, CartService, CategoryService, ConversationInitService, ConversationService, DialogComponent, DialogService, FacilityService, FeatureService, FulfillmentService, HideFooterDirective, InventoryService, LayoutService, LoadingInterceptor, LoadingService, MediaService, MembershipService, NavigationService, NotificationService, NotificationStore, NotificationTemplateService, OfferingService, OrderPayoutService, OrderService, PaymentService, PostService, ProductCategoryService, ProductService, PropertySearchService, PropertyService, ResourceCategoryService, ResourceService, SERVICE_DIRECTIVES, SidenavService, SnackBarService, SupportService, ThemeService, TimeZoneService, TitleService, provideAngularServices };
3120
3180
  //# sourceMappingURL=rolatech-angular-services.mjs.map