@churchapps/apphelper 0.5.10 → 0.6.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.
- package/dist/components/ErrorMessages.js +1 -1
- package/dist/components/ErrorMessages.js.map +1 -1
- package/dist/components/FormCardPayment.js +2 -2
- package/dist/components/FormCardPayment.js.map +1 -1
- package/dist/components/ImageEditor.d.ts.map +1 -1
- package/dist/components/ImageEditor.js +13 -8
- package/dist/components/ImageEditor.js.map +1 -1
- package/dist/components/PageHeader.js +1 -1
- package/dist/components/PageHeader.js.map +1 -1
- package/dist/components/QuestionEdit.js +2 -2
- package/dist/components/QuestionEdit.js.map +1 -1
- package/dist/components/SmallButton.js +1 -1
- package/dist/components/SmallButton.js.map +1 -1
- package/dist/components/gallery/GalleryModal.d.ts.map +1 -1
- package/dist/components/gallery/GalleryModal.js +2 -6
- package/dist/components/gallery/GalleryModal.js.map +1 -1
- package/dist/components/header/SecondaryMenu.js +2 -2
- package/dist/components/header/SecondaryMenu.js.map +1 -1
- package/dist/components/header/SiteHeader.d.ts.map +1 -1
- package/dist/components/header/SiteHeader.js +0 -3
- package/dist/components/header/SiteHeader.js.map +1 -1
- package/dist/components/notes/Note.js +1 -1
- package/dist/components/notes/Note.js.map +1 -1
- package/dist/components/wrapper/ChurchList.d.ts.map +1 -1
- package/dist/components/wrapper/ChurchList.js +0 -7
- package/dist/components/wrapper/ChurchList.js.map +1 -1
- package/dist/components/wrapper/NewPrivateMessage.d.ts.map +1 -1
- package/dist/components/wrapper/NewPrivateMessage.js +1 -2
- package/dist/components/wrapper/NewPrivateMessage.js.map +1 -1
- package/dist/components/wrapper/Notifications.js +1 -1
- package/dist/components/wrapper/Notifications.js.map +1 -1
- package/dist/components/wrapper/PrivateMessageDetails.d.ts.map +1 -1
- package/dist/components/wrapper/PrivateMessageDetails.js +0 -2
- package/dist/components/wrapper/PrivateMessageDetails.js.map +1 -1
- package/dist/components/wrapper/PrivateMessages.js +1 -1
- package/dist/components/wrapper/PrivateMessages.js.map +1 -1
- package/dist/components/wrapper/UserMenu.d.ts.map +1 -1
- package/dist/components/wrapper/UserMenu.js +0 -13
- package/dist/components/wrapper/UserMenu.js.map +1 -1
- package/dist/helpers/ErrorHelper.d.ts.map +1 -1
- package/dist/helpers/ErrorHelper.js +0 -2
- package/dist/helpers/ErrorHelper.js.map +1 -1
- package/dist/helpers/NotificationService.d.ts +0 -18
- package/dist/helpers/NotificationService.d.ts.map +1 -1
- package/dist/helpers/NotificationService.js +0 -65
- package/dist/helpers/NotificationService.js.map +1 -1
- package/dist/helpers/SlugHelper.d.ts.map +1 -1
- package/dist/helpers/SlugHelper.js +5 -19
- package/dist/helpers/SlugHelper.js.map +1 -1
- package/dist/helpers/SocketHelper.d.ts.map +1 -1
- package/dist/helpers/SocketHelper.js +1 -53
- package/dist/helpers/SocketHelper.js.map +1 -1
- package/dist/helpers/UserHelper.d.ts.map +1 -1
- package/dist/helpers/UserHelper.js +0 -4
- package/dist/helpers/UserHelper.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ErrorMessages.tsx +1 -1
- package/src/components/FormCardPayment.tsx +1 -1
- package/src/components/ImageEditor.tsx +167 -161
- package/src/components/PageHeader.tsx +2 -2
- package/src/components/QuestionEdit.tsx +2 -2
- package/src/components/SmallButton.tsx +1 -1
- package/src/components/gallery/GalleryModal.tsx +169 -173
- package/src/components/header/SecondaryMenu.tsx +2 -2
- package/src/components/header/SiteHeader.tsx +204 -207
- package/src/components/notes/Note.tsx +2 -2
- package/src/components/wrapper/ChurchList.tsx +145 -154
- package/src/components/wrapper/NewPrivateMessage.tsx +1 -2
- package/src/components/wrapper/Notifications.tsx +1 -1
- package/src/components/wrapper/PrivateMessageDetails.tsx +2 -6
- package/src/components/wrapper/PrivateMessages.tsx +1 -1
- package/src/components/wrapper/UserMenu.tsx +3 -17
- package/src/helpers/ErrorHelper.ts +41 -43
- package/src/helpers/NotificationService.ts +232 -296
- package/src/helpers/SlugHelper.ts +5 -19
- package/src/helpers/SocketHelper.ts +247 -296
- package/src/helpers/UserHelper.ts +2 -6
|
@@ -1,154 +1,145 @@
|
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
setUserChurches([props.currentUserChurch]);
|
|
90
|
-
} else {
|
|
91
|
-
setUserChurches(
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
+
const [userChurches, setUserChurches] = useState(() => {
|
|
14
|
+
try {
|
|
15
|
+
// If we have currentUserChurch, use it as fallback
|
|
16
|
+
if (props.currentUserChurch && (!props.userChurches || !Array.isArray(props.userChurches))) {
|
|
17
|
+
return [props.currentUserChurch];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let churches = props.userChurches;
|
|
21
|
+
|
|
22
|
+
// Ensure we have an array
|
|
23
|
+
if (!Array.isArray(churches)) {
|
|
24
|
+
console.warn('ChurchList - Expected array but got:', typeof churches, churches);
|
|
25
|
+
// If it's a plain church object and we have currentUserChurch, use that
|
|
26
|
+
if (props.currentUserChurch) {
|
|
27
|
+
return [props.currentUserChurch];
|
|
28
|
+
}
|
|
29
|
+
churches = [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Filter for valid userChurch objects (should have church property)
|
|
33
|
+
const validChurches = churches.filter(uc => {
|
|
34
|
+
const isValid = uc && uc.church && uc.church.id;
|
|
35
|
+
if (!isValid) {
|
|
36
|
+
console.warn('ChurchList - Invalid church structure:', uc);
|
|
37
|
+
}
|
|
38
|
+
return isValid;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// If no valid churches but we have currentUserChurch, use it
|
|
42
|
+
if (validChurches.length === 0 && props.currentUserChurch) {
|
|
43
|
+
return [props.currentUserChurch];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return validChurches;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('ChurchList - Error processing churches:', error);
|
|
49
|
+
// Last resort: if we have currentUserChurch, use it
|
|
50
|
+
if (props.currentUserChurch) {
|
|
51
|
+
return [props.currentUserChurch];
|
|
52
|
+
}
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Update local state when props change
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
try {
|
|
60
|
+
// If we have currentUserChurch, use it as fallback
|
|
61
|
+
if (props.currentUserChurch && (!props.userChurches || !Array.isArray(props.userChurches))) {
|
|
62
|
+
setUserChurches([props.currentUserChurch]);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let churches = props.userChurches;
|
|
67
|
+
|
|
68
|
+
// Ensure we have an array
|
|
69
|
+
if (!Array.isArray(churches)) {
|
|
70
|
+
if (props.currentUserChurch) {
|
|
71
|
+
setUserChurches([props.currentUserChurch]);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
churches = [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Filter for valid userChurch objects
|
|
78
|
+
const validChurches = churches.filter(uc => uc && uc.church && uc.church.id);
|
|
79
|
+
|
|
80
|
+
// If no valid churches but we have currentUserChurch, use it
|
|
81
|
+
if (validChurches.length === 0 && props.currentUserChurch) {
|
|
82
|
+
setUserChurches([props.currentUserChurch]);
|
|
83
|
+
} else {
|
|
84
|
+
setUserChurches(validChurches);
|
|
85
|
+
}
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error('ChurchList useEffect - Error updating churches:', error);
|
|
88
|
+
if (props.currentUserChurch) {
|
|
89
|
+
setUserChurches([props.currentUserChurch]);
|
|
90
|
+
} else {
|
|
91
|
+
setUserChurches([]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, [props.userChurches, props.currentUserChurch]);
|
|
95
|
+
|
|
96
|
+
const handleDelete = async (uc: LoginUserChurchInterface) => {
|
|
97
|
+
// Helper function to get label with fallback
|
|
98
|
+
const getLabel = (key: string, fallback: string) => {
|
|
99
|
+
const label = Locale.label(key);
|
|
100
|
+
return label && label !== key ? label : fallback;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
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());
|
|
104
|
+
if (window.confirm(confirmMessage)) {
|
|
105
|
+
await ApiHelper.delete(`/userchurch/record/${props.context.user.id}/${uc.church.id}/${uc.person.id}`, "MembershipApi");
|
|
106
|
+
await ApiHelper.delete(`/rolemembers/self/${uc.church.id}/${props.context.user.id}`, "MembershipApi");
|
|
107
|
+
// remove the same from userChurches
|
|
108
|
+
const idx = ArrayHelper.getIndex(UserHelper.userChurches, "church.id", uc.church.id);
|
|
109
|
+
if (idx > -1) UserHelper.userChurches.splice(idx, 1);
|
|
110
|
+
props?.onDelete();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Helper function to get label with fallback
|
|
115
|
+
const getLabel = (key: string, fallback: string) => {
|
|
116
|
+
const label = Locale.label(key);
|
|
117
|
+
return label && label !== key ? label : fallback;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
let result: React.ReactElement[] = [];
|
|
121
|
+
|
|
122
|
+
userChurches.forEach(uc => {
|
|
123
|
+
const userChurch = uc;
|
|
124
|
+
const churchName = uc.church.name;
|
|
125
|
+
result.push(<NavItem
|
|
126
|
+
key={userChurch.church.id}
|
|
127
|
+
selected={(uc.church.id === props.currentUserChurch.church.id) && true}
|
|
128
|
+
onClick={async () => {
|
|
129
|
+
await UserHelper.selectChurch(props.context, userChurch.church.id, null);
|
|
130
|
+
|
|
131
|
+
// Call the onChurchChange callback if provided
|
|
132
|
+
if (props.onChurchChange) {
|
|
133
|
+
props.onChurchChange();
|
|
134
|
+
}
|
|
135
|
+
}}
|
|
136
|
+
label={churchName || "Unknown"}
|
|
137
|
+
icon="church"
|
|
138
|
+
deleteIcon={uc.church.id !== props.currentUserChurch.church.id ? "delete" : null}
|
|
139
|
+
deleteLabel={getLabel("wrapper.deleteChurch", "Delete")}
|
|
140
|
+
deleteFunction={() => { handleDelete(uc); }}
|
|
141
|
+
/>);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return <div id="church-list">{result}</div>;
|
|
145
|
+
};
|
|
@@ -62,7 +62,6 @@ export const NewPrivateMessage: React.FC<Props> = (props) => {
|
|
|
62
62
|
}
|
|
63
63
|
} catch (error) {
|
|
64
64
|
// No existing conversation found, continue to create new one
|
|
65
|
-
console.log("No existing conversation found for person:", person.id);
|
|
66
65
|
}
|
|
67
66
|
setSelectedPerson(person);
|
|
68
67
|
}
|
|
@@ -161,7 +160,7 @@ export const NewPrivateMessage: React.FC<Props> = (props) => {
|
|
|
161
160
|
{isSearching && (
|
|
162
161
|
<Box>
|
|
163
162
|
{[...Array(3)].map((_, index) => (
|
|
164
|
-
<Box key={index} sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
|
|
163
|
+
<Box key={`skeleton-${index}`} sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
|
|
165
164
|
<Skeleton variant="circular" width={48} height={48} sx={{ mr: 2 }} />
|
|
166
165
|
<Skeleton variant="text" width="60%" height={24} />
|
|
167
166
|
</Box>
|
|
@@ -205,7 +205,7 @@ export const Notifications: React.FC<Props> = (props) => {
|
|
|
205
205
|
{isLoading ? (
|
|
206
206
|
<Box sx={{ p: 2 }}>
|
|
207
207
|
{[...Array(3)].map((_, index) => (
|
|
208
|
-
<Box key={index} sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
|
|
208
|
+
<Box key={`skeleton-${index}`} sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
|
|
209
209
|
<Skeleton variant="circular" width={48} height={48} sx={{ mr: 2 }} />
|
|
210
210
|
<Box sx={{ flex: 1 }}>
|
|
211
211
|
<Skeleton variant="text" width="80%" height={24} />
|
|
@@ -31,17 +31,13 @@ export const PrivateMessageDetails: React.FC<Props> = (props) => {
|
|
|
31
31
|
const clearNotification = async () => {
|
|
32
32
|
if (props.privateMessage.notifyPersonId === props.context.person.id) {
|
|
33
33
|
try {
|
|
34
|
-
console.log("Marking private message as read:", props.privateMessage.id);
|
|
35
|
-
|
|
36
34
|
// Clear the notification by getting the private message details
|
|
37
35
|
await ApiHelper.get(`/privateMessages/${props.privateMessage.id}`, "MessagingApi");
|
|
38
|
-
|
|
36
|
+
|
|
39
37
|
// Manually refresh notification counts to ensure immediate UI update
|
|
40
38
|
const notificationService = NotificationService.getInstance();
|
|
41
39
|
await notificationService.refresh();
|
|
42
|
-
|
|
43
|
-
console.log("Private message marked as read and notifications refreshed");
|
|
44
|
-
|
|
40
|
+
|
|
45
41
|
// Notify parent component that message was marked as read
|
|
46
42
|
if (props.onMessageRead) {
|
|
47
43
|
props.onMessageRead();
|
|
@@ -527,7 +527,7 @@ export const PrivateMessages: React.FC<Props> = React.memo((props) => {
|
|
|
527
527
|
{isLoading ? (
|
|
528
528
|
<Box sx={{ p: 2 }}>
|
|
529
529
|
{[...Array(3)].map((_, index) => (
|
|
530
|
-
<Box key={index} sx={{ px: 2, py: 0.5, mb: 1 }}>
|
|
530
|
+
<Box key={`skeleton-${index}`} sx={{ px: 2, py: 0.5, mb: 1 }}>
|
|
531
531
|
<Box sx={{
|
|
532
532
|
p: 3,
|
|
533
533
|
borderRadius: 3,
|
|
@@ -96,10 +96,8 @@ const UserMenuContent: React.FC<Props> = React.memo((props) => {
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const handleSwitchChurch = () => {
|
|
99
|
-
console.log('UserMenu - handleSwitchChurch called');
|
|
100
99
|
removeCookie("lastChurchId", { path: "/" });
|
|
101
100
|
setTabIndex(2);
|
|
102
|
-
console.log('UserMenu - tabIndex set to 2');
|
|
103
101
|
};
|
|
104
102
|
|
|
105
103
|
const getMainLinks = () => {
|
|
@@ -151,7 +149,6 @@ const UserMenuContent: React.FC<Props> = React.memo((props) => {
|
|
|
151
149
|
const [tabIndex, setTabIndex] = React.useState(0);
|
|
152
150
|
|
|
153
151
|
const getTabs = () => {
|
|
154
|
-
console.log('UserMenu getTabs - Current tabIndex:', tabIndex);
|
|
155
152
|
return (
|
|
156
153
|
<Box sx={{ borderBottom: 1, borderColor: "divider" }}>
|
|
157
154
|
<TabPanel value={tabIndex} index={0}>
|
|
@@ -165,26 +162,16 @@ const UserMenuContent: React.FC<Props> = React.memo((props) => {
|
|
|
165
162
|
<div style={{ maxHeight: '70vh', overflowY: "auto" }}>
|
|
166
163
|
<NavItem label="Back" key="ChurchBack" icon="arrow_back" onClick={() => { setTabIndex(0); }} />
|
|
167
164
|
{(() => {
|
|
168
|
-
console.log('UserMenu Church Tab - Rendering church list section');
|
|
169
|
-
console.log('UserMenu Church Tab - Full context:', props.context);
|
|
170
|
-
console.log('UserMenu Church Tab - context.userChurches:', props.context?.userChurches);
|
|
171
|
-
console.log('UserMenu Church Tab - context.userChurches[0]:', props.context?.userChurches?.[0]);
|
|
172
|
-
console.log('UserMenu Church Tab - context.userChurch:', props.context?.userChurch);
|
|
173
|
-
console.log('UserMenu Church Tab - userChurches type:', typeof props.context?.userChurches);
|
|
174
|
-
console.log('UserMenu Church Tab - userChurches is array?', Array.isArray(props.context?.userChurches));
|
|
175
|
-
console.log('UserMenu Church Tab - userChurches length:', props.context?.userChurches?.length);
|
|
176
|
-
|
|
177
165
|
// Check if userChurches is actually the userChurch object
|
|
178
166
|
if (props.context?.userChurches && !Array.isArray(props.context.userChurches) && (props.context.userChurches as any).id) {
|
|
179
167
|
console.error('UserMenu - ERROR: context.userChurches contains a single church object instead of an array!');
|
|
180
|
-
console.log('UserMenu - Attempting to use context.userChurch as single item array');
|
|
181
168
|
const churchArray = props.context.userChurch ? [props.context.userChurch] : [];
|
|
182
169
|
return <ChurchList userChurches={churchArray} currentUserChurch={props.context?.userChurch} context={props.context} onDelete={handleClose} onChurchChange={() => {
|
|
183
170
|
handleClose();
|
|
184
171
|
// Don't navigate - just close the menu and let the context update trigger re-renders
|
|
185
172
|
}} />;
|
|
186
173
|
}
|
|
187
|
-
|
|
174
|
+
|
|
188
175
|
if (!props.context?.userChurches) {
|
|
189
176
|
return <Typography sx={{ p: 2, color: 'text.secondary' }}>Loading churches...</Typography>;
|
|
190
177
|
} else if (!Array.isArray(props.context.userChurches)) {
|
|
@@ -193,10 +180,9 @@ const UserMenuContent: React.FC<Props> = React.memo((props) => {
|
|
|
193
180
|
return <Typography sx={{ p: 2, color: 'text.secondary' }}>No churches available</Typography>;
|
|
194
181
|
} else {
|
|
195
182
|
// Ensure we always pass an array
|
|
196
|
-
const churchesArray = Array.isArray(props.context.userChurches)
|
|
197
|
-
? props.context.userChurches
|
|
183
|
+
const churchesArray = Array.isArray(props.context.userChurches)
|
|
184
|
+
? props.context.userChurches
|
|
198
185
|
: [props.context.userChurches];
|
|
199
|
-
console.log('UserMenu - Passing to ChurchList:', churchesArray);
|
|
200
186
|
return <ChurchList userChurches={churchesArray} currentUserChurch={props.context?.userChurch} context={props.context} onDelete={handleClose} onChurchChange={() => {
|
|
201
187
|
handleClose();
|
|
202
188
|
// Don't navigate - just close the menu and let the context update trigger re-renders
|
|
@@ -1,43 +1,41 @@
|
|
|
1
|
-
import { ErrorLogInterface, ErrorAppDataInterface } from "@churchapps/helpers";
|
|
2
|
-
import { ApiHelper } from "@churchapps/helpers";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export class ErrorHelper {
|
|
6
|
-
|
|
7
|
-
static getAppData: () => { churchId: string, userId: string, originUrl: string, application: string };
|
|
8
|
-
static customErrorHandler: (errorLog: ErrorLogInterface) => void;
|
|
9
|
-
|
|
10
|
-
static init = (getAppData: () => ErrorAppDataInterface, customErrorHandler: (errorLog: ErrorLogInterface) => void) => {
|
|
11
|
-
ErrorHelper.getAppData = getAppData;
|
|
12
|
-
ErrorHelper.customErrorHandler = customErrorHandler;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static logError = (errorType: string, message: string, details: string) => {
|
|
16
|
-
if (this.getAppData) {
|
|
17
|
-
const data = this.getAppData();
|
|
18
|
-
const log: ErrorLogInterface = {
|
|
19
|
-
application: data.application,
|
|
20
|
-
errorTime: new Date(),
|
|
21
|
-
userId: data.userId,
|
|
22
|
-
churchId: data.churchId,
|
|
23
|
-
originUrl: data.originUrl,
|
|
24
|
-
errorType: errorType,
|
|
25
|
-
message: message,
|
|
26
|
-
details: details
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (log.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}
|
|
1
|
+
import { ErrorLogInterface, ErrorAppDataInterface } from "@churchapps/helpers";
|
|
2
|
+
import { ApiHelper } from "@churchapps/helpers";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class ErrorHelper {
|
|
6
|
+
|
|
7
|
+
static getAppData: () => { churchId: string, userId: string, originUrl: string, application: string };
|
|
8
|
+
static customErrorHandler: (errorLog: ErrorLogInterface) => void;
|
|
9
|
+
|
|
10
|
+
static init = (getAppData: () => ErrorAppDataInterface, customErrorHandler: (errorLog: ErrorLogInterface) => void) => {
|
|
11
|
+
ErrorHelper.getAppData = getAppData;
|
|
12
|
+
ErrorHelper.customErrorHandler = customErrorHandler;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static logError = (errorType: string, message: string, details: string) => {
|
|
16
|
+
if (this.getAppData) {
|
|
17
|
+
const data = this.getAppData();
|
|
18
|
+
const log: ErrorLogInterface = {
|
|
19
|
+
application: data.application,
|
|
20
|
+
errorTime: new Date(),
|
|
21
|
+
userId: data.userId,
|
|
22
|
+
churchId: data.churchId,
|
|
23
|
+
originUrl: data.originUrl,
|
|
24
|
+
errorType: errorType,
|
|
25
|
+
message: message,
|
|
26
|
+
details: details
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if (log.errorType === "401" && log.message.indexOf("/users/login") > -1) return;
|
|
31
|
+
if (log.message.indexOf("clientErrors") > -1) return;
|
|
32
|
+
try {
|
|
33
|
+
// Error posting to /errors endpoint disabled
|
|
34
|
+
// ApiHelper.postAnonymous("/clientErrors", [log], "MembershipApi");
|
|
35
|
+
} catch (error) {
|
|
36
|
+
}
|
|
37
|
+
if (ErrorHelper.customErrorHandler) ErrorHelper.customErrorHandler(log);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|