@churchapps/apphelper 0.2.71 → 0.2.73
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonationPage.d.ts","sourceRoot":"","sources":["../../src/donationComponents/DonationPage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAA2D,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK/G,UAAU,KAAK;IAAG,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;AAErG,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"DonationPage.d.ts","sourceRoot":"","sources":["../../src/donationComponents/DonationPage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAA2D,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK/G,UAAU,KAAK;IAAG,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;AAErG,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA4KxC,CAAA"}
|
|
@@ -22,7 +22,12 @@ const DonationPage = (props) => {
|
|
|
22
22
|
const [person, setPerson] = react_1.default.useState(null);
|
|
23
23
|
const [message, setMessage] = react_1.default.useState(null);
|
|
24
24
|
const [appName, setAppName] = react_1.default.useState("");
|
|
25
|
+
const [anchorEl, setAnchorEl] = react_1.default.useState(null);
|
|
26
|
+
const open = Boolean(anchorEl);
|
|
25
27
|
const isMounted = (0, useMountedState_1.useMountedState)();
|
|
28
|
+
const handleClose = () => {
|
|
29
|
+
setAnchorEl(null);
|
|
30
|
+
};
|
|
26
31
|
const loadData = () => {
|
|
27
32
|
if (props === null || props === void 0 ? void 0 : props.appName)
|
|
28
33
|
setAppName(props.appName);
|
|
@@ -68,6 +73,32 @@ const DonationPage = (props) => {
|
|
|
68
73
|
setPaymentMethods(null);
|
|
69
74
|
loadData();
|
|
70
75
|
};
|
|
76
|
+
const getEditContent = () => {
|
|
77
|
+
const result = [];
|
|
78
|
+
const date = new Date();
|
|
79
|
+
const currentY = date.getFullYear();
|
|
80
|
+
const lastY = date.getFullYear() - 1;
|
|
81
|
+
const current_year = donations.filter(d => new Date(d.donationDate).getFullYear() === currentY);
|
|
82
|
+
const last_year = donations.filter(d => new Date(d.donationDate).getFullYear() === lastY);
|
|
83
|
+
const customHeaders = [
|
|
84
|
+
{ label: "amount", key: "amount" },
|
|
85
|
+
{ label: "donationDate", key: "donationDate" },
|
|
86
|
+
{ label: "fundName", key: "fund.name" },
|
|
87
|
+
{ label: "method", key: "method" },
|
|
88
|
+
{ label: "methodDetails", key: "methodDetails" },
|
|
89
|
+
];
|
|
90
|
+
result.push(react_1.default.createElement(react_1.default.Fragment, null,
|
|
91
|
+
react_1.default.createElement(material_1.Button, { id: "download-button", "aria-controls": open ? "download-menu" : undefined, "aria-haspopup": "true", "aria-expanded": open ? "true" : undefined, onClick: (e) => {
|
|
92
|
+
setAnchorEl(e.currentTarget);
|
|
93
|
+
} },
|
|
94
|
+
react_1.default.createElement(material_1.Icon, null, "download")),
|
|
95
|
+
react_1.default.createElement(material_1.Menu, { id: "download-menu", anchorEl: anchorEl, open: open, onClose: handleClose, MenuListProps: { 'aria-labelledby': "download-button" } },
|
|
96
|
+
react_1.default.createElement(material_1.MenuItem, { onClick: handleClose, dense: true },
|
|
97
|
+
react_1.default.createElement(components_2.ExportLink, { data: current_year, filename: "current_year_donations", customHeaders: customHeaders, text: "Current Year", icon: "payments" })),
|
|
98
|
+
react_1.default.createElement(material_1.MenuItem, { onClick: handleClose, dense: true },
|
|
99
|
+
react_1.default.createElement(components_2.ExportLink, { data: last_year, filename: "last_year_donations", customHeaders: customHeaders, text: "Last Year", icon: "payments" })))));
|
|
100
|
+
return result;
|
|
101
|
+
};
|
|
71
102
|
const getRows = () => {
|
|
72
103
|
let rows = [];
|
|
73
104
|
if (donations.length === 0) {
|
|
@@ -117,7 +148,7 @@ const DonationPage = (props) => {
|
|
|
117
148
|
else
|
|
118
149
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
119
150
|
react_1.default.createElement(components_1.DonationForm, { person: person, customerId: customerId, paymentMethods: paymentMethods, stripePromise: stripePromise, donationSuccess: handleDataUpdate, church: props === null || props === void 0 ? void 0 : props.church, churchLogo: props === null || props === void 0 ? void 0 : props.churchLogo }),
|
|
120
|
-
react_1.default.createElement(components_2.DisplayBox, { headerIcon: "payments", headerText: "Donations" }, getTable()),
|
|
151
|
+
react_1.default.createElement(components_2.DisplayBox, { headerIcon: "payments", headerText: "Donations", editContent: getEditContent() }, getTable()),
|
|
121
152
|
react_1.default.createElement(components_1.RecurringDonations, { customerId: customerId, paymentMethods: paymentMethods, appName: appName, dataUpdate: handleDataUpdate }),
|
|
122
153
|
react_1.default.createElement(components_1.PaymentMethods, { person: person, customerId: customerId, paymentMethods: paymentMethods, appName: appName, stripePromise: stripePromise, dataUpdate: handleDataUpdate })));
|
|
123
154
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonationPage.js","sourceRoot":"","sources":["../../src/donationComponents/DonationPage.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAEb,kDAA0B;AAC1B,iDAAuD;AACvD,6CAAgF;AAChF,
|
|
1
|
+
{"version":3,"file":"DonationPage.js","sourceRoot":"","sources":["../../src/donationComponents/DonationPage.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAEb,kDAA0B;AAC1B,iDAAuD;AACvD,6CAAgF;AAChF,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L,KAAK,uBAAL,KAAK,CAAE,MAAM,EAAE,UAAU,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,GAAI;gBAC/M,8BAAC,uBAAU,IAAC,UAAU,EAAC,UAAU,EAAC,UAAU,EAAC,WAAW,EAAC,WAAW,EAAE,cAAc,EAAE,IACnF,QAAQ,EAAE,CACA;gBACb,8BAAC,+BAAkB,IAAC,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,GAAI;gBAC9H,8BAAC,2BAAc,IAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,GAAI,CACvK,CACJ,CAAC;IACJ,CAAC,CAAA;IAED,OAAO,CACL;QACG,cAAc,IAAI,OAAO,IAAI,8BAAC,gBAAK,IAAC,QAAQ,EAAC,SAAS,IAAE,OAAO,CAAS;QACxE,0BAA0B,EAAE,CAC5B,CACJ,CAAC;AACJ,CAAC,CAAA;AA5KY,QAAA,YAAY,gBA4KxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@churchapps/apphelper",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.73",
|
|
4
4
|
"description": "Library of helper functions for React and NextJS ChurchApps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"react-router-dom": "^6.15.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@churchapps/helpers": "^1.0.
|
|
38
|
+
"@churchapps/helpers": "^1.0.24",
|
|
39
39
|
"@emotion/cache": "^11.11.0",
|
|
40
40
|
"@emotion/react": "^11.11.1",
|
|
41
41
|
"@emotion/styled": "^11.11.0",
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { loadStripe, Stripe } from "@stripe/stripe-js";
|
|
5
5
|
import { DonationForm, RecurringDonations, PaymentMethods } from "./components";
|
|
6
|
-
import { DisplayBox, Loading } from "../components";
|
|
6
|
+
import { DisplayBox, ExportLink, Loading } from "../components";
|
|
7
7
|
import { ApiHelper, DateHelper, UniqueIdHelper, CurrencyHelper, Locale } from "../helpers";
|
|
8
8
|
import { DonationInterface, PersonInterface, StripePaymentMethod, ChurchInterface } from "@churchapps/helpers";
|
|
9
9
|
import { Link } from "react-router-dom"
|
|
10
|
-
import { Table, TableBody, TableRow, TableCell, TableHead, Alert } from "@mui/material"
|
|
10
|
+
import { Table, TableBody, TableRow, TableCell, TableHead, Alert, Button, Icon, Menu, MenuItem } from "@mui/material"
|
|
11
11
|
import { useMountedState } from "../hooks/useMountedState";
|
|
12
12
|
|
|
13
13
|
interface Props { personId: string, appName?: string, church?: ChurchInterface, churchLogo?: string }
|
|
@@ -20,8 +20,14 @@ export const DonationPage: React.FC<Props> = (props) => {
|
|
|
20
20
|
const [person, setPerson] = React.useState<PersonInterface>(null);
|
|
21
21
|
const [message, setMessage] = React.useState<string>(null);
|
|
22
22
|
const [appName, setAppName] = React.useState<string>("");
|
|
23
|
+
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
24
|
+
const open = Boolean(anchorEl);
|
|
23
25
|
const isMounted = useMountedState();
|
|
24
26
|
|
|
27
|
+
const handleClose = () => {
|
|
28
|
+
setAnchorEl(null);
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
const loadData = () => {
|
|
26
32
|
if (props?.appName) setAppName(props.appName);
|
|
27
33
|
if (!UniqueIdHelper.isMissing(props.personId)) {
|
|
@@ -64,6 +70,49 @@ export const DonationPage: React.FC<Props> = (props) => {
|
|
|
64
70
|
loadData();
|
|
65
71
|
}
|
|
66
72
|
|
|
73
|
+
const getEditContent = () => {
|
|
74
|
+
const result: JSX.Element[] = [];
|
|
75
|
+
const date = new Date();
|
|
76
|
+
const currentY = date.getFullYear();
|
|
77
|
+
const lastY = date.getFullYear() - 1;
|
|
78
|
+
|
|
79
|
+
const current_year = donations.filter(d => new Date(d.donationDate).getFullYear() === currentY);
|
|
80
|
+
const last_year = donations.filter(d => new Date(d.donationDate).getFullYear() === lastY);
|
|
81
|
+
const customHeaders = [
|
|
82
|
+
{ label: "amount", key: "amount" },
|
|
83
|
+
{ label: "donationDate", key: "donationDate" },
|
|
84
|
+
{ label: "fundName", key: "fund.name" },
|
|
85
|
+
{ label: "method", key: "method"},
|
|
86
|
+
{ label: "methodDetails", key: "methodDetails"},
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
result.push(<>
|
|
90
|
+
<Button
|
|
91
|
+
id="download-button"
|
|
92
|
+
aria-controls={open ? "download-menu" : undefined}
|
|
93
|
+
aria-haspopup="true"
|
|
94
|
+
aria-expanded={open ? "true" : undefined}
|
|
95
|
+
onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
|
|
96
|
+
setAnchorEl(e.currentTarget);
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<Icon>download</Icon>
|
|
100
|
+
</Button>
|
|
101
|
+
<Menu
|
|
102
|
+
id="download-menu"
|
|
103
|
+
anchorEl={anchorEl}
|
|
104
|
+
open={open}
|
|
105
|
+
onClose={handleClose}
|
|
106
|
+
MenuListProps={{ 'aria-labelledby': "download-button" }}
|
|
107
|
+
>
|
|
108
|
+
<MenuItem onClick={handleClose} dense><ExportLink data={current_year} filename="current_year_donations" customHeaders={customHeaders} text="Current Year" icon="payments" /></MenuItem>
|
|
109
|
+
<MenuItem onClick={handleClose} dense><ExportLink data={last_year} filename="last_year_donations" customHeaders={customHeaders} text="Last Year" icon="payments" /></MenuItem>
|
|
110
|
+
</Menu>
|
|
111
|
+
</>);
|
|
112
|
+
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
67
116
|
const getRows = () => {
|
|
68
117
|
let rows: JSX.Element[] = [];
|
|
69
118
|
|
|
@@ -120,7 +169,7 @@ export const DonationPage: React.FC<Props> = (props) => {
|
|
|
120
169
|
else return (
|
|
121
170
|
<>
|
|
122
171
|
<DonationForm person={person} customerId={customerId} paymentMethods={paymentMethods} stripePromise={stripePromise} donationSuccess={handleDataUpdate} church={props?.church} churchLogo={props?.churchLogo} />
|
|
123
|
-
<DisplayBox headerIcon="payments" headerText="Donations">
|
|
172
|
+
<DisplayBox headerIcon="payments" headerText="Donations" editContent={getEditContent()}>
|
|
124
173
|
{getTable()}
|
|
125
174
|
</DisplayBox>
|
|
126
175
|
<RecurringDonations customerId={customerId} paymentMethods={paymentMethods} appName={appName} dataUpdate={handleDataUpdate} />
|