@transcommerce/cwm-shared 1.1.17 → 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 {
@@ -949,572 +1051,193 @@ class Product {
949
1051
  }
950
1052
  }
951
1053
 
952
- /**
953
- * Provides a wrapper for accessing the web storage API and synchronizing session storage across tabs/windows.
954
- */
955
- class LocalStorageService {
956
- static syncListenerInitialized = false;
957
- syncKeys = [];
958
- initEvent = new Subject();
959
- reservedKeys = [
960
- 'sync_keys',
961
- 'addToSyncKeys',
962
- 'removeFromSyncKeys',
963
- 'getSessionStorage',
964
- 'setSessionStorage',
965
- 'addToSessionStorage',
966
- 'removeFromSessionStorage',
967
- 'clearAllSessionsStorage'
968
- ];
969
- InitializeStorageSyncListener() {
970
- if (LocalStorageService.syncListenerInitialized == true) {
971
- return;
972
- }
973
- LocalStorageService.syncListenerInitialized = true;
974
- window.addEventListener('storage', this.sessionStorageTransferHandler, false);
975
- this.syncSessionStorage();
976
- }
977
- deInitializeStorageSyncListener() {
978
- window.removeEventListener('storage', this.sessionStorageTransferHandler, false);
979
- LocalStorageService.syncListenerInitialized = false;
980
- }
981
- clearAllStorage() {
982
- this.clearAllSessionsStorage();
983
- this.clearLocalStorage();
984
- }
985
- clearAllSessionsStorage() {
986
- this.clearInstanceSessionStorage();
987
- localStorage.removeItem(DbKeys.SYNC_KEYS);
988
- localStorage.setItem('clearAllSessionsStorage', '_dummy');
989
- localStorage.removeItem('clearAllSessionsStorage');
990
- }
991
- clearInstanceSessionStorage() {
992
- sessionStorage.clear();
993
- this.syncKeys = [];
994
- }
995
- clearLocalStorage() {
996
- localStorage.clear();
997
- }
998
- saveSessionData(data, key = DbKeys.USER_DATA) {
999
- this.testForInvalidKeys(key);
1000
- this.removeFromSyncKeys(key);
1001
- localStorage.removeItem(key);
1002
- this.sessionStorageSetItem(key, data);
1003
- }
1004
- saveSyncedSessionData(data, key = DbKeys.USER_DATA) {
1005
- this.testForInvalidKeys(key);
1006
- localStorage.removeItem(key);
1007
- this.addToSessionStorage(data, key);
1008
- }
1009
- savePermanentData(data, key = DbKeys.USER_DATA) {
1010
- this.testForInvalidKeys(key);
1011
- this.removeFromSessionStorage(key);
1012
- this.localStorageSetItem(key, data);
1013
- }
1014
- moveDataToSessionStorage(key = DbKeys.USER_DATA) {
1015
- this.testForInvalidKeys(key);
1016
- const data = this.getData(key);
1017
- if (data == null) {
1018
- return;
1019
- }
1020
- this.saveSessionData(data, key);
1021
- }
1022
- moveDataToSyncedSessionStorage(key = DbKeys.USER_DATA) {
1023
- this.testForInvalidKeys(key);
1024
- const data = this.getData(key);
1025
- if (data == null) {
1026
- return;
1027
- }
1028
- this.saveSyncedSessionData(data, key);
1029
- }
1030
- moveDataToPermanentStorage(key = DbKeys.USER_DATA) {
1031
- this.testForInvalidKeys(key);
1032
- const data = this.getData(key);
1033
- if (data == null) {
1034
- return;
1035
- }
1036
- this.savePermanentData(data, key);
1037
- }
1038
- exists(key = DbKeys.USER_DATA) {
1039
- let data = sessionStorage.getItem(key);
1040
- if (data == null) {
1041
- data = localStorage.getItem(key);
1042
- }
1043
- return data != null;
1044
- }
1045
- getData(key = DbKeys.USER_DATA) {
1046
- this.testForInvalidKeys(key);
1047
- let data = this.sessionStorageGetItem(key);
1048
- if (data == '') {
1049
- data = this.localStorageGetItem(key);
1050
- }
1051
- return data;
1052
- }
1053
- getDataObject(key = DbKeys.USER_DATA, isDateType = false) {
1054
- let data = this.getData(key);
1055
- if (data != null) {
1056
- if (isDateType) {
1057
- data = new Date(data);
1058
- }
1059
- return data;
1060
- }
1061
- else {
1062
- return data;
1063
- }
1064
- }
1065
- deleteData(key = DbKeys.USER_DATA) {
1066
- this.testForInvalidKeys(key);
1067
- this.removeFromSessionStorage(key);
1068
- localStorage.removeItem(key);
1054
+ class SafeHtmlPipe {
1055
+ sanitizer;
1056
+ constructor(sanitizer) {
1057
+ this.sanitizer = sanitizer;
1069
1058
  }
1070
- getInitEvent() {
1071
- return this.initEvent.asObservable();
1059
+ transform(value) {
1060
+ return this.sanitizer.bypassSecurityTrustHtml(value);
1072
1061
  }
1073
- sessionStorageTransferHandler = (event) => {
1074
- if (!event.newValue) {
1075
- return;
1076
- }
1077
- if (event.key == 'getSessionStorage') {
1078
- if (sessionStorage.length) {
1079
- this.localStorageSetItem('setSessionStorage', sessionStorage);
1080
- localStorage.removeItem('setSessionStorage');
1081
- }
1082
- }
1083
- else if (event.key == 'setSessionStorage') {
1084
- if (!this.syncKeys.length) {
1085
- this.loadSyncKeys();
1086
- }
1087
- const data = JSON.parse(event.newValue);
1088
- // console.info("Set => Key: Transfer setSessionStorage" + ", data: " + JSON.stringify(data));
1089
- for (const key in data) {
1090
- if (this.syncKeysContains(key)) {
1091
- 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
1092
1147
  }
1093
- }
1094
- this.onInit();
1095
- }
1096
- else if (event.key == 'addToSessionStorage') {
1097
- const data = JSON.parse(event.newValue);
1098
- // console.warn("Set => Key: Transfer addToSessionStorage" + ", data: " + JSON.stringify(data));
1099
- this.addToSessionStorageHelper(data.data, data.key);
1100
- }
1101
- else if (event.key == 'removeFromSessionStorage') {
1102
- this.removeFromSessionStorageHelper(event.newValue);
1103
- }
1104
- else if (event.key == 'clearAllSessionsStorage' && sessionStorage.length) {
1105
- this.clearInstanceSessionStorage();
1106
- }
1107
- else if (event.key == 'addToSyncKeys') {
1108
- this.addToSyncKeysHelper(event.newValue);
1109
- }
1110
- else if (event.key == 'removeFromSyncKeys') {
1111
- this.removeFromSyncKeysHelper(event.newValue);
1112
- }
1113
- };
1114
- syncSessionStorage() {
1115
- localStorage.setItem('getSessionStorage', '_dummy');
1116
- localStorage.removeItem('getSessionStorage');
1117
- }
1118
- addToSessionStorage(data, key) {
1119
- this.addToSessionStorageHelper(data, key);
1120
- this.addToSyncKeysBackup(key);
1121
- this.localStorageSetItem('addToSessionStorage', { key, data });
1122
- localStorage.removeItem('addToSessionStorage');
1123
- }
1124
- addToSessionStorageHelper(data, key) {
1125
- this.addToSyncKeysHelper(key);
1126
- this.sessionStorageSetItem(key, data);
1127
- }
1128
- removeFromSessionStorage(keyToRemove) {
1129
- this.removeFromSessionStorageHelper(keyToRemove);
1130
- this.removeFromSyncKeysBackup(keyToRemove);
1131
- localStorage.setItem('removeFromSessionStorage', keyToRemove);
1132
- localStorage.removeItem('removeFromSessionStorage');
1133
- }
1134
- removeFromSessionStorageHelper(keyToRemove) {
1135
- sessionStorage.removeItem(keyToRemove);
1136
- this.removeFromSyncKeysHelper(keyToRemove);
1137
- }
1138
- testForInvalidKeys(key) {
1139
- if (!key) {
1140
- throw new Error('key cannot be empty');
1141
- }
1142
- if (this.reservedKeys.some(x => x == key)) {
1143
- throw new Error(`The storage key "${key}" is reserved and cannot be used. Please use a different key`);
1144
- }
1145
- }
1146
- syncKeysContains(key) {
1147
- if (Array.isArray(this.syncKeys))
1148
- return this.syncKeys.some(x => x == key);
1149
- else
1150
- return false;
1151
- }
1152
- loadSyncKeys() {
1153
- if (this.syncKeys.length) {
1154
- return;
1155
- }
1156
- this.syncKeys = this.getSyncKeysFromStorage();
1157
- }
1158
- getSyncKeysFromStorage(defaultValue = []) {
1159
- const data = this.localStorageGetItem(DbKeys.SYNC_KEYS);
1160
- if (data == null) {
1161
- return defaultValue;
1162
- }
1163
- else {
1164
- return data;
1165
- }
1166
- }
1167
- addToSyncKeys(key) {
1168
- this.addToSyncKeysHelper(key);
1169
- this.addToSyncKeysBackup(key);
1170
- localStorage.setItem('addToSyncKeys', key);
1171
- localStorage.removeItem('addToSyncKeys');
1172
- }
1173
- addToSyncKeysBackup(key) {
1174
- const storedSyncKeys = this.getSyncKeysFromStorage();
1175
- if (!storedSyncKeys.some(x => x == key)) {
1176
- storedSyncKeys.push(key);
1177
- this.localStorageSetItem(DbKeys.SYNC_KEYS, storedSyncKeys);
1178
- }
1179
- }
1180
- removeFromSyncKeysBackup(key) {
1181
- const storedSyncKeys = this.getSyncKeysFromStorage();
1182
- const index = storedSyncKeys.indexOf(key);
1183
- if (index > -1) {
1184
- storedSyncKeys.splice(index, 1);
1185
- this.localStorageSetItem(DbKeys.SYNC_KEYS, storedSyncKeys);
1186
- }
1187
- }
1188
- addToSyncKeysHelper(key) {
1189
- if (!this.syncKeysContains(key)) {
1190
- this.syncKeys.push(key);
1191
- }
1192
- }
1193
- removeFromSyncKeys(key) {
1194
- this.removeFromSyncKeysHelper(key);
1195
- this.removeFromSyncKeysBackup(key);
1196
- localStorage.setItem('removeFromSyncKeys', key);
1197
- localStorage.removeItem('removeFromSyncKeys');
1198
- }
1199
- removeFromSyncKeysHelper(key) {
1200
- const index = this.syncKeys.indexOf(key);
1201
- if (index > -1) {
1202
- this.syncKeys.splice(index, 1);
1203
- }
1204
- }
1205
- localStorageSetItem(key, data) {
1206
- localStorage.setItem(key, JSON.stringify(data));
1207
- }
1208
- sessionStorageSetItem(key, data) {
1209
- sessionStorage.setItem(key, JSON.stringify(data));
1210
- }
1211
- localStorageGetItem(key) {
1212
- return Utilities.JsonTryParse(localStorage.getItem(key) ?? '');
1213
- }
1214
- sessionStorageGetItem(key) {
1215
- return Utilities.JsonTryParse(sessionStorage.getItem(key) ?? '');
1216
- }
1217
- onInit() {
1218
- setTimeout(() => {
1219
- //this.initEvent.next();
1220
- this.initEvent.complete();
1221
- });
1222
- }
1223
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1224
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocalStorageService, providedIn: 'root' });
1225
- }
1226
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocalStorageService, decorators: [{
1227
- type: Injectable,
1228
- args: [{
1229
- providedIn: 'root'
1230
- }]
1231
- }] });
1232
-
1233
- const MockConfig = {
1234
- "authConfig": {
1235
- "logLevel": "Info",
1236
- "configConnectString": "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=tyjA;Secret=1FgL95lHkXViZX4Qf2GcRqn26mhTYDVYany8ToXpTnO68AzrdUUEJQQJ99AHAC8vTInIcYexAAACAZACsteF",
1237
- "clientId": "af1486e0-a27f-4c8d-8503-0752d90ce72d",
1238
- "tenantId": "445012c4-563a-4795-84d0-f7473a3197e0",
1239
- "authority": "https://login.microsoft.com/445012c4-563a-4795-84d0-f7473a3197e0",
1240
- "scopes": "openid,email,profile",
1241
- "menu_uri": "http://localhost:4200/",
1242
- "redirect_uri": "https://www.cheapweedmenu.com",
1243
- "logout_redirect_uri": "https://www.cheapweedmenu.com",
1244
- "prompt": "login"
1245
- },
1246
- "apiConfig": {
1247
- "apiBaseUrl": "https://cheap-weed-menus-webapi.azurewebsites.net",
1248
- "addCustomerApiRoute": "/AddCustomer",
1249
- "addSubscriptionApiRoute": "/subscription",
1250
- "getInventoryApiRoute": "/inventory",
1251
- "apiKey": "8b66d117-5d23-4b81-8c2f-52142c67d0cd",
1252
- "clientId": "5dd15878-aa4c-4adf-8650-b931f32a7b67",
1253
- "locationId": "10f19fc5-31d0-4d76-bad4-ad593c9803ae"
1254
- },
1255
- "menuBoardConfig": {
1256
- "amountToScroll": 1,
1257
- "autoScrollTimeout": 20,
1258
- "dataAgeThreshold": 300000
1259
- },
1260
- "footerCarouselConfig": {
1261
- "slidesToShow": 3,
1262
- "slidesToScroll": 1,
1263
- "dots": false,
1264
- "infinite": true,
1265
- "autoplay": true,
1266
- "autoplaySpeed": 10000,
1267
- "speed": 500,
1268
- "arrows": false
1269
- },
1270
- "footerCarouselSlideConfig": [
1271
- {
1272
- "image": "../../../images/sunday.png",
1273
- "title": "CBD Sunday",
1274
- "description": "20% off all CBD products & house pre-rolls",
1275
- "highlighted": false,
1276
- "textColor": "white",
1277
- "backgroundColor": "black"
1278
- },
1279
- {
1280
- "image": "../../../images/new-monday.jpg",
1281
- "title": "Edible Monday",
1282
- "description": "10% off edibles",
1283
- "highlighted": false,
1284
- "textColor": "white",
1285
- "backgroundColor": "black"
1286
- },
1287
- {
1288
- "image": "../../../images/tuesday.png",
1289
- "title": "Doobie Tuesday",
1290
- "description": "10% off all pre-rolls & packs<",
1291
- "highlighted": false,
1292
- "textColor": "black",
1293
- "backgroundColor": "white"
1294
- },
1295
- {
1296
- "image": "../../../images/wednesday.png",
1297
- "title": "Weed Crush Wednesday",
1298
- "description": "10% off all jar bud",
1299
- "highlighted": false,
1300
- "textColor": "black",
1301
- "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
1302
1218
  },
1303
1219
  {
1304
- "image": "../../../images/thursday.png",
1305
- "title": "Thirsty Thursday",
1306
- "description": "10% off Tinctures, RSO & cartridges",
1307
- "highlighted": false,
1308
- "textColor": "black",
1309
- "backgroundColor": "white"
1310
- },
1311
- {
1312
- "image": "../../../images/friday.png",
1313
- "title": "Fire Friday",
1314
- "description": "10% off all jar bud",
1315
- "highlighted": false,
1316
- "textColor": "black",
1317
- "backgroundColor": "white"
1318
- },
1319
- {
1320
- "image": "../../../images/saturday.png",
1321
- "title": "Shatterday Saturday",
1322
- "description": "10% off all concentrate",
1323
- "highlighted": false,
1324
- "textColor": "white",
1325
- "backgroundColor": "black"
1326
- }
1327
- ]
1328
- };
1329
-
1330
- /*
1331
- The LogService is really just a wrapper around the existing console logging functionality
1332
- The three main reasons for using this service are:
1333
- 1. The abstraction layer will allow us to pick a different logging endpoint if needed
1334
- 2. This service allows you to specify what level verbosity you want this service tp log with
1335
- 3. Has logic to log method entry and exit points automagically
1336
- */
1337
- class LogService {
1338
- logLevel = 'Info';
1339
- _className = "";
1340
- get className() { return this._className; }
1341
- set className(value) {
1342
- this._className = value;
1343
- this.methodName = "constructor()";
1344
- }
1345
- _methodName = "";
1346
- get methodName() { return this._methodName; }
1347
- set methodName(value) {
1348
- if (value === "" && this.logLevel != 'None') {
1349
- this.info("End of method");
1350
- console.groupEnd();
1351
- console.timeEnd(this.targetName);
1352
- this._methodName = value;
1353
- }
1354
- else if (this.logLevel != 'None') {
1355
- this._methodName = value;
1356
- console.group(this.targetName);
1357
- console.time(this.targetName);
1358
- this.info("Start of method");
1359
- }
1360
- }
1361
- get targetName() {
1362
- if (this.methodName === "")
1363
- return this.className;
1364
- else
1365
- return this.className + "." + this.methodName;
1366
- }
1367
- get prefix() {
1368
- return Date.now().toLocaleString() + " " + this.targetName + "> ";
1369
- }
1370
- log(message, ...optionalParams) {
1371
- if (this.logLevel != 'None') {
1372
- if (this.targetName != this.className)
1373
- console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
1374
- else
1375
- console.log(this.prefix + " " + message, optionalParams);
1376
- }
1377
- }
1378
- info(message, ...optionalParams) {
1379
- if (this.logLevel === 'Debug' || this.logLevel === 'Info') {
1380
- if (this.targetName != this.className)
1381
- console.timeLog(this.targetName, this.prefix + " " + message, optionalParams);
1382
- else
1383
- console.info(this.prefix + " " + message, optionalParams);
1384
- }
1385
- }
1386
- warn(message, ...optionalParams) {
1387
- if (this.logLevel === 'Warn' || this.logLevel === 'Debug' || this.logLevel === 'Info') {
1388
- if (this.targetName != this.className) {
1389
- console.timeEnd(this.targetName);
1390
- console.time(this.targetName);
1391
- }
1392
- console.warn(this.prefix + " " + message, optionalParams);
1393
- }
1394
- }
1395
- error(message, ...optionalParams) {
1396
- if (this.logLevel != 'None') {
1397
- if (this.targetName != this.className) {
1398
- console.timeEnd(this.targetName);
1399
- console.time(this.targetName);
1400
- }
1401
- console.error(this.prefix + " " + message, optionalParams);
1402
- }
1403
- }
1404
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1405
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LogService, providedIn: 'root' });
1406
- }
1407
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LogService, decorators: [{
1408
- type: Injectable,
1409
- args: [{
1410
- providedIn: 'root'
1411
- }]
1412
- }] });
1413
-
1414
- class ConfigService {
1415
- logService;
1416
- mockData = false;
1417
- configClient;
1418
- configConnectString;
1419
- _configCache;
1420
- get configCache() {
1421
- return this._configCache;
1422
- }
1423
- set configCache(value) {
1424
- this._configCache = value;
1425
- }
1426
- constructor(logService) {
1427
- this.logService = logService;
1428
- this.logService.className = "ConfigService";
1429
- this.configConnectString = "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=tyjA;Secret=1FgL95lHkXViZX4Qf2GcRqn26mhTYDVYany8ToXpTnO68AzrdUUEJQQJ99AHAC8vTInIcYexAAACAZACsteF";
1430
- this.configClient = new AppConfigurationClient(this.configConnectString);
1431
- this.logService.log("Config Client", this.configClient);
1432
- this.logService.methodName = "";
1433
- }
1434
- async getConfigurationSettingAsync(key, label) {
1435
- this.logService.methodName = "getConfigurationSettingAsync()";
1436
- const setting = await this.configClient.getConfigurationSetting({ key: key, label: label.replace(".", "") });
1437
- this.logService.log("Configuration Setting Key/Value", key, setting.value);
1438
- return setting.value;
1439
- }
1440
- async setConfigurationSettingAsync(templateName, label, setting, contentType = "Text") {
1441
- this.logService.className = "ConfigService";
1442
- this.logService.methodName = "setConfigurationSettingAsync()";
1443
- const configurationSetting = {
1444
- key: templateName,
1445
- label: label,
1446
- value: setting,
1447
- contentType: contentType,
1448
- };
1449
- this.logService.log("Setting", configurationSetting);
1450
- await this.configClient.setConfigurationSetting(configurationSetting);
1451
- this.logService.methodName = "";
1452
- }
1453
- async getConfigAsync(company) {
1454
- this.logService.className = "ConfigService";
1455
- this.logService.methodName = "getConfigAsync()";
1456
- if (this.configCache == undefined) {
1457
- this.logService.log("configCache == undefined");
1458
- // If we want to use Mock data then load the Mock data into the cache
1459
- if (this.mockData) {
1460
- this.configCache = MockConfig;
1461
- }
1462
- else {
1463
- const jsonConfig = await this.getConfigurationSettingAsync("App.Config.Json", company) ?? "{ }";
1464
- this.configCache = JSON.parse(jsonConfig);
1465
- }
1466
- }
1467
- this.logService.log("Config Cache", this.configCache);
1468
- const config = this.configCache;
1469
- this.logService.methodName = "";
1470
- return config;
1471
- }
1472
- async saveConfigAsync(config, company) {
1473
- this.logService.className = "ConfigService";
1474
- this.logService.methodName = "saveConfigAsync()";
1475
- // Update configuration cache
1476
- this.configCache = config;
1477
- this.logService.log("Updated Config Cache", this.configCache);
1478
- if (this.mockData) {
1479
- return;
1480
- }
1481
- await this.setConfigurationSettingAsync("App.Config.Json", company, config, "JSON");
1482
- this.logService.methodName = "";
1483
- }
1484
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
1485
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, providedIn: 'root' });
1486
- }
1487
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ConfigService, decorators: [{
1488
- type: Injectable,
1489
- args: [{
1490
- providedIn: 'root'
1491
- }]
1492
- }], ctorParameters: () => [{ type: LogService }] });
1493
-
1494
- const MockInventoryApiResponse = {
1495
- "status": 200,
1496
- "data": [
1497
- {
1498
- "brand": "Portland Cannabis Market",
1220
+ "brand": "Garden First",
1499
1221
  "cannabinoidInformation": [
1500
1222
  {
1501
- "lowerRange": 0,
1502
- "name": "cbd",
1223
+ "lowerRange": 25.5,
1224
+ "name": "thc",
1503
1225
  "unitOfMeasure": "%",
1504
1226
  "unitOfMeasureToGramsMultiplier": null,
1505
- "upperRange": 0
1227
+ "upperRange": 25.5
1506
1228
  },
1507
1229
  {
1508
- "lowerRange": 25.25,
1509
- "name": "thc",
1230
+ "lowerRange": 0.1,
1231
+ "name": "cbd",
1510
1232
  "unitOfMeasure": "%",
1511
1233
  "unitOfMeasureToGramsMultiplier": null,
1512
- "upperRange": 25.25
1234
+ "upperRange": 0.1
1513
1235
  }
1514
1236
  ],
1515
1237
  "category": "Flower",
1516
1238
  "clientId": "5dd15878-aa4c-4adf-8650-b931f32a7b67",
1517
- "createdAt": "2024-05-06T21:41:03Z",
1239
+ "costInMinorUnits": 374,
1240
+ "createdAt": "2024-06-14T21:25:49Z",
1518
1241
  "currencyCode": "USD",
1519
1242
  "customCategoryName": null,
1520
1243
  "erpId": null,
@@ -1523,165 +1246,76 @@ const MockInventoryApiResponse = {
1523
1246
  "inventoryUnitOfMeasure": "grams",
1524
1247
  "inventoryUnitOfMeasureToGramsMultiplier": 1,
1525
1248
  "invoiceNumber": null,
1526
- "isMixAndMatch": false,
1249
+ "isMixAndMatch": true,
1527
1250
  "isSoldByWeight": true,
1528
1251
  "isStackable": true,
1529
1252
  "locationId": "10f19fc5-31d0-4d76-bad4-ad593c9803ae",
1530
1253
  "locationName": "Portland Pot Shop",
1531
1254
  "manifestId": null,
1532
1255
  "nutrients": null,
1533
- "parentproductId": "88caa95f-8a25-4960-ae1f-0894d86e8f02",
1534
- "parentproductName": "Royal Hindu Truffle by Upper Rogue Terraces",
1535
- "postTaxPriceInPennies": 800,
1536
- "preTaxPriceInPennies": 667,
1537
- "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,
1538
1261
  "productDescription": "",
1539
- "productId": "df363dba-1cd3-402e-b6c3-b3697abed6ee",
1540
- "productName": "Royal Hindu Truffle by Upper Rogue Terraces",
1262
+ "productId": "db3b1fdc-f0b3-4936-afae-c0a828abfbaf",
1263
+ "productName": "Donny Burger by Garden First",
1541
1264
  "productPictureURL": null,
1542
1265
  "productUnitOfMeasure": "grams",
1543
1266
  "productUnitOfMeasureToGramsMultiplier": 1,
1544
- "productUpdatedAt": "2024-06-30T02:42:59.621977Z",
1267
+ "productUpdatedAt": "2024-06-30T02:42:36.303028Z",
1545
1268
  "productWeight": null,
1546
1269
  "purchaseCategory": "rec",
1547
- "quantity": 146.89,
1548
- "regulatoryId": "1A4010300000D4A000001042",
1549
- "sku": "zddCdpqRvw",
1270
+ "quantity": 95.8,
1271
+ "regulatoryId": "1A4010300016ECD000037910",
1272
+ "sku": "FSS0cRLR6G",
1550
1273
  "speciesName": "Indica",
1551
- "supplierName": "Portland Cannabis Market",
1274
+ "supplierName": "Hunter Distributing",
1552
1275
  "terpenes": null,
1553
1276
  "type": null,
1554
- "variantId": "b0ed44e0-68df-44f3-a34a-f05bb5bd8ae0",
1277
+ "variantId": "c3beca27-92a6-413a-938f-f8cf699d1b86",
1555
1278
  "variantName": "",
1556
1279
  "weightTierInformation": [
1557
1280
  {
1558
1281
  "gramAmount": 1,
1559
1282
  "name": "Grams",
1560
- "pricePerUnitInMinorUnits": 667
1283
+ "pricePerUnitInMinorUnits": 1000
1561
1284
  },
1562
1285
  {
1563
1286
  "gramAmount": 3.5,
1564
1287
  "name": "Eighth",
1565
- "pricePerUnitInMinorUnits": 2167
1288
+ "pricePerUnitInMinorUnits": 3083
1566
1289
  },
1567
1290
  {
1568
1291
  "gramAmount": 7,
1569
1292
  "name": "Quarter",
1570
- "pricePerUnitInMinorUnits": 3833
1293
+ "pricePerUnitInMinorUnits": 5417
1571
1294
  },
1572
1295
  {
1573
1296
  "gramAmount": 14,
1574
1297
  "name": "Half-Ounce",
1575
- "pricePerUnitInMinorUnits": 7000
1298
+ "pricePerUnitInMinorUnits": 10000
1576
1299
  },
1577
1300
  {
1578
1301
  "gramAmount": 28,
1579
1302
  "name": "Ounce",
1580
- "pricePerUnitInMinorUnits": 12917
1303
+ "pricePerUnitInMinorUnits": 18750
1581
1304
  }
1582
- ],
1583
- costInMinorUnits: 0
1305
+ ]
1584
1306
  },
1585
1307
  {
1586
- "brand": "Garden First",
1308
+ "brand": "Portland Pot Shop",
1587
1309
  "cannabinoidInformation": [
1588
1310
  {
1589
- "lowerRange": 25.5,
1311
+ "lowerRange": 35.41,
1590
1312
  "name": "thc",
1591
1313
  "unitOfMeasure": "%",
1592
1314
  "unitOfMeasureToGramsMultiplier": null,
1593
- "upperRange": 25.5
1315
+ "upperRange": 35.41
1594
1316
  },
1595
1317
  {
1596
- "lowerRange": 0.1,
1597
- "name": "cbd",
1598
- "unitOfMeasure": "%",
1599
- "unitOfMeasureToGramsMultiplier": null,
1600
- "upperRange": 0.1
1601
- }
1602
- ],
1603
- "category": "Flower",
1604
- "clientId": "5dd15878-aa4c-4adf-8650-b931f32a7b67",
1605
- "costInMinorUnits": 374,
1606
- "createdAt": "2024-06-14T21:25:49Z",
1607
- "currencyCode": "USD",
1608
- "customCategoryName": null,
1609
- "erpId": null,
1610
- "erpName": null,
1611
- "expirationDate": null,
1612
- "inventoryUnitOfMeasure": "grams",
1613
- "inventoryUnitOfMeasureToGramsMultiplier": 1,
1614
- "invoiceNumber": null,
1615
- "isMixAndMatch": true,
1616
- "isSoldByWeight": true,
1617
- "isStackable": true,
1618
- "locationId": "10f19fc5-31d0-4d76-bad4-ad593c9803ae",
1619
- "locationName": "Portland Pot Shop",
1620
- "manifestId": null,
1621
- "nutrients": null,
1622
- "parentproductId": "798c79ac-7b88-425d-bd2f-c8684fdac27f",
1623
- "parentproductName": "Donny Burger by Garden First",
1624
- "postTaxPriceInPennies": 1200,
1625
- "preTaxPriceInPennies": 1000,
1626
- "priceInMinorUnits": 1000,
1627
- "productDescription": "",
1628
- "productId": "db3b1fdc-f0b3-4936-afae-c0a828abfbaf",
1629
- "productName": "Donny Burger by Garden First",
1630
- "productPictureURL": null,
1631
- "productUnitOfMeasure": "grams",
1632
- "productUnitOfMeasureToGramsMultiplier": 1,
1633
- "productUpdatedAt": "2024-06-30T02:42:36.303028Z",
1634
- "productWeight": null,
1635
- "purchaseCategory": "rec",
1636
- "quantity": 95.8,
1637
- "regulatoryId": "1A4010300016ECD000037910",
1638
- "sku": "FSS0cRLR6G",
1639
- "speciesName": "Indica",
1640
- "supplierName": "Hunter Distributing",
1641
- "terpenes": null,
1642
- "type": null,
1643
- "variantId": "c3beca27-92a6-413a-938f-f8cf699d1b86",
1644
- "variantName": "",
1645
- "weightTierInformation": [
1646
- {
1647
- "gramAmount": 1,
1648
- "name": "Grams",
1649
- "pricePerUnitInMinorUnits": 1000
1650
- },
1651
- {
1652
- "gramAmount": 3.5,
1653
- "name": "Eighth",
1654
- "pricePerUnitInMinorUnits": 3083
1655
- },
1656
- {
1657
- "gramAmount": 7,
1658
- "name": "Quarter",
1659
- "pricePerUnitInMinorUnits": 5417
1660
- },
1661
- {
1662
- "gramAmount": 14,
1663
- "name": "Half-Ounce",
1664
- "pricePerUnitInMinorUnits": 10000
1665
- },
1666
- {
1667
- "gramAmount": 28,
1668
- "name": "Ounce",
1669
- "pricePerUnitInMinorUnits": 18750
1670
- }
1671
- ]
1672
- },
1673
- {
1674
- "brand": "Portland Pot Shop",
1675
- "cannabinoidInformation": [
1676
- {
1677
- "lowerRange": 35.41,
1678
- "name": "thc",
1679
- "unitOfMeasure": "%",
1680
- "unitOfMeasureToGramsMultiplier": null,
1681
- "upperRange": 35.41
1682
- },
1683
- {
1684
- "lowerRange": 0.13,
1318
+ "lowerRange": 0.13,
1685
1319
  "name": "cbd",
1686
1320
  "unitOfMeasure": "%",
1687
1321
  "unitOfMeasureToGramsMultiplier": null,
@@ -27234,256 +26868,695 @@ const MockInventoryApiResponse = {
27234
26868
  "variantName": "",
27235
26869
  "weightTierInformation": null
27236
26870
  }
27237
- ]
27238
- };
27239
-
27240
- class BaseApiService {
27241
- configService;
27242
- httpClient;
27243
- logService;
27244
- config;
27245
- get apiBaseUrl() {
27246
- if (this.config)
27247
- return this.config.apiBaseUrl;
27248
- else
27249
- 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');
27250
27436
  }
27251
- get apiFullUrl() {
27252
- 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');
27253
27442
  }
27254
- constructor(configService, httpClient, logService) {
27255
- this.configService = configService;
27256
- this.httpClient = httpClient;
27257
- this.logService = logService;
27443
+ addToSessionStorageHelper(data, key) {
27444
+ this.addToSyncKeysHelper(key);
27445
+ this.sessionStorageSetItem(key, data);
27258
27446
  }
27259
- 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 });
27260
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseApiService });
27261
- }
27262
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseApiService, decorators: [{
27263
- type: Injectable
27264
- }], ctorParameters: () => [{ type: ConfigService }, { type: i2.HttpClient }, { type: LogService }] });
27265
-
27266
- class InventoryApiService extends BaseApiService {
27267
- demoData = false;
27268
- get httpHeaders() {
27269
- return new HttpHeaders()
27270
- .set('key', this.config?.apiKey)
27271
- .set('clientId', this.config?.clientId)
27272
- .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');
27273
27452
  }
27274
- get apiFullUrl() {
27275
- return this.apiBaseUrl + this.config?.getInventoryApiRoute;
27453
+ removeFromSessionStorageHelper(keyToRemove) {
27454
+ sessionStorage.removeItem(keyToRemove);
27455
+ this.removeFromSyncKeysHelper(keyToRemove);
27276
27456
  }
27277
- async getProductsAsync(companyName) {
27278
- this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
27279
- if (this.demoData) {
27280
- 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;
27281
27481
  }
27282
27482
  else {
27283
- return firstValueFrom(this.httpClient.get(this.apiFullUrl, { headers: this.httpHeaders }));
27483
+ return data;
27284
27484
  }
27285
27485
  }
27286
- async getCategoriesAsync(companyName) {
27287
- { }
27288
- const productApiResponse = await this.getProductsAsync(companyName);
27289
- 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');
27290
27491
  }
27291
- async getProductsByAllCategories(companyName) {
27292
- const productApiResponse = await this.getProductsAsync(companyName);
27293
- if (productApiResponse.status != HttpStatusCode.Ok) {
27294
- 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);
27295
27497
  }
27296
- const allProducts = productApiResponse.data.map((value) => Product.FromFlowhubProduct(value))
27297
- .sort((a, b) => a.category.localeCompare(b.category));
27298
- const allCategories = keys(countBy(allProducts, (product) => product.category))
27299
- .map((category) => Category.MapFromString(category));
27300
- const productsByAllCategories = [];
27301
- allCategories.sort().forEach(category => productsByAllCategories.push({
27302
- key: category.name,
27303
- value: allProducts.filter((product) => product.category === category.name &&
27304
- product.quantity > 0).sort()
27305
- }));
27306
- return productsByAllCategories;
27307
27498
  }
27308
- ;
27309
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InventoryApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
27310
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InventoryApiService });
27311
- }
27312
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InventoryApiService, decorators: [{
27313
- type: Injectable
27314
- }] });
27315
-
27316
- class AuthService {
27317
- 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
+ }
27318
27506
  }
27319
- static getAuthConfig() {
27320
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27321
- const wind = window;
27322
- return wind.authConfig;
27507
+ addToSyncKeysHelper(key) {
27508
+ if (!this.syncKeysContains(key)) {
27509
+ this.syncKeys.push(key);
27510
+ }
27323
27511
  }
27324
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
27325
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, providedIn: 'root' });
27326
- }
27327
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, decorators: [{
27328
- type: Injectable,
27329
- args: [{
27330
- providedIn: 'root'
27331
- }]
27332
- }], ctorParameters: () => [] });
27333
-
27334
- class CustomerApiService extends BaseApiService {
27335
- get apiFullUrl() {
27336
- 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');
27337
27517
  }
27338
- async getCustomerAsync(customerId) { return; }
27339
- async getCustomersAsync() { return; }
27340
- async setCustomerAsync(companyName, customer) {
27341
- this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
27342
- return;
27518
+ removeFromSyncKeysHelper(key) {
27519
+ const index = this.syncKeys.indexOf(key);
27520
+ if (index > -1) {
27521
+ this.syncKeys.splice(index, 1);
27522
+ }
27343
27523
  }
27344
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CustomerApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
27345
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CustomerApiService, providedIn: 'root' });
27346
- }
27347
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: CustomerApiService, decorators: [{
27348
- type: Injectable,
27349
- args: [{
27350
- providedIn: 'root'
27351
- }]
27352
- }] });
27353
-
27354
- class SafeHtmlPipe {
27355
- sanitizer;
27356
- constructor(sanitizer) {
27357
- this.sanitizer = sanitizer;
27524
+ localStorageSetItem(key, data) {
27525
+ localStorage.setItem(key, JSON.stringify(data));
27358
27526
  }
27359
- transform(value) {
27360
- return this.sanitizer.bypassSecurityTrustHtml(value);
27527
+ sessionStorageSetItem(key, data) {
27528
+ sessionStorage.setItem(key, JSON.stringify(data));
27361
27529
  }
27362
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: SafeHtmlPipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
27363
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: SafeHtmlPipe, isStandalone: false, name: "safeHtml" });
27364
- }
27365
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: SafeHtmlPipe, decorators: [{
27366
- type: Pipe,
27367
- args: [{
27368
- name: 'safeHtml',
27369
- standalone: false
27370
- }]
27371
- }], ctorParameters: () => [{ type: i1.DomSanitizer }] });
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
- //export * from './lib/components/external-navigation/external-navigation.component'
27479
- //export * from './lib/components/navigate-to-route/navigate-to-route.component'
27480
- //export * from './lib/components/page-not-found/page-not-found.component'
27481
- //export * from './lib/components/route-based-templates/route-based-templates.component'
27482
- // Factories
27483
27556
 
27484
27557
  /**
27485
27558
  * Generated bundle index. Do not edit.
27486
27559
  */
27487
27560
 
27488
- export { AuthService, BaseApiService, CardTypes, Category, ConfigService, Customer, CustomerApiService, CwmSharedModule, DbKeys, InventoryApiService, Justifications, LocalStorageService, LogService, LoggingVerbosity, MSALGuardConfigFactory, MSALInstanceFactory, MSALInterceptorConfigFactory, 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 };
27489
27562
  //# sourceMappingURL=transcommerce-cwm-shared.mjs.map