@transcommerce/cwm-shared 1.1.15 → 1.1.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.
@@ -1,15 +1,117 @@
1
- import { InteractionType, PublicClientApplication } from '@azure/msal-browser';
2
1
  import * as i0 from '@angular/core';
3
- import { Injectable, Pipe, NgModule } from '@angular/core';
4
- import * as i2 from '@angular/common/http';
5
- import { HttpResponseBase, HttpResponse, HttpErrorResponse, HttpHeaders, HttpStatusCode, HTTP_INTERCEPTORS } from '@angular/common/http';
6
- import { Subject, firstValueFrom } from 'rxjs';
2
+ import { Component, Injectable, Pipe, NgModule } from '@angular/core';
3
+ import * as i1 from '@angular/router';
4
+ import * as i2 from '@angular/forms';
5
+ import { FormsModule } from '@angular/forms';
6
+ import { InteractionType, PublicClientApplication } from '@azure/msal-browser';
7
+ import * as i2$1 from '@angular/common/http';
8
+ import { HttpResponseBase, HttpResponse, HttpErrorResponse, HttpHeaders, HttpStatusCode } from '@angular/common/http';
9
+ import { CommonModule } from '@angular/common';
10
+ export * from '@angular/common';
11
+ import * as i1$1 from '@angular/platform-browser';
12
+ import { BrowserModule } from '@angular/platform-browser';
13
+ import { MsalModule } from '@azure/msal-angular';
14
+ export * from '@azure/msal-angular';
7
15
  import { AppConfigurationClient } from '@azure/app-configuration';
16
+ import { firstValueFrom, Subject } from 'rxjs';
8
17
  import { keys, countBy } from 'lodash';
9
- import * as i1 from '@angular/platform-browser';
10
- import { BrowserModule } from '@angular/platform-browser';
11
- import { CommonModule } from '@angular/common';
12
- import { MsalModule, MsalService, MSAL_INSTANCE, MSAL_INTERCEPTOR_CONFIG, MsalInterceptor } from '@azure/msal-angular';
18
+
19
+ class ExternalNavigationComponent {
20
+ router;
21
+ route = "";
22
+ constructor(router) {
23
+ this.router = router;
24
+ }
25
+ ngAfterViewInit() {
26
+ document.getElementById("txtRoute")?.focus();
27
+ }
28
+ navigateToRoute() {
29
+ const route = this.route.trim();
30
+ const router = this.router;
31
+ setTimeout(() => { router.navigate([route]).then(); }, 1000);
32
+ }
33
+ navigate() {
34
+ this.router.navigate([this.route], { skipLocationChange: true }).then();
35
+ }
36
+ navigateByUrl() {
37
+ this.router.navigateByUrl(this.route, { skipLocationChange: true }).then();
38
+ }
39
+ navigateToExternalUrl() {
40
+ window.open(this.route, '_blank');
41
+ }
42
+ navigateToExternalHref() {
43
+ window.location.href = this.route;
44
+ }
45
+ onKeyPress($event) {
46
+ if ($event.key == 'Enter') {
47
+ this.navigateToExternalUrl();
48
+ }
49
+ }
50
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExternalNavigationComponent, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
51
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.15", type: ExternalNavigationComponent, isStandalone: false, selector: "cwm-external-navigation", ngImport: i0, template: `<div class="container">
52
+ <h3>Enter the destination route, URL, or Href you want and press the button that uses the navigation method of your choosing:</h3>
53
+ <input id="txtRoute" type="text" [(ngModel)]="route" placeholder="Enter the destination route, URL, or Href..."
54
+ (keydown)="onKeyPress($event)"/>
55
+ <button (click)="navigateToRoute()">Navigate to route</button>
56
+ <button (click)="navigate()">Navigate</button>
57
+ <button (click)="navigateByUrl()">Navigate by URL</button>
58
+ <button (click)="navigateToExternalUrl()">Navigate to external URL</button>
59
+ <button (click)="navigateToExternalHref()">Navigate to external Href</button>
60
+ </div>`, isInline: true, dependencies: [{ kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
61
+ }
62
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExternalNavigationComponent, decorators: [{
63
+ type: Component,
64
+ args: [{
65
+ selector: 'cwm-external-navigation',
66
+ standalone: false,
67
+ template: `<div class="container">
68
+ <h3>Enter the destination route, URL, or Href you want and press the button that uses the navigation method of your choosing:</h3>
69
+ <input id="txtRoute" type="text" [(ngModel)]="route" placeholder="Enter the destination route, URL, or Href..."
70
+ (keydown)="onKeyPress($event)"/>
71
+ <button (click)="navigateToRoute()">Navigate to route</button>
72
+ <button (click)="navigate()">Navigate</button>
73
+ <button (click)="navigateByUrl()">Navigate by URL</button>
74
+ <button (click)="navigateToExternalUrl()">Navigate to external URL</button>
75
+ <button (click)="navigateToExternalHref()">Navigate to external Href</button>
76
+ </div>`
77
+ }]
78
+ }], ctorParameters: () => [{ type: i1.Router }] });
79
+
80
+ class NavigateToRouteComponent {
81
+ router;
82
+ route = '';
83
+ constructor(router) {
84
+ this.router = router;
85
+ }
86
+ ngAfterViewInit() {
87
+ document.getElementById("txtRoute")?.focus();
88
+ }
89
+ navigateToRoute() {
90
+ const route = this.route.trim();
91
+ const router = this.router;
92
+ setTimeout(() => { router.navigate([route]); }, 1000);
93
+ }
94
+ onKeyPress($event) {
95
+ if ($event.key == 'Enter') {
96
+ this.navigateToRoute();
97
+ }
98
+ }
99
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: NavigateToRouteComponent, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
100
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.15", type: NavigateToRouteComponent, isStandalone: false, selector: "cwm-navigate-to-route", ngImport: i0, template: "<div class=\"container\">\n <h2>Enter the route you want to navigate to:</h2>\n <input id=\"txtRoute\" type=\"text\" [(ngModel)]=\"route\" placeholder=\"Enter Route...\"\n (keydown)=\"onKeyPress($event)\"/>\n <button (click)=\"navigateToRoute()\">Navigate</button>\n</div>\n``\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
101
+ }
102
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: NavigateToRouteComponent, decorators: [{
103
+ type: Component,
104
+ args: [{ selector: 'cwm-navigate-to-route', standalone: false, template: "<div class=\"container\">\n <h2>Enter the route you want to navigate to:</h2>\n <input id=\"txtRoute\" type=\"text\" [(ngModel)]=\"route\" placeholder=\"Enter Route...\"\n (keydown)=\"onKeyPress($event)\"/>\n <button (click)=\"navigateToRoute()\">Navigate</button>\n</div>\n``\n", styles: [":host{display:block}\n"] }]
105
+ }], ctorParameters: () => [{ type: i1.Router }] });
106
+
107
+ class PageNotFoundComponent {
108
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: PageNotFoundComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
109
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.15", type: PageNotFoundComponent, isStandalone: false, selector: "cwm-page-not-found", ngImport: i0, template: "<p>\n Page Not Found\n</p>\n", styles: [""] });
110
+ }
111
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: PageNotFoundComponent, decorators: [{
112
+ type: Component,
113
+ args: [{ selector: 'cwm-page-not-found', standalone: false, template: "<p>\n Page Not Found\n</p>\n" }]
114
+ }] });
13
115
 
14
116
  function MSALGuardConfigFactory() {
15
117
  return {
@@ -30,6 +132,15 @@ function MSALInstanceFactory() {
30
132
  });
31
133
  }
32
134
 
135
+ function MSALInterceptorConfigFactory() {
136
+ const protectedResourceMap = new Map();
137
+ protectedResourceMap.set('https://graph.microsoft.com/v1.0/me', ['user.read']);
138
+ return {
139
+ interactionType: InteractionType.Popup, // or Redirect
140
+ protectedResourceMap
141
+ };
142
+ }
143
+
33
144
  /* eslint-disable no-useless-catch */
34
145
  /* eslint-disable @typescript-eslint/no-explicit-any */
35
146
  /**
@@ -940,572 +1051,193 @@ class Product {
940
1051
  }
941
1052
  }
942
1053
 
943
- /**
944
- * Provides a wrapper for accessing the web storage API and synchronizing session storage across tabs/windows.
945
- */
946
- class LocalStorageService {
947
- static syncListenerInitialized = false;
948
- syncKeys = [];
949
- initEvent = new Subject();
950
- reservedKeys = [
951
- 'sync_keys',
952
- 'addToSyncKeys',
953
- 'removeFromSyncKeys',
954
- 'getSessionStorage',
955
- 'setSessionStorage',
956
- 'addToSessionStorage',
957
- 'removeFromSessionStorage',
958
- 'clearAllSessionsStorage'
959
- ];
960
- InitializeStorageSyncListener() {
961
- if (LocalStorageService.syncListenerInitialized == true) {
962
- return;
963
- }
964
- LocalStorageService.syncListenerInitialized = true;
965
- window.addEventListener('storage', this.sessionStorageTransferHandler, false);
966
- this.syncSessionStorage();
967
- }
968
- deInitializeStorageSyncListener() {
969
- window.removeEventListener('storage', this.sessionStorageTransferHandler, false);
970
- LocalStorageService.syncListenerInitialized = false;
971
- }
972
- clearAllStorage() {
973
- this.clearAllSessionsStorage();
974
- this.clearLocalStorage();
975
- }
976
- clearAllSessionsStorage() {
977
- this.clearInstanceSessionStorage();
978
- localStorage.removeItem(DbKeys.SYNC_KEYS);
979
- localStorage.setItem('clearAllSessionsStorage', '_dummy');
980
- localStorage.removeItem('clearAllSessionsStorage');
981
- }
982
- clearInstanceSessionStorage() {
983
- sessionStorage.clear();
984
- this.syncKeys = [];
985
- }
986
- clearLocalStorage() {
987
- localStorage.clear();
988
- }
989
- saveSessionData(data, key = DbKeys.USER_DATA) {
990
- this.testForInvalidKeys(key);
991
- this.removeFromSyncKeys(key);
992
- localStorage.removeItem(key);
993
- this.sessionStorageSetItem(key, data);
994
- }
995
- saveSyncedSessionData(data, key = DbKeys.USER_DATA) {
996
- this.testForInvalidKeys(key);
997
- localStorage.removeItem(key);
998
- this.addToSessionStorage(data, key);
999
- }
1000
- savePermanentData(data, key = DbKeys.USER_DATA) {
1001
- this.testForInvalidKeys(key);
1002
- this.removeFromSessionStorage(key);
1003
- this.localStorageSetItem(key, data);
1004
- }
1005
- moveDataToSessionStorage(key = DbKeys.USER_DATA) {
1006
- this.testForInvalidKeys(key);
1007
- const data = this.getData(key);
1008
- if (data == null) {
1009
- return;
1010
- }
1011
- this.saveSessionData(data, key);
1012
- }
1013
- moveDataToSyncedSessionStorage(key = DbKeys.USER_DATA) {
1014
- this.testForInvalidKeys(key);
1015
- const data = this.getData(key);
1016
- if (data == null) {
1017
- return;
1018
- }
1019
- this.saveSyncedSessionData(data, key);
1020
- }
1021
- moveDataToPermanentStorage(key = DbKeys.USER_DATA) {
1022
- this.testForInvalidKeys(key);
1023
- const data = this.getData(key);
1024
- if (data == null) {
1025
- return;
1026
- }
1027
- this.savePermanentData(data, key);
1028
- }
1029
- exists(key = DbKeys.USER_DATA) {
1030
- let data = sessionStorage.getItem(key);
1031
- if (data == null) {
1032
- data = localStorage.getItem(key);
1033
- }
1034
- return data != null;
1035
- }
1036
- getData(key = DbKeys.USER_DATA) {
1037
- this.testForInvalidKeys(key);
1038
- let data = this.sessionStorageGetItem(key);
1039
- if (data == '') {
1040
- data = this.localStorageGetItem(key);
1041
- }
1042
- return data;
1043
- }
1044
- getDataObject(key = DbKeys.USER_DATA, isDateType = false) {
1045
- let data = this.getData(key);
1046
- if (data != null) {
1047
- if (isDateType) {
1048
- data = new Date(data);
1049
- }
1050
- return data;
1051
- }
1052
- else {
1053
- return data;
1054
- }
1055
- }
1056
- deleteData(key = DbKeys.USER_DATA) {
1057
- this.testForInvalidKeys(key);
1058
- this.removeFromSessionStorage(key);
1059
- localStorage.removeItem(key);
1054
+ class SafeHtmlPipe {
1055
+ sanitizer;
1056
+ constructor(sanitizer) {
1057
+ this.sanitizer = sanitizer;
1060
1058
  }
1061
- getInitEvent() {
1062
- return this.initEvent.asObservable();
1059
+ transform(value) {
1060
+ return this.sanitizer.bypassSecurityTrustHtml(value);
1063
1061
  }
1064
- sessionStorageTransferHandler = (event) => {
1065
- if (!event.newValue) {
1066
- return;
1067
- }
1068
- if (event.key == 'getSessionStorage') {
1069
- if (sessionStorage.length) {
1070
- this.localStorageSetItem('setSessionStorage', sessionStorage);
1071
- localStorage.removeItem('setSessionStorage');
1072
- }
1073
- }
1074
- else if (event.key == 'setSessionStorage') {
1075
- if (!this.syncKeys.length) {
1076
- this.loadSyncKeys();
1077
- }
1078
- const data = JSON.parse(event.newValue);
1079
- // console.info("Set => Key: Transfer setSessionStorage" + ", data: " + JSON.stringify(data));
1080
- for (const key in data) {
1081
- if (this.syncKeysContains(key)) {
1082
- this.sessionStorageSetItem(key, JSON.parse(data[key]));
1062
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: SafeHtmlPipe, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
1063
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: SafeHtmlPipe, isStandalone: false, name: "safeHtml" });
1064
+ }
1065
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: SafeHtmlPipe, decorators: [{
1066
+ type: Pipe,
1067
+ args: [{
1068
+ name: 'safeHtml',
1069
+ standalone: false
1070
+ }]
1071
+ }], ctorParameters: () => [{ type: i1$1.DomSanitizer }] });
1072
+
1073
+ // Components
1074
+ // Service / Mocks
1075
+ // Services - providers
1076
+ class CwmSharedModule {
1077
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CwmSharedModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1078
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: CwmSharedModule, declarations: [ExternalNavigationComponent,
1079
+ NavigateToRouteComponent,
1080
+ PageNotFoundComponent,
1081
+ SafeHtmlPipe], imports: [CommonModule,
1082
+ BrowserModule,
1083
+ MsalModule,
1084
+ FormsModule], exports: [CommonModule,
1085
+ BrowserModule,
1086
+ MsalModule,
1087
+ FormsModule,
1088
+ ExternalNavigationComponent,
1089
+ NavigateToRouteComponent,
1090
+ PageNotFoundComponent,
1091
+ SafeHtmlPipe] });
1092
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CwmSharedModule, imports: [CommonModule,
1093
+ BrowserModule,
1094
+ MsalModule,
1095
+ FormsModule, CommonModule,
1096
+ BrowserModule,
1097
+ MsalModule,
1098
+ FormsModule] });
1099
+ }
1100
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CwmSharedModule, decorators: [{
1101
+ type: NgModule,
1102
+ args: [{
1103
+ declarations: [
1104
+ ExternalNavigationComponent,
1105
+ NavigateToRouteComponent,
1106
+ PageNotFoundComponent,
1107
+ SafeHtmlPipe
1108
+ ],
1109
+ imports: [
1110
+ CommonModule,
1111
+ BrowserModule,
1112
+ MsalModule,
1113
+ FormsModule
1114
+ ],
1115
+ exports: [
1116
+ CommonModule,
1117
+ BrowserModule,
1118
+ MsalModule,
1119
+ FormsModule,
1120
+ ExternalNavigationComponent,
1121
+ NavigateToRouteComponent,
1122
+ PageNotFoundComponent,
1123
+ SafeHtmlPipe
1124
+ ]
1125
+ }]
1126
+ }] });
1127
+
1128
+ const MockInventoryApiResponse = {
1129
+ "status": 200,
1130
+ "data": [
1131
+ {
1132
+ "brand": "Portland Cannabis Market",
1133
+ "cannabinoidInformation": [
1134
+ {
1135
+ "lowerRange": 0,
1136
+ "name": "cbd",
1137
+ "unitOfMeasure": "%",
1138
+ "unitOfMeasureToGramsMultiplier": null,
1139
+ "upperRange": 0
1140
+ },
1141
+ {
1142
+ "lowerRange": 25.25,
1143
+ "name": "thc",
1144
+ "unitOfMeasure": "%",
1145
+ "unitOfMeasureToGramsMultiplier": null,
1146
+ "upperRange": 25.25
1083
1147
  }
1084
- }
1085
- this.onInit();
1086
- }
1087
- else if (event.key == 'addToSessionStorage') {
1088
- const data = JSON.parse(event.newValue);
1089
- // console.warn("Set => Key: Transfer addToSessionStorage" + ", data: " + JSON.stringify(data));
1090
- this.addToSessionStorageHelper(data.data, data.key);
1091
- }
1092
- else if (event.key == 'removeFromSessionStorage') {
1093
- this.removeFromSessionStorageHelper(event.newValue);
1094
- }
1095
- else if (event.key == 'clearAllSessionsStorage' && sessionStorage.length) {
1096
- this.clearInstanceSessionStorage();
1097
- }
1098
- else if (event.key == 'addToSyncKeys') {
1099
- this.addToSyncKeysHelper(event.newValue);
1100
- }
1101
- else if (event.key == 'removeFromSyncKeys') {
1102
- this.removeFromSyncKeysHelper(event.newValue);
1103
- }
1104
- };
1105
- syncSessionStorage() {
1106
- localStorage.setItem('getSessionStorage', '_dummy');
1107
- localStorage.removeItem('getSessionStorage');
1108
- }
1109
- addToSessionStorage(data, key) {
1110
- this.addToSessionStorageHelper(data, key);
1111
- this.addToSyncKeysBackup(key);
1112
- this.localStorageSetItem('addToSessionStorage', { key, data });
1113
- localStorage.removeItem('addToSessionStorage');
1114
- }
1115
- addToSessionStorageHelper(data, key) {
1116
- this.addToSyncKeysHelper(key);
1117
- this.sessionStorageSetItem(key, data);
1118
- }
1119
- removeFromSessionStorage(keyToRemove) {
1120
- this.removeFromSessionStorageHelper(keyToRemove);
1121
- this.removeFromSyncKeysBackup(keyToRemove);
1122
- localStorage.setItem('removeFromSessionStorage', keyToRemove);
1123
- localStorage.removeItem('removeFromSessionStorage');
1124
- }
1125
- removeFromSessionStorageHelper(keyToRemove) {
1126
- sessionStorage.removeItem(keyToRemove);
1127
- this.removeFromSyncKeysHelper(keyToRemove);
1128
- }
1129
- testForInvalidKeys(key) {
1130
- if (!key) {
1131
- throw new Error('key cannot be empty');
1132
- }
1133
- if (this.reservedKeys.some(x => x == key)) {
1134
- throw new Error(`The storage key "${key}" is reserved and cannot be used. Please use a different key`);
1135
- }
1136
- }
1137
- syncKeysContains(key) {
1138
- if (Array.isArray(this.syncKeys))
1139
- return this.syncKeys.some(x => x == key);
1140
- else
1141
- return false;
1142
- }
1143
- loadSyncKeys() {
1144
- if (this.syncKeys.length) {
1145
- return;
1146
- }
1147
- this.syncKeys = this.getSyncKeysFromStorage();
1148
- }
1149
- getSyncKeysFromStorage(defaultValue = []) {
1150
- const data = this.localStorageGetItem(DbKeys.SYNC_KEYS);
1151
- if (data == null) {
1152
- return defaultValue;
1153
- }
1154
- else {
1155
- return data;
1156
- }
1157
- }
1158
- addToSyncKeys(key) {
1159
- this.addToSyncKeysHelper(key);
1160
- this.addToSyncKeysBackup(key);
1161
- localStorage.setItem('addToSyncKeys', key);
1162
- localStorage.removeItem('addToSyncKeys');
1163
- }
1164
- addToSyncKeysBackup(key) {
1165
- const storedSyncKeys = this.getSyncKeysFromStorage();
1166
- if (!storedSyncKeys.some(x => x == key)) {
1167
- storedSyncKeys.push(key);
1168
- this.localStorageSetItem(DbKeys.SYNC_KEYS, storedSyncKeys);
1169
- }
1170
- }
1171
- removeFromSyncKeysBackup(key) {
1172
- const storedSyncKeys = this.getSyncKeysFromStorage();
1173
- const index = storedSyncKeys.indexOf(key);
1174
- if (index > -1) {
1175
- storedSyncKeys.splice(index, 1);
1176
- this.localStorageSetItem(DbKeys.SYNC_KEYS, storedSyncKeys);
1177
- }
1178
- }
1179
- addToSyncKeysHelper(key) {
1180
- if (!this.syncKeysContains(key)) {
1181
- this.syncKeys.push(key);
1182
- }
1183
- }
1184
- removeFromSyncKeys(key) {
1185
- this.removeFromSyncKeysHelper(key);
1186
- this.removeFromSyncKeysBackup(key);
1187
- localStorage.setItem('removeFromSyncKeys', key);
1188
- localStorage.removeItem('removeFromSyncKeys');
1189
- }
1190
- removeFromSyncKeysHelper(key) {
1191
- const index = this.syncKeys.indexOf(key);
1192
- if (index > -1) {
1193
- this.syncKeys.splice(index, 1);
1194
- }
1195
- }
1196
- localStorageSetItem(key, data) {
1197
- localStorage.setItem(key, JSON.stringify(data));
1198
- }
1199
- sessionStorageSetItem(key, data) {
1200
- sessionStorage.setItem(key, JSON.stringify(data));
1201
- }
1202
- localStorageGetItem(key) {
1203
- return Utilities.JsonTryParse(localStorage.getItem(key) ?? '');
1204
- }
1205
- sessionStorageGetItem(key) {
1206
- return Utilities.JsonTryParse(sessionStorage.getItem(key) ?? '');
1207
- }
1208
- onInit() {
1209
- setTimeout(() => {
1210
- //this.initEvent.next();
1211
- this.initEvent.complete();
1212
- });
1213
- }
1214
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1215
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocalStorageService, providedIn: 'root' });
1216
- }
1217
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocalStorageService, decorators: [{
1218
- type: Injectable,
1219
- args: [{
1220
- providedIn: 'root'
1221
- }]
1222
- }] });
1223
-
1224
- const MockConfig = {
1225
- "authConfig": {
1226
- "logLevel": "Info",
1227
- "configConnectString": "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=tyjA;Secret=1FgL95lHkXViZX4Qf2GcRqn26mhTYDVYany8ToXpTnO68AzrdUUEJQQJ99AHAC8vTInIcYexAAACAZACsteF",
1228
- "clientId": "af1486e0-a27f-4c8d-8503-0752d90ce72d",
1229
- "tenantId": "445012c4-563a-4795-84d0-f7473a3197e0",
1230
- "authority": "https://login.microsoft.com/445012c4-563a-4795-84d0-f7473a3197e0",
1231
- "scopes": "openid,email,profile",
1232
- "menu_uri": "http://localhost:4200/",
1233
- "redirect_uri": "https://www.cheapweedmenu.com",
1234
- "logout_redirect_uri": "https://www.cheapweedmenu.com",
1235
- "prompt": "login"
1236
- },
1237
- "apiConfig": {
1238
- "apiBaseUrl": "https://cheap-weed-menus-webapi.azurewebsites.net",
1239
- "addCustomerApiRoute": "/AddCustomer",
1240
- "addSubscriptionApiRoute": "/subscription",
1241
- "getInventoryApiRoute": "/inventory",
1242
- "apiKey": "8b66d117-5d23-4b81-8c2f-52142c67d0cd",
1243
- "clientId": "5dd15878-aa4c-4adf-8650-b931f32a7b67",
1244
- "locationId": "10f19fc5-31d0-4d76-bad4-ad593c9803ae"
1245
- },
1246
- "menuBoardConfig": {
1247
- "amountToScroll": 1,
1248
- "autoScrollTimeout": 20,
1249
- "dataAgeThreshold": 300000
1250
- },
1251
- "footerCarouselConfig": {
1252
- "slidesToShow": 3,
1253
- "slidesToScroll": 1,
1254
- "dots": false,
1255
- "infinite": true,
1256
- "autoplay": true,
1257
- "autoplaySpeed": 10000,
1258
- "speed": 500,
1259
- "arrows": false
1260
- },
1261
- "footerCarouselSlideConfig": [
1262
- {
1263
- "image": "../../../images/sunday.png",
1264
- "title": "CBD Sunday",
1265
- "description": "20% off all CBD products & house pre-rolls",
1266
- "highlighted": false,
1267
- "textColor": "white",
1268
- "backgroundColor": "black"
1269
- },
1270
- {
1271
- "image": "../../../images/new-monday.jpg",
1272
- "title": "Edible Monday",
1273
- "description": "10% off edibles",
1274
- "highlighted": false,
1275
- "textColor": "white",
1276
- "backgroundColor": "black"
1277
- },
1278
- {
1279
- "image": "../../../images/tuesday.png",
1280
- "title": "Doobie Tuesday",
1281
- "description": "10% off all pre-rolls & packs<",
1282
- "highlighted": false,
1283
- "textColor": "black",
1284
- "backgroundColor": "white"
1148
+ ],
1149
+ "category": "Flower",
1150
+ "clientId": "5dd15878-aa4c-4adf-8650-b931f32a7b67",
1151
+ "createdAt": "2024-05-06T21:41:03Z",
1152
+ "currencyCode": "USD",
1153
+ "customCategoryName": null,
1154
+ "erpId": null,
1155
+ "erpName": null,
1156
+ "expirationDate": null,
1157
+ "inventoryUnitOfMeasure": "grams",
1158
+ "inventoryUnitOfMeasureToGramsMultiplier": 1,
1159
+ "invoiceNumber": null,
1160
+ "isMixAndMatch": false,
1161
+ "isSoldByWeight": true,
1162
+ "isStackable": true,
1163
+ "locationId": "10f19fc5-31d0-4d76-bad4-ad593c9803ae",
1164
+ "locationName": "Portland Pot Shop",
1165
+ "manifestId": null,
1166
+ "nutrients": null,
1167
+ "parentproductId": "88caa95f-8a25-4960-ae1f-0894d86e8f02",
1168
+ "parentproductName": "Royal Hindu Truffle by Upper Rogue Terraces",
1169
+ "postTaxPriceInPennies": 800,
1170
+ "preTaxPriceInPennies": 667,
1171
+ "priceInMinorUnits": 667,
1172
+ "productDescription": "",
1173
+ "productId": "df363dba-1cd3-402e-b6c3-b3697abed6ee",
1174
+ "productName": "Royal Hindu Truffle by Upper Rogue Terraces",
1175
+ "productPictureURL": null,
1176
+ "productUnitOfMeasure": "grams",
1177
+ "productUnitOfMeasureToGramsMultiplier": 1,
1178
+ "productUpdatedAt": "2024-06-30T02:42:59.621977Z",
1179
+ "productWeight": null,
1180
+ "purchaseCategory": "rec",
1181
+ "quantity": 146.89,
1182
+ "regulatoryId": "1A4010300000D4A000001042",
1183
+ "sku": "zddCdpqRvw",
1184
+ "speciesName": "Indica",
1185
+ "supplierName": "Portland Cannabis Market",
1186
+ "terpenes": null,
1187
+ "type": null,
1188
+ "variantId": "b0ed44e0-68df-44f3-a34a-f05bb5bd8ae0",
1189
+ "variantName": "",
1190
+ "weightTierInformation": [
1191
+ {
1192
+ "gramAmount": 1,
1193
+ "name": "Grams",
1194
+ "pricePerUnitInMinorUnits": 667
1195
+ },
1196
+ {
1197
+ "gramAmount": 3.5,
1198
+ "name": "Eighth",
1199
+ "pricePerUnitInMinorUnits": 2167
1200
+ },
1201
+ {
1202
+ "gramAmount": 7,
1203
+ "name": "Quarter",
1204
+ "pricePerUnitInMinorUnits": 3833
1205
+ },
1206
+ {
1207
+ "gramAmount": 14,
1208
+ "name": "Half-Ounce",
1209
+ "pricePerUnitInMinorUnits": 7000
1210
+ },
1211
+ {
1212
+ "gramAmount": 28,
1213
+ "name": "Ounce",
1214
+ "pricePerUnitInMinorUnits": 12917
1215
+ }
1216
+ ],
1217
+ costInMinorUnits: 0
1285
1218
  },
1286
1219
  {
1287
- "image": "../../../images/wednesday.png",
1288
- "title": "Weed Crush Wednesday",
1289
- "description": "10% off all jar bud",
1290
- "highlighted": false,
1291
- "textColor": "black",
1292
- "backgroundColor": "white"
1293
- },
1294
- {
1295
- "image": "../../../images/thursday.png",
1296
- "title": "Thirsty Thursday",
1297
- "description": "10% off Tinctures, RSO & cartridges",
1298
- "highlighted": false,
1299
- "textColor": "black",
1300
- "backgroundColor": "white"
1301
- },
1302
- {
1303
- "image": "../../../images/friday.png",
1304
- "title": "Fire Friday",
1305
- "description": "10% off all jar bud",
1306
- "highlighted": false,
1307
- "textColor": "black",
1308
- "backgroundColor": "white"
1309
- },
1310
- {
1311
- "image": "../../../images/saturday.png",
1312
- "title": "Shatterday Saturday",
1313
- "description": "10% off all concentrate",
1314
- "highlighted": false,
1315
- "textColor": "white",
1316
- "backgroundColor": "black"
1317
- }
1318
- ]
1319
- };
1320
-
1321
- /*
1322
- The LogService is really just a wrapper around the existing console logging functionality
1323
- The three main reasons for using this service are:
1324
- 1. The abstraction layer will allow us to pick a different logging endpoint if needed
1325
- 2. This service allows you to specify what level verbosity you want this service tp log with
1326
- 3. Has logic to log method entry and exit points automagically
1327
- */
1328
- class LogService {
1329
- logLevel = 'Info';
1330
- _className = "";
1331
- get className() { return this._className; }
1332
- set className(value) {
1333
- this._className = value;
1334
- this.methodName = "constructor()";
1335
- }
1336
- _methodName = "";
1337
- get methodName() { return this._methodName; }
1338
- set methodName(value) {
1339
- if (value === "" && this.logLevel != 'None') {
1340
- this.info("End of method");
1341
- console.groupEnd();
1342
- console.timeEnd(this.targetName);
1343
- this._methodName = value;
1344
- }
1345
- else if (this.logLevel != 'None') {
1346
- this._methodName = value;
1347
- console.group(this.targetName);
1348
- console.time(this.targetName);
1349
- this.info("Start of method");
1350
- }
1351
- }
1352
- get targetName() {
1353
- if (this.methodName === "")
1354
- return this.className;
1355
- else
1356
- return this.className + "." + this.methodName;
1357
- }
1358
- get prefix() {
1359
- return Date.now().toLocaleString() + " " + this.targetName + "> ";
1360
- }
1361
- log(message, ...optionalParams) {
1362
- if (this.logLevel != 'None') {
1363
- if (this.targetName != this.className)
1364
- console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
1365
- else
1366
- console.log(this.prefix + " " + message, optionalParams);
1367
- }
1368
- }
1369
- info(message, ...optionalParams) {
1370
- if (this.logLevel === 'Debug' || this.logLevel === 'Info') {
1371
- if (this.targetName != this.className)
1372
- console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
1373
- else
1374
- console.info(this.prefix + " " + message, optionalParams);
1375
- }
1376
- }
1377
- warn(message, ...optionalParams) {
1378
- if (this.logLevel === 'Warn' || this.logLevel === 'Debug' || this.logLevel === 'Info') {
1379
- if (this.targetName != this.className) {
1380
- console.timeEnd(this.targetName);
1381
- console.time(this.targetName);
1382
- }
1383
- console.warn(this.prefix + " " + message, optionalParams);
1384
- }
1385
- }
1386
- error(message, ...optionalParams) {
1387
- if (this.logLevel != 'None') {
1388
- if (this.targetName != this.className) {
1389
- console.timeEnd(this.targetName);
1390
- console.time(this.targetName);
1391
- }
1392
- console.error(this.prefix + " " + message, optionalParams);
1393
- }
1394
- }
1395
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1396
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LogService, providedIn: 'root' });
1397
- }
1398
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LogService, decorators: [{
1399
- type: Injectable,
1400
- args: [{
1401
- providedIn: 'root'
1402
- }]
1403
- }] });
1404
-
1405
- class ConfigService {
1406
- logService;
1407
- mockData = false;
1408
- configClient;
1409
- configConnectString;
1410
- _configCache;
1411
- get configCache() {
1412
- return this._configCache;
1413
- }
1414
- set configCache(value) {
1415
- this._configCache = value;
1416
- }
1417
- constructor(logService) {
1418
- this.logService = logService;
1419
- this.logService.className = "ConfigService";
1420
- this.configConnectString = "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=tyjA;Secret=1FgL95lHkXViZX4Qf2GcRqn26mhTYDVYany8ToXpTnO68AzrdUUEJQQJ99AHAC8vTInIcYexAAACAZACsteF";
1421
- this.configClient = new AppConfigurationClient(this.configConnectString);
1422
- this.logService.log("Config Client", this.configClient);
1423
- this.logService.methodName = "";
1424
- }
1425
- async getConfigurationSettingAsync(key, label) {
1426
- this.logService.methodName = "getConfigurationSettingAsync()";
1427
- const setting = await this.configClient.getConfigurationSetting({ key: key, label: label.replace(".", "") });
1428
- this.logService.log("Configuration Setting Key/Value", key, setting.value);
1429
- return setting.value;
1430
- }
1431
- async setConfigurationSettingAsync(templateName, label, setting, contentType = "Text") {
1432
- this.logService.className = "ConfigService";
1433
- this.logService.methodName = "setConfigurationSettingAsync()";
1434
- const configurationSetting = {
1435
- key: templateName,
1436
- label: label,
1437
- value: setting,
1438
- contentType: contentType,
1439
- };
1440
- this.logService.log("Setting", configurationSetting);
1441
- await this.configClient.setConfigurationSetting(configurationSetting);
1442
- this.logService.methodName = "";
1443
- }
1444
- async getConfigAsync(company) {
1445
- this.logService.className = "ConfigService";
1446
- this.logService.methodName = "getConfigAsync()";
1447
- if (this.configCache == undefined) {
1448
- this.logService.log("configCache == undefined");
1449
- // If we want to use Mock data then load the Mock data into the cache
1450
- if (this.mockData) {
1451
- this.configCache = MockConfig;
1452
- }
1453
- else {
1454
- const jsonConfig = await this.getConfigurationSettingAsync("App.Config.Json", company) ?? "{ }";
1455
- this.configCache = JSON.parse(jsonConfig);
1456
- }
1457
- }
1458
- this.logService.log("Config Cache", this.configCache);
1459
- const config = this.configCache;
1460
- this.logService.methodName = "";
1461
- return config;
1462
- }
1463
- async saveConfigAsync(config, company) {
1464
- this.logService.className = "ConfigService";
1465
- this.logService.methodName = "saveConfigAsync()";
1466
- // Update configuration cache
1467
- this.configCache = config;
1468
- this.logService.log("Updated Config Cache", this.configCache);
1469
- if (this.mockData) {
1470
- return;
1471
- }
1472
- await this.setConfigurationSettingAsync("App.Config.Json", company, config, "JSON");
1473
- this.logService.methodName = "";
1474
- }
1475
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
1476
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, providedIn: 'root' });
1477
- }
1478
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, decorators: [{
1479
- type: Injectable,
1480
- args: [{
1481
- providedIn: 'root'
1482
- }]
1483
- }], ctorParameters: () => [{ type: LogService }] });
1484
-
1485
- const MockInventoryApiResponse = {
1486
- "status": 200,
1487
- "data": [
1488
- {
1489
- "brand": "Portland Cannabis Market",
1220
+ "brand": "Garden First",
1490
1221
  "cannabinoidInformation": [
1491
1222
  {
1492
- "lowerRange": 0,
1493
- "name": "cbd",
1223
+ "lowerRange": 25.5,
1224
+ "name": "thc",
1494
1225
  "unitOfMeasure": "%",
1495
1226
  "unitOfMeasureToGramsMultiplier": null,
1496
- "upperRange": 0
1227
+ "upperRange": 25.5
1497
1228
  },
1498
1229
  {
1499
- "lowerRange": 25.25,
1500
- "name": "thc",
1230
+ "lowerRange": 0.1,
1231
+ "name": "cbd",
1501
1232
  "unitOfMeasure": "%",
1502
1233
  "unitOfMeasureToGramsMultiplier": null,
1503
- "upperRange": 25.25
1234
+ "upperRange": 0.1
1504
1235
  }
1505
1236
  ],
1506
1237
  "category": "Flower",
1507
1238
  "clientId": "5dd15878-aa4c-4adf-8650-b931f32a7b67",
1508
- "createdAt": "2024-05-06T21:41:03Z",
1239
+ "costInMinorUnits": 374,
1240
+ "createdAt": "2024-06-14T21:25:49Z",
1509
1241
  "currencyCode": "USD",
1510
1242
  "customCategoryName": null,
1511
1243
  "erpId": null,
@@ -1514,150 +1246,61 @@ const MockInventoryApiResponse = {
1514
1246
  "inventoryUnitOfMeasure": "grams",
1515
1247
  "inventoryUnitOfMeasureToGramsMultiplier": 1,
1516
1248
  "invoiceNumber": null,
1517
- "isMixAndMatch": false,
1249
+ "isMixAndMatch": true,
1518
1250
  "isSoldByWeight": true,
1519
1251
  "isStackable": true,
1520
1252
  "locationId": "10f19fc5-31d0-4d76-bad4-ad593c9803ae",
1521
1253
  "locationName": "Portland Pot Shop",
1522
1254
  "manifestId": null,
1523
1255
  "nutrients": null,
1524
- "parentproductId": "88caa95f-8a25-4960-ae1f-0894d86e8f02",
1525
- "parentproductName": "Royal Hindu Truffle by Upper Rogue Terraces",
1526
- "postTaxPriceInPennies": 800,
1527
- "preTaxPriceInPennies": 667,
1528
- "priceInMinorUnits": 667,
1256
+ "parentproductId": "798c79ac-7b88-425d-bd2f-c8684fdac27f",
1257
+ "parentproductName": "Donny Burger by Garden First",
1258
+ "postTaxPriceInPennies": 1200,
1259
+ "preTaxPriceInPennies": 1000,
1260
+ "priceInMinorUnits": 1000,
1529
1261
  "productDescription": "",
1530
- "productId": "df363dba-1cd3-402e-b6c3-b3697abed6ee",
1531
- "productName": "Royal Hindu Truffle by Upper Rogue Terraces",
1262
+ "productId": "db3b1fdc-f0b3-4936-afae-c0a828abfbaf",
1263
+ "productName": "Donny Burger by Garden First",
1532
1264
  "productPictureURL": null,
1533
1265
  "productUnitOfMeasure": "grams",
1534
1266
  "productUnitOfMeasureToGramsMultiplier": 1,
1535
- "productUpdatedAt": "2024-06-30T02:42:59.621977Z",
1267
+ "productUpdatedAt": "2024-06-30T02:42:36.303028Z",
1536
1268
  "productWeight": null,
1537
1269
  "purchaseCategory": "rec",
1538
- "quantity": 146.89,
1539
- "regulatoryId": "1A4010300000D4A000001042",
1540
- "sku": "zddCdpqRvw",
1270
+ "quantity": 95.8,
1271
+ "regulatoryId": "1A4010300016ECD000037910",
1272
+ "sku": "FSS0cRLR6G",
1541
1273
  "speciesName": "Indica",
1542
- "supplierName": "Portland Cannabis Market",
1274
+ "supplierName": "Hunter Distributing",
1543
1275
  "terpenes": null,
1544
1276
  "type": null,
1545
- "variantId": "b0ed44e0-68df-44f3-a34a-f05bb5bd8ae0",
1277
+ "variantId": "c3beca27-92a6-413a-938f-f8cf699d1b86",
1546
1278
  "variantName": "",
1547
1279
  "weightTierInformation": [
1548
1280
  {
1549
1281
  "gramAmount": 1,
1550
1282
  "name": "Grams",
1551
- "pricePerUnitInMinorUnits": 667
1283
+ "pricePerUnitInMinorUnits": 1000
1552
1284
  },
1553
1285
  {
1554
1286
  "gramAmount": 3.5,
1555
1287
  "name": "Eighth",
1556
- "pricePerUnitInMinorUnits": 2167
1288
+ "pricePerUnitInMinorUnits": 3083
1557
1289
  },
1558
1290
  {
1559
1291
  "gramAmount": 7,
1560
1292
  "name": "Quarter",
1561
- "pricePerUnitInMinorUnits": 3833
1293
+ "pricePerUnitInMinorUnits": 5417
1562
1294
  },
1563
1295
  {
1564
1296
  "gramAmount": 14,
1565
1297
  "name": "Half-Ounce",
1566
- "pricePerUnitInMinorUnits": 7000
1298
+ "pricePerUnitInMinorUnits": 10000
1567
1299
  },
1568
1300
  {
1569
1301
  "gramAmount": 28,
1570
1302
  "name": "Ounce",
1571
- "pricePerUnitInMinorUnits": 12917
1572
- }
1573
- ],
1574
- costInMinorUnits: 0
1575
- },
1576
- {
1577
- "brand": "Garden First",
1578
- "cannabinoidInformation": [
1579
- {
1580
- "lowerRange": 25.5,
1581
- "name": "thc",
1582
- "unitOfMeasure": "%",
1583
- "unitOfMeasureToGramsMultiplier": null,
1584
- "upperRange": 25.5
1585
- },
1586
- {
1587
- "lowerRange": 0.1,
1588
- "name": "cbd",
1589
- "unitOfMeasure": "%",
1590
- "unitOfMeasureToGramsMultiplier": null,
1591
- "upperRange": 0.1
1592
- }
1593
- ],
1594
- "category": "Flower",
1595
- "clientId": "5dd15878-aa4c-4adf-8650-b931f32a7b67",
1596
- "costInMinorUnits": 374,
1597
- "createdAt": "2024-06-14T21:25:49Z",
1598
- "currencyCode": "USD",
1599
- "customCategoryName": null,
1600
- "erpId": null,
1601
- "erpName": null,
1602
- "expirationDate": null,
1603
- "inventoryUnitOfMeasure": "grams",
1604
- "inventoryUnitOfMeasureToGramsMultiplier": 1,
1605
- "invoiceNumber": null,
1606
- "isMixAndMatch": true,
1607
- "isSoldByWeight": true,
1608
- "isStackable": true,
1609
- "locationId": "10f19fc5-31d0-4d76-bad4-ad593c9803ae",
1610
- "locationName": "Portland Pot Shop",
1611
- "manifestId": null,
1612
- "nutrients": null,
1613
- "parentproductId": "798c79ac-7b88-425d-bd2f-c8684fdac27f",
1614
- "parentproductName": "Donny Burger by Garden First",
1615
- "postTaxPriceInPennies": 1200,
1616
- "preTaxPriceInPennies": 1000,
1617
- "priceInMinorUnits": 1000,
1618
- "productDescription": "",
1619
- "productId": "db3b1fdc-f0b3-4936-afae-c0a828abfbaf",
1620
- "productName": "Donny Burger by Garden First",
1621
- "productPictureURL": null,
1622
- "productUnitOfMeasure": "grams",
1623
- "productUnitOfMeasureToGramsMultiplier": 1,
1624
- "productUpdatedAt": "2024-06-30T02:42:36.303028Z",
1625
- "productWeight": null,
1626
- "purchaseCategory": "rec",
1627
- "quantity": 95.8,
1628
- "regulatoryId": "1A4010300016ECD000037910",
1629
- "sku": "FSS0cRLR6G",
1630
- "speciesName": "Indica",
1631
- "supplierName": "Hunter Distributing",
1632
- "terpenes": null,
1633
- "type": null,
1634
- "variantId": "c3beca27-92a6-413a-938f-f8cf699d1b86",
1635
- "variantName": "",
1636
- "weightTierInformation": [
1637
- {
1638
- "gramAmount": 1,
1639
- "name": "Grams",
1640
- "pricePerUnitInMinorUnits": 1000
1641
- },
1642
- {
1643
- "gramAmount": 3.5,
1644
- "name": "Eighth",
1645
- "pricePerUnitInMinorUnits": 3083
1646
- },
1647
- {
1648
- "gramAmount": 7,
1649
- "name": "Quarter",
1650
- "pricePerUnitInMinorUnits": 5417
1651
- },
1652
- {
1653
- "gramAmount": 14,
1654
- "name": "Half-Ounce",
1655
- "pricePerUnitInMinorUnits": 10000
1656
- },
1657
- {
1658
- "gramAmount": 28,
1659
- "name": "Ounce",
1660
- "pricePerUnitInMinorUnits": 18750
1303
+ "pricePerUnitInMinorUnits": 18750
1661
1304
  }
1662
1305
  ]
1663
1306
  },
@@ -27225,261 +26868,695 @@ const MockInventoryApiResponse = {
27225
26868
  "variantName": "",
27226
26869
  "weightTierInformation": null
27227
26870
  }
27228
- ]
27229
- };
27230
-
27231
- class BaseApiService {
27232
- configService;
27233
- httpClient;
27234
- logService;
27235
- config;
27236
- get apiBaseUrl() {
27237
- if (this.config)
27238
- return this.config.apiBaseUrl;
27239
- else
27240
- return Utilities.baseUrl();
26871
+ ]
26872
+ };
26873
+
26874
+ const MockConfig = {
26875
+ "authConfig": {
26876
+ "logLevel": "Info",
26877
+ "configConnectString": "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=tyjA;Secret=1FgL95lHkXViZX4Qf2GcRqn26mhTYDVYany8ToXpTnO68AzrdUUEJQQJ99AHAC8vTInIcYexAAACAZACsteF",
26878
+ "clientId": "af1486e0-a27f-4c8d-8503-0752d90ce72d",
26879
+ "tenantId": "445012c4-563a-4795-84d0-f7473a3197e0",
26880
+ "authority": "https://login.microsoft.com/445012c4-563a-4795-84d0-f7473a3197e0",
26881
+ "scopes": "openid,email,profile",
26882
+ "menu_uri": "http://localhost:4200/",
26883
+ "redirect_uri": "https://www.cheapweedmenu.com",
26884
+ "logout_redirect_uri": "https://www.cheapweedmenu.com",
26885
+ "prompt": "login"
26886
+ },
26887
+ "apiConfig": {
26888
+ "apiBaseUrl": "https://cheap-weed-menus-webapi.azurewebsites.net",
26889
+ "addCustomerApiRoute": "/AddCustomer",
26890
+ "addSubscriptionApiRoute": "/subscription",
26891
+ "getInventoryApiRoute": "/inventory",
26892
+ "apiKey": "8b66d117-5d23-4b81-8c2f-52142c67d0cd",
26893
+ "clientId": "5dd15878-aa4c-4adf-8650-b931f32a7b67",
26894
+ "locationId": "10f19fc5-31d0-4d76-bad4-ad593c9803ae"
26895
+ },
26896
+ "menuBoardConfig": {
26897
+ "amountToScroll": 1,
26898
+ "autoScrollTimeout": 20,
26899
+ "dataAgeThreshold": 300000
26900
+ },
26901
+ "footerCarouselConfig": {
26902
+ "slidesToShow": 3,
26903
+ "slidesToScroll": 1,
26904
+ "dots": false,
26905
+ "infinite": true,
26906
+ "autoplay": true,
26907
+ "autoplaySpeed": 10000,
26908
+ "speed": 500,
26909
+ "arrows": false
26910
+ },
26911
+ "footerCarouselSlideConfig": [
26912
+ {
26913
+ "image": "../../../images/sunday.png",
26914
+ "title": "CBD Sunday",
26915
+ "description": "20% off all CBD products & house pre-rolls",
26916
+ "highlighted": false,
26917
+ "textColor": "white",
26918
+ "backgroundColor": "black"
26919
+ },
26920
+ {
26921
+ "image": "../../../images/new-monday.jpg",
26922
+ "title": "Edible Monday",
26923
+ "description": "10% off edibles",
26924
+ "highlighted": false,
26925
+ "textColor": "white",
26926
+ "backgroundColor": "black"
26927
+ },
26928
+ {
26929
+ "image": "../../../images/tuesday.png",
26930
+ "title": "Doobie Tuesday",
26931
+ "description": "10% off all pre-rolls & packs<",
26932
+ "highlighted": false,
26933
+ "textColor": "black",
26934
+ "backgroundColor": "white"
26935
+ },
26936
+ {
26937
+ "image": "../../../images/wednesday.png",
26938
+ "title": "Weed Crush Wednesday",
26939
+ "description": "10% off all jar bud",
26940
+ "highlighted": false,
26941
+ "textColor": "black",
26942
+ "backgroundColor": "white"
26943
+ },
26944
+ {
26945
+ "image": "../../../images/thursday.png",
26946
+ "title": "Thirsty Thursday",
26947
+ "description": "10% off Tinctures, RSO & cartridges",
26948
+ "highlighted": false,
26949
+ "textColor": "black",
26950
+ "backgroundColor": "white"
26951
+ },
26952
+ {
26953
+ "image": "../../../images/friday.png",
26954
+ "title": "Fire Friday",
26955
+ "description": "10% off all jar bud",
26956
+ "highlighted": false,
26957
+ "textColor": "black",
26958
+ "backgroundColor": "white"
26959
+ },
26960
+ {
26961
+ "image": "../../../images/saturday.png",
26962
+ "title": "Shatterday Saturday",
26963
+ "description": "10% off all concentrate",
26964
+ "highlighted": false,
26965
+ "textColor": "white",
26966
+ "backgroundColor": "black"
26967
+ }
26968
+ ]
26969
+ };
26970
+
26971
+ const MockProfile = {
26972
+ companyName: "The Portland Pot Shop",
26973
+ businessPhones: ["503.555.1212"],
26974
+ displayName: "PPS User",
26975
+ givenName: "PPS Menu User",
26976
+ id: "",
26977
+ jobTitle: "Menu",
26978
+ mail: "portlandpotshop@google.com",
26979
+ mobilePhone: "503.555.1212",
26980
+ officeLocation: "autoscroll",
26981
+ photoUrl: "",
26982
+ preferredLanguage: "en-us",
26983
+ surname: "Pot Shop",
26984
+ userPrincipalName: "portlandpotshop"
26985
+ };
26986
+
26987
+ class AuthService {
26988
+ constructor() {
26989
+ }
26990
+ static getAuthConfig() {
26991
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26992
+ const wind = window;
26993
+ return wind.authConfig;
26994
+ }
26995
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
26996
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, providedIn: 'root' });
26997
+ }
26998
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, decorators: [{
26999
+ type: Injectable,
27000
+ args: [{
27001
+ providedIn: 'root'
27002
+ }]
27003
+ }], ctorParameters: () => [] });
27004
+
27005
+ /*
27006
+ The LogService is really just a wrapper around the existing console logging functionality
27007
+ The three main reasons for using this service are:
27008
+ 1. The abstraction layer will allow us to pick a different logging endpoint if needed
27009
+ 2. This service allows you to specify what level verbosity you want this service tp log with
27010
+ 3. Has logic to log method entry and exit points automagically
27011
+ */
27012
+ class LogService {
27013
+ logLevel = 'Info';
27014
+ _className = "";
27015
+ get className() { return this._className; }
27016
+ set className(value) {
27017
+ this._className = value;
27018
+ this.methodName = "constructor()";
27019
+ }
27020
+ _methodName = "";
27021
+ get methodName() { return this._methodName; }
27022
+ set methodName(value) {
27023
+ if (value === "" && this.logLevel != 'None') {
27024
+ this.info("End of method");
27025
+ console.groupEnd();
27026
+ console.timeEnd(this.targetName);
27027
+ this._methodName = value;
27028
+ }
27029
+ else if (this.logLevel != 'None') {
27030
+ this._methodName = value;
27031
+ console.group(this.targetName);
27032
+ console.time(this.targetName);
27033
+ this.info("Start of method");
27034
+ }
27035
+ }
27036
+ get targetName() {
27037
+ if (this.methodName === "")
27038
+ return this.className;
27039
+ else
27040
+ return this.className + "." + this.methodName;
27041
+ }
27042
+ get prefix() {
27043
+ return Date.now().toLocaleString() + " " + this.targetName + "> ";
27044
+ }
27045
+ log(message, ...optionalParams) {
27046
+ if (this.logLevel != 'None') {
27047
+ if (this.targetName != this.className)
27048
+ console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
27049
+ else
27050
+ console.log(this.prefix + " " + message, optionalParams);
27051
+ }
27052
+ }
27053
+ info(message, ...optionalParams) {
27054
+ if (this.logLevel === 'Debug' || this.logLevel === 'Info') {
27055
+ if (this.targetName != this.className)
27056
+ console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
27057
+ else
27058
+ console.info(this.prefix + " " + message, optionalParams);
27059
+ }
27060
+ }
27061
+ warn(message, ...optionalParams) {
27062
+ if (this.logLevel === 'Warn' || this.logLevel === 'Debug' || this.logLevel === 'Info') {
27063
+ if (this.targetName != this.className) {
27064
+ console.timeEnd(this.targetName);
27065
+ console.time(this.targetName);
27066
+ }
27067
+ console.warn(this.prefix + " " + message, optionalParams);
27068
+ }
27069
+ }
27070
+ error(message, ...optionalParams) {
27071
+ if (this.logLevel != 'None') {
27072
+ if (this.targetName != this.className) {
27073
+ console.timeEnd(this.targetName);
27074
+ console.time(this.targetName);
27075
+ }
27076
+ console.error(this.prefix + " " + message, optionalParams);
27077
+ }
27078
+ }
27079
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
27080
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LogService, providedIn: 'root' });
27081
+ }
27082
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LogService, decorators: [{
27083
+ type: Injectable,
27084
+ args: [{
27085
+ providedIn: 'root'
27086
+ }]
27087
+ }] });
27088
+
27089
+ class ConfigService {
27090
+ logService;
27091
+ mockData = false;
27092
+ configClient;
27093
+ configConnectString;
27094
+ _configCache;
27095
+ get configCache() {
27096
+ return this._configCache;
27097
+ }
27098
+ set configCache(value) {
27099
+ this._configCache = value;
27100
+ }
27101
+ constructor(logService) {
27102
+ this.logService = logService;
27103
+ this.logService.className = "ConfigService";
27104
+ this.configConnectString = "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=tyjA;Secret=1FgL95lHkXViZX4Qf2GcRqn26mhTYDVYany8ToXpTnO68AzrdUUEJQQJ99AHAC8vTInIcYexAAACAZACsteF";
27105
+ this.configClient = new AppConfigurationClient(this.configConnectString);
27106
+ this.logService.log("Config Client", this.configClient);
27107
+ this.logService.methodName = "";
27108
+ }
27109
+ async getConfigurationSettingAsync(key, label) {
27110
+ this.logService.methodName = "getConfigurationSettingAsync()";
27111
+ const setting = await this.configClient.getConfigurationSetting({ key: key, label: label.replace(".", "") });
27112
+ this.logService.log("Configuration Setting Key/Value", key, setting.value);
27113
+ return setting.value;
27114
+ }
27115
+ async setConfigurationSettingAsync(templateName, label, setting, contentType = "Text") {
27116
+ this.logService.className = "ConfigService";
27117
+ this.logService.methodName = "setConfigurationSettingAsync()";
27118
+ const configurationSetting = {
27119
+ key: templateName,
27120
+ label: label,
27121
+ value: setting,
27122
+ contentType: contentType,
27123
+ };
27124
+ this.logService.log("Setting", configurationSetting);
27125
+ await this.configClient.setConfigurationSetting(configurationSetting);
27126
+ this.logService.methodName = "";
27127
+ }
27128
+ async getConfigAsync(company) {
27129
+ this.logService.className = "ConfigService";
27130
+ this.logService.methodName = "getConfigAsync()";
27131
+ if (this.configCache == undefined) {
27132
+ this.logService.log("configCache == undefined");
27133
+ // If we want to use Mock data then load the Mock data into the cache
27134
+ if (this.mockData) {
27135
+ this.configCache = MockConfig;
27136
+ }
27137
+ else {
27138
+ const jsonConfig = await this.getConfigurationSettingAsync("App.Config.Json", company) ?? "{ }";
27139
+ this.configCache = JSON.parse(jsonConfig);
27140
+ }
27141
+ }
27142
+ this.logService.log("Config Cache", this.configCache);
27143
+ const config = this.configCache;
27144
+ this.logService.methodName = "";
27145
+ return config;
27146
+ }
27147
+ async saveConfigAsync(config, company) {
27148
+ this.logService.className = "ConfigService";
27149
+ this.logService.methodName = "saveConfigAsync()";
27150
+ // Update configuration cache
27151
+ this.configCache = config;
27152
+ this.logService.log("Updated Config Cache", this.configCache);
27153
+ if (this.mockData) {
27154
+ return;
27155
+ }
27156
+ await this.setConfigurationSettingAsync("App.Config.Json", company, config, "JSON");
27157
+ this.logService.methodName = "";
27158
+ }
27159
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
27160
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, providedIn: 'root' });
27161
+ }
27162
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, decorators: [{
27163
+ type: Injectable,
27164
+ args: [{
27165
+ providedIn: 'root'
27166
+ }]
27167
+ }], ctorParameters: () => [{ type: LogService }] });
27168
+
27169
+ class BaseApiService {
27170
+ configService;
27171
+ httpClient;
27172
+ logService;
27173
+ config;
27174
+ get apiBaseUrl() {
27175
+ if (this.config)
27176
+ return this.config.apiBaseUrl;
27177
+ else
27178
+ return Utilities.baseUrl();
27179
+ }
27180
+ get apiFullUrl() {
27181
+ return this.apiBaseUrl;
27182
+ }
27183
+ constructor(configService, httpClient, logService) {
27184
+ this.configService = configService;
27185
+ this.httpClient = httpClient;
27186
+ this.logService = logService;
27187
+ }
27188
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseApiService, deps: [{ token: ConfigService }, { token: i2$1.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
27189
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseApiService, providedIn: 'root' });
27190
+ }
27191
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseApiService, decorators: [{
27192
+ type: Injectable,
27193
+ args: [{
27194
+ providedIn: 'root'
27195
+ }]
27196
+ }], ctorParameters: () => [{ type: ConfigService }, { type: i2$1.HttpClient }, { type: LogService }] });
27197
+
27198
+ class CustomerApiService extends BaseApiService {
27199
+ get apiFullUrl() {
27200
+ return this.apiBaseUrl + this.config?.addCustomerApiRoute;
27201
+ }
27202
+ async getCustomerAsync(customerId) { return; }
27203
+ async getCustomersAsync() { return; }
27204
+ async setCustomerAsync(companyName, customer) {
27205
+ this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
27206
+ return;
27207
+ }
27208
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CustomerApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
27209
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CustomerApiService, providedIn: 'root' });
27210
+ }
27211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CustomerApiService, decorators: [{
27212
+ type: Injectable,
27213
+ args: [{
27214
+ providedIn: 'root'
27215
+ }]
27216
+ }] });
27217
+
27218
+ class InventoryApiService extends BaseApiService {
27219
+ demoData = false;
27220
+ get httpHeaders() {
27221
+ return new HttpHeaders()
27222
+ .set('key', this.config?.apiKey)
27223
+ .set('clientId', this.config?.clientId)
27224
+ .set('locationId', this.config?.locationId);
27225
+ }
27226
+ get apiFullUrl() {
27227
+ return this.apiBaseUrl + this.config?.getInventoryApiRoute;
27228
+ }
27229
+ async getProductsAsync(companyName) {
27230
+ this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
27231
+ if (this.demoData) {
27232
+ return Promise.resolve(MockInventoryApiResponse);
27233
+ }
27234
+ else {
27235
+ return firstValueFrom(this.httpClient.get(this.apiFullUrl, { headers: this.httpHeaders }));
27236
+ }
27237
+ }
27238
+ async getCategoriesAsync(companyName) {
27239
+ { }
27240
+ const productApiResponse = await this.getProductsAsync(companyName);
27241
+ return keys(countBy(productApiResponse.data, (product) => product.category));
27242
+ }
27243
+ async getProductsByAllCategories(companyName) {
27244
+ const productApiResponse = await this.getProductsAsync(companyName);
27245
+ if (productApiResponse.status != HttpStatusCode.Ok) {
27246
+ throw new Error(`ProductApiResponse status: ${productApiResponse.status}`);
27247
+ }
27248
+ const allProducts = productApiResponse.data.map((value) => Product.FromFlowhubProduct(value))
27249
+ .sort((a, b) => a.category.localeCompare(b.category));
27250
+ const allCategories = keys(countBy(allProducts, (product) => product.category))
27251
+ .map((category) => Category.MapFromString(category));
27252
+ const productsByAllCategories = [];
27253
+ allCategories.sort().forEach(category => productsByAllCategories.push({
27254
+ key: category.name,
27255
+ value: allProducts.filter((product) => product.category === category.name &&
27256
+ product.quantity > 0).sort()
27257
+ }));
27258
+ return productsByAllCategories;
27259
+ }
27260
+ ;
27261
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InventoryApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
27262
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InventoryApiService, providedIn: 'root' });
27263
+ }
27264
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InventoryApiService, decorators: [{
27265
+ type: Injectable,
27266
+ args: [{
27267
+ providedIn: 'root'
27268
+ }]
27269
+ }] });
27270
+
27271
+ /**
27272
+ * Provides a wrapper for accessing the web storage API and synchronizing session storage across tabs/windows.
27273
+ */
27274
+ class LocalStorageService {
27275
+ static syncListenerInitialized = false;
27276
+ syncKeys = [];
27277
+ initEvent = new Subject();
27278
+ reservedKeys = [
27279
+ 'sync_keys',
27280
+ 'addToSyncKeys',
27281
+ 'removeFromSyncKeys',
27282
+ 'getSessionStorage',
27283
+ 'setSessionStorage',
27284
+ 'addToSessionStorage',
27285
+ 'removeFromSessionStorage',
27286
+ 'clearAllSessionsStorage'
27287
+ ];
27288
+ InitializeStorageSyncListener() {
27289
+ if (LocalStorageService.syncListenerInitialized == true) {
27290
+ return;
27291
+ }
27292
+ LocalStorageService.syncListenerInitialized = true;
27293
+ window.addEventListener('storage', this.sessionStorageTransferHandler, false);
27294
+ this.syncSessionStorage();
27295
+ }
27296
+ deInitializeStorageSyncListener() {
27297
+ window.removeEventListener('storage', this.sessionStorageTransferHandler, false);
27298
+ LocalStorageService.syncListenerInitialized = false;
27299
+ }
27300
+ clearAllStorage() {
27301
+ this.clearAllSessionsStorage();
27302
+ this.clearLocalStorage();
27303
+ }
27304
+ clearAllSessionsStorage() {
27305
+ this.clearInstanceSessionStorage();
27306
+ localStorage.removeItem(DbKeys.SYNC_KEYS);
27307
+ localStorage.setItem('clearAllSessionsStorage', '_dummy');
27308
+ localStorage.removeItem('clearAllSessionsStorage');
27309
+ }
27310
+ clearInstanceSessionStorage() {
27311
+ sessionStorage.clear();
27312
+ this.syncKeys = [];
27313
+ }
27314
+ clearLocalStorage() {
27315
+ localStorage.clear();
27316
+ }
27317
+ saveSessionData(data, key = DbKeys.USER_DATA) {
27318
+ this.testForInvalidKeys(key);
27319
+ this.removeFromSyncKeys(key);
27320
+ localStorage.removeItem(key);
27321
+ this.sessionStorageSetItem(key, data);
27322
+ }
27323
+ saveSyncedSessionData(data, key = DbKeys.USER_DATA) {
27324
+ this.testForInvalidKeys(key);
27325
+ localStorage.removeItem(key);
27326
+ this.addToSessionStorage(data, key);
27327
+ }
27328
+ savePermanentData(data, key = DbKeys.USER_DATA) {
27329
+ this.testForInvalidKeys(key);
27330
+ this.removeFromSessionStorage(key);
27331
+ this.localStorageSetItem(key, data);
27332
+ }
27333
+ moveDataToSessionStorage(key = DbKeys.USER_DATA) {
27334
+ this.testForInvalidKeys(key);
27335
+ const data = this.getData(key);
27336
+ if (data == null) {
27337
+ return;
27338
+ }
27339
+ this.saveSessionData(data, key);
27340
+ }
27341
+ moveDataToSyncedSessionStorage(key = DbKeys.USER_DATA) {
27342
+ this.testForInvalidKeys(key);
27343
+ const data = this.getData(key);
27344
+ if (data == null) {
27345
+ return;
27346
+ }
27347
+ this.saveSyncedSessionData(data, key);
27348
+ }
27349
+ moveDataToPermanentStorage(key = DbKeys.USER_DATA) {
27350
+ this.testForInvalidKeys(key);
27351
+ const data = this.getData(key);
27352
+ if (data == null) {
27353
+ return;
27354
+ }
27355
+ this.savePermanentData(data, key);
27356
+ }
27357
+ exists(key = DbKeys.USER_DATA) {
27358
+ let data = sessionStorage.getItem(key);
27359
+ if (data == null) {
27360
+ data = localStorage.getItem(key);
27361
+ }
27362
+ return data != null;
27363
+ }
27364
+ getData(key = DbKeys.USER_DATA) {
27365
+ this.testForInvalidKeys(key);
27366
+ let data = this.sessionStorageGetItem(key);
27367
+ if (data == '') {
27368
+ data = this.localStorageGetItem(key);
27369
+ }
27370
+ return data;
27371
+ }
27372
+ getDataObject(key = DbKeys.USER_DATA, isDateType = false) {
27373
+ let data = this.getData(key);
27374
+ if (data != null) {
27375
+ if (isDateType) {
27376
+ data = new Date(data);
27377
+ }
27378
+ return data;
27379
+ }
27380
+ else {
27381
+ return data;
27382
+ }
27383
+ }
27384
+ deleteData(key = DbKeys.USER_DATA) {
27385
+ this.testForInvalidKeys(key);
27386
+ this.removeFromSessionStorage(key);
27387
+ localStorage.removeItem(key);
27388
+ }
27389
+ getInitEvent() {
27390
+ return this.initEvent.asObservable();
27391
+ }
27392
+ sessionStorageTransferHandler = (event) => {
27393
+ if (!event.newValue) {
27394
+ return;
27395
+ }
27396
+ if (event.key == 'getSessionStorage') {
27397
+ if (sessionStorage.length) {
27398
+ this.localStorageSetItem('setSessionStorage', sessionStorage);
27399
+ localStorage.removeItem('setSessionStorage');
27400
+ }
27401
+ }
27402
+ else if (event.key == 'setSessionStorage') {
27403
+ if (!this.syncKeys.length) {
27404
+ this.loadSyncKeys();
27405
+ }
27406
+ const data = JSON.parse(event.newValue);
27407
+ // console.info("Set => Key: Transfer setSessionStorage" + ", data: " + JSON.stringify(data));
27408
+ for (const key in data) {
27409
+ if (this.syncKeysContains(key)) {
27410
+ this.sessionStorageSetItem(key, JSON.parse(data[key]));
27411
+ }
27412
+ }
27413
+ this.onInit();
27414
+ }
27415
+ else if (event.key == 'addToSessionStorage') {
27416
+ const data = JSON.parse(event.newValue);
27417
+ // console.warn("Set => Key: Transfer addToSessionStorage" + ", data: " + JSON.stringify(data));
27418
+ this.addToSessionStorageHelper(data.data, data.key);
27419
+ }
27420
+ else if (event.key == 'removeFromSessionStorage') {
27421
+ this.removeFromSessionStorageHelper(event.newValue);
27422
+ }
27423
+ else if (event.key == 'clearAllSessionsStorage' && sessionStorage.length) {
27424
+ this.clearInstanceSessionStorage();
27425
+ }
27426
+ else if (event.key == 'addToSyncKeys') {
27427
+ this.addToSyncKeysHelper(event.newValue);
27428
+ }
27429
+ else if (event.key == 'removeFromSyncKeys') {
27430
+ this.removeFromSyncKeysHelper(event.newValue);
27431
+ }
27432
+ };
27433
+ syncSessionStorage() {
27434
+ localStorage.setItem('getSessionStorage', '_dummy');
27435
+ localStorage.removeItem('getSessionStorage');
27241
27436
  }
27242
- get apiFullUrl() {
27243
- return this.apiBaseUrl;
27437
+ addToSessionStorage(data, key) {
27438
+ this.addToSessionStorageHelper(data, key);
27439
+ this.addToSyncKeysBackup(key);
27440
+ this.localStorageSetItem('addToSessionStorage', { key, data });
27441
+ localStorage.removeItem('addToSessionStorage');
27244
27442
  }
27245
- constructor(configService, httpClient, logService) {
27246
- this.configService = configService;
27247
- this.httpClient = httpClient;
27248
- this.logService = logService;
27443
+ addToSessionStorageHelper(data, key) {
27444
+ this.addToSyncKeysHelper(key);
27445
+ this.sessionStorageSetItem(key, data);
27249
27446
  }
27250
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseApiService, deps: [{ token: ConfigService }, { token: i2.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
27251
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseApiService });
27252
- }
27253
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseApiService, decorators: [{
27254
- type: Injectable
27255
- }], ctorParameters: () => [{ type: ConfigService }, { type: i2.HttpClient }, { type: LogService }] });
27256
-
27257
- class InventoryApiService extends BaseApiService {
27258
- demoData = false;
27259
- get httpHeaders() {
27260
- return new HttpHeaders()
27261
- .set('key', this.config?.apiKey)
27262
- .set('clientId', this.config?.clientId)
27263
- .set('locationId', this.config?.locationId);
27447
+ removeFromSessionStorage(keyToRemove) {
27448
+ this.removeFromSessionStorageHelper(keyToRemove);
27449
+ this.removeFromSyncKeysBackup(keyToRemove);
27450
+ localStorage.setItem('removeFromSessionStorage', keyToRemove);
27451
+ localStorage.removeItem('removeFromSessionStorage');
27264
27452
  }
27265
- get apiFullUrl() {
27266
- return this.apiBaseUrl + this.config?.getInventoryApiRoute;
27453
+ removeFromSessionStorageHelper(keyToRemove) {
27454
+ sessionStorage.removeItem(keyToRemove);
27455
+ this.removeFromSyncKeysHelper(keyToRemove);
27267
27456
  }
27268
- async getProductsAsync(companyName) {
27269
- this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
27270
- if (this.demoData) {
27271
- return Promise.resolve(MockInventoryApiResponse);
27457
+ testForInvalidKeys(key) {
27458
+ if (!key) {
27459
+ throw new Error('key cannot be empty');
27460
+ }
27461
+ if (this.reservedKeys.some(x => x == key)) {
27462
+ throw new Error(`The storage key "${key}" is reserved and cannot be used. Please use a different key`);
27463
+ }
27464
+ }
27465
+ syncKeysContains(key) {
27466
+ if (Array.isArray(this.syncKeys))
27467
+ return this.syncKeys.some(x => x == key);
27468
+ else
27469
+ return false;
27470
+ }
27471
+ loadSyncKeys() {
27472
+ if (this.syncKeys.length) {
27473
+ return;
27474
+ }
27475
+ this.syncKeys = this.getSyncKeysFromStorage();
27476
+ }
27477
+ getSyncKeysFromStorage(defaultValue = []) {
27478
+ const data = this.localStorageGetItem(DbKeys.SYNC_KEYS);
27479
+ if (data == null) {
27480
+ return defaultValue;
27272
27481
  }
27273
27482
  else {
27274
- return firstValueFrom(this.httpClient.get(this.apiFullUrl, { headers: this.httpHeaders }));
27483
+ return data;
27275
27484
  }
27276
27485
  }
27277
- async getCategoriesAsync(companyName) {
27278
- { }
27279
- const productApiResponse = await this.getProductsAsync(companyName);
27280
- return keys(countBy(productApiResponse.data, (product) => product.category));
27486
+ addToSyncKeys(key) {
27487
+ this.addToSyncKeysHelper(key);
27488
+ this.addToSyncKeysBackup(key);
27489
+ localStorage.setItem('addToSyncKeys', key);
27490
+ localStorage.removeItem('addToSyncKeys');
27281
27491
  }
27282
- async getProductsByAllCategories(companyName) {
27283
- const productApiResponse = await this.getProductsAsync(companyName);
27284
- if (productApiResponse.status != HttpStatusCode.Ok) {
27285
- throw new Error(`ProductApiResponse status: ${productApiResponse.status}`);
27492
+ addToSyncKeysBackup(key) {
27493
+ const storedSyncKeys = this.getSyncKeysFromStorage();
27494
+ if (!storedSyncKeys.some(x => x == key)) {
27495
+ storedSyncKeys.push(key);
27496
+ this.localStorageSetItem(DbKeys.SYNC_KEYS, storedSyncKeys);
27286
27497
  }
27287
- const allProducts = productApiResponse.data.map((value) => Product.FromFlowhubProduct(value))
27288
- .sort((a, b) => a.category.localeCompare(b.category));
27289
- const allCategories = keys(countBy(allProducts, (product) => product.category))
27290
- .map((category) => Category.MapFromString(category));
27291
- const productsByAllCategories = [];
27292
- allCategories.sort().forEach(category => productsByAllCategories.push({
27293
- key: category.name,
27294
- value: allProducts.filter((product) => product.category === category.name &&
27295
- product.quantity > 0).sort()
27296
- }));
27297
- return productsByAllCategories;
27298
27498
  }
27299
- ;
27300
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InventoryApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
27301
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InventoryApiService });
27302
- }
27303
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InventoryApiService, decorators: [{
27304
- type: Injectable
27305
- }] });
27306
-
27307
- class AuthService {
27308
- constructor() {
27499
+ removeFromSyncKeysBackup(key) {
27500
+ const storedSyncKeys = this.getSyncKeysFromStorage();
27501
+ const index = storedSyncKeys.indexOf(key);
27502
+ if (index > -1) {
27503
+ storedSyncKeys.splice(index, 1);
27504
+ this.localStorageSetItem(DbKeys.SYNC_KEYS, storedSyncKeys);
27505
+ }
27309
27506
  }
27310
- static getAuthConfig() {
27311
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27312
- const wind = window;
27313
- return wind.authConfig;
27507
+ addToSyncKeysHelper(key) {
27508
+ if (!this.syncKeysContains(key)) {
27509
+ this.syncKeys.push(key);
27510
+ }
27314
27511
  }
27315
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
27316
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, providedIn: 'root' });
27317
- }
27318
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, decorators: [{
27319
- type: Injectable,
27320
- args: [{
27321
- providedIn: 'root'
27322
- }]
27323
- }], ctorParameters: () => [] });
27324
-
27325
- class CustomerApiService extends BaseApiService {
27326
- get apiFullUrl() {
27327
- return this.apiBaseUrl + this.config?.addCustomerApiRoute;
27512
+ removeFromSyncKeys(key) {
27513
+ this.removeFromSyncKeysHelper(key);
27514
+ this.removeFromSyncKeysBackup(key);
27515
+ localStorage.setItem('removeFromSyncKeys', key);
27516
+ localStorage.removeItem('removeFromSyncKeys');
27328
27517
  }
27329
- async getCustomerAsync(customerId) { return; }
27330
- async getCustomersAsync() { return; }
27331
- async setCustomerAsync(companyName, customer) {
27332
- this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
27333
- return;
27518
+ removeFromSyncKeysHelper(key) {
27519
+ const index = this.syncKeys.indexOf(key);
27520
+ if (index > -1) {
27521
+ this.syncKeys.splice(index, 1);
27522
+ }
27334
27523
  }
27335
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CustomerApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
27336
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CustomerApiService, providedIn: 'root' });
27337
- }
27338
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CustomerApiService, decorators: [{
27339
- type: Injectable,
27340
- args: [{
27341
- providedIn: 'root'
27342
- }]
27343
- }] });
27344
-
27345
- class SafeHtmlPipe {
27346
- sanitizer;
27347
- constructor(sanitizer) {
27348
- this.sanitizer = sanitizer;
27524
+ localStorageSetItem(key, data) {
27525
+ localStorage.setItem(key, JSON.stringify(data));
27349
27526
  }
27350
- transform(value) {
27351
- return this.sanitizer.bypassSecurityTrustHtml(value);
27527
+ sessionStorageSetItem(key, data) {
27528
+ sessionStorage.setItem(key, JSON.stringify(data));
27352
27529
  }
27353
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: SafeHtmlPipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
27354
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: SafeHtmlPipe, isStandalone: false, name: "safeHtml" });
27355
- }
27356
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: SafeHtmlPipe, decorators: [{
27357
- type: Pipe,
27358
- args: [{
27359
- name: 'safeHtml',
27360
- standalone: false
27361
- }]
27362
- }], ctorParameters: () => [{ type: i1.DomSanitizer }] });
27363
-
27364
- function MSALInterceptorConfigFactory() {
27365
- const protectedResourceMap = new Map();
27366
- protectedResourceMap.set('https://graph.microsoft.com/v1.0/me', ['user.read']);
27367
- return {
27368
- interactionType: InteractionType.Popup, // or Redirect
27369
- protectedResourceMap
27370
- };
27371
- }
27372
-
27373
- // Services - providers
27374
- const isIE = window.navigator.userAgent.indexOf('MSIE ') > -1 || window.navigator.userAgent.indexOf('Trident/') > -1;
27375
- const baseUrl = Utilities.baseUrl();
27376
- const apiUri = "api://" + window.location.hostname;
27377
- const authConfig = AuthService.getAuthConfig();
27378
- class CwmSharedModule {
27379
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CwmSharedModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
27380
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: CwmSharedModule, declarations: [
27381
- //ExternalNavigationComponent,
27382
- //NavigateToRouteComponent,
27383
- SafeHtmlPipe], imports: [CommonModule,
27384
- BrowserModule,
27385
- MsalModule] });
27386
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CwmSharedModule, providers: [
27387
- CustomerApiService,
27388
- LogService,
27389
- LocalStorageService,
27390
- ConfigService,
27391
- InventoryApiService,
27392
- MsalService,
27393
- {
27394
- provide: MSAL_INSTANCE,
27395
- useFactory: MSALInstanceFactory
27396
- },
27397
- {
27398
- provide: MSAL_INTERCEPTOR_CONFIG,
27399
- useFactory: MSALInterceptorConfigFactory
27400
- },
27401
- {
27402
- provide: HTTP_INTERCEPTORS,
27403
- useClass: MsalInterceptor,
27404
- multi: true
27405
- }
27406
- ], imports: [CommonModule,
27407
- BrowserModule,
27408
- MsalModule] });
27530
+ localStorageGetItem(key) {
27531
+ return Utilities.JsonTryParse(localStorage.getItem(key) ?? '');
27532
+ }
27533
+ sessionStorageGetItem(key) {
27534
+ return Utilities.JsonTryParse(sessionStorage.getItem(key) ?? '');
27535
+ }
27536
+ onInit() {
27537
+ setTimeout(() => {
27538
+ //this.initEvent.next();
27539
+ this.initEvent.complete();
27540
+ });
27541
+ }
27542
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
27543
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocalStorageService, providedIn: 'root' });
27409
27544
  }
27410
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CwmSharedModule, decorators: [{
27411
- type: NgModule,
27545
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocalStorageService, decorators: [{
27546
+ type: Injectable,
27412
27547
  args: [{
27413
- declarations: [
27414
- //ExternalNavigationComponent,
27415
- //NavigateToRouteComponent,
27416
- SafeHtmlPipe,
27417
- ],
27418
- imports: [
27419
- CommonModule,
27420
- BrowserModule,
27421
- MsalModule,
27422
- /*
27423
- AppRoutingModule,
27424
- RouterModule,
27425
- AvatarModule,
27426
- BrowserModule,
27427
- BrowserAnimationsModule,
27428
- NoopAnimationsModule,
27429
- SlickCarouselModule,
27430
- FormsModule,
27431
- ReactiveFormsModule,
27432
- MsalModule*/
27433
- ],
27434
- providers: [
27435
- CustomerApiService,
27436
- LogService,
27437
- LocalStorageService,
27438
- ConfigService,
27439
- InventoryApiService,
27440
- MsalService,
27441
- {
27442
- provide: MSAL_INSTANCE,
27443
- useFactory: MSALInstanceFactory
27444
- },
27445
- {
27446
- provide: MSAL_INTERCEPTOR_CONFIG,
27447
- useFactory: MSALInterceptorConfigFactory
27448
- },
27449
- {
27450
- provide: HTTP_INTERCEPTORS,
27451
- useClass: MsalInterceptor,
27452
- multi: true
27453
- }
27454
- ]
27548
+ providedIn: 'root'
27455
27549
  }]
27456
27550
  }] });
27457
27551
 
27458
- const MockProfile = {
27459
- companyName: "The Portland Pot Shop",
27460
- businessPhones: ["503.555.1212"],
27461
- displayName: "PPS User",
27462
- givenName: "PPS Menu User",
27463
- id: "",
27464
- jobTitle: "Menu",
27465
- mail: "portlandpotshop@google.com",
27466
- mobilePhone: "503.555.1212",
27467
- officeLocation: "autoscroll",
27468
- photoUrl: "",
27469
- preferredLanguage: "en-us",
27470
- surname: "Pot Shop",
27471
- userPrincipalName: "portlandpotshop"
27472
- };
27473
-
27474
27552
  // ================================================
27475
27553
  // Export every type you want this module to expose
27476
27554
  // ================================================
27477
27555
  // Components
27478
- // Factories
27479
27556
 
27480
27557
  /**
27481
27558
  * Generated bundle index. Do not edit.
27482
27559
  */
27483
27560
 
27484
- export { AuthService, BaseApiService, CardTypes, Category, ConfigService, Customer, CustomerApiService, CwmSharedModule, DbKeys, InventoryApiService, Justifications, LocalStorageService, LogService, LoggingVerbosity, MSALGuardConfigFactory, MSALInstanceFactory, MockConfig, MockInventoryApiResponse, MockProfile, NamedColors, OnElementStyle, Product, Profile, SafeHtmlPipe, TimeSpan, TimeSpanOverflowError, UserTypes, Utilities, decodeToken, doWithLock, isTokenValid, waitFor };
27561
+ export { AuthService, BaseApiService, CardTypes, Category, ConfigService, Customer, CustomerApiService, CwmSharedModule, DbKeys, ExternalNavigationComponent, InventoryApiService, Justifications, LocalStorageService, LogService, LoggingVerbosity, MSALGuardConfigFactory, MSALInstanceFactory, MSALInterceptorConfigFactory, MockConfig, MockInventoryApiResponse, MockProfile, NamedColors, NavigateToRouteComponent, OnElementStyle, PageNotFoundComponent, Product, Profile, SafeHtmlPipe, TimeSpan, TimeSpanOverflowError, UserTypes, Utilities, decodeToken, doWithLock, isTokenValid, waitFor };
27485
27562
  //# sourceMappingURL=transcommerce-cwm-shared.mjs.map