@churchapps/apphelper 0.4.7 → 0.4.8

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.
Files changed (101) hide show
  1. package/CHUMS_COMPONENT_EXTRACTION_CANDIDATES.md +210 -0
  2. package/COMPONENT_USAGE_REPORT.md +322 -0
  3. package/dist/components/header/SecondaryMenu.js +3 -3
  4. package/dist/components/header/SecondaryMenu.js.map +1 -1
  5. package/dist/components/index.d.ts +0 -2
  6. package/dist/components/index.d.ts.map +1 -1
  7. package/dist/components/index.js +1 -5
  8. package/dist/components/index.js.map +1 -1
  9. package/dist/helpers/FileHelper.d.ts +1 -1
  10. package/dist/helpers/FileHelper.d.ts.map +1 -1
  11. package/dist/helpers/FileHelper.js +2 -6
  12. package/dist/helpers/FileHelper.js.map +1 -1
  13. package/dist/index.d.ts +0 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +0 -1
  16. package/dist/index.js.map +1 -1
  17. package/package.json +1 -1
  18. package/src/components/header/SecondaryMenu.tsx +3 -3
  19. package/src/components/index.tsx +0 -2
  20. package/src/helpers/FileHelper.ts +3 -6
  21. package/src/index.ts +0 -1
  22. package/dist/components/CreatePerson.d.ts +0 -15
  23. package/dist/components/CreatePerson.d.ts.map +0 -1
  24. package/dist/components/CreatePerson.js +0 -100
  25. package/dist/components/CreatePerson.js.map +0 -1
  26. package/dist/components/PersonAdd.d.ts +0 -16
  27. package/dist/components/PersonAdd.d.ts.map +0 -1
  28. package/dist/components/PersonAdd.js +0 -52
  29. package/dist/components/PersonAdd.js.map +0 -1
  30. package/dist/donationComponents/DonationPage.d.ts +0 -11
  31. package/dist/donationComponents/DonationPage.d.ts.map +0 -1
  32. package/dist/donationComponents/DonationPage.js +0 -150
  33. package/dist/donationComponents/DonationPage.js.map +0 -1
  34. package/dist/donationComponents/components/BankForm.d.ts +0 -14
  35. package/dist/donationComponents/components/BankForm.d.ts.map +0 -1
  36. package/dist/donationComponents/components/BankForm.js +0 -125
  37. package/dist/donationComponents/components/BankForm.js.map +0 -1
  38. package/dist/donationComponents/components/CardForm.d.ts +0 -13
  39. package/dist/donationComponents/components/CardForm.d.ts.map +0 -1
  40. package/dist/donationComponents/components/CardForm.js +0 -122
  41. package/dist/donationComponents/components/CardForm.js.map +0 -1
  42. package/dist/donationComponents/components/DonationForm.d.ts +0 -15
  43. package/dist/donationComponents/components/DonationForm.d.ts.map +0 -1
  44. package/dist/donationComponents/components/DonationForm.js +0 -200
  45. package/dist/donationComponents/components/DonationForm.js.map +0 -1
  46. package/dist/donationComponents/components/FundDonation.d.ts +0 -12
  47. package/dist/donationComponents/components/FundDonation.d.ts.map +0 -1
  48. package/dist/donationComponents/components/FundDonation.js +0 -32
  49. package/dist/donationComponents/components/FundDonation.js.map +0 -1
  50. package/dist/donationComponents/components/FundDonations.d.ts +0 -11
  51. package/dist/donationComponents/components/FundDonations.d.ts.map +0 -1
  52. package/dist/donationComponents/components/FundDonations.js +0 -33
  53. package/dist/donationComponents/components/FundDonations.js.map +0 -1
  54. package/dist/donationComponents/components/NonAuthDonation.d.ts +0 -12
  55. package/dist/donationComponents/components/NonAuthDonation.d.ts.map +0 -1
  56. package/dist/donationComponents/components/NonAuthDonation.js +0 -27
  57. package/dist/donationComponents/components/NonAuthDonation.js.map +0 -1
  58. package/dist/donationComponents/components/NonAuthDonationInner.d.ts +0 -12
  59. package/dist/donationComponents/components/NonAuthDonationInner.d.ts.map +0 -1
  60. package/dist/donationComponents/components/NonAuthDonationInner.js +0 -276
  61. package/dist/donationComponents/components/NonAuthDonationInner.js.map +0 -1
  62. package/dist/donationComponents/components/PaymentMethods.d.ts +0 -14
  63. package/dist/donationComponents/components/PaymentMethods.d.ts.map +0 -1
  64. package/dist/donationComponents/components/PaymentMethods.js +0 -86
  65. package/dist/donationComponents/components/PaymentMethods.js.map +0 -1
  66. package/dist/donationComponents/components/RecurringDonations.d.ts +0 -10
  67. package/dist/donationComponents/components/RecurringDonations.d.ts.map +0 -1
  68. package/dist/donationComponents/components/RecurringDonations.js +0 -93
  69. package/dist/donationComponents/components/RecurringDonations.js.map +0 -1
  70. package/dist/donationComponents/components/RecurringDonationsEdit.d.ts +0 -11
  71. package/dist/donationComponents/components/RecurringDonationsEdit.d.ts.map +0 -1
  72. package/dist/donationComponents/components/RecurringDonationsEdit.js +0 -66
  73. package/dist/donationComponents/components/RecurringDonationsEdit.js.map +0 -1
  74. package/dist/donationComponents/components/index.d.ts +0 -10
  75. package/dist/donationComponents/components/index.d.ts.map +0 -1
  76. package/dist/donationComponents/components/index.js +0 -22
  77. package/dist/donationComponents/components/index.js.map +0 -1
  78. package/dist/donationComponents/index.d.ts +0 -4
  79. package/dist/donationComponents/index.d.ts.map +0 -1
  80. package/dist/donationComponents/index.js +0 -10
  81. package/dist/donationComponents/index.js.map +0 -1
  82. package/dist/donationComponents/modals/DonationPreviewModal.d.ts +0 -15
  83. package/dist/donationComponents/modals/DonationPreviewModal.d.ts.map +0 -1
  84. package/dist/donationComponents/modals/DonationPreviewModal.js +0 -33
  85. package/dist/donationComponents/modals/DonationPreviewModal.js.map +0 -1
  86. package/src/components/CreatePerson.tsx +0 -135
  87. package/src/components/PersonAdd.tsx +0 -81
  88. package/src/donationComponents/DonationPage.tsx +0 -215
  89. package/src/donationComponents/components/BankForm.tsx +0 -161
  90. package/src/donationComponents/components/CardForm.tsx +0 -106
  91. package/src/donationComponents/components/DonationForm.tsx +0 -255
  92. package/src/donationComponents/components/FundDonation.tsx +0 -58
  93. package/src/donationComponents/components/FundDonations.tsx +0 -44
  94. package/src/donationComponents/components/NonAuthDonation.tsx +0 -33
  95. package/src/donationComponents/components/NonAuthDonationInner.tsx +0 -295
  96. package/src/donationComponents/components/PaymentMethods.tsx +0 -137
  97. package/src/donationComponents/components/RecurringDonations.tsx +0 -123
  98. package/src/donationComponents/components/RecurringDonationsEdit.tsx +0 -95
  99. package/src/donationComponents/components/index.tsx +0 -9
  100. package/src/donationComponents/index.ts +0 -3
  101. package/src/donationComponents/modals/DonationPreviewModal.tsx +0 -68
@@ -1,93 +0,0 @@
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.RecurringDonations = void 0;
8
- const jsx_runtime_1 = require("react/jsx-runtime");
9
- const react_1 = __importDefault(require("react"));
10
- const components_1 = require("../../components");
11
- const helpers_1 = require("../../helpers");
12
- const helpers_2 = require("@churchapps/helpers");
13
- const _1 = require(".");
14
- const material_1 = require("@mui/material");
15
- ;
16
- const RecurringDonations = (props) => {
17
- const [subscriptions, setSubscriptions] = react_1.default.useState([]);
18
- const [mode, setMode] = react_1.default.useState("display");
19
- const [editSubscription, setEditSubscription] = react_1.default.useState();
20
- const loadData = () => {
21
- if (props.customerId) {
22
- helpers_1.ApiHelper.get("/customers/" + props.customerId + "/subscriptions", "GivingApi").then(subResult => {
23
- const subs = [];
24
- const requests = subResult.data?.map((s) => helpers_1.ApiHelper.get("/subscriptionfunds?subscriptionId=" + s.id, "GivingApi").then(subFunds => {
25
- s.funds = subFunds;
26
- subs.push(s);
27
- }));
28
- return requests && Promise.all(requests).then(() => {
29
- setSubscriptions(subs);
30
- });
31
- });
32
- }
33
- };
34
- const handleUpdate = (message) => {
35
- loadData();
36
- setMode("display");
37
- if (message)
38
- props.dataUpdate(message);
39
- };
40
- const handleEdit = (sub) => (e) => {
41
- e.preventDefault();
42
- setEditSubscription(sub);
43
- setMode("edit");
44
- };
45
- const getPaymentMethod = (sub) => {
46
- const pm = props.paymentMethods.find((pm) => pm.id === (sub.default_payment_method || sub.default_source));
47
- if (!pm)
48
- return (0, jsx_runtime_1.jsx)("span", { style: { color: "red" }, children: helpers_1.Locale.label("donation.recurring.notFound") });
49
- return `${pm.name} ****${pm.last4}`;
50
- };
51
- const getInterval = (subscription) => {
52
- let interval = subscription.plan.interval_count + " " + subscription.plan.interval;
53
- return subscription.plan.interval_count > 1 ? interval + "s" : interval;
54
- };
55
- const getFunds = (subscription) => {
56
- let result = [];
57
- subscription.funds.forEach((fund) => {
58
- result.push((0, jsx_runtime_1.jsxs)("div", { children: [fund.name, " ", (0, jsx_runtime_1.jsx)("span", { style: { float: "right" }, children: helpers_1.CurrencyHelper.formatCurrency(fund.amount) })] }, subscription.id + fund.id));
59
- });
60
- const total = (subscription.plan.amount / 100);
61
- result.push((0, jsx_runtime_1.jsxs)("div", { style: { borderTop: "solid #dee2e6 1px" }, children: ["Total ", (0, jsx_runtime_1.jsx)("span", { style: { float: "right" }, children: helpers_1.CurrencyHelper.formatCurrency(total) })] }, subscription.id + "-total"));
62
- return result;
63
- };
64
- const getEditOptions = (sub) => {
65
- if ((!helpers_1.UserHelper.checkAccess(helpers_2.Permissions.givingApi.settings.edit) && props.appName !== "B1App") || props?.paymentMethods?.length === 0)
66
- return null;
67
- return (0, jsx_runtime_1.jsx)("a", { "aria-label": "edit-button", onClick: handleEdit(sub), href: "about:blank", children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "edit" }) });
68
- };
69
- const getTableHeader = () => {
70
- let result = [];
71
- result.push((0, jsx_runtime_1.jsxs)(material_1.TableRow, { sx: { textAlign: "left" }, children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)("b", { children: helpers_1.Locale.label("donation.recurring.startDate") }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)("b", { children: helpers_1.Locale.label("donation.recurring.amount") }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)("b", { children: helpers_1.Locale.label("donation.recurring.interval") }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)("b", { children: helpers_1.Locale.label("donation.recurring.paymentMethod") }) }), props?.paymentMethods?.length > 0 && (0, jsx_runtime_1.jsx)(material_1.TableCell, {})] }, "header"));
72
- return result;
73
- };
74
- const getTableRows = () => {
75
- let rows = [];
76
- subscriptions.forEach((sub) => {
77
- rows.push((0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { children: helpers_1.DateHelper.prettyDate(new Date(sub.billing_cycle_anchor * 1000)) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: getFunds(sub) }), (0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.recurring.every"), " ", getInterval(sub)] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { className: "capitalize", children: getPaymentMethod(sub) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { align: "right", children: getEditOptions(sub) })] }, sub.id));
78
- });
79
- return rows;
80
- };
81
- const getSubscriptionsTable = () => ((0, jsx_runtime_1.jsxs)(material_1.Table, { children: [(0, jsx_runtime_1.jsx)(material_1.TableHead, { children: getTableHeader() }), (0, jsx_runtime_1.jsx)(material_1.TableBody, { children: getTableRows() })] }));
82
- react_1.default.useEffect(loadData, []); //eslint-disable-line
83
- if (!subscriptions.length)
84
- return null;
85
- if (mode === "display") {
86
- return ((0, jsx_runtime_1.jsx)(components_1.DisplayBox, { "data-testid": "recurring-donations", headerIcon: "restart_alt", headerText: "Recurring Donations", children: getSubscriptionsTable() }));
87
- }
88
- if (mode === "edit" && editSubscription) {
89
- return ((0, jsx_runtime_1.jsx)(_1.RecurringDonationsEdit, { customerId: props.customerId, paymentMethods: props.paymentMethods, editSubscription: editSubscription, subscriptionUpdated: handleUpdate }));
90
- }
91
- };
92
- exports.RecurringDonations = RecurringDonations;
93
- //# sourceMappingURL=RecurringDonations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RecurringDonations.js","sourceRoot":"","sources":["../../../src/donationComponents/components/RecurringDonations.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,kDAA0B;AAC1B,iDAA8C;AAC9C,2CAA0F;AAC1F,iDAAyE;AACzE,wBA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G,EAAE,CAAC,CAClC,wBAAC,gBAAK,eACJ,uBAAC,oBAAS,cAAE,cAAc,EAAE,GAAa,EACzC,uBAAC,oBAAS,cAAE,YAAY,EAAE,GAAa,IACjC,CACT,CAAA;IAED,eAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,qBAAqB;IAEpD,IAAI,CAAC,aAAa,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,CACL,uBAAC,uBAAU,mBAAa,qBAAqB,EAAC,UAAU,EAAC,aAAa,EAAC,UAAU,EAAC,qBAAqB,YACpG,qBAAqB,EAAE,GACb,CACd,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,IAAI,gBAAgB,EAAE,CAAC;QACxC,OAAO,CACL,uBAAC,yBAAsB,IAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,YAAY,GAAI,CACtK,CAAC;IACJ,CAAC;AACH,CAAC,CAAA;AA/GY,QAAA,kBAAkB,sBA+G9B"}
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- import { StripePaymentMethod, SubscriptionInterface } from "@churchapps/helpers";
3
- interface Props {
4
- subscriptionUpdated: (message?: string) => void;
5
- customerId: string;
6
- paymentMethods: StripePaymentMethod[];
7
- editSubscription: SubscriptionInterface;
8
- }
9
- export declare const RecurringDonationsEdit: React.FC<Props>;
10
- export {};
11
- //# sourceMappingURL=RecurringDonationsEdit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RecurringDonationsEdit.d.ts","sourceRoot":"","sources":["../../../src/donationComponents/components/RecurringDonationsEdit.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAIjF,UAAU,KAAK;IAAG,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,mBAAmB,EAAE,CAAC;IAAC,gBAAgB,EAAE,qBAAqB,CAAA;CAAE;AAEvK,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAmFlD,CAAA"}
@@ -1,66 +0,0 @@
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.RecurringDonationsEdit = void 0;
8
- const jsx_runtime_1 = require("react/jsx-runtime");
9
- const react_1 = __importDefault(require("react"));
10
- const helpers_1 = require("../../helpers");
11
- const components_1 = require("../../components");
12
- const material_1 = require("@mui/material");
13
- const helpers_2 = require("../../helpers");
14
- ;
15
- const RecurringDonationsEdit = (props) => {
16
- const [editSubscription, setEditSubscription] = react_1.default.useState(props.editSubscription);
17
- const [interval, setInterval] = react_1.default.useState("one_month");
18
- const handleCancel = () => { props.subscriptionUpdated(); };
19
- const handleSave = () => {
20
- let sub = { ...editSubscription };
21
- const pmFound = props.paymentMethods.find((pm) => pm.id === sub.id);
22
- if (!pmFound) {
23
- let pm = props.paymentMethods[0];
24
- sub.default_payment_method = pm.type === "card" ? pm.id : null;
25
- sub.default_source = pm.type === "bank" ? pm.id : null;
26
- }
27
- helpers_1.ApiHelper.post("/subscriptions", [sub], "GivingApi").then(() => props.subscriptionUpdated(helpers_1.Locale.label("donation.donationForm.recurringUpdated")));
28
- };
29
- const handleDelete = () => {
30
- const conf = window.confirm(helpers_1.Locale.label("donation.donationForm.confirmDelete"));
31
- if (!conf)
32
- return;
33
- let promises = [];
34
- promises.push(helpers_1.ApiHelper.delete("/subscriptions/" + props.editSubscription.id, "GivingApi"));
35
- promises.push(helpers_1.ApiHelper.delete("/subscriptionfunds/subscription/" + props.editSubscription.id, "GivingApi"));
36
- Promise.all(promises).then(() => props.subscriptionUpdated(helpers_1.Locale.label("donation.donationForm.cancelled")));
37
- };
38
- const handleChange = (e) => {
39
- let sub = { ...editSubscription };
40
- let value = e.target.value;
41
- switch (e.target.name) {
42
- case "method":
43
- let pm = props.paymentMethods.find((pm) => pm.id === value);
44
- sub.default_payment_method = pm.type === "card" ? value : null;
45
- sub.default_source = pm.type === "bank" ? value : null;
46
- break;
47
- case "interval":
48
- setInterval(value);
49
- const inter = helpers_2.DonationHelper.getInterval(value);
50
- sub.plan.interval_count = inter.interval_count;
51
- sub.plan.interval = inter.interval;
52
- break;
53
- }
54
- setEditSubscription(sub);
55
- };
56
- const getFields = () => ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (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.jsxs)(material_1.FormControl, { fullWidth: true, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: helpers_1.Locale.label("donation.donationForm.method") }), (0, jsx_runtime_1.jsx)(material_1.Select, { label: helpers_1.Locale.label("donation.donationForm.method"), name: "method", "aria-label": "method", value: editSubscription.default_payment_method || editSubscription.default_source, className: "capitalize", onChange: handleChange, children: props.paymentMethods.map((paymentMethod, i) => (0, jsx_runtime_1.jsxs)(material_1.MenuItem, { value: paymentMethod.id, children: [paymentMethod.name, " ****", paymentMethod.last4] }, i)) })] }) }), (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: helpers_1.Locale.label("donation.donationForm.frequency"), name: "interval", "aria-label": "interval", value: interval, onChange: handleChange, 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") })] })] }) })] }) }));
57
- react_1.default.useEffect(() => {
58
- if (props.editSubscription) {
59
- const keyName = helpers_2.DonationHelper.getIntervalKeyName(props.editSubscription.plan.interval_count, props.editSubscription.plan.interval);
60
- setInterval(keyName);
61
- }
62
- }, [props.editSubscription]);
63
- return ((0, jsx_runtime_1.jsx)(components_1.InputBox, { "aria-label": "person-details-box", headerIcon: "person", headerText: helpers_1.Locale.label("donation.donationForm.editRecurring"), ariaLabelSave: "save-button", ariaLabelDelete: "delete-button", cancelFunction: handleCancel, deleteFunction: handleDelete, saveFunction: handleSave, children: getFields() }));
64
- };
65
- exports.RecurringDonationsEdit = RecurringDonationsEdit;
66
- //# sourceMappingURL=RecurringDonationsEdit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RecurringDonationsEdit.js","sourceRoot":"","sources":["../../../src/donationComponents/components/RecurringDonationsEdit.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,kDAA0B;AAC1B,2CAAkD;AAClD,iDAA4C;AAE5C,4CAA6G;AAC7G,2CAA8C;AAEyH,CAAC;AAEjK,MAAM,sBAAsB,GAAoB,CAAC,KAAK,EAAE,EAAE;IAC/D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,eAAK,CAAC,QAAQ,CAA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,YAAY,EAAE,UAAU,YAC5Q,SAAS,EAAE,GACH,CACZ,CAAC;AACJ,CAAC,CAAA;AAnFY,QAAA,sBAAsB,0BAmFlC"}
@@ -1,10 +0,0 @@
1
- export { BankForm } from "./BankForm";
2
- export { CardForm } from "./CardForm";
3
- export { DonationForm } from "./DonationForm";
4
- export { NonAuthDonation } from "./NonAuthDonation";
5
- export { PaymentMethods } from "./PaymentMethods";
6
- export { RecurringDonations } from "./RecurringDonations";
7
- export { RecurringDonationsEdit } from "./RecurringDonationsEdit";
8
- export { FundDonations } from "./FundDonations";
9
- export { FundDonation } from "./FundDonation";
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FundDonation = exports.FundDonations = exports.RecurringDonationsEdit = exports.RecurringDonations = exports.PaymentMethods = exports.NonAuthDonation = exports.DonationForm = exports.CardForm = exports.BankForm = void 0;
4
- var BankForm_1 = require("./BankForm");
5
- Object.defineProperty(exports, "BankForm", { enumerable: true, get: function () { return BankForm_1.BankForm; } });
6
- var CardForm_1 = require("./CardForm");
7
- Object.defineProperty(exports, "CardForm", { enumerable: true, get: function () { return CardForm_1.CardForm; } });
8
- var DonationForm_1 = require("./DonationForm");
9
- Object.defineProperty(exports, "DonationForm", { enumerable: true, get: function () { return DonationForm_1.DonationForm; } });
10
- var NonAuthDonation_1 = require("./NonAuthDonation");
11
- Object.defineProperty(exports, "NonAuthDonation", { enumerable: true, get: function () { return NonAuthDonation_1.NonAuthDonation; } });
12
- var PaymentMethods_1 = require("./PaymentMethods");
13
- Object.defineProperty(exports, "PaymentMethods", { enumerable: true, get: function () { return PaymentMethods_1.PaymentMethods; } });
14
- var RecurringDonations_1 = require("./RecurringDonations");
15
- Object.defineProperty(exports, "RecurringDonations", { enumerable: true, get: function () { return RecurringDonations_1.RecurringDonations; } });
16
- var RecurringDonationsEdit_1 = require("./RecurringDonationsEdit");
17
- Object.defineProperty(exports, "RecurringDonationsEdit", { enumerable: true, get: function () { return RecurringDonationsEdit_1.RecurringDonationsEdit; } });
18
- var FundDonations_1 = require("./FundDonations");
19
- Object.defineProperty(exports, "FundDonations", { enumerable: true, get: function () { return FundDonations_1.FundDonations; } });
20
- var FundDonation_1 = require("./FundDonation");
21
- Object.defineProperty(exports, "FundDonation", { enumerable: true, get: function () { return FundDonation_1.FundDonation; } });
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
@@ -1,4 +0,0 @@
1
- export { FundDonations } from "./components/FundDonations";
2
- export { NonAuthDonation } from "./components/NonAuthDonation";
3
- export { DonationPage } from "./DonationPage";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/donationComponents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DonationPage = exports.NonAuthDonation = exports.FundDonations = void 0;
4
- var FundDonations_1 = require("./components/FundDonations");
5
- Object.defineProperty(exports, "FundDonations", { enumerable: true, get: function () { return FundDonations_1.FundDonations; } });
6
- var NonAuthDonation_1 = require("./components/NonAuthDonation");
7
- Object.defineProperty(exports, "NonAuthDonation", { enumerable: true, get: function () { return NonAuthDonation_1.NonAuthDonation; } });
8
- var DonationPage_1 = require("./DonationPage");
9
- Object.defineProperty(exports, "DonationPage", { enumerable: true, get: function () { return DonationPage_1.DonationPage; } });
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/donationComponents/index.ts"],"names":[],"mappings":";;;AAAA,4DAA2D;AAAlD,8GAAA,aAAa,OAAA;AACtB,gEAA+D;AAAtD,kHAAA,eAAe,OAAA;AACxB,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- import { StripeDonationInterface } from "@churchapps/helpers";
3
- interface Props {
4
- show: boolean;
5
- onHide: () => void;
6
- handleDonate: (message: string) => void;
7
- donation: StripeDonationInterface;
8
- donationType: string;
9
- paymentMethodName: string;
10
- funds: any;
11
- payFee: number;
12
- }
13
- export declare const DonationPreviewModal: React.FC<Props>;
14
- export {};
15
- //# sourceMappingURL=DonationPreviewModal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DonationPreviewModal.d.ts","sourceRoot":"","sources":["../../../src/donationComponents/modals/DonationPreviewModal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,UAAU,KAAK;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiDhD,CAAA"}
@@ -1,33 +0,0 @@
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.DonationPreviewModal = void 0;
8
- const jsx_runtime_1 = require("react/jsx-runtime");
9
- const react_1 = __importDefault(require("react"));
10
- const helpers_1 = require("../../helpers");
11
- const material_1 = require("@mui/material");
12
- const DonationPreviewModal = (props) => {
13
- const donationType = { once: "One-time Donation", recurring: "Recurring Donation" };
14
- const [isLoading, setLoading] = react_1.default.useState(false);
15
- const handleClick = () => {
16
- setLoading(true);
17
- let message = "Thank you for your donation.";
18
- if (props.donationType === "recurring")
19
- message = "Recurring donation created. " + message;
20
- props.handleDonate(message);
21
- };
22
- const formatInterval = () => {
23
- const count = props.donation.interval.interval_count;
24
- const interval = props.donation.interval.interval;
25
- let result = `${count} ${interval}`;
26
- return count > 1 ? result + "s" : result;
27
- };
28
- return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: props.show, ...props, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: "Donation Preview" }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.Table, { children: (0, jsx_runtime_1.jsxs)(material_1.TableBody, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("person.name"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: props.donation.person.name })] }), (0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.preview.method"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { className: "capitalize", children: props.paymentMethodName })] }), (0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.preview.type"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: donationType[props.donationType] })] }), props.donationType === "once"
29
- && (0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.preview.date"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: helpers_1.DateHelper.formatHtml5Date(new Date(props.donation.billing_cycle_anchor)) })] }), (0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.preview.weekly"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: props.donation.notes })] }), props.donationType === "recurring"
30
- && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.preview.startingOn"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: helpers_1.DateHelper.formatHtml5Date(new Date(props.donation.billing_cycle_anchor)) })] }), (0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.preview.every"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { className: "capitalize", children: formatInterval() })] })] }), (0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.preview.funds"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: props.donation.funds.map((fund, i) => (0, jsx_runtime_1.jsxs)("p", { children: [helpers_1.CurrencyHelper.formatCurrency(fund.amount), " - ", fund.name] }, i)) })] }), props.payFee > 0 && (0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.preview.fee"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: helpers_1.CurrencyHelper.formatCurrency(props.payFee) })] }), (0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableCell, { children: [helpers_1.Locale.label("donation.preview.total"), ":"] }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)("h4", { children: helpers_1.CurrencyHelper.formatCurrency(props.donation.amount) }) })] })] }) }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { onClick: props.onHide, variant: "outlined", "aria-label": "cancel-button", children: helpers_1.Locale.label("donation.common.cancel") }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: handleClick, variant: "contained", "aria-label": "donate-button", disabled: isLoading, children: helpers_1.Locale.label("donation.preview.donate") })] })] }));
31
- };
32
- exports.DonationPreviewModal = DonationPreviewModal;
33
- //# sourceMappingURL=DonationPreviewModal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DonationPreviewModal.js","sourceRoot":"","sources":["../../../src/donationComponents/modals/DonationPreviewModal.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,kDAA0B;AAC1B,2CAAmE;AAEnE,4CAAgI;AAazH,MAAM,oBAAoB,GAAoB,CAAC,KAAK,EAAE,EAAE;IAC7D,MAAM,YAAY,GAAQ,EAAE,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;IACzF,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,CAAC;IAE/D,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,OAAO,GAAG,8BAA8B,CAAC;QAC7C,IAAI,KAAK,CAAC,YAAY,KAAK,WAAW;YAAE,OAAO,GAAG,8BAA8B,GAAG,OAAO,CAAC;QAC3F,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAA;IAED,MAAM,cAAc,GAAG,GAAG,EAAE;QAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC;QACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAClD,IAAI,MAAM,GAAG,GAAG,KAAK,IAAI,QAAQ,EAAE,CAAC;QACpC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3C,CAAC,CAAA;IAED,OAAO,CACL,wBAAC,i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AC,GAAU,EAC9H,uBAAC,iBAAM,IAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAC,WAAW,gBAAY,eAAe,EAAC,QAAQ,EAAE,SAAS,YAAG,gBAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,GAAU,IACtI,IACT,CACV,CAAC;AACJ,CAAC,CAAA;AAjDY,QAAA,oBAAoB,wBAiDhC"}
@@ -1,135 +0,0 @@
1
- "use client";
2
-
3
- import React from "react"
4
- import { UserHelper, ApiHelper, Locale } from "../helpers";
5
- import { Permissions, PersonInterface, HouseholdInterface } from "@churchapps/helpers";
6
- import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Grid, TextField } from "@mui/material"
7
- import { ErrorMessages } from "./ErrorMessages"
8
- import { useMountedState } from "../hooks/useMountedState"
9
-
10
- interface CommonProps {
11
- onCreate?: (person: PersonInterface) => void;
12
- }
13
-
14
- type ConditionalProps =
15
- | { showInModal: true; onClose: () => void; }
16
- | { showInModal?: false; onClose?: never; }
17
-
18
- type Props = CommonProps & ConditionalProps
19
-
20
- export function CreatePerson({ onCreate = () => { }, showInModal = false, ...props }: Props) {
21
- const [person, setPerson] = React.useState<PersonInterface>({ name: { first: "", last: "" }, contactInfo: {} });
22
- const [errors, setErrors] = React.useState<string[]>([]);
23
- const [isSubmitting, setIsSubmitting] = React.useState(false);
24
- const isMounted = useMountedState()
25
-
26
- const validate = () => {
27
- const result = [];
28
- if (!person.name?.first) result.push("Please enter a first name.");
29
- if (!person.name?.last) result.push("Please enter a last name.");
30
- setErrors(result);
31
- return result.length === 0;
32
- }
33
-
34
- const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
35
- setErrors([]);
36
- const p = { ...person } as PersonInterface;
37
- let value = e.target.value;
38
- switch (e.target.name) {
39
- case "first": p.name.first = value; break;
40
- case "last": p.name.last = value; break;
41
- case "email": p.contactInfo.email = value; break;
42
- }
43
- setPerson(p);
44
- }
45
-
46
- const validateEmail = (email: string) => (/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(.\w{2,3})+$/.test(email));
47
-
48
- const checkExistingEmail = async () => {
49
- const result = await ApiHelper.get("/people/search?email=" + person.contactInfo.email, "MembershipApi");
50
- return result[0];
51
- }
52
-
53
- const handleSave = () => {
54
- let household = { name: person.name.last } as HouseholdInterface;
55
-
56
- setIsSubmitting(true);
57
- ApiHelper.post("/households", [household], "MembershipApi").then(data => {
58
- household.id = data[0].id;
59
- person.householdId = household.id;
60
- person.name.display = [person.name.first, person.name.last].join(" ");
61
- ApiHelper.post("/people", [person], "MembershipApi").then(data => {
62
- person.id = data[0].id
63
- onCreate(person);
64
- setPerson({ ...person, name: { first: "", last: "" }, contactInfo: { email: "" } });
65
- }).finally(() => {
66
- if (isMounted()) {
67
- setIsSubmitting(false);
68
- showInModal && props.onClose();
69
- }
70
- });
71
- });
72
- }
73
-
74
- async function handleSubmit() {
75
- if (validate()) {
76
- if (person.contactInfo.email && (person.contactInfo.email?.trim() !== undefined || person.contactInfo.email?.trim() !== "")) {
77
- if (!validateEmail(person.contactInfo.email)) {
78
- setErrors(["Please enter a valid email address."]);
79
- } else {
80
- const existingPerson = await checkExistingEmail();
81
- if (existingPerson) {
82
- if (window.confirm(`${existingPerson.name.display} already exists with an email of ${existingPerson.contactInfo.email}. Are you sure you wish to add ${person.name.first} ${person.name.last}?`)) {
83
- handleSave();
84
- }
85
- } else {
86
- handleSave();
87
- }
88
- }
89
- } else {
90
- handleSave();
91
- }
92
- }
93
- }
94
-
95
- if (!UserHelper.checkAccess(Permissions.membershipApi.people.edit)) return null;
96
- if (showInModal) {
97
- return (
98
- <>
99
- <ErrorMessages errors={errors} />
100
- <Dialog open onClose={props.onClose} fullWidth>
101
- <DialogTitle>{Locale.label("createPerson.addNewPerson")}</DialogTitle>
102
- <DialogContent>
103
- <TextField margin="dense" required fullWidth type="text" aria-label="firstName" label={Locale.label("createPerson.firstName")} name="first" value={person.name.first || ""} onChange={handleChange} onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => e.key === "Enter" && handleSubmit} />
104
- <TextField margin="dense" required fullWidth type="text" aria-label="lastName" label={Locale.label("createPerson.lastName")} name="last" value={person.name.last || ""} onChange={handleChange} onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => e.key === "Enter" && handleSubmit} />
105
- <TextField margin="dense" fullWidth type="text" aria-label="email" label={Locale.label("createPerson.email")} name="email" value={person.contactInfo.email || ""} onChange={handleChange} onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => e.key === "Enter" && handleSubmit} />
106
- </DialogContent>
107
- <DialogActions>
108
- <Button onClick={() => { props.onClose(); }}>{Locale.label("common.cancel")}</Button>
109
- <Button type="submit" variant="contained" disabled={isSubmitting} onClick={handleSubmit}>{Locale.label("common.add")}</Button>
110
- </DialogActions>
111
- </Dialog>
112
- </>
113
- )
114
- }
115
- return (
116
- <div>
117
- <p className="pl-1 mb-3 text-dark"><b>{Locale.label("createPerson.addNewPerson")}</b></p>
118
- <ErrorMessages errors={errors} />
119
- <Grid container spacing={3} alignItems="center">
120
- <Grid size={{ xs: 12, md: 6 }}>
121
- <TextField size="small" margin="none" required fullWidth type="text" aria-label="firstName" label={Locale.label("createPerson.firstName")} name="first" value={person.name.first || ""} onChange={handleChange} onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => e.key === "Enter" && handleSubmit} />
122
- </Grid>
123
- <Grid size={{ xs: 12, md: 6 }}>
124
- <TextField size="small" margin="none" required fullWidth type="text" aria-label="lastName" label={Locale.label("createPerson.lastName")} name="last" value={person.name.last || ""} onChange={handleChange} onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => e.key === "Enter" && handleSubmit} />
125
- </Grid>
126
- <Grid size={12}>
127
- <TextField size="small" margin="none" fullWidth type="text" aria-label="email" label={Locale.label("createPerson.email")} name="email" value={person.contactInfo.email || ""} onChange={handleChange} onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => e.key === "Enter" && handleSubmit} />
128
- </Grid>
129
- <Grid size={12}>
130
- <Button type="submit" fullWidth variant="contained" disabled={isSubmitting} onClick={handleSubmit}>{Locale.label("common.add")}</Button>
131
- </Grid>
132
- </Grid>
133
- </div>
134
- )
135
- }
@@ -1,81 +0,0 @@
1
- "use client";
2
-
3
- import React, { useState } from "react";
4
- import { ApiHelper, Locale } from "../helpers";
5
- import { PersonInterface } from "@churchapps/helpers"
6
- import { TextField, Button, Table, TableBody, TableRow, TableCell, Typography, useThemeProps } from "@mui/material";
7
- import { SmallButton } from "./SmallButton";
8
- import { CreatePerson } from "./CreatePerson";
9
-
10
- interface Props {
11
- addFunction: (person: PersonInterface) => void;
12
- person?: PersonInterface;
13
- getPhotoUrl: (person: PersonInterface) => string;
14
- searchClicked?: () => void;
15
- filterList?: string[];
16
- includeEmail?: boolean;
17
- actionLabel?: string;
18
- showCreatePersonOnNotFound?: boolean;
19
- onCreate?: (person: PersonInterface) => void;
20
-
21
- }
22
-
23
- export const PersonAdd: React.FC<Props> = ({ addFunction, getPhotoUrl, searchClicked, filterList = [], includeEmail = false, actionLabel, showCreatePersonOnNotFound = false, onCreate }) => {
24
- const [searchResults, setSearchResults] = useState<PersonInterface[]>([]);
25
- const [searchText, setSearchText] = useState("");
26
- const [hasSearched, setHasSearched] = useState<boolean>(false);
27
- const [open, setOpen] = useState<boolean>(false);
28
-
29
- const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { e.preventDefault(); setHasSearched(false); setSearchText(e.currentTarget.value); }
30
- const handleKeyDown = (e: React.KeyboardEvent<any>) => { if (e.key === "Enter") { e.preventDefault(); handleSearch(null); } }
31
-
32
- const handleSearch = (e: React.MouseEvent) => {
33
- if (e !== null) e.preventDefault();
34
- let term = searchText.trim();
35
- ApiHelper.post("/people/search", { term: term }, "MembershipApi")
36
- .then((data: PersonInterface[]) => {
37
- setHasSearched(true);
38
- const filteredResult = data.filter(s => !filterList.includes(s.id))
39
- setSearchResults(filteredResult);
40
- if (searchClicked) {
41
- searchClicked();
42
- }
43
- });
44
- }
45
- const handleAdd = (person: PersonInterface) => {
46
- let sr: PersonInterface[] = [...searchResults];
47
- const idx = sr.indexOf(person);
48
- sr.splice(idx, 1);
49
- setSearchResults(sr);
50
- addFunction(person);
51
- }
52
-
53
- //<button className="text-success no-default-style" aria-label="addPerson" data-index={i} onClick={handleAdd}><Icon>person</Icon> Add</button>
54
- let rows = [];
55
- for (let i = 0; i < searchResults.length; i++) {
56
- const sr = searchResults[i];
57
-
58
- rows.push(
59
- <TableRow key={sr.id}>
60
- <TableCell><img src={getPhotoUrl(sr)} alt="avatar" /></TableCell>
61
- <TableCell>{sr.name.display}{includeEmail && (<><br /><i style={{ color: "#999" }}>{sr.contactInfo.email}</i></>)}</TableCell>
62
- <TableCell>
63
- <SmallButton color="success" icon="person" text={actionLabel || "Add"} ariaLabel="addPerson" onClick={() => handleAdd(sr)} data-testid={`add-person-${sr.id}`} />
64
- </TableCell>
65
- </TableRow>
66
- );
67
- }
68
-
69
- return (
70
- <>
71
- <TextField fullWidth name="personAddText" label={Locale.label("person.person")} value={searchText} onChange={handleChange} onKeyDown={handleKeyDown} data-testid="person-search-input"
72
- InputProps={{ endAdornment: <Button variant="contained" id="searchButton" data-testid="search-button" onClick={handleSearch}>{Locale.label("common.search")}</Button> }}
73
- />
74
- {showCreatePersonOnNotFound && hasSearched && searchText && searchResults.length === 0 && (
75
- <Typography sx={{ marginTop: "7px" }}>{Locale.label("person.noRec")} <a href="about:blank" onClick={(e) => { e.preventDefault(); setOpen(true); }}>{Locale.label("createPerson.addNewPerson")}</a></Typography>
76
- )}
77
- <Table size="small" id="householdMemberAddTable"><TableBody>{rows}</TableBody></Table>
78
- {open && <CreatePerson showInModal onClose={() => { setOpen(false); }} onCreate={person => { setSearchText(""); setSearchResults([person]); if (onCreate) onCreate(person); }} />}
79
- </>
80
- );
81
- }