@churchapps/apphelper 0.4.11 → 0.4.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.
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import type { PaperProps } from "@mui/material/Paper";
3
+ interface Props {
4
+ churchId: string;
5
+ mainContainerCssProps?: PaperProps;
6
+ showHeader?: boolean;
7
+ recaptchaSiteKey: string;
8
+ churchLogo?: string;
9
+ }
10
+ export declare const NonAuthDonation: React.FC<Props>;
11
+ export {};
12
+ //# sourceMappingURL=NonAuthDonation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NonAuthDonation.d.ts","sourceRoot":"","sources":["../../../src/donationComponents/components/NonAuthDonation.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,UAAU,KAAK;IAAG,QAAQ,EAAE,MAAM,CAAC;IAAC,qBAAqB,CAAC,EAAE,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;AAE7I,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAoB3C,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.NonAuthDonation = void 0;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const react_1 = __importDefault(require("react"));
10
+ const react_stripe_js_1 = require("@stripe/react-stripe-js");
11
+ const stripe_js_1 = require("@stripe/stripe-js");
12
+ const helpers_1 = require("../../helpers");
13
+ const NonAuthDonationInner_1 = require("./NonAuthDonationInner");
14
+ const NonAuthDonation = ({ mainContainerCssProps, showHeader, ...props }) => {
15
+ const [stripePromise, setStripe] = react_1.default.useState(null);
16
+ const init = () => {
17
+ helpers_1.ApiHelper.get("/gateways/churchId/" + props.churchId, "GivingApi").then(data => {
18
+ if (data.length && data[0]?.publicKey) {
19
+ setStripe((0, stripe_js_1.loadStripe)(data[0].publicKey));
20
+ }
21
+ });
22
+ };
23
+ react_1.default.useEffect(init, []); //eslint-disable-line
24
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.Elements, { stripe: stripePromise, children: (0, jsx_runtime_1.jsx)(NonAuthDonationInner_1.NonAuthDonationInner, { churchId: props.churchId, mainContainerCssProps: mainContainerCssProps, showHeader: showHeader, recaptchaSiteKey: props.recaptchaSiteKey, churchLogo: props?.churchLogo }) }) }));
25
+ };
26
+ exports.NonAuthDonation = NonAuthDonation;
27
+ //# sourceMappingURL=NonAuthDonation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NonAuthDonation.js","sourceRoot":"","sources":["../../../src/donationComponents/components/NonAuthDonation.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,kDAA0B;AAC1B,6DAAmD;AACnD,iDAA+C;AAE/C,2CAA0C;AAC1C,iEAA8D;AAKvD,MAAM,eAAe,GAAoB,CAAC,EAAE,qBAAqB,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAClG,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAkB,IAAI,CAAC,CAAC;IAEzE,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,mBAAS,CAAC,GAAG,CAAC,qBAAqB,GAAG,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAC7E,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;gBACtC,SAAS,CAAC,IAAA,sBAAU,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,eAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,qBAAqB;IAEhD,OAAO,CACL,2DACE,uBAAC,0BAAQ,IAAC,MAAM,EAAE,aAAa,YAC7B,uBAAC,2CAAoB,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAI,GACxL,GACV,CACJ,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,eAAe,mBAoB1B"}
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import type { PaperProps } from "@mui/material/Paper";
3
+ interface Props {
4
+ churchId: string;
5
+ mainContainerCssProps?: PaperProps;
6
+ showHeader?: boolean;
7
+ recaptchaSiteKey: string;
8
+ churchLogo?: string;
9
+ }
10
+ export declare const NonAuthDonationInner: React.FC<Props>;
11
+ export {};
12
+ //# sourceMappingURL=NonAuthDonationInner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NonAuthDonationInner.d.ts","sourceRoot":"","sources":["../../../src/donationComponents/components/NonAuthDonationInner.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,UAAU,KAAK;IAAG,QAAQ,EAAE,MAAM,CAAC;IAAC,qBAAqB,CAAC,EAAE,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;AAE7I,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2RhD,CAAC"}
@@ -0,0 +1,277 @@
1
+ "use client";
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.NonAuthDonationInner = void 0;
41
+ const jsx_runtime_1 = require("react/jsx-runtime");
42
+ const react_stripe_js_1 = require("@stripe/react-stripe-js");
43
+ const react_1 = __importStar(require("react"));
44
+ const react_google_recaptcha_1 = __importDefault(require("react-google-recaptcha"));
45
+ const components_1 = require("../../components");
46
+ const _1 = require(".");
47
+ const helpers_1 = require("../../helpers");
48
+ const material_1 = require("@mui/material");
49
+ const NonAuthDonationInner = ({ mainContainerCssProps, showHeader = true, ...props }) => {
50
+ const stripe = (0, react_stripe_js_1.useStripe)();
51
+ const elements = (0, react_stripe_js_1.useElements)();
52
+ const formStyling = { style: { base: { fontSize: "18px" } } };
53
+ const [firstName, setFirstName] = react_1.default.useState("");
54
+ const [lastName, setLastName] = react_1.default.useState("");
55
+ const [email, setEmail] = react_1.default.useState("");
56
+ const [fundsTotal, setFundsTotal] = react_1.default.useState(0);
57
+ const [transactionFee, setTransactionFee] = react_1.default.useState(0);
58
+ const [total, setTotal] = react_1.default.useState(0);
59
+ const [errors, setErrors] = react_1.default.useState([]);
60
+ const [fundDonations, setFundDonations] = react_1.default.useState([]);
61
+ const [funds, setFunds] = react_1.default.useState([]);
62
+ const [donationComplete, setDonationComplete] = react_1.default.useState(false);
63
+ const [processing, setProcessing] = react_1.default.useState(false);
64
+ const [donationType, setDonationType] = (0, react_1.useState)("once");
65
+ const [interval, setInterval] = (0, react_1.useState)("one_month");
66
+ const [startDate, setStartDate] = (0, react_1.useState)(new Date().toDateString());
67
+ const [captchaResponse, setCaptchaResponse] = (0, react_1.useState)("");
68
+ const [church, setChurch] = (0, react_1.useState)();
69
+ const [gateway, setGateway] = react_1.default.useState(null);
70
+ const [searchParams, setSearchParams] = react_1.default.useState();
71
+ const captchaRef = (0, react_1.useRef)(null);
72
+ const getUrlParam = (param) => {
73
+ if (typeof window === "undefined")
74
+ return null;
75
+ const urlParams = new URLSearchParams(window.location.search);
76
+ return urlParams.get(param);
77
+ };
78
+ const init = () => {
79
+ const fundId = getUrlParam("fundId");
80
+ const amount = getUrlParam("amount");
81
+ setSearchParams({ fundId, amount });
82
+ helpers_1.ApiHelper.get("/funds/churchId/" + props.churchId, "GivingApi").then(data => {
83
+ setFunds(data);
84
+ if (fundId && fundId !== "") {
85
+ const selectedFund = data.find((f) => f.id === fundId);
86
+ if (selectedFund) {
87
+ setFundDonations([{ fundId: selectedFund.id, amount: (amount && amount !== "") ? parseFloat(amount) : 0 }]);
88
+ }
89
+ }
90
+ else if (data.length) {
91
+ setFundDonations([{ fundId: data[0].id }]);
92
+ }
93
+ });
94
+ helpers_1.ApiHelper.get("/churches/" + props.churchId, "MembershipApi").then(data => {
95
+ setChurch(data);
96
+ });
97
+ helpers_1.ApiHelper.get("/gateways/churchId/" + props.churchId, "GivingApi").then(data => {
98
+ if (data.length !== 0)
99
+ setGateway(data[0]);
100
+ });
101
+ };
102
+ const handleCaptchaChange = (value) => {
103
+ const captchaToken = captchaRef.current.getValue();
104
+ helpers_1.ApiHelper.postAnonymous("/donate/captcha-verify", { token: captchaToken }, "GivingApi").then((data) => { setCaptchaResponse(data.response); });
105
+ };
106
+ const handleCheckChange = (e, checked) => {
107
+ const totalPayAmount = checked ? fundsTotal + transactionFee : fundsTotal;
108
+ setTotal(totalPayAmount);
109
+ };
110
+ // const handleAutoPayFee = () => {
111
+ // let totalPayAmount = fundsTotal + transactionFee;
112
+ // setTotal(totalPayAmount);
113
+ // }
114
+ const handleSave = async () => {
115
+ if (validate()) {
116
+ setProcessing(true);
117
+ helpers_1.ApiHelper.post("/users/loadOrCreate", { userEmail: email, firstName, lastName }, "MembershipApi")
118
+ .catch(ex => { setErrors([ex.toString()]); setProcessing(false); })
119
+ .then(async (userData) => {
120
+ const personData = { churchId: props.churchId, firstName, lastName, email };
121
+ const person = await helpers_1.ApiHelper.post("/people/loadOrCreate", personData, "MembershipApi");
122
+ saveCard(userData, person);
123
+ });
124
+ }
125
+ };
126
+ const saveCard = async (user, person) => {
127
+ const cardData = elements.getElement(react_stripe_js_1.CardElement);
128
+ const stripePM = await stripe.createPaymentMethod({ type: "card", card: cardData });
129
+ if (stripePM.error) {
130
+ setErrors([stripePM.error.message]);
131
+ setProcessing(false);
132
+ }
133
+ else {
134
+ const pm = { id: stripePM.paymentMethod.id, personId: person.id, email: email, name: person.name.display, churchId: props.churchId };
135
+ await helpers_1.ApiHelper.post("/paymentmethods/addcard", pm, "GivingApi").then(result => {
136
+ if (result?.raw?.message) {
137
+ setErrors([result.raw.message]);
138
+ setProcessing(false);
139
+ }
140
+ else {
141
+ const d = result;
142
+ saveDonation(d.paymentMethod, d.customerId, person);
143
+ }
144
+ });
145
+ }
146
+ };
147
+ const saveDonation = async (paymentMethod, customerId, person) => {
148
+ const donation = {
149
+ amount: total,
150
+ id: paymentMethod.id,
151
+ customerId: customerId,
152
+ type: paymentMethod.type,
153
+ churchId: props.churchId,
154
+ funds: [],
155
+ person: {
156
+ id: person?.id,
157
+ email: person?.contactInfo?.email,
158
+ name: person?.name?.display
159
+ }
160
+ };
161
+ if (donationType === "recurring") {
162
+ donation.billing_cycle_anchor = +new Date(startDate);
163
+ donation.interval = helpers_1.DonationHelper.getInterval(interval);
164
+ }
165
+ for (const fundDonation of fundDonations) {
166
+ const fund = funds.find((fund) => fund.id === fundDonation.fundId);
167
+ donation.funds.push({ id: fundDonation.fundId, amount: fundDonation.amount || 0, name: fund.name });
168
+ }
169
+ const churchObj = {
170
+ name: church.name,
171
+ subDomain: church.subDomain,
172
+ churchURL: typeof window !== "undefined" && window.location.origin,
173
+ logo: props?.churchLogo
174
+ };
175
+ let results;
176
+ if (donationType === "once")
177
+ results = await helpers_1.ApiHelper.post("/donate/charge/", { ...donation, church: churchObj }, "GivingApi");
178
+ if (donationType === "recurring")
179
+ results = await helpers_1.ApiHelper.post("/donate/subscribe/", { ...donation, church: churchObj }, "GivingApi");
180
+ if (results?.status === "succeeded" || results?.status === "pending" || results?.status === "active") {
181
+ setDonationComplete(true);
182
+ }
183
+ if (results?.raw?.message) {
184
+ setErrors([results?.raw?.message]);
185
+ setProcessing(false);
186
+ }
187
+ setProcessing(false);
188
+ };
189
+ const validate = () => {
190
+ const result = [];
191
+ if (!firstName)
192
+ result.push(helpers_1.Locale.label("donation.donationForm.validate.firstName"));
193
+ if (!lastName)
194
+ result.push(helpers_1.Locale.label("donation.donationForm.validate.lastName"));
195
+ if (!email)
196
+ result.push(helpers_1.Locale.label("donation.donationForm.validate.email"));
197
+ if (fundsTotal === 0)
198
+ result.push(helpers_1.Locale.label("donation.donationForm.validate.amount"));
199
+ if (result.length === 0) {
200
+ if (!email.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w+)+$/))
201
+ result.push(helpers_1.Locale.label("donation.donationForm.validate.validEmail")); //eslint-disable-line
202
+ }
203
+ //Todo - make sure the account doesn't exist. (loadOrCreate?)
204
+ setErrors(result);
205
+ return result.length === 0;
206
+ };
207
+ const handleChange = (e) => {
208
+ const val = e.currentTarget.value;
209
+ switch (e.currentTarget.name) {
210
+ case "firstName":
211
+ setFirstName(val);
212
+ break;
213
+ case "lastName":
214
+ setLastName(val);
215
+ break;
216
+ case "email":
217
+ setEmail(val);
218
+ break;
219
+ case "startDate":
220
+ setStartDate(val);
221
+ break;
222
+ case "interval":
223
+ setInterval(val);
224
+ break;
225
+ }
226
+ };
227
+ const handleFundDonationsChange = async (fd) => {
228
+ setFundDonations(fd);
229
+ let totalAmount = 0;
230
+ const selectedFunds = [];
231
+ for (const fundDonation of fd) {
232
+ totalAmount += fundDonation.amount || 0;
233
+ const fund = funds.find((fund) => fund.id === fundDonation.fundId);
234
+ selectedFunds.push({ id: fundDonation.fundId, amount: fundDonation.amount || 0, name: fund.name });
235
+ }
236
+ setFundsTotal(totalAmount);
237
+ setTotal(totalAmount);
238
+ const fee = await getTransactionFee(totalAmount);
239
+ setTransactionFee(fee);
240
+ if (gateway && gateway.payFees === true) {
241
+ setTotal(totalAmount + fee);
242
+ }
243
+ };
244
+ const getTransactionFee = async (amount) => {
245
+ if (amount > 0) {
246
+ try {
247
+ const response = await helpers_1.ApiHelper.post("/donate/fee?churchId=" + props.churchId, { type: "creditCard", amount }, "GivingApi");
248
+ return response.calculatedFee;
249
+ }
250
+ catch (error) {
251
+ console.log("Error calculating transaction fee: ", error);
252
+ return 0;
253
+ }
254
+ }
255
+ else {
256
+ return 0;
257
+ }
258
+ };
259
+ const getFundList = () => {
260
+ if (funds) {
261
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("hr", {}), (0, jsx_runtime_1.jsx)("h4", { children: helpers_1.Locale.label("donation.donationForm.funds") }), (0, jsx_runtime_1.jsx)(_1.FundDonations, { fundDonations: fundDonations, funds: funds, params: searchParams, updatedFunction: handleFundDonationsChange })] }));
262
+ }
263
+ };
264
+ react_1.default.useEffect(init, []); //eslint-disable-line
265
+ // React.useEffect(() => { gateway && gateway.payFees === true && handleAutoPayFee() }, [fundDonations]);
266
+ if (donationComplete)
267
+ return (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", children: helpers_1.Locale.label("donation.donationForm.thankYou") });
268
+ else {
269
+ return ((0, jsx_runtime_1.jsxs)(components_1.InputBox, { headerIcon: showHeader ? "volunteer_activism" : "", headerText: showHeader ? "Donate" : "", saveFunction: handleSave, saveText: "Donate", isSubmitting: processing || !captchaResponse || captchaResponse === "robot", mainContainerCssProps: mainContainerCssProps, children: [(0, jsx_runtime_1.jsx)(components_1.ErrorMessages, { errors: errors }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 3, children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { size: { xs: 12, md: 6 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { "aria-label": "single-donation", size: "small", fullWidth: true, style: { minHeight: "50px" }, variant: donationType === "once" ? "contained" : "outlined", onClick: () => setDonationType("once"), children: helpers_1.Locale.label("donation.donationForm.make") }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { size: { xs: 12, md: 6 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { "aria-label": "recurring-donation", size: "small", fullWidth: true, style: { minHeight: "50px" }, variant: donationType === "recurring" ? "contained" : "outlined", onClick: () => setDonationType("recurring"), children: helpers_1.Locale.label("donation.donationForm.makeRecurring") }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { size: { xs: 12, md: 6 }, children: (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, label: helpers_1.Locale.label("person.firstName"), name: "firstName", value: firstName, onChange: handleChange }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { size: { xs: 12, md: 6 }, children: (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, label: helpers_1.Locale.label("person.lastName"), name: "lastName", value: lastName, onChange: handleChange }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { size: { xs: 12, md: 6 }, children: (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, label: helpers_1.Locale.label("person.email"), name: "email", value: email, onChange: handleChange }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { size: { xs: 12, md: 6 }, children: (0, jsx_runtime_1.jsx)(react_google_recaptcha_1.default, { sitekey: props.recaptchaSiteKey, ref: captchaRef, onChange: handleCaptchaChange }) })] }), (0, jsx_runtime_1.jsx)("div", { style: { padding: 10, border: "1px solid #CCC", borderRadius: 5, marginTop: 10 }, children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.CardElement, { options: formStyling }) }), donationType === "recurring"
270
+ && (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 3, style: { marginTop: 0 }, children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { size: { xs: 12, md: 6 }, children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: helpers_1.Locale.label("donation.donationForm.frequency") }), (0, jsx_runtime_1.jsxs)(material_1.Select, { label: "Frequency", name: "interval", "aria-label": "interval", value: interval, onChange: (e) => { setInterval(e.target.value); }, children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "one_week", children: helpers_1.Locale.label("donation.donationForm.weekly") }), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "two_week", children: helpers_1.Locale.label("donation.donationForm.biWeekly") }), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "one_month", children: helpers_1.Locale.label("donation.donationForm.monthly") }), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "three_month", children: helpers_1.Locale.label("donation.donationForm.quarterly") }), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "one_year", children: helpers_1.Locale.label("donation.donationForm.annually") })] })] }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { size: { xs: 12, md: 6 }, children: (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, name: "startDate", type: "date", "aria-label": "startDate", label: helpers_1.Locale.label("donation.donationForm.startDate"), value: helpers_1.DateHelper.formatHtml5Date(new Date(startDate)), onChange: handleChange }) })] }), getFundList(), (0, jsx_runtime_1.jsx)("div", { children: fundsTotal > 0
271
+ && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(gateway && gateway.payFees === true)
272
+ ? (0, jsx_runtime_1.jsxs)(material_1.Typography, { fontSize: 14, fontStyle: "italic", children: ["*", helpers_1.Locale.label("donation.donationForm.fees").replace("{}", helpers_1.CurrencyHelper.formatCurrency(transactionFee))] })
273
+ : ((0, jsx_runtime_1.jsx)(material_1.FormGroup, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, {}), name: "transaction-fee", label: helpers_1.Locale.label("donation.donationForm.cover").replace("{}", helpers_1.CurrencyHelper.formatCurrency(transactionFee)), onChange: handleCheckChange }) })), (0, jsx_runtime_1.jsxs)("p", { children: ["Total Donation Amount: $", total] })] }) })] }));
274
+ }
275
+ };
276
+ exports.NonAuthDonationInner = NonAuthDonationInner;
277
+ //# sourceMappingURL=NonAuthDonationInner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NonAuthDonationInner.js","sourceRoot":"","sources":["../../../src/donationComponents/components/NonAuthDonationInner.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;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,CAAC,OAAO,CAAC,IAAI,EAAE,wBAAc,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,IAAc;oCACtK,CAAC,CAAC,CACA,uBAAC,oBAAS,cACR,uBAAC,2BAAgB,IAAC,OAAO,EAAE,uBAAC,mBAAQ,KAAG,EAAE,IAAI,EAAC,iBAAiB,EAAC,KAAK,EAAE,gBAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,wBAAc,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,iBAAiB,GAAI,GACtM,CACb,EACH,sEAA4B,KAAK,IAAK,IACrC,GAED,IACG,CACZ,CAAC;IACJ,CAAC;AACD,CAAC,CAAC;AA3RW,QAAA,oBAAoB,wBA2R/B"}
@@ -3,6 +3,8 @@ export { CardForm } from "./CardForm";
3
3
  export { DonationForm } from "./DonationForm";
