@churchapps/apphelper 0.4.50 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/components/FormCardPayment.d.ts +1 -1
  2. package/dist/components/FormCardPayment.d.ts.map +1 -1
  3. package/dist/components/FormCardPayment.js +27 -10
  4. package/dist/components/FormCardPayment.js.map +1 -1
  5. package/dist/components/Loading.js +36 -36
  6. package/dist/components/notes/Notes.js +27 -27
  7. package/dist/helpers/index.d.ts +1 -1
  8. package/dist/helpers/index.d.ts.map +1 -1
  9. package/dist/helpers/index.js +1 -1
  10. package/dist/helpers/index.js.map +1 -1
  11. package/dist/public/css/cropper.css +309 -309
  12. package/dist/public/css/styles.css +111 -111
  13. package/package.json +72 -73
  14. package/public/css/cropper.css +309 -309
  15. package/public/css/styles.css +111 -111
  16. package/public/locales/de.json +269 -269
  17. package/public/locales/en.json +276 -276
  18. package/public/locales/es.json +272 -272
  19. package/public/locales/fr.json +269 -269
  20. package/public/locales/hi.json +269 -269
  21. package/public/locales/it.json +269 -269
  22. package/public/locales/ko.json +269 -269
  23. package/public/locales/no.json +269 -269
  24. package/public/locales/pt.json +269 -269
  25. package/public/locales/ru.json +269 -269
  26. package/public/locales/tl.json +269 -269
  27. package/public/locales/zh.json +269 -269
  28. package/src/components/DisplayBox.tsx +83 -83
  29. package/src/components/ErrorMessages.tsx +28 -28
  30. package/src/components/ExportLink.tsx +81 -81
  31. package/src/components/FloatingSupport.tsx +18 -18
  32. package/src/components/FormCardPayment.tsx +184 -169
  33. package/src/components/FormSubmissionEdit.tsx +168 -168
  34. package/src/components/HelpIcon.tsx +12 -12
  35. package/src/components/ImageEditor.tsx +161 -161
  36. package/src/components/InputBox.tsx +96 -96
  37. package/src/components/Loading.tsx +77 -77
  38. package/src/components/PageHeader.tsx +110 -110
  39. package/src/components/PersonAvatar.tsx +77 -77
  40. package/src/components/QuestionEdit.tsx +99 -99
  41. package/src/components/SmallButton.tsx +42 -42
  42. package/src/components/SupportModal.tsx +32 -32
  43. package/src/components/TabPanel.tsx +28 -28
  44. package/src/components/gallery/GalleryModal.tsx +173 -173
  45. package/src/components/gallery/StockPhotos.tsx +95 -95
  46. package/src/components/gallery/index.ts +1 -1
  47. package/src/components/header/Banner.tsx +11 -11
  48. package/src/components/header/PrimaryMenu.tsx +100 -100
  49. package/src/components/header/SecondaryMenu.tsx +23 -23
  50. package/src/components/header/SecondaryMenuAlt.tsx +40 -40
  51. package/src/components/header/SiteHeader.tsx +207 -207
  52. package/src/components/header/SupportDrawer.tsx +111 -111
  53. package/src/components/header/index.tsx +2 -2
  54. package/src/components/index.tsx +20 -20
  55. package/src/components/notes/AddNote.tsx +180 -180
  56. package/src/components/notes/Note.tsx +68 -68
  57. package/src/components/notes/Notes.tsx +208 -208
  58. package/src/components/notes/index.ts +3 -3
  59. package/src/components/wrapper/AppList.tsx +19 -19
  60. package/src/components/wrapper/ChurchList.tsx +154 -154
  61. package/src/components/wrapper/NavItem.tsx +47 -47
  62. package/src/components/wrapper/NewPrivateMessage.tsx +253 -253
  63. package/src/components/wrapper/Notifications.tsx +223 -223
  64. package/src/components/wrapper/PrivateMessageDetails.tsx +112 -112
  65. package/src/components/wrapper/PrivateMessages.tsx +576 -576
  66. package/src/components/wrapper/UserMenu.tsx +383 -383
  67. package/src/components/wrapper/index.tsx +8 -8
  68. package/src/helpers/AnalyticsHelper.ts +32 -32
  69. package/src/helpers/AppearanceHelper.ts +73 -73
  70. package/src/helpers/ArrayHelper.ts +87 -87
  71. package/src/helpers/CurrencyHelper.ts +10 -10
  72. package/src/helpers/DateHelper.ts +104 -104
  73. package/src/helpers/ErrorHelper.ts +43 -43
  74. package/src/helpers/EventHelper.ts +49 -49
  75. package/src/helpers/FileHelper.ts +31 -31
  76. package/src/helpers/Locale.ts +457 -457
  77. package/src/helpers/NotificationService.ts +296 -296
  78. package/src/helpers/PersonHelper.ts +62 -62
  79. package/src/helpers/SlugHelper.ts +37 -37
  80. package/src/helpers/SocketHelper.ts +296 -296
  81. package/src/helpers/UniqueIdHelper.ts +36 -36
  82. package/src/helpers/UserHelper.ts +104 -104
  83. package/src/helpers/createEmotionCache.ts +17 -17
  84. package/src/helpers/index.ts +58 -50
  85. package/src/hooks/index.ts +3 -3
  86. package/src/hooks/useMountedState.ts +16 -16
  87. package/src/hooks/useNotifications.ts +93 -93
  88. package/src/index.ts +2 -2
  89. package/src/types/interface-extensions.d.ts +12 -0
  90. package/tsconfig.json +31 -31
  91. package/dist/public/locales/de.json +0 -270
  92. package/dist/public/locales/en.json +0 -277
  93. package/dist/public/locales/es.json +0 -272
  94. package/dist/public/locales/fr.json +0 -270
  95. package/dist/public/locales/hi.json +0 -270
  96. package/dist/public/locales/it.json +0 -270
  97. package/dist/public/locales/ko.json +0 -270
  98. package/dist/public/locales/no.json +0 -270
  99. package/dist/public/locales/pt.json +0 -270
  100. package/dist/public/locales/ru.json +0 -270
  101. package/dist/public/locales/tl.json +0 -270
  102. package/dist/public/locales/zh.json +0 -270
@@ -1,154 +1,154 @@
1
- "use client";
2
-
3
- import React, { useState } from "react";
4
- import { LoginUserChurchInterface, UserContextInterface, ArrayHelper } from "@churchapps/helpers";
5
- import { ApiHelper } from "@churchapps/helpers";
6
- import { UserHelper } from "../../helpers/UserHelper";
7
- import { NavItem } from "./NavItem";
8
- import { Locale } from "../../helpers";
9
-
10
- export interface Props { userChurches: LoginUserChurchInterface[], currentUserChurch: LoginUserChurchInterface, context: UserContextInterface, onDelete?: () => void, onChurchChange?: () => void }
11
-
12
- export const ChurchList: React.FC<Props> = props => {
13
- console.log('ChurchList - Rendering with props:', props);
14
-
15
- const [userChurches, setUserChurches] = useState(() => {
16
- try {
17
- // If we have currentUserChurch, use it as fallback
18
- if (props.currentUserChurch && (!props.userChurches || !Array.isArray(props.userChurches))) {
19
- console.log('ChurchList - Using currentUserChurch as single item array');
20
- return [props.currentUserChurch];
21
- }
22
-
23
- let churches = props.userChurches;
24
-
25
- // Ensure we have an array
26
- if (!Array.isArray(churches)) {
27
- console.warn('ChurchList - Expected array but got:', typeof churches, churches);
28
- // If it's a plain church object and we have currentUserChurch, use that
29
- if (props.currentUserChurch) {
30
- return [props.currentUserChurch];
31
- }
32
- churches = [];
33
- }
34
-
35
- console.log('ChurchList - Processing churches array:', churches);
36
-
37
- // Filter for valid userChurch objects (should have church property)
38
- const validChurches = churches.filter(uc => {
39
- const isValid = uc && uc.church && uc.church.id;
40
- if (!isValid) {
41
- console.warn('ChurchList - Invalid church structure:', uc);
42
- }
43
- return isValid;
44
- });
45
-
46
- // If no valid churches but we have currentUserChurch, use it
47
- if (validChurches.length === 0 && props.currentUserChurch) {
48
- console.log('ChurchList - No valid churches found, using currentUserChurch');
49
- return [props.currentUserChurch];
50
- }
51
-
52
- console.log('ChurchList - Valid churches:', validChurches);
53
- return validChurches;
54
- } catch (error) {
55
- console.error('ChurchList - Error processing churches:', error);
56
- // Last resort: if we have currentUserChurch, use it
57
- if (props.currentUserChurch) {
58
- return [props.currentUserChurch];
59
- }
60
- return [];
61
- }
62
- });
63
-
64
- // Update local state when props change
65
- React.useEffect(() => {
66
- try {
67
- // If we have currentUserChurch, use it as fallback
68
- if (props.currentUserChurch && (!props.userChurches || !Array.isArray(props.userChurches))) {
69
- setUserChurches([props.currentUserChurch]);
70
- return;
71
- }
72
-
73
- let churches = props.userChurches;
74
-
75
- // Ensure we have an array
76
- if (!Array.isArray(churches)) {
77
- if (props.currentUserChurch) {
78
- setUserChurches([props.currentUserChurch]);
79
- return;
80
- }
81
- churches = [];
82
- }
83
-
84
- // Filter for valid userChurch objects
85
- const validChurches = churches.filter(uc => uc && uc.church && uc.church.id);
86
-
87
- // If no valid churches but we have currentUserChurch, use it
88
- if (validChurches.length === 0 && props.currentUserChurch) {
89
- setUserChurches([props.currentUserChurch]);
90
- } else {
91
- setUserChurches(validChurches);
92
- }
93
- } catch (error) {
94
- console.error('ChurchList useEffect - Error updating churches:', error);
95
- if (props.currentUserChurch) {
96
- setUserChurches([props.currentUserChurch]);
97
- } else {
98
- setUserChurches([]);
99
- }
100
- }
101
- }, [props.userChurches, props.currentUserChurch]);
102
-
103
- const handleDelete = async (uc: LoginUserChurchInterface) => {
104
- // Helper function to get label with fallback
105
- const getLabel = (key: string, fallback: string) => {
106
- const label = Locale.label(key);
107
- return label && label !== key ? label : fallback;
108
- };
109
-
110
- const confirmMessage = getLabel("wrapper.sureRemoveChurch", "Are you sure you wish to delete this church? You will no longer be a member of {}.").replace("{}", uc.church.name?.toUpperCase());
111
- if (window.confirm(confirmMessage)) {
112
- await ApiHelper.delete(`/userchurch/record/${props.context.user.id}/${uc.church.id}/${uc.person.id}`, "MembershipApi");
113
- await ApiHelper.delete(`/rolemembers/self/${uc.church.id}/${props.context.user.id}`, "MembershipApi");
114
- // remove the same from userChurches
115
- const idx = ArrayHelper.getIndex(UserHelper.userChurches, "church.id", uc.church.id);
116
- if (idx > -1) UserHelper.userChurches.splice(idx, 1);
117
- props?.onDelete();
118
- }
119
- }
120
-
121
- // Helper function to get label with fallback
122
- const getLabel = (key: string, fallback: string) => {
123
- const label = Locale.label(key);
124
- return label && label !== key ? label : fallback;
125
- };
126
-
127
- let result: React.ReactElement[] = [];
128
-
129
- userChurches.forEach(uc => {
130
- const userChurch = uc;
131
- const churchName = uc.church.name;
132
- result.push(<NavItem
133
- key={userChurch.church.id}
134
- selected={(uc.church.id === props.currentUserChurch.church.id) && true}
135
- onClick={async () => {
136
- console.log('ChurchList - Selecting church:', userChurch.church.name);
137
- await UserHelper.selectChurch(props.context, userChurch.church.id, null);
138
- console.log('ChurchList - Church selected');
139
-
140
- // Call the onChurchChange callback if provided
141
- if (props.onChurchChange) {
142
- props.onChurchChange();
143
- }
144
- }}
145
- label={churchName || "Unknown"}
146
- icon="church"
147
- deleteIcon={uc.church.id !== props.currentUserChurch.church.id ? "delete" : null}
148
- deleteLabel={getLabel("wrapper.deleteChurch", "Delete")}
149
- deleteFunction={() => { handleDelete(uc); }}
150
- />);
151
- });
152
-
153
- return <div id="church-list">{result}</div>;
154
- };
1
+ "use client";
2
+
3
+ import React, { useState } from "react";
4
+ import { LoginUserChurchInterface, UserContextInterface, ArrayHelper } from "@churchapps/helpers";
5
+ import { ApiHelper } from "@churchapps/helpers";
6
+ import { UserHelper } from "../../helpers/UserHelper";
7
+ import { NavItem } from "./NavItem";
8
+ import { Locale } from "../../helpers";
9
+
10
+ export interface Props { userChurches: LoginUserChurchInterface[], currentUserChurch: LoginUserChurchInterface, context: UserContextInterface, onDelete?: () => void, onChurchChange?: () => void }
11
+
12
+ export const ChurchList: React.FC<Props> = props => {
13
+ console.log('ChurchList - Rendering with props:', props);
14
+
15
+ const [userChurches, setUserChurches] = useState(() => {
16
+ try {
17
+ // If we have currentUserChurch, use it as fallback
18
+ if (props.currentUserChurch && (!props.userChurches || !Array.isArray(props.userChurches))) {
19
+ console.log('ChurchList - Using currentUserChurch as single item array');
20
+ return [props.currentUserChurch];
21
+ }
22
+
23
+ let churches = props.userChurches;
24
+
25
+ // Ensure we have an array
26
+ if (!Array.isArray(churches)) {
27
+ console.warn('ChurchList - Expected array but got:', typeof churches, churches);
28
+ // If it's a plain church object and we have currentUserChurch, use that
29
+ if (props.currentUserChurch) {
30
+ return [props.currentUserChurch];
31
+ }
32
+ churches = [];
33
+ }
34
+
35
+ console.log('ChurchList - Processing churches array:', churches);
36
+
37
+ // Filter for valid userChurch objects (should have church property)
38
+ const validChurches = churches.filter(uc => {
39
+ const isValid = uc && uc.church && uc.church.id;
40
+ if (!isValid) {
41
+ console.warn('ChurchList - Invalid church structure:', uc);
42
+ }
43
+ return isValid;
44
+ });
45
+
46
+ // If no valid churches but we have currentUserChurch, use it
47
+ if (validChurches.length === 0 && props.currentUserChurch) {
48
+ console.log('ChurchList - No valid churches found, using currentUserChurch');
49
+ return [props.currentUserChurch];
50
+ }
51
+
52
+ console.log('ChurchList - Valid churches:', validChurches);
53
+ return validChurches;
54
+ } catch (error) {
55
+ console.error('ChurchList - Error processing churches:', error);
56
+ // Last resort: if we have currentUserChurch, use it
57
+ if (props.currentUserChurch) {
58
+ return [props.currentUserChurch];
59
+ }
60
+ return [];
61
+ }
62
+ });
63
+
64
+ // Update local state when props change
65
+ React.useEffect(() => {
66
+ try {
67
+ // If we have currentUserChurch, use it as fallback
68
+ if (props.currentUserChurch && (!props.userChurches || !Array.isArray(props.userChurches))) {
69
+ setUserChurches([props.currentUserChurch]);
70
+ return;
71
+ }
72
+
73
+ let churches = props.userChurches;
74
+
75
+ // Ensure we have an array
76
+ if (!Array.isArray(churches)) {
77
+ if (props.currentUserChurch) {
78
+ setUserChurches([props.currentUserChurch]);
79
+ return;
80
+ }
81
+ churches = [];
82
+ }
83
+
84
+ // Filter for valid userChurch objects
85
+ const validChurches = churches.filter(uc => uc && uc.church && uc.church.id);
86
+
87
+ // If no valid churches but we have currentUserChurch, use it
88
+ if (validChurches.length === 0 && props.currentUserChurch) {
89
+ setUserChurches([props.currentUserChurch]);
90
+ } else {
91
+ setUserChurches(validChurches);
92
+ }
93
+ } catch (error) {
94
+ console.error('ChurchList useEffect - Error updating churches:', error);
95
+ if (props.currentUserChurch) {
96
+ setUserChurches([props.currentUserChurch]);
97
+ } else {
98
+ setUserChurches([]);
99
+ }
100
+ }
101
+ }, [props.userChurches, props.currentUserChurch]);
102
+
103
+ const handleDelete = async (uc: LoginUserChurchInterface) => {
104
+ // Helper function to get label with fallback
105
+ const getLabel = (key: string, fallback: string) => {
106
+ const label = Locale.label(key);
107
+ return label && label !== key ? label : fallback;
108
+ };
109
+
110
+ const confirmMessage = getLabel("wrapper.sureRemoveChurch", "Are you sure you wish to delete this church? You will no longer be a member of {}.").replace("{}", uc.church.name?.toUpperCase());
111
+ if (window.confirm(confirmMessage)) {
112
+ await ApiHelper.delete(`/userchurch/record/${props.context.user.id}/${uc.church.id}/${uc.person.id}`, "MembershipApi");
113
+ await ApiHelper.delete(`/rolemembers/self/${uc.church.id}/${props.context.user.id}`, "MembershipApi");
114
+ // remove the same from userChurches
115
+ const idx = ArrayHelper.getIndex(UserHelper.userChurches, "church.id", uc.church.id);
116
+ if (idx > -1) UserHelper.userChurches.splice(idx, 1);
117
+ props?.onDelete();
118
+ }
119
+ }
120
+
121
+ // Helper function to get label with fallback
122
+ const getLabel = (key: string, fallback: string) => {
123
+ const label = Locale.label(key);
124
+ return label && label !== key ? label : fallback;
125
+ };
126
+
127
+ let result: React.ReactElement[] = [];
128
+
129
+ userChurches.forEach(uc => {
130
+ const userChurch = uc;
131
+ const churchName = uc.church.name;
132
+ result.push(<NavItem
133
+ key={userChurch.church.id}
134
+ selected={(uc.church.id === props.currentUserChurch.church.id) && true}
135
+ onClick={async () => {
136
+ console.log('ChurchList - Selecting church:', userChurch.church.name);
137
+ await UserHelper.selectChurch(props.context, userChurch.church.id, null);
138
+ console.log('ChurchList - Church selected');
139
+
140
+ // Call the onChurchChange callback if provided
141
+ if (props.onChurchChange) {
142
+ props.onChurchChange();
143
+ }
144
+ }}
145
+ label={churchName || "Unknown"}
146
+ icon="church"
147
+ deleteIcon={uc.church.id !== props.currentUserChurch.church.id ? "delete" : null}
148
+ deleteLabel={getLabel("wrapper.deleteChurch", "Delete")}
149
+ deleteFunction={() => { handleDelete(uc); }}
150
+ />);
151
+ });
152
+
153
+ return <div id="church-list">{result}</div>;
154
+ };
@@ -1,47 +1,47 @@
1
- "use client";
2
-
3
- import React from "react";
4
- import { Badge, Icon, IconButton, ListItemButton, ListItemIcon, ListItemText, Tooltip } from "@mui/material";
5
-
6
- interface Props {
7
- badgeCount?: number;
8
- url?: string;
9
- target?: string;
10
- label: string;
11
- icon: string;
12
- onClick?: () => void;
13
- onNavigate?: (url: string) => void;
14
- external?: boolean;
15
- selected?: boolean;
16
- deleteIcon?: string;
17
- deleteLabel?: string;
18
- deleteFunction?: () => void;
19
- }
20
-
21
- export const NavItem: React.FC<Props> = (props) => {
22
-
23
- const getIcon = () => {
24
- if (props.badgeCount && props.badgeCount > 0) return <Badge badgeContent={props.badgeCount} color="error"><Icon>{props.icon}</Icon></Badge>
25
- else return <Icon>{props.icon}</Icon>
26
- }
27
-
28
- const getLinkContents = () => (<ListItemButton data-testid={`nav-item-${props.label?.toLowerCase()?.replace(/\s+/g, '-')}`}>
29
- <Tooltip title={props.label || ""} arrow placement="right">
30
- <ListItemIcon sx={{ minWidth: "40px" }}>{getIcon()}</ListItemIcon>
31
- </Tooltip>
32
- <ListItemText primary={props.label} />
33
- {props?.deleteIcon
34
- ? (
35
- <Tooltip title={props.deleteLabel || ""} arrow placement="left">
36
- <IconButton onClick={props.deleteFunction ? (e) => { e.stopPropagation(); e.preventDefault(); props.deleteFunction() } : null} sx={{ color: "#f7a9a9" }} size="small" aria-label={props.deleteLabel || "Delete item"} data-testid="nav-item-delete">
37
- <Icon sx={{ fontSize: 19 }}>delete</Icon>
38
- </IconButton>
39
- </Tooltip>
40
- )
41
- : ""}
42
- </ListItemButton>)
43
-
44
- if (props.external) return (<a href={props.url} target={props.target} rel="noreferrer" style={{ textDecoration: "none" }} className={(props.selected) ? "selected" : ""} onClick={(e) => { e.preventDefault(); props.onClick ? props.onClick() : window.location.href = props.url }}>{getLinkContents()}</a>)
45
- else return (<a href="about:blank" style={{ textDecoration: "none" }} className={(props.selected) ? "selected" : ""} onClick={(e) => { e.preventDefault(); props.onClick ? props.onClick() : props.onNavigate(props.url) }}>{getLinkContents()}</a>)
46
- //else return (<StyledNavLink to={props.url || "about:blank"} target={props.target} className={(props.selected) ? "selected" : ""} onClick={(e) => { e.preventDefault(); (props.onClick) ? props.onClick() : props.onNavigate(props.url)}}>{getLinkContents()}</StyledNavLink>)
47
- };
1
+ "use client";
2
+
3
+ import React from "react";
4
+ import { Badge, Icon, IconButton, ListItemButton, ListItemIcon, ListItemText, Tooltip } from "@mui/material";
5
+
6
+ interface Props {
7
+ badgeCount?: number;
8
+ url?: string;
9
+ target?: string;
10
+ label: string;
11
+ icon: string;
12
+ onClick?: () => void;
13
+ onNavigate?: (url: string) => void;
14
+ external?: boolean;
15
+ selected?: boolean;
16
+ deleteIcon?: string;
17
+ deleteLabel?: string;
18
+ deleteFunction?: () => void;
19
+ }
20
+
21
+ export const NavItem: React.FC<Props> = (props) => {
22
+
23
+ const getIcon = () => {
24
+ if (props.badgeCount && props.badgeCount > 0) return <Badge badgeContent={props.badgeCount} color="error"><Icon>{props.icon}</Icon></Badge>
25
+ else return <Icon>{props.icon}</Icon>
26
+ }
27
+
28
+ const getLinkContents = () => (<ListItemButton data-testid={`nav-item-${props.label?.toLowerCase()?.replace(/\s+/g, '-')}`}>
29
+ <Tooltip title={props.label || ""} arrow placement="right">
30
+ <ListItemIcon sx={{ minWidth: "40px" }}>{getIcon()}</ListItemIcon>
31
+ </Tooltip>
32
+ <ListItemText primary={props.label} />
33
+ {props?.deleteIcon
34
+ ? (
35
+ <Tooltip title={props.deleteLabel || ""} arrow placement="left">
36
+ <IconButton onClick={props.deleteFunction ? (e) => { e.stopPropagation(); e.preventDefault(); props.deleteFunction() } : null} sx={{ color: "#f7a9a9" }} size="small" aria-label={props.deleteLabel || "Delete item"} data-testid="nav-item-delete">
37
+ <Icon sx={{ fontSize: 19 }}>delete</Icon>
38
+ </IconButton>
39
+ </Tooltip>
40
+ )
41
+ : ""}
42
+ </ListItemButton>)
43
+
44
+ if (props.external) return (<a href={props.url} target={props.target} rel="noreferrer" style={{ textDecoration: "none" }} className={(props.selected) ? "selected" : ""} onClick={(e) => { e.preventDefault(); props.onClick ? props.onClick() : window.location.href = props.url }}>{getLinkContents()}</a>)
45
+ else return (<a href="about:blank" style={{ textDecoration: "none" }} className={(props.selected) ? "selected" : ""} onClick={(e) => { e.preventDefault(); props.onClick ? props.onClick() : props.onNavigate(props.url) }}>{getLinkContents()}</a>)
46
+ //else return (<StyledNavLink to={props.url || "about:blank"} target={props.target} className={(props.selected) ? "selected" : ""} onClick={(e) => { e.preventDefault(); (props.onClick) ? props.onClick() : props.onNavigate(props.url)}}>{getLinkContents()}</StyledNavLink>)
47
+ };