@beabee/beabee-common 1.10.22 → 1.11.0
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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertAnswers = exports.
|
|
3
|
+
exports.convertAnswers = exports.stringifyAnswer = exports.convertComponentsToFilters = exports.flattenComponents = void 0;
|
|
4
4
|
function flattenComponents(components) {
|
|
5
5
|
return components.flatMap((component) => [
|
|
6
6
|
component,
|
|
@@ -13,7 +13,7 @@ function convertValuesToOptions(values) {
|
|
|
13
13
|
}
|
|
14
14
|
function convertComponentToFilter(component) {
|
|
15
15
|
const baseItem = {
|
|
16
|
-
|
|
16
|
+
label: component.label || component.key,
|
|
17
17
|
nullable: true,
|
|
18
18
|
};
|
|
19
19
|
switch (component.type) {
|
|
@@ -56,7 +56,7 @@ function getNiceAnswer(component, value) {
|
|
|
56
56
|
return value;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function stringifyAnswer(component, answer) {
|
|
60
60
|
if (!answer) {
|
|
61
61
|
return "";
|
|
62
62
|
}
|
|
@@ -73,13 +73,14 @@ function convertAnswer(component, answer) {
|
|
|
73
73
|
return answer.toString();
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
exports.
|
|
76
|
+
exports.stringifyAnswer = stringifyAnswer;
|
|
77
77
|
function convertAnswers(formSchema, answers) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
const validComponents = flattenComponents(formSchema.components).filter((c) => c.input);
|
|
79
|
+
const labels = validComponents.map((c) => [c.key, c.label || c.key]);
|
|
80
|
+
const values = validComponents.map((c) => [c.key, stringifyAnswer(c, answers[c.key])]);
|
|
81
|
+
return {
|
|
82
|
+
labels: Object.fromEntries(labels),
|
|
83
|
+
values: Object.fromEntries(values),
|
|
84
|
+
};
|
|
84
85
|
}
|
|
85
86
|
exports.convertAnswers = convertAnswers;
|
|
@@ -4,12 +4,12 @@ exports.calcPaymentFee = void 0;
|
|
|
4
4
|
const data_1 = require("../data");
|
|
5
5
|
const stripeFees = {
|
|
6
6
|
gb: {
|
|
7
|
-
[data_1.PaymentMethod.StripeCard]: (amount) => 0.2 + 0.
|
|
7
|
+
[data_1.PaymentMethod.StripeCard]: (amount) => 0.2 + 0.015 * amount,
|
|
8
8
|
[data_1.PaymentMethod.StripeSEPA]: () => 0.3,
|
|
9
|
-
[data_1.PaymentMethod.StripeBACS]: (amount) => 0.2
|
|
9
|
+
[data_1.PaymentMethod.StripeBACS]: (amount) => Math.min(2, Math.max(0.2, 0.01 * amount)),
|
|
10
10
|
},
|
|
11
11
|
eu: {
|
|
12
|
-
[data_1.PaymentMethod.StripeCard]: (amount) => 0.25 + 0.
|
|
12
|
+
[data_1.PaymentMethod.StripeCard]: (amount) => 0.25 + 0.015 * amount,
|
|
13
13
|
[data_1.PaymentMethod.StripeSEPA]: () => 0.35,
|
|
14
14
|
[data_1.PaymentMethod.StripeBACS]: () => 0, // Not available
|
|
15
15
|
},
|
|
@@ -19,7 +19,7 @@ const stripeFees = {
|
|
|
19
19
|
[data_1.PaymentMethod.StripeBACS]: () => 0, // Not available
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
|
-
const gcFee = (amount) => 0.2 + amount
|
|
22
|
+
const gcFee = (amount) => 0.2 + amount * 0.01;
|
|
23
23
|
function calcPaymentFee(feeable, country) {
|
|
24
24
|
const feeFn = feeable.paymentMethod === data_1.PaymentMethod.GoCardlessDirectDebit
|
|
25
25
|
? gcFee
|
|
@@ -9,7 +9,7 @@ function convertValuesToOptions(values) {
|
|
|
9
9
|
}
|
|
10
10
|
function convertComponentToFilter(component) {
|
|
11
11
|
const baseItem = {
|
|
12
|
-
|
|
12
|
+
label: component.label || component.key,
|
|
13
13
|
nullable: true,
|
|
14
14
|
};
|
|
15
15
|
switch (component.type) {
|
|
@@ -51,7 +51,7 @@ function getNiceAnswer(component, value) {
|
|
|
51
51
|
return value;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
export function
|
|
54
|
+
export function stringifyAnswer(component, answer) {
|
|
55
55
|
if (!answer) {
|
|
56
56
|
return "";
|
|
57
57
|
}
|
|
@@ -69,10 +69,11 @@ export function convertAnswer(component, answer) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
export function convertAnswers(formSchema, answers) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
const validComponents = flattenComponents(formSchema.components).filter((c) => c.input);
|
|
73
|
+
const labels = validComponents.map((c) => [c.key, c.label || c.key]);
|
|
74
|
+
const values = validComponents.map((c) => [c.key, stringifyAnswer(c, answers[c.key])]);
|
|
75
|
+
return {
|
|
76
|
+
labels: Object.fromEntries(labels),
|
|
77
|
+
values: Object.fromEntries(values),
|
|
78
|
+
};
|
|
78
79
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ContributionPeriod, PaymentMethod } from "../data";
|
|
2
2
|
const stripeFees = {
|
|
3
3
|
gb: {
|
|
4
|
-
[PaymentMethod.StripeCard]: (amount) => 0.2 + 0.
|
|
4
|
+
[PaymentMethod.StripeCard]: (amount) => 0.2 + 0.015 * amount,
|
|
5
5
|
[PaymentMethod.StripeSEPA]: () => 0.3,
|
|
6
|
-
[PaymentMethod.StripeBACS]: (amount) => 0.2
|
|
6
|
+
[PaymentMethod.StripeBACS]: (amount) => Math.min(2, Math.max(0.2, 0.01 * amount)),
|
|
7
7
|
},
|
|
8
8
|
eu: {
|
|
9
|
-
[PaymentMethod.StripeCard]: (amount) => 0.25 + 0.
|
|
9
|
+
[PaymentMethod.StripeCard]: (amount) => 0.25 + 0.015 * amount,
|
|
10
10
|
[PaymentMethod.StripeSEPA]: () => 0.35,
|
|
11
11
|
[PaymentMethod.StripeBACS]: () => 0, // Not available
|
|
12
12
|
},
|
|
@@ -16,7 +16,7 @@ const stripeFees = {
|
|
|
16
16
|
[PaymentMethod.StripeBACS]: () => 0, // Not available
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
|
-
const gcFee = (amount) => 0.2 + amount
|
|
19
|
+
const gcFee = (amount) => 0.2 + amount * 0.01;
|
|
20
20
|
export function calcPaymentFee(feeable, country) {
|
|
21
21
|
const feeFn = feeable.paymentMethod === PaymentMethod.GoCardlessDirectDebit
|
|
22
22
|
? gcFee
|
|
@@ -2,5 +2,8 @@ import { CalloutComponentSchema, CalloutFormSchema, CalloutResponseAnswer, Callo
|
|
|
2
2
|
import { Filters } from "../search";
|
|
3
3
|
export declare function flattenComponents(components: CalloutComponentSchema[]): CalloutComponentSchema[];
|
|
4
4
|
export declare function convertComponentsToFilters(components: CalloutComponentSchema[]): Filters;
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function convertAnswers(formSchema: CalloutFormSchema, answers: CalloutResponseAnswers):
|
|
5
|
+
export declare function stringifyAnswer(component: CalloutComponentSchema, answer: CalloutResponseAnswer): string;
|
|
6
|
+
export declare function convertAnswers(formSchema: CalloutFormSchema, answers: CalloutResponseAnswers): {
|
|
7
|
+
labels: Record<string, string>;
|
|
8
|
+
values: Record<string, string>;
|
|
9
|
+
};
|