4
4
  export { FundDonation } from "./FundDonation";
5
5
  export { FundDonations } from "./FundDonations";
6
+ export { NonAuthDonation } from "./NonAuthDonation";
7
+ export { NonAuthDonationInner } from "./NonAuthDonationInner";
6
8
  export { PaymentMethods } from "./PaymentMethods";
7
9
  export { RecurringDonations } from "./RecurringDonations";
8
10
  export { RecurringDonationsEdit } from "./RecurringDonationsEdit";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/donationComponents/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/donationComponents/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RecurringDonationsEdit = exports.RecurringDonations = exports.PaymentMethods = exports.FundDonations = exports.FundDonation = exports.DonationForm = exports.CardForm = exports.BankForm = void 0;
3
+ exports.RecurringDonationsEdit = exports.RecurringDonations = exports.PaymentMethods = exports.NonAuthDonationInner = exports.NonAuthDonation = exports.FundDonations = exports.FundDonation = exports.DonationForm = exports.CardForm = exports.BankForm = void 0;
4
4
  var BankForm_1 = require("./BankForm");
5
5
  Object.defineProperty(exports, "BankForm", { enumerable: true, get: function () { return BankForm_1.BankForm; } });
6
6
  var CardForm_1 = require("./CardForm");
@@ -11,6 +11,10 @@ var FundDonation_1 = require("./FundDonation");
11
11
  Object.defineProperty(exports, "FundDonation", { enumerable: true, get: function () { return FundDonation_1.FundDonation; } });
12
12
  var FundDonations_1 = require("./FundDonations");
13
13
  Object.defineProperty(exports, "FundDonations", { enumerable: true, get: function () { return FundDonations_1.FundDonations; } });
14
+ var NonAuthDonation_1 = require("./NonAuthDonation");
15
+ Object.defineProperty(exports, "NonAuthDonation", { enumerable: true, get: function () { return NonAuthDonation_1.NonAuthDonation; } });
16
+ var NonAuthDonationInner_1 = require("./NonAuthDonationInner");
17
+ Object.defineProperty(exports, "NonAuthDonationInner", { enumerable: true, get: function () { return NonAuthDonationInner_1.NonAuthDonationInner; } });
14
18
  var PaymentMethods_1 = require("./PaymentMethods");
15
19
  Object.defineProperty(exports, "PaymentMethods", { enumerable: true, get: function () { return PaymentMethods_1.PaymentMethods; } });
16
20
  var RecurringDonations_1 = require("./RecurringDonations");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/donationComponents/components/index.tsx"],"names":[],"mappings":";;;AAAA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/donationComponents/components/index.tsx"],"names":[],"mappings":";;;AAAA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchapps/apphelper",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "description": "Library of helper functions for React and NextJS ChurchApps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,34 @@
1
+ "use client";
2
+
3
+ import React from "react";
4
+ import { Elements } from "@stripe/react-stripe-js";
5
+ import { loadStripe } from "@stripe/stripe-js";
6
+ import type { Stripe } from "@stripe/stripe-js";
7
+ import { ApiHelper } from "../../helpers";
8
+ import { NonAuthDonationInner } from "./NonAuthDonationInner";
9
+ import type { PaperProps } from "@mui/material/Paper";
10
+
11
+ interface Props { churchId: string, mainContainerCssProps?: PaperProps, showHeader?: boolean, recaptchaSiteKey: string, churchLogo?: string }
12
+
13
+ export const NonAuthDonation: React.FC<Props> = ({ mainContainerCssProps, showHeader, ...props }) => {
14
+ const [stripePromise, setStripe] = React.useState<Promise<Stripe>>(null);
15
+
16
+ const init = () => {
17
+ ApiHelper.get("/gateways/churchId/" + props.churchId, "GivingApi").then(data => {
18
+ if (data.length && data[0]?.publicKey) {
19
+ setStripe(loadStripe(data[0].publicKey));
20
+ }
21
+ });
22
+ };
23
+
24
+ React.useEffect(init, []); //eslint-disable-line
25
+
26
+ return (
27
+ <>
28
+ <Elements stripe={stripePromise}>
29
+ <NonAuthDonationInner churchId={props.churchId} mainContainerCssProps={mainContainerCssProps} showHeader={showHeader} recaptchaSiteKey={props.recaptchaSiteKey} churchLogo={props?.churchLogo} />
30
+ </Elements>
31
+ </>
32
+ );
33
+ };
34
+
@@ -0,0 +1,300 @@
1
+ "use client";
2
+
3
+ import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js";
4
+ import React, { useState, useRef } from "react";
5
+ import ReCAPTCHA from "react-google-recaptcha";
6
+ import { ErrorMessages, InputBox } from "../../components";
7
+ import { FundDonations } from ".";
8
+ import { ApiHelper, DateHelper, CurrencyHelper, Locale, DonationHelper } from "../../helpers";
9
+ import { FundDonationInterface, FundInterface, PersonInterface, StripeDonationInterface, StripePaymentMethod, UserInterface, ChurchInterface } from "@churchapps/helpers";
10
+ import {
11
+ Grid, Alert, TextField, Button, FormControl, InputLabel, Select, MenuItem, FormGroup, FormControlLabel, Checkbox, Typography
12
+ } from "@mui/material";
13
+ import type { PaperProps } from "@mui/material/Paper";
14
+
15
+ interface Props { churchId: string, mainContainerCssProps?: PaperProps, showHeader?: boolean, recaptchaSiteKey: string, churchLogo?: string }
16
+
17
+ export const NonAuthDonationInner: React.FC<Props> = ({ mainContainerCssProps, showHeader = true, ...props }) => {
18
+ const stripe = useStripe();
19
+ const elements = useElements();
20
+ const formStyling = { style: { base: { fontSize: "18px" } } };
21
+ const [firstName, setFirstName] = React.useState("");
22
+ const [lastName, setLastName] = React.useState("");
23
+ const [email, setEmail] = React.useState("");
24
+ const [fundsTotal, setFundsTotal] = React.useState<number>(0);
25
+ const [transactionFee, setTransactionFee] = React.useState<number>(0);
26
+ const [total, setTotal] = React.useState<number>(0);
27
+ const [errors, setErrors] = React.useState([]);
28
+ const [fundDonations, setFundDonations] = React.useState<FundDonationInterface[]>([]);
29
+ const [funds, setFunds] = React.useState<FundInterface[]>([]);
30
+ const [donationComplete, setDonationComplete] = React.useState(false);
31
+ const [processing, setProcessing] = React.useState(false);
32
+ const [donationType, setDonationType] = useState<"once" | "recurring">("once");
33
+ const [interval, setInterval] = useState("one_month");
34
+ const [startDate, setStartDate] = useState(new Date().toDateString());
35
+ const [captchaResponse, setCaptchaResponse] = useState("");
36
+ const [church, setChurch] = useState<ChurchInterface>();
37
+ const [gateway, setGateway] = React.useState(null);
38
+ const [searchParams, setSearchParams] = React.useState<any>();
39
+ const captchaRef = useRef(null);
40
+
41
+ const getUrlParam = (param: string) => {
42
+ if (typeof window === "undefined") return null;
43
+ const urlParams = new URLSearchParams(window.location.search);
44
+ return urlParams.get(param);
45
+ };
46
+
47
+ const init = () => {
48
+ const fundId = getUrlParam("fundId");
49
+ const amount = getUrlParam("amount");
50
+ setSearchParams({ fundId, amount });
51
+
52
+ ApiHelper.get("/funds/churchId/" + props.churchId, "GivingApi").then(data => {
53
+ setFunds(data);
54
+ if (fundId && fundId !== "") {
55
+ const selectedFund = data.find((f: FundInterface) => f.id === fundId);
56
+ if (selectedFund) {
57
+ setFundDonations([{ fundId: selectedFund.id, amount: (amount && amount !== "") ? parseFloat(amount) : 0 }]);
58
+ }
59
+ } else if (data.length) {
60
+ setFundDonations([{ fundId: data[0].id }]);
61
+ }
62
+ });
63
+ ApiHelper.get("/churches/" + props.churchId, "MembershipApi").then(data => {
64
+ setChurch(data);
65
+ });
66
+ ApiHelper.get("/gateways/churchId/" + props.churchId, "GivingApi").then(data => {
67
+ if (data.length !== 0) setGateway(data[0]);
68
+ });
69
+ };
70
+
71
+ const handleCaptchaChange = (value: string) => {
72
+ const captchaToken = captchaRef.current.getValue();
73
+ ApiHelper.postAnonymous("/donate/captcha-verify", { token: captchaToken }, "GivingApi").then((data) => { setCaptchaResponse(data.response); });
74
+ };
75
+
76
+ const handleCheckChange = (e: React.SyntheticEvent<Element, Event>, checked: boolean) => {
77
+ const totalPayAmount = checked ? fundsTotal + transactionFee : fundsTotal;
78
+ setTotal(totalPayAmount);
79
+ };
80
+
81
+ // const handleAutoPayFee = () => {
82
+ // let totalPayAmount = fundsTotal + transactionFee;
83
+ // setTotal(totalPayAmount);
84
+ // }
85
+
86
+ const handleSave = async () => {
87
+ if (validate()) {
88
+ setProcessing(true);
89
+ ApiHelper.post("/users/loadOrCreate", { userEmail: email, firstName, lastName }, "MembershipApi")
90
+ .catch(ex => { setErrors([ex.toString()]); setProcessing(false); })
91
+ .then(async userData => {
92
+ const personData = { churchId: props.churchId, firstName, lastName, email };
93
+ const person = await ApiHelper.post("/people/loadOrCreate", personData, "MembershipApi");
94
+ saveCard(userData, person);
95
+ });
96
+ }
97
+ };
98
+
99
+ const saveCard = async (user: UserInterface, person: PersonInterface) => {
100
+ const cardData = elements.getElement(CardElement);
101
+ const stripePM = await stripe.createPaymentMethod({ type: "card", card: cardData });
102
+ if (stripePM.error) { setErrors([stripePM.error.message]); setProcessing(false); } else {
103
+ const pm = { id: stripePM.paymentMethod.id, personId: person.id, email: email, name: person.name.display, churchId: props.churchId };
104
+ await ApiHelper.post("/paymentmethods/addcard", pm, "GivingApi").then(result => {
105
+ if (result?.raw?.message) {
106
+ setErrors([result.raw.message]);
107
+ setProcessing(false);
108
+ } else {
109
+ const d: { paymentMethod: StripePaymentMethod, customerId: string } = result;
110
+ saveDonation(d.paymentMethod, d.customerId, person);
111
+ }
112
+ });
113
+ }
114
+ };
115
+
116
+ const saveDonation = async (paymentMethod: StripePaymentMethod, customerId: string, person?: PersonInterface) => {
117
+ const donation: StripeDonationInterface = {
118
+ amount: total,
119
+ id: paymentMethod.id,
120
+ customerId: customerId,
121
+ type: paymentMethod.type,
122
+ churchId: props.churchId,
123
+ funds: [],
124
+ person: {
125
+ id: person?.id,
126
+ email: person?.contactInfo?.email,
127
+ name: person?.name?.display
128
+ }
129
+ };
130
+
131
+ if (donationType === "recurring") {
132
+ donation.billing_cycle_anchor = + new Date(startDate);
133
+ donation.interval = DonationHelper.getInterval(interval);
134
+ }
135
+
136
+ for (const fundDonation of fundDonations) {
137
+ const fund = funds.find((fund: FundInterface) => fund.id === fundDonation.fundId);
138
+ donation.funds.push({ id: fundDonation.fundId, amount: fundDonation.amount || 0, name: fund.name });
139
+ }
140
+
141
+ const churchObj = {
142
+ name: church.name,
143
+ subDomain: church.subDomain,
144
+ churchURL: typeof window !== "undefined" && window.location.origin,
145
+ logo: props?.churchLogo
146
+ };
147
+
148
+ let results;
149
+ if (donationType === "once") results = await ApiHelper.post("/donate/charge/", { ...donation, church: churchObj }, "GivingApi");
150
+ if (donationType === "recurring") results = await ApiHelper.post("/donate/subscribe/", { ...donation, church: churchObj }, "GivingApi");
151
+
152
+ if (results?.status === "succeeded" || results?.status === "pending" || results?.status === "active") {
153
+ setDonationComplete(true);
154
+ }
155
+ if (results?.raw?.message) {
156
+ setErrors([results?.raw?.message]);
157
+ setProcessing(false);
158
+ }
159
+ setProcessing(false);
160
+ };
161
+
162
+ const validate = () => {
163
+ const result = [];
164
+ if (!firstName) result.push(Locale.label("donation.donationForm.validate.firstName"));
165
+ if (!lastName) result.push(Locale.label("donation.donationForm.validate.lastName"));
166
+ if (!email) result.push(Locale.label("donation.donationForm.validate.email"));
167
+ if (fundsTotal === 0) result.push(Locale.label("donation.donationForm.validate.amount"));
168
+ if (result.length === 0) {
169
+ if (!email.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w+)+$/)) result.push(Locale.label("donation.donationForm.validate.validEmail")); //eslint-disable-line
170
+ }
171
+ //Todo - make sure the account doesn't exist. (loadOrCreate?)
172
+ setErrors(result);
173
+ return result.length === 0;
174
+ };
175
+
176
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
177
+ const val = e.currentTarget.value;
178
+ switch (e.currentTarget.name) {
179
+ case "firstName": setFirstName(val); break;
180
+ case "lastName": setLastName(val); break;
181
+ case "email": setEmail(val); break;
182
+ case "startDate": setStartDate(val); break;
183
+ case "interval": setInterval(val); break;
184
+ }
185
+ };
186
+
187
+ const handleFundDonationsChange = async (fd: FundDonationInterface[]) => {
188
+ setFundDonations(fd);
189
+ let totalAmount = 0;
190
+ const selectedFunds: any = [];
191
+ for (const fundDonation of fd) {
192
+ totalAmount += fundDonation.amount || 0;
193
+ const fund = funds.find((fund: FundInterface) => fund.id === fundDonation.fundId);
194
+ selectedFunds.push({ id: fundDonation.fundId, amount: fundDonation.amount || 0, name: fund.name });
195
+ }
196
+ setFundsTotal(totalAmount);
197
+ setTotal(totalAmount);
198
+
199
+ const fee = await getTransactionFee(totalAmount);
200
+ setTransactionFee(fee);
201
+
202
+ if (gateway && gateway.payFees === true) {
203
+ setTotal(totalAmount + fee);
204
+ }
205
+ };
206
+
207
+ const getTransactionFee = async (amount: number) => {
208
+ if (amount > 0) {
209
+ try {
210
+ const response = await ApiHelper.post("/donate/fee?churchId=" + props.churchId, { type: "creditCard", amount }, "GivingApi");
211
+ return response.calculatedFee;
212
+ } catch (error) {
213
+ console.log("Error calculating transaction fee: ", error);
214
+ return 0;
215
+ }
216
+ } else {
217
+ return 0;
218
+ }
219
+ };
220
+
221
+ const getFundList = () => {
222
+ if (funds) {
223
+ return (<>
224
+ <hr />
225
+ <h4>{Locale.label("donation.donationForm.funds")}</h4>
226
+ <FundDonations fundDonations={fundDonations} funds={funds} params={searchParams} updatedFunction={handleFundDonationsChange} />
227
+ </>);
228
+ }
229
+ };
230
+
231
+ React.useEffect(init, []); //eslint-disable-line
232
+
233
+ // React.useEffect(() => { gateway && gateway.payFees === true && handleAutoPayFee() }, [fundDonations]);
234
+
235
+ if (donationComplete) return <Alert severity="success">{Locale.label("donation.donationForm.thankYou")}</Alert>;
236
+ else {
237
+ return (
238
+ <InputBox headerIcon={showHeader ? "volunteer_activism" : ""} headerText={showHeader ? "Donate" : ""} saveFunction={handleSave} saveText="Donate" isSubmitting={processing || !captchaResponse || captchaResponse === "robot"} mainContainerCssProps={mainContainerCssProps}>
239
+ <ErrorMessages errors={errors} />
240
+ <Grid container spacing={3}>
241
+ <Grid size={{ xs: 12, md: 6 }}>
242
+ <Button aria-label="single-donation" size="small" fullWidth style={{ minHeight: "50px" }} variant={donationType === "once" ? "contained" : "outlined"} onClick={() => setDonationType("once")}>{Locale.label("donation.donationForm.make")}</Button>
243
+ </Grid>
244
+ <Grid size={{ xs: 12, md: 6 }}>
245
+ <Button aria-label="recurring-donation" size="small" fullWidth style={{ minHeight: "50px" }} variant={donationType === "recurring" ? "contained" : "outlined"} onClick={() => setDonationType("recurring")}>{Locale.label("donation.donationForm.makeRecurring")}</Button>
246
+ </Grid>
247
+ <Grid size={{ xs: 12, md: 6 }}>
248
+ <TextField fullWidth label={Locale.label("person.firstName")} name="firstName" value={firstName} onChange={handleChange} />
249
+ </Grid>
250
+ <Grid size={{ xs: 12, md: 6 }}>
251
+ <TextField fullWidth label={Locale.label("person.lastName")} name="lastName" value={lastName} onChange={handleChange} />
252
+ </Grid>
253
+ <Grid size={{ xs: 12, md: 6 }}>
254
+ <TextField fullWidth label={Locale.label("person.email")} name="email" value={email} onChange={handleChange} />
255
+ </Grid>
256
+ <Grid size={{ xs: 12, md: 6 }}>
257
+ <ReCAPTCHA sitekey={props.recaptchaSiteKey} ref={captchaRef} onChange={handleCaptchaChange} />
258
+ </Grid>
259
+ </Grid>
260
+ <div style={{ padding: 10, border: "1px solid #CCC", borderRadius: 5, marginTop: 10 }}>
261
+ <CardElement options={formStyling} />
262
+ </div>
263
+ {donationType === "recurring"
264
+ && <Grid container spacing={3} style={{ marginTop: 0 }}>
265
+ <Grid size={{ xs: 12, md: 6 }}>
266
+ <FormControl fullWidth>
267
+ <InputLabel>{Locale.label("donation.donationForm.frequency")}</InputLabel>
268
+ <Select label="Frequency" name="interval" aria-label="interval" value={interval} onChange={(e) => { setInterval(e.target.value); }}>
269
+ <MenuItem value="one_week">{Locale.label("donation.donationForm.weekly")}</MenuItem>
270
+ <MenuItem value="two_week">{Locale.label("donation.donationForm.biWeekly")}</MenuItem>
271
+ <MenuItem value="one_month">{Locale.label("donation.donationForm.monthly")}</MenuItem>
272
+ <MenuItem value="three_month">{Locale.label("donation.donationForm.quarterly")}</MenuItem>
273
+ <MenuItem value="one_year">{Locale.label("donation.donationForm.annually")}</MenuItem>
274
+ </Select>
275
+ </FormControl>
276
+ </Grid>
277
+ <Grid size={{ xs: 12, md: 6 }}>
278
+ <TextField fullWidth name="startDate" type="date" aria-label="startDate" label={Locale.label("donation.donationForm.startDate")} value={DateHelper.formatHtml5Date(new Date(startDate))} onChange={handleChange} />
279
+ </Grid>
280
+ </Grid>
281
+ }
282
+ {getFundList()}
283
+ <div>
284
+ {fundsTotal > 0
285
+ && <>
286
+ {(gateway && gateway.payFees === true)
287
+ ? <Typography fontSize={14} fontStyle="italic">*{Locale.label("donation.donationForm.fees").replace("{}", CurrencyHelper.formatCurrency(transactionFee))}</Typography>
288
+ : (
289
+ <FormGroup>
290
+ <FormControlLabel control={<Checkbox />} name="transaction-fee" label={Locale.label("donation.donationForm.cover").replace("{}", CurrencyHelper.formatCurrency(transactionFee))} onChange={handleCheckChange} />
291
+ </FormGroup>
292
+ )}
293
+ <p>Total Donation Amount: ${total}</p>
294
+ </>
295
+ }
296
+ </div>
297
+ </InputBox>
298
+ );
299
+ }
300
+ };
@@ -3,6 +3,8 @@ export { CardForm } from "./CardForm";
3
3
  export { DonationForm } from "./DonationForm";
4
4
  export { FundDonation } from "./FundDonation";
5
5
  export { FundDonations } from "./FundDonations";
6
+ export { NonAuthDonation } from "./NonAuthDonation";
7
+ export { NonAuthDonationInner } from "./NonAuthDonationInner";
6
8
  export { PaymentMethods } from "./PaymentMethods";
7
9
  export { RecurringDonations } from "./RecurringDonations";
8
10
  export { RecurringDonationsEdit } from "./RecurringDonationsEdit";