@churchapps/helpers 1.0.10 → 1.0.12
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.
- package/LICENSE +21 -21
- package/README.md +15 -15
- package/dist/UserHelper.d.ts +2 -2
- package/dist/UserHelper.d.ts.map +1 -1
- package/dist/UserHelper.js.map +1 -1
- package/dist/interfaces/Access.d.ts +1 -1
- package/dist/interfaces/Access.d.ts.map +1 -1
- package/dist/interfaces/Messaging.d.ts +20 -2
- package/dist/interfaces/Messaging.d.ts.map +1 -1
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js +1 -0
- package/dist/interfaces/index.js.map +1 -1
- package/package.json +38 -38
- package/src/ApiHelper.ts +132 -132
- package/src/AppearanceHelper.ts +69 -69
- package/src/ArrayHelper.ts +156 -156
- package/src/CommonEnvironmentHelper.ts +80 -80
- package/src/CurrencyHelper.ts +10 -10
- package/src/DateHelper.ts +122 -122
- package/src/DonationHelper.ts +26 -26
- package/src/ErrorHelper.ts +36 -36
- package/src/EventHelper.ts +49 -49
- package/src/FileHelper.ts +31 -31
- package/src/PersonHelper.ts +75 -75
- package/src/UniqueIdHelper.ts +36 -36
- package/src/UserHelper.ts +59 -59
- package/src/index.ts +12 -12
- package/src/interfaces/Access.ts +24 -24
- package/src/interfaces/Attendance.ts +8 -8
- package/src/interfaces/Content.ts +10 -10
- package/src/interfaces/Doing.ts +24 -24
- package/src/interfaces/Donation.ts +45 -45
- package/src/interfaces/Error.ts +17 -17
- package/src/interfaces/Membership.ts +51 -51
- package/src/interfaces/Messaging.ts +11 -20
- package/src/interfaces/Permissions.ts +68 -68
- package/src/interfaces/Reporting.ts +7 -7
- package/src/interfaces/UserContextInterface.ts +13 -13
- package/src/interfaces/index.ts +14 -12
- package/tsconfig.json +36 -36
package/src/AppearanceHelper.ts
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
export interface AppearanceInterface { primaryColor?: string, primaryContrast?: string, secondaryColor?: string, secondaryContrast?: string, logoLight?: string, logoDark?: string, favicon_400x400?: string, favicon_16x16?: string }
|
|
3
|
-
|
|
4
|
-
export class AppearanceHelper {
|
|
5
|
-
|
|
6
|
-
public static getLogoDark(appearanceSettings: AppearanceInterface, defaultLogo: string) {
|
|
7
|
-
return (appearanceSettings?.logoDark) ? appearanceSettings.logoDark : defaultLogo;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public static getLogoLight(appearanceSettings: AppearanceInterface, defaultLogo: string) {
|
|
11
|
-
return (appearanceSettings?.logoLight) ? appearanceSettings.logoLight : defaultLogo;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public static getFavicon(appearanceSettings: AppearanceInterface, size: "400" | "16") {
|
|
15
|
-
if (size === "400") {
|
|
16
|
-
return appearanceSettings?.favicon_400x400;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (size === "16") {
|
|
20
|
-
return appearanceSettings?.favicon_16x16;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public static getLogo(appearanceSettings: AppearanceInterface, defaultLogoLight: string, defaultLogoDark: string, backgroundColor: string) {
|
|
27
|
-
const isDark = (appearanceSettings.logoDark) ? this.isDark(backgroundColor) : false;
|
|
28
|
-
if (isDark) return this.getLogoDark(appearanceSettings, defaultLogoDark);
|
|
29
|
-
else return this.getLogoLight(appearanceSettings, defaultLogoLight);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private static isDark(backgroundColor: string) {
|
|
33
|
-
let valid = false;
|
|
34
|
-
let r = 0;
|
|
35
|
-
let g = 0;
|
|
36
|
-
let b = 0;
|
|
37
|
-
|
|
38
|
-
if (backgroundColor.match(/#[0-9a-fA-F{6}]/)) {
|
|
39
|
-
r = this.getHexValue(backgroundColor.substring(1, 2));
|
|
40
|
-
g = this.getHexValue(backgroundColor.substring(3, 4));
|
|
41
|
-
b = this.getHexValue(backgroundColor.substring(5, 6));
|
|
42
|
-
valid = true;
|
|
43
|
-
} else if (backgroundColor.match(/#[0-9a-fA-F{3}]/)) {
|
|
44
|
-
r = this.getHexValue(backgroundColor.substring(1, 1));
|
|
45
|
-
g = this.getHexValue(backgroundColor.substring(2, 2));
|
|
46
|
-
b = this.getHexValue(backgroundColor.substring(3, 3));
|
|
47
|
-
valid = true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!valid) return false;
|
|
51
|
-
else {
|
|
52
|
-
//HSP brightness formula. Some colors have a bigger impact on our perceived brightness than others.
|
|
53
|
-
const rWeight = .299 * Math.pow(r, 2);
|
|
54
|
-
const gWeight = .587 * Math.pow(g, 2);
|
|
55
|
-
const bWeight = .114 * Math.pow(b, 2);
|
|
56
|
-
const brightness = Math.sqrt(rWeight + gWeight + bWeight);
|
|
57
|
-
//return brightness < 128; //
|
|
58
|
-
return brightness < 156;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private static getHexValue(hex: string) {
|
|
64
|
-
let result = parseInt(hex, 16);
|
|
65
|
-
if (hex.length === 1) result = result * 16;
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
}
|
|
1
|
+
|
|
2
|
+
export interface AppearanceInterface { primaryColor?: string, primaryContrast?: string, secondaryColor?: string, secondaryContrast?: string, logoLight?: string, logoDark?: string, favicon_400x400?: string, favicon_16x16?: string }
|
|
3
|
+
|
|
4
|
+
export class AppearanceHelper {
|
|
5
|
+
|
|
6
|
+
public static getLogoDark(appearanceSettings: AppearanceInterface, defaultLogo: string) {
|
|
7
|
+
return (appearanceSettings?.logoDark) ? appearanceSettings.logoDark : defaultLogo;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public static getLogoLight(appearanceSettings: AppearanceInterface, defaultLogo: string) {
|
|
11
|
+
return (appearanceSettings?.logoLight) ? appearanceSettings.logoLight : defaultLogo;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public static getFavicon(appearanceSettings: AppearanceInterface, size: "400" | "16") {
|
|
15
|
+
if (size === "400") {
|
|
16
|
+
return appearanceSettings?.favicon_400x400;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (size === "16") {
|
|
20
|
+
return appearanceSettings?.favicon_16x16;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static getLogo(appearanceSettings: AppearanceInterface, defaultLogoLight: string, defaultLogoDark: string, backgroundColor: string) {
|
|
27
|
+
const isDark = (appearanceSettings.logoDark) ? this.isDark(backgroundColor) : false;
|
|
28
|
+
if (isDark) return this.getLogoDark(appearanceSettings, defaultLogoDark);
|
|
29
|
+
else return this.getLogoLight(appearanceSettings, defaultLogoLight);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private static isDark(backgroundColor: string) {
|
|
33
|
+
let valid = false;
|
|
34
|
+
let r = 0;
|
|
35
|
+
let g = 0;
|
|
36
|
+
let b = 0;
|
|
37
|
+
|
|
38
|
+
if (backgroundColor.match(/#[0-9a-fA-F{6}]/)) {
|
|
39
|
+
r = this.getHexValue(backgroundColor.substring(1, 2));
|
|
40
|
+
g = this.getHexValue(backgroundColor.substring(3, 4));
|
|
41
|
+
b = this.getHexValue(backgroundColor.substring(5, 6));
|
|
42
|
+
valid = true;
|
|
43
|
+
} else if (backgroundColor.match(/#[0-9a-fA-F{3}]/)) {
|
|
44
|
+
r = this.getHexValue(backgroundColor.substring(1, 1));
|
|
45
|
+
g = this.getHexValue(backgroundColor.substring(2, 2));
|
|
46
|
+
b = this.getHexValue(backgroundColor.substring(3, 3));
|
|
47
|
+
valid = true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!valid) return false;
|
|
51
|
+
else {
|
|
52
|
+
//HSP brightness formula. Some colors have a bigger impact on our perceived brightness than others.
|
|
53
|
+
const rWeight = .299 * Math.pow(r, 2);
|
|
54
|
+
const gWeight = .587 * Math.pow(g, 2);
|
|
55
|
+
const bWeight = .114 * Math.pow(b, 2);
|
|
56
|
+
const brightness = Math.sqrt(rWeight + gWeight + bWeight);
|
|
57
|
+
//return brightness < 128; //
|
|
58
|
+
return brightness < 156;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private static getHexValue(hex: string) {
|
|
64
|
+
let result = parseInt(hex, 16);
|
|
65
|
+
if (hex.length === 1) result = result * 16;
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|
package/src/ArrayHelper.ts
CHANGED
|
@@ -1,156 +1,156 @@
|
|
|
1
|
-
import { UniqueIdHelper } from "./UniqueIdHelper";
|
|
2
|
-
|
|
3
|
-
export class ArrayHelper {
|
|
4
|
-
static getIds(array: any[], propertyName: string) {
|
|
5
|
-
const result: string[] = [];
|
|
6
|
-
for (const item of array) {
|
|
7
|
-
const id = item[propertyName]?.toString();
|
|
8
|
-
if (!UniqueIdHelper.isMissing(id) && result.indexOf(id) === -1) result.push(id);
|
|
9
|
-
}
|
|
10
|
-
return result;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static sortBy(array: any[], propertyName: string, descending: boolean = false) {
|
|
14
|
-
array.sort((a, b) => {
|
|
15
|
-
const valA = a[propertyName];
|
|
16
|
-
const valB = b[propertyName];
|
|
17
|
-
if (valA < valB) return descending ? 1 : -1;
|
|
18
|
-
else return descending ? -1 : 1;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static getIndex(array: any[], propertyName: string, value: any) {
|
|
23
|
-
for (let i = 0; i < array.length; i++) {
|
|
24
|
-
const item = array[i];
|
|
25
|
-
if (ArrayHelper.compare(item, propertyName, value)) return i;
|
|
26
|
-
}
|
|
27
|
-
return -1;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static getOne(array: any[], propertyName: string, value: any) {
|
|
31
|
-
for (const item of array || []) if (ArrayHelper.compare(item, propertyName, value)) return item;
|
|
32
|
-
return null
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static getAll(array: any[], propertyName: string, value: any) {
|
|
36
|
-
const result: any[] = []
|
|
37
|
-
for (const item of array || []) {
|
|
38
|
-
if (ArrayHelper.compare(item, propertyName, value)) result.push(item);
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static getAllArray(array: any[], propertyName: string, values: any[]) {
|
|
44
|
-
const result: any[] = []
|
|
45
|
-
for (const item of array || []) if (values.indexOf(item[propertyName]) > -1) result.push(item);
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private static compare(item: any, propertyName: string, value: any) {
|
|
50
|
-
const propChain = propertyName.split(".");
|
|
51
|
-
if (propChain.length === 1) return item[propertyName] === value;
|
|
52
|
-
else {
|
|
53
|
-
let obj = item;
|
|
54
|
-
for (let i = 0; i < propChain.length - 1; i++) {
|
|
55
|
-
if (obj) obj = item[propChain[i]];
|
|
56
|
-
}
|
|
57
|
-
return obj[propChain[propChain.length - 1]] === value;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
static getUniqueValues(array: any[], propertyName: string) {
|
|
62
|
-
const result: any[] = [];
|
|
63
|
-
|
|
64
|
-
for (const item of array) {
|
|
65
|
-
const val = (propertyName.indexOf(".") === -1) ? item[propertyName] : this.getDeepValue(item, propertyName)
|
|
66
|
-
if (result.indexOf(val) === -1) result.push(val);
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
static getUnique(array: any[]) {
|
|
72
|
-
const result: any[] = []
|
|
73
|
-
const jsonList: string[] = [];
|
|
74
|
-
for (const item of array) {
|
|
75
|
-
const json = JSON.stringify(item);
|
|
76
|
-
if (jsonList.indexOf(json) === -1) {
|
|
77
|
-
result.push(item);
|
|
78
|
-
jsonList.push(json);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
static getAllOperatorArray(array: any[], propertyName: string, values: any[], operator: string, dataType = "string") {
|
|
85
|
-
const result: any[] = [];
|
|
86
|
-
values.forEach(v => {
|
|
87
|
-
const filtered = this.getAllOperator(array, propertyName, v, operator.replace("notIn", "notEqual").replace("in", "equals").replace("donatedTo", "equals"), dataType);
|
|
88
|
-
filtered.forEach(f => result.push(f));
|
|
89
|
-
})
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
static getAllOperator(array: any[], propertyName: string, value: any, operator: string, dataType = "string") {
|
|
94
|
-
const result: any[] = []
|
|
95
|
-
for (const item of array) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
let propVal = item[propertyName] || "";
|
|
99
|
-
let compVal = value || "";
|
|
100
|
-
if (dataType === "number") {
|
|
101
|
-
propVal = parseFloat(propVal);
|
|
102
|
-
compVal = parseFloat(compVal);
|
|
103
|
-
} else if (dataType === "string") {
|
|
104
|
-
propVal = propVal.toLowerCase();
|
|
105
|
-
compVal = compVal.toLowerCase();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
switch (operator) {
|
|
109
|
-
case "equals":
|
|
110
|
-
if (propVal === compVal) result.push(item);
|
|
111
|
-
break;
|
|
112
|
-
case "startsWith":
|
|
113
|
-
if (propVal.indexOf(compVal) === 0) result.push(item);
|
|
114
|
-
break;
|
|
115
|
-
case "endsWith":
|
|
116
|
-
if (propVal.indexOf(compVal) === propVal.length - compVal.length) result.push(item);
|
|
117
|
-
break;
|
|
118
|
-
case "contains":
|
|
119
|
-
if (propVal.indexOf(compVal) > -1) result.push(item);
|
|
120
|
-
break;
|
|
121
|
-
case "greaterThan":
|
|
122
|
-
if (propVal > compVal) result.push(item);
|
|
123
|
-
break;
|
|
124
|
-
case "greaterThanEqual":
|
|
125
|
-
if (propVal >= compVal) result.push(item);
|
|
126
|
-
break;
|
|
127
|
-
case "lessThan":
|
|
128
|
-
if (propVal < compVal) result.push(item);
|
|
129
|
-
break;
|
|
130
|
-
case "lessThanEqual":
|
|
131
|
-
if (propVal <= compVal) result.push(item);
|
|
132
|
-
break;
|
|
133
|
-
case "notEqual":
|
|
134
|
-
if (propVal !== compVal) result.push(item);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
static getDeepValue(item: any, propertyName: string) {
|
|
142
|
-
const propertyNames = propertyName.split(".");
|
|
143
|
-
let result: any = item;
|
|
144
|
-
propertyNames.forEach(name => {
|
|
145
|
-
result = result[name];
|
|
146
|
-
});
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
static fillArray(contents: string, length: number) {
|
|
151
|
-
const result = [];
|
|
152
|
-
for (let i = 0; i < length; i++) result.push(contents);
|
|
153
|
-
return result;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
}
|
|
1
|
+
import { UniqueIdHelper } from "./UniqueIdHelper";
|
|
2
|
+
|
|
3
|
+
export class ArrayHelper {
|
|
4
|
+
static getIds(array: any[], propertyName: string) {
|
|
5
|
+
const result: string[] = [];
|
|
6
|
+
for (const item of array) {
|
|
7
|
+
const id = item[propertyName]?.toString();
|
|
8
|
+
if (!UniqueIdHelper.isMissing(id) && result.indexOf(id) === -1) result.push(id);
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static sortBy(array: any[], propertyName: string, descending: boolean = false) {
|
|
14
|
+
array.sort((a, b) => {
|
|
15
|
+
const valA = a[propertyName];
|
|
16
|
+
const valB = b[propertyName];
|
|
17
|
+
if (valA < valB) return descending ? 1 : -1;
|
|
18
|
+
else return descending ? -1 : 1;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getIndex(array: any[], propertyName: string, value: any) {
|
|
23
|
+
for (let i = 0; i < array.length; i++) {
|
|
24
|
+
const item = array[i];
|
|
25
|
+
if (ArrayHelper.compare(item, propertyName, value)) return i;
|
|
26
|
+
}
|
|
27
|
+
return -1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static getOne(array: any[], propertyName: string, value: any) {
|
|
31
|
+
for (const item of array || []) if (ArrayHelper.compare(item, propertyName, value)) return item;
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static getAll(array: any[], propertyName: string, value: any) {
|
|
36
|
+
const result: any[] = []
|
|
37
|
+
for (const item of array || []) {
|
|
38
|
+
if (ArrayHelper.compare(item, propertyName, value)) result.push(item);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static getAllArray(array: any[], propertyName: string, values: any[]) {
|
|
44
|
+
const result: any[] = []
|
|
45
|
+
for (const item of array || []) if (values.indexOf(item[propertyName]) > -1) result.push(item);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private static compare(item: any, propertyName: string, value: any) {
|
|
50
|
+
const propChain = propertyName.split(".");
|
|
51
|
+
if (propChain.length === 1) return item[propertyName] === value;
|
|
52
|
+
else {
|
|
53
|
+
let obj = item;
|
|
54
|
+
for (let i = 0; i < propChain.length - 1; i++) {
|
|
55
|
+
if (obj) obj = item[propChain[i]];
|
|
56
|
+
}
|
|
57
|
+
return obj[propChain[propChain.length - 1]] === value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static getUniqueValues(array: any[], propertyName: string) {
|
|
62
|
+
const result: any[] = [];
|
|
63
|
+
|
|
64
|
+
for (const item of array) {
|
|
65
|
+
const val = (propertyName.indexOf(".") === -1) ? item[propertyName] : this.getDeepValue(item, propertyName)
|
|
66
|
+
if (result.indexOf(val) === -1) result.push(val);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static getUnique(array: any[]) {
|
|
72
|
+
const result: any[] = []
|
|
73
|
+
const jsonList: string[] = [];
|
|
74
|
+
for (const item of array) {
|
|
75
|
+
const json = JSON.stringify(item);
|
|
76
|
+
if (jsonList.indexOf(json) === -1) {
|
|
77
|
+
result.push(item);
|
|
78
|
+
jsonList.push(json);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static getAllOperatorArray(array: any[], propertyName: string, values: any[], operator: string, dataType = "string") {
|
|
85
|
+
const result: any[] = [];
|
|
86
|
+
values.forEach(v => {
|
|
87
|
+
const filtered = this.getAllOperator(array, propertyName, v, operator.replace("notIn", "notEqual").replace("in", "equals").replace("donatedTo", "equals"), dataType);
|
|
88
|
+
filtered.forEach(f => result.push(f));
|
|
89
|
+
})
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static getAllOperator(array: any[], propertyName: string, value: any, operator: string, dataType = "string") {
|
|
94
|
+
const result: any[] = []
|
|
95
|
+
for (const item of array) {
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
let propVal = item[propertyName] || "";
|
|
99
|
+
let compVal = value || "";
|
|
100
|
+
if (dataType === "number") {
|
|
101
|
+
propVal = parseFloat(propVal);
|
|
102
|
+
compVal = parseFloat(compVal);
|
|
103
|
+
} else if (dataType === "string") {
|
|
104
|
+
propVal = propVal.toLowerCase();
|
|
105
|
+
compVal = compVal.toLowerCase();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
switch (operator) {
|
|
109
|
+
case "equals":
|
|
110
|
+
if (propVal === compVal) result.push(item);
|
|
111
|
+
break;
|
|
112
|
+
case "startsWith":
|
|
113
|
+
if (propVal.indexOf(compVal) === 0) result.push(item);
|
|
114
|
+
break;
|
|
115
|
+
case "endsWith":
|
|
116
|
+
if (propVal.indexOf(compVal) === propVal.length - compVal.length) result.push(item);
|
|
117
|
+
break;
|
|
118
|
+
case "contains":
|
|
119
|
+
if (propVal.indexOf(compVal) > -1) result.push(item);
|
|
120
|
+
break;
|
|
121
|
+
case "greaterThan":
|
|
122
|
+
if (propVal > compVal) result.push(item);
|
|
123
|
+
break;
|
|
124
|
+
case "greaterThanEqual":
|
|
125
|
+
if (propVal >= compVal) result.push(item);
|
|
126
|
+
break;
|
|
127
|
+
case "lessThan":
|
|
128
|
+
if (propVal < compVal) result.push(item);
|
|
129
|
+
break;
|
|
130
|
+
case "lessThanEqual":
|
|
131
|
+
if (propVal <= compVal) result.push(item);
|
|
132
|
+
break;
|
|
133
|
+
case "notEqual":
|
|
134
|
+
if (propVal !== compVal) result.push(item);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static getDeepValue(item: any, propertyName: string) {
|
|
142
|
+
const propertyNames = propertyName.split(".");
|
|
143
|
+
let result: any = item;
|
|
144
|
+
propertyNames.forEach(name => {
|
|
145
|
+
result = result[name];
|
|
146
|
+
});
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static fillArray(contents: string, length: number) {
|
|
151
|
+
const result = [];
|
|
152
|
+
for (let i = 0; i < length; i++) result.push(contents);
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
}
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
export class CommonEnvironmentHelper {
|
|
3
|
-
public static AttendanceApi = "";
|
|
4
|
-
public static DoingApi = "";
|
|
5
|
-
public static GivingApi = "";
|
|
6
|
-
public static MembershipApi = "";
|
|
7
|
-
public static ReportingApi = "";
|
|
8
|
-
public static MessagingApi = "";
|
|
9
|
-
public static MessagingApiSocket = "";
|
|
10
|
-
public static ContentApi = "";
|
|
11
|
-
public static GoogleAnalyticsTag = "";
|
|
12
|
-
|
|
13
|
-
static ContentRoot = "";
|
|
14
|
-
static B1Root = "";
|
|
15
|
-
static ChumsRoot = "";
|
|
16
|
-
static LessonsRoot = "";
|
|
17
|
-
|
|
18
|
-
static init = (stage: string) => {
|
|
19
|
-
switch (stage) {
|
|
20
|
-
case "staging": CommonEnvironmentHelper.initStaging(); break;
|
|
21
|
-
case "prod": CommonEnvironmentHelper.initProd(); break;
|
|
22
|
-
default: CommonEnvironmentHelper.initDev(); break;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static initDev = () => {
|
|
27
|
-
this.initStaging(); //Use staging values for anything not provided
|
|
28
|
-
CommonEnvironmentHelper.AttendanceApi = process.env.REACT_APP_ATTENDANCE_API || process.env.NEXT_PUBLIC_ATTENDANCE_API || CommonEnvironmentHelper.AttendanceApi;
|
|
29
|
-
CommonEnvironmentHelper.DoingApi = process.env.REACT_APP_DOING_API || process.env.NEXT_PUBLIC_DOING_API || CommonEnvironmentHelper.DoingApi;
|
|
30
|
-
CommonEnvironmentHelper.GivingApi = process.env.REACT_APP_GIVING_API || process.env.NEXT_PUBLIC_GIVING_API || CommonEnvironmentHelper.GivingApi;
|
|
31
|
-
CommonEnvironmentHelper.MembershipApi = process.env.REACT_APP_MEMBERSHIP_API || process.env.NEXT_PUBLIC_MEMBERSHIP_API || CommonEnvironmentHelper.MembershipApi;
|
|
32
|
-
CommonEnvironmentHelper.ReportingApi = process.env.REACT_APP_REPORTING_API || process.env.NEXT_PUBLIC_REPORTING_API || CommonEnvironmentHelper.ReportingApi;
|
|
33
|
-
CommonEnvironmentHelper.MessagingApi = process.env.REACT_APP_MESSAGING_API || process.env.NEXT_PUBLIC_MESSAGING_API || CommonEnvironmentHelper.MessagingApi;
|
|
34
|
-
CommonEnvironmentHelper.MessagingApiSocket = process.env.REACT_APP_MESSAGING_API_SOCKET || process.env.NEXT_PUBLIC_MESSAGING_API_SOCKET || CommonEnvironmentHelper.MessagingApiSocket;
|
|
35
|
-
CommonEnvironmentHelper.ContentApi = process.env.REACT_APP_CONTENT_API || process.env.NEXT_PUBLIC_CONTENT_API || CommonEnvironmentHelper.ContentApi;
|
|
36
|
-
CommonEnvironmentHelper.GoogleAnalyticsTag = process.env.REACT_APP_GOOGLE_ANALYTICS || process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS || CommonEnvironmentHelper.GoogleAnalyticsTag;
|
|
37
|
-
|
|
38
|
-
CommonEnvironmentHelper.ContentRoot = process.env.REACT_APP_CONTENT_ROOT || process.env.NEXT_PUBLIC_CONTENT_ROOT || CommonEnvironmentHelper.ContentRoot;
|
|
39
|
-
CommonEnvironmentHelper.B1Root = process.env.REACT_APP_B1_ROOT || process.env.NEXT_PUBLIC_B1_ROOT || CommonEnvironmentHelper.B1Root;
|
|
40
|
-
CommonEnvironmentHelper.ChumsRoot = process.env.REACT_APP_CHUMS_ROOT || process.env.NEXT_PUBLIC_CHUMS_ROOT || CommonEnvironmentHelper.ChumsRoot;
|
|
41
|
-
CommonEnvironmentHelper.LessonsRoot = process.env.REACT_APP_LESSONS_ROOT || process.env.NEXT_PUBLIC_LESSONS_ROOT || CommonEnvironmentHelper.LessonsRoot;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//NOTE: None of these values are secret.
|
|
45
|
-
static initStaging = () => {
|
|
46
|
-
CommonEnvironmentHelper.AttendanceApi = "https://attendanceapi.staging.churchapps.org";
|
|
47
|
-
CommonEnvironmentHelper.DoingApi = "https://doingapi.staging.churchapps.org";
|
|
48
|
-
CommonEnvironmentHelper.GivingApi = "https://givingapi.staging.churchapps.org";
|
|
49
|
-
CommonEnvironmentHelper.MembershipApi = "https://membershipapi.staging.churchapps.org";
|
|
50
|
-
CommonEnvironmentHelper.ReportingApi = "https://reportingapi.staging.churchapps.org";
|
|
51
|
-
CommonEnvironmentHelper.MessagingApi = "https://messagingapi.staging.churchapps.org";
|
|
52
|
-
CommonEnvironmentHelper.MessagingApiSocket = "wss://socket.staging.churchapps.org";
|
|
53
|
-
CommonEnvironmentHelper.ContentApi = "https://contentapi.staging.churchapps.org";
|
|
54
|
-
CommonEnvironmentHelper.GoogleAnalyticsTag = "";
|
|
55
|
-
|
|
56
|
-
CommonEnvironmentHelper.ContentRoot = "https://content.staging.churchapps.org";
|
|
57
|
-
CommonEnvironmentHelper.B1Root = "https://{key}.staging.b1.church";
|
|
58
|
-
CommonEnvironmentHelper.ChumsRoot = "https://app.staging.chums.org";
|
|
59
|
-
CommonEnvironmentHelper.LessonsRoot = "https://staging.lessons.church";
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//NOTE: None of these values are secret.
|
|
63
|
-
static initProd = () => {
|
|
64
|
-
CommonEnvironmentHelper.AttendanceApi = "https://attendanceapi.churchapps.org";
|
|
65
|
-
CommonEnvironmentHelper.DoingApi = "https://doingapi.churchapps.org";
|
|
66
|
-
CommonEnvironmentHelper.GivingApi = "https://givingapi.churchapps.org";
|
|
67
|
-
CommonEnvironmentHelper.MembershipApi = "https://membershipapi.churchapps.org";
|
|
68
|
-
CommonEnvironmentHelper.ReportingApi = "https://reportingapi.churchapps.org";
|
|
69
|
-
CommonEnvironmentHelper.MessagingApi = "https://messagingapi.churchapps.org";
|
|
70
|
-
CommonEnvironmentHelper.MessagingApiSocket = "wss://socket.churchapps.org";
|
|
71
|
-
CommonEnvironmentHelper.ContentApi = "https://contentapi.churchapps.org";
|
|
72
|
-
|
|
73
|
-
CommonEnvironmentHelper.ContentRoot = "https://content.churchapps.org";
|
|
74
|
-
CommonEnvironmentHelper.B1Root = "https://{key}.b1.church";
|
|
75
|
-
CommonEnvironmentHelper.ChumsRoot = "https://app.chums.org";
|
|
76
|
-
CommonEnvironmentHelper.LessonsRoot = "https://lessons.church";
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
1
|
+
|
|
2
|
+
export class CommonEnvironmentHelper {
|
|
3
|
+
public static AttendanceApi = "";
|
|
4
|
+
public static DoingApi = "";
|
|
5
|
+
public static GivingApi = "";
|
|
6
|
+
public static MembershipApi = "";
|
|
7
|
+
public static ReportingApi = "";
|
|
8
|
+
public static MessagingApi = "";
|
|
9
|
+
public static MessagingApiSocket = "";
|
|
10
|
+
public static ContentApi = "";
|
|
11
|
+
public static GoogleAnalyticsTag = "";
|
|
12
|
+
|
|
13
|
+
static ContentRoot = "";
|
|
14
|
+
static B1Root = "";
|
|
15
|
+
static ChumsRoot = "";
|
|
16
|
+
static LessonsRoot = "";
|
|
17
|
+
|
|
18
|
+
static init = (stage: string) => {
|
|
19
|
+
switch (stage) {
|
|
20
|
+
case "staging": CommonEnvironmentHelper.initStaging(); break;
|
|
21
|
+
case "prod": CommonEnvironmentHelper.initProd(); break;
|
|
22
|
+
default: CommonEnvironmentHelper.initDev(); break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static initDev = () => {
|
|
27
|
+
this.initStaging(); //Use staging values for anything not provided
|
|
28
|
+
CommonEnvironmentHelper.AttendanceApi = process.env.REACT_APP_ATTENDANCE_API || process.env.NEXT_PUBLIC_ATTENDANCE_API || CommonEnvironmentHelper.AttendanceApi;
|
|
29
|
+
CommonEnvironmentHelper.DoingApi = process.env.REACT_APP_DOING_API || process.env.NEXT_PUBLIC_DOING_API || CommonEnvironmentHelper.DoingApi;
|
|
30
|
+
CommonEnvironmentHelper.GivingApi = process.env.REACT_APP_GIVING_API || process.env.NEXT_PUBLIC_GIVING_API || CommonEnvironmentHelper.GivingApi;
|
|
31
|
+
CommonEnvironmentHelper.MembershipApi = process.env.REACT_APP_MEMBERSHIP_API || process.env.NEXT_PUBLIC_MEMBERSHIP_API || CommonEnvironmentHelper.MembershipApi;
|
|
32
|
+
CommonEnvironmentHelper.ReportingApi = process.env.REACT_APP_REPORTING_API || process.env.NEXT_PUBLIC_REPORTING_API || CommonEnvironmentHelper.ReportingApi;
|
|
33
|
+
CommonEnvironmentHelper.MessagingApi = process.env.REACT_APP_MESSAGING_API || process.env.NEXT_PUBLIC_MESSAGING_API || CommonEnvironmentHelper.MessagingApi;
|
|
34
|
+
CommonEnvironmentHelper.MessagingApiSocket = process.env.REACT_APP_MESSAGING_API_SOCKET || process.env.NEXT_PUBLIC_MESSAGING_API_SOCKET || CommonEnvironmentHelper.MessagingApiSocket;
|
|
35
|
+
CommonEnvironmentHelper.ContentApi = process.env.REACT_APP_CONTENT_API || process.env.NEXT_PUBLIC_CONTENT_API || CommonEnvironmentHelper.ContentApi;
|
|
36
|
+
CommonEnvironmentHelper.GoogleAnalyticsTag = process.env.REACT_APP_GOOGLE_ANALYTICS || process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS || CommonEnvironmentHelper.GoogleAnalyticsTag;
|
|
37
|
+
|
|
38
|
+
CommonEnvironmentHelper.ContentRoot = process.env.REACT_APP_CONTENT_ROOT || process.env.NEXT_PUBLIC_CONTENT_ROOT || CommonEnvironmentHelper.ContentRoot;
|
|
39
|
+
CommonEnvironmentHelper.B1Root = process.env.REACT_APP_B1_ROOT || process.env.NEXT_PUBLIC_B1_ROOT || CommonEnvironmentHelper.B1Root;
|
|
40
|
+
CommonEnvironmentHelper.ChumsRoot = process.env.REACT_APP_CHUMS_ROOT || process.env.NEXT_PUBLIC_CHUMS_ROOT || CommonEnvironmentHelper.ChumsRoot;
|
|
41
|
+
CommonEnvironmentHelper.LessonsRoot = process.env.REACT_APP_LESSONS_ROOT || process.env.NEXT_PUBLIC_LESSONS_ROOT || CommonEnvironmentHelper.LessonsRoot;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//NOTE: None of these values are secret.
|
|
45
|
+
static initStaging = () => {
|
|
46
|
+
CommonEnvironmentHelper.AttendanceApi = "https://attendanceapi.staging.churchapps.org";
|
|
47
|
+
CommonEnvironmentHelper.DoingApi = "https://doingapi.staging.churchapps.org";
|
|
48
|
+
CommonEnvironmentHelper.GivingApi = "https://givingapi.staging.churchapps.org";
|
|
49
|
+
CommonEnvironmentHelper.MembershipApi = "https://membershipapi.staging.churchapps.org";
|
|
50
|
+
CommonEnvironmentHelper.ReportingApi = "https://reportingapi.staging.churchapps.org";
|
|
51
|
+
CommonEnvironmentHelper.MessagingApi = "https://messagingapi.staging.churchapps.org";
|
|
52
|
+
CommonEnvironmentHelper.MessagingApiSocket = "wss://socket.staging.churchapps.org";
|
|
53
|
+
CommonEnvironmentHelper.ContentApi = "https://contentapi.staging.churchapps.org";
|
|
54
|
+
CommonEnvironmentHelper.GoogleAnalyticsTag = "";
|
|
55
|
+
|
|
56
|
+
CommonEnvironmentHelper.ContentRoot = "https://content.staging.churchapps.org";
|
|
57
|
+
CommonEnvironmentHelper.B1Root = "https://{key}.staging.b1.church";
|
|
58
|
+
CommonEnvironmentHelper.ChumsRoot = "https://app.staging.chums.org";
|
|
59
|
+
CommonEnvironmentHelper.LessonsRoot = "https://staging.lessons.church";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//NOTE: None of these values are secret.
|
|
63
|
+
static initProd = () => {
|
|
64
|
+
CommonEnvironmentHelper.AttendanceApi = "https://attendanceapi.churchapps.org";
|
|
65
|
+
CommonEnvironmentHelper.DoingApi = "https://doingapi.churchapps.org";
|
|
66
|
+
CommonEnvironmentHelper.GivingApi = "https://givingapi.churchapps.org";
|
|
67
|
+
CommonEnvironmentHelper.MembershipApi = "https://membershipapi.churchapps.org";
|
|
68
|
+
CommonEnvironmentHelper.ReportingApi = "https://reportingapi.churchapps.org";
|
|
69
|
+
CommonEnvironmentHelper.MessagingApi = "https://messagingapi.churchapps.org";
|
|
70
|
+
CommonEnvironmentHelper.MessagingApiSocket = "wss://socket.churchapps.org";
|
|
71
|
+
CommonEnvironmentHelper.ContentApi = "https://contentapi.churchapps.org";
|
|
72
|
+
|
|
73
|
+
CommonEnvironmentHelper.ContentRoot = "https://content.churchapps.org";
|
|
74
|
+
CommonEnvironmentHelper.B1Root = "https://{key}.b1.church";
|
|
75
|
+
CommonEnvironmentHelper.ChumsRoot = "https://app.chums.org";
|
|
76
|
+
CommonEnvironmentHelper.LessonsRoot = "https://lessons.church";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
package/src/CurrencyHelper.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export class CurrencyHelper {
|
|
2
|
-
static formatCurrency(amount: number) {
|
|
3
|
-
const formatter = new Intl.NumberFormat("en-US", {
|
|
4
|
-
style: "currency",
|
|
5
|
-
currency: "USD",
|
|
6
|
-
minimumFractionDigits: 2
|
|
7
|
-
});
|
|
8
|
-
return formatter.format(amount);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
export class CurrencyHelper {
|
|
2
|
+
static formatCurrency(amount: number) {
|
|
3
|
+
const formatter = new Intl.NumberFormat("en-US", {
|
|
4
|
+
style: "currency",
|
|
5
|
+
currency: "USD",
|
|
6
|
+
minimumFractionDigits: 2
|
|
7
|
+
});
|
|
8
|
+
return formatter.format(amount);
|
|
9
|
+
}
|
|
10
|
+
}
|