@churchapps/apphelper 0.4.50 → 0.5.1
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/FormCardPayment.d.ts +1 -1
- package/dist/components/FormCardPayment.d.ts.map +1 -1
- package/dist/components/FormCardPayment.js +27 -10
- package/dist/components/FormCardPayment.js.map +1 -1
- package/dist/components/Loading.js +36 -36
- package/dist/components/notes/Notes.js +27 -27
- package/dist/helpers/UserHelper.d.ts.map +1 -1
- package/dist/helpers/UserHelper.js +4 -1
- package/dist/helpers/UserHelper.js.map +1 -1
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/index.js.map +1 -1
- package/dist/public/css/cropper.css +309 -309
- package/dist/public/css/styles.css +111 -111
- package/package.json +72 -73
- package/public/css/cropper.css +309 -309
- package/public/css/styles.css +111 -111
- package/public/locales/de.json +269 -269
- package/public/locales/en.json +276 -276
- package/public/locales/es.json +272 -272
- package/public/locales/fr.json +269 -269
- package/public/locales/hi.json +269 -269
- package/public/locales/it.json +269 -269
- package/public/locales/ko.json +269 -269
- package/public/locales/no.json +269 -269
- package/public/locales/pt.json +269 -269
- package/public/locales/ru.json +269 -269
- package/public/locales/tl.json +269 -269
- package/public/locales/zh.json +269 -269
- package/src/components/DisplayBox.tsx +83 -83
- package/src/components/ErrorMessages.tsx +28 -28
- package/src/components/ExportLink.tsx +81 -81
- package/src/components/FloatingSupport.tsx +18 -18
- package/src/components/FormCardPayment.tsx +184 -169
- package/src/components/FormSubmissionEdit.tsx +168 -168
- package/src/components/HelpIcon.tsx +12 -12
- package/src/components/ImageEditor.tsx +161 -161
- package/src/components/InputBox.tsx +96 -96
- package/src/components/Loading.tsx +77 -77
- package/src/components/PageHeader.tsx +110 -110
- package/src/components/PersonAvatar.tsx +77 -77
- package/src/components/QuestionEdit.tsx +99 -99
- package/src/components/SmallButton.tsx +42 -42
- package/src/components/SupportModal.tsx +32 -32
- package/src/components/TabPanel.tsx +28 -28
- package/src/components/gallery/GalleryModal.tsx +173 -173
- package/src/components/gallery/StockPhotos.tsx +95 -95
- package/src/components/gallery/index.ts +1 -1
- package/src/components/header/Banner.tsx +11 -11
- package/src/components/header/PrimaryMenu.tsx +100 -100
- package/src/components/header/SecondaryMenu.tsx +23 -23
- package/src/components/header/SecondaryMenuAlt.tsx +40 -40
- package/src/components/header/SiteHeader.tsx +207 -207
- package/src/components/header/SupportDrawer.tsx +111 -111
- package/src/components/header/index.tsx +2 -2
- package/src/components/index.tsx +20 -20
- package/src/components/notes/AddNote.tsx +180 -180
- package/src/components/notes/Note.tsx +68 -68
- package/src/components/notes/Notes.tsx +208 -208
- package/src/components/notes/index.ts +3 -3
- package/src/components/wrapper/AppList.tsx +19 -19
- package/src/components/wrapper/ChurchList.tsx +154 -154
- package/src/components/wrapper/NavItem.tsx +47 -47
- package/src/components/wrapper/NewPrivateMessage.tsx +253 -253
- package/src/components/wrapper/Notifications.tsx +223 -223
- package/src/components/wrapper/PrivateMessageDetails.tsx +112 -112
- package/src/components/wrapper/PrivateMessages.tsx +576 -576
- package/src/components/wrapper/UserMenu.tsx +383 -383
- package/src/components/wrapper/index.tsx +8 -8
- package/src/helpers/AnalyticsHelper.ts +32 -32
- package/src/helpers/AppearanceHelper.ts +73 -73
- package/src/helpers/ArrayHelper.ts +87 -87
- package/src/helpers/CurrencyHelper.ts +10 -10
- package/src/helpers/DateHelper.ts +104 -104
- package/src/helpers/ErrorHelper.ts +43 -43
- package/src/helpers/EventHelper.ts +49 -49
- package/src/helpers/FileHelper.ts +31 -31
- package/src/helpers/Locale.ts +457 -457
- package/src/helpers/NotificationService.ts +296 -296
- package/src/helpers/PersonHelper.ts +62 -62
- package/src/helpers/SlugHelper.ts +37 -37
- package/src/helpers/SocketHelper.ts +296 -296
- package/src/helpers/UniqueIdHelper.ts +36 -36
- package/src/helpers/UserHelper.ts +107 -104
- package/src/helpers/createEmotionCache.ts +17 -17
- package/src/helpers/index.ts +58 -50
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useMountedState.ts +16 -16
- package/src/hooks/useNotifications.ts +93 -93
- package/src/index.ts +2 -2
- package/src/types/interface-extensions.d.ts +12 -0
- package/tsconfig.json +31 -31
- package/dist/public/locales/de.json +0 -270
- package/dist/public/locales/en.json +0 -277
- package/dist/public/locales/es.json +0 -272
- package/dist/public/locales/fr.json +0 -270
- package/dist/public/locales/hi.json +0 -270
- package/dist/public/locales/it.json +0 -270
- package/dist/public/locales/ko.json +0 -270
- package/dist/public/locales/no.json +0 -270
- package/dist/public/locales/pt.json +0 -270
- package/dist/public/locales/ru.json +0 -270
- package/dist/public/locales/tl.json +0 -270
- package/dist/public/locales/zh.json +0 -270
|
@@ -1,223 +1,223 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, { useState } from "react";
|
|
4
|
-
import { ApiHelper } from "@churchapps/helpers";
|
|
5
|
-
import {
|
|
6
|
-
Box,
|
|
7
|
-
Icon,
|
|
8
|
-
Stack,
|
|
9
|
-
Typography,
|
|
10
|
-
Paper,
|
|
11
|
-
List,
|
|
12
|
-
ListItem,
|
|
13
|
-
ListItemAvatar,
|
|
14
|
-
ListItemText,
|
|
15
|
-
Avatar,
|
|
16
|
-
Chip,
|
|
17
|
-
Divider,
|
|
18
|
-
IconButton,
|
|
19
|
-
Skeleton,
|
|
20
|
-
useTheme
|
|
21
|
-
} from "@mui/material";
|
|
22
|
-
import {
|
|
23
|
-
Notifications as NotificationsIcon,
|
|
24
|
-
Task as TaskIcon,
|
|
25
|
-
Assignment as AssignmentIcon,
|
|
26
|
-
OpenInNew as OpenInNewIcon
|
|
27
|
-
} from "@mui/icons-material";
|
|
28
|
-
import { NotificationInterface, UserContextInterface } from "@churchapps/helpers";
|
|
29
|
-
import { DateHelper } from "../../helpers";
|
|
30
|
-
|
|
31
|
-
interface Props {
|
|
32
|
-
appName: string;
|
|
33
|
-
context: UserContextInterface;
|
|
34
|
-
onNavigate: (url: string) => void;
|
|
35
|
-
onUpdate: () => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const Notifications: React.FC<Props> = (props) => {
|
|
39
|
-
const [notifications, setNotifications] = useState<NotificationInterface[]>([]);
|
|
40
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
41
|
-
const theme = useTheme();
|
|
42
|
-
|
|
43
|
-
const loadData = async () => {
|
|
44
|
-
setIsLoading(true);
|
|
45
|
-
const n: NotificationInterface[] = await ApiHelper.get("/notifications/my", "MessagingApi");
|
|
46
|
-
setNotifications(n);
|
|
47
|
-
setIsLoading(false);
|
|
48
|
-
props.onUpdate();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
React.useEffect(() => { loadData(); }, []); //eslint-disable-line
|
|
52
|
-
|
|
53
|
-
const getAppUrl = (appName:string) => {
|
|
54
|
-
switch (appName) {
|
|
55
|
-
case props.appName.toLowerCase(): return "";
|
|
56
|
-
case "chums": return "https://app.chums.org";
|
|
57
|
-
case "b1": return "https://" + props.context.userChurch.church.subDomain + ".b1.church";
|
|
58
|
-
default: return "";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const handleClick = (notification:NotificationInterface) => {
|
|
63
|
-
let app = "";
|
|
64
|
-
let path = "";
|
|
65
|
-
switch (notification.contentType) {
|
|
66
|
-
case "task": app = "chums"; path = "/tasks/" + notification.contentId; break;
|
|
67
|
-
case "assignment": app = "b1"; path = "/my/plans/" + notification.contentId; break;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const appUrl = getAppUrl(app);
|
|
71
|
-
if (appUrl === "") {
|
|
72
|
-
props.onNavigate(path);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
window.open(appUrl + path, "_blank");
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const getNotificationIcon = (contentType: string) => {
|
|
80
|
-
switch (contentType) {
|
|
81
|
-
case "task": return <TaskIcon />;
|
|
82
|
-
case "assignment": return <AssignmentIcon />;
|
|
83
|
-
default: return <NotificationsIcon />;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const getNotificationList = () => {
|
|
88
|
-
if (notifications.length === 0) {
|
|
89
|
-
return (
|
|
90
|
-
<Box id="notifications-empty" sx={{ textAlign: 'center', py: 4 }}>
|
|
91
|
-
<NotificationsIcon sx={{ fontSize: 48, color: 'grey.400', mb: 2 }} />
|
|
92
|
-
<Typography variant="h6" color="textSecondary">
|
|
93
|
-
No notifications
|
|
94
|
-
</Typography>
|
|
95
|
-
<Typography variant="body2" color="textSecondary">
|
|
96
|
-
You're all caught up!
|
|
97
|
-
</Typography>
|
|
98
|
-
</Box>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<List id="notifications-list" sx={{ width: '100%' }}>
|
|
104
|
-
{notifications.map((notification, index) => {
|
|
105
|
-
let datePosted = new Date(notification.timeSent);
|
|
106
|
-
const displayDuration = DateHelper.getDisplayDuration(datePosted);
|
|
107
|
-
const isUnread = notification.isNew;
|
|
108
|
-
|
|
109
|
-
return (
|
|
110
|
-
<React.Fragment key={notification.id}>
|
|
111
|
-
<ListItem
|
|
112
|
-
id={`notification-item-${notification.id}`}
|
|
113
|
-
component="button"
|
|
114
|
-
onClick={() => handleClick(notification)}
|
|
115
|
-
sx={{
|
|
116
|
-
alignItems: 'flex-start',
|
|
117
|
-
py: 2,
|
|
118
|
-
cursor: 'pointer',
|
|
119
|
-
bgcolor: isUnread ? 'action.hover' : 'transparent',
|
|
120
|
-
'&:hover': {
|
|
121
|
-
bgcolor: 'action.hover'
|
|
122
|
-
},
|
|
123
|
-
borderRadius: 1,
|
|
124
|
-
mb: 0.5
|
|
125
|
-
}}
|
|
126
|
-
>
|
|
127
|
-
<ListItemAvatar>
|
|
128
|
-
<Avatar
|
|
129
|
-
sx={{
|
|
130
|
-
bgcolor: isUnread ? 'primary.main' : 'grey.400',
|
|
131
|
-
width: 48,
|
|
132
|
-
height: 48
|
|
133
|
-
}}
|
|
134
|
-
>
|
|
135
|
-
{getNotificationIcon(notification.contentType)}
|
|
136
|
-
</Avatar>
|
|
137
|
-
</ListItemAvatar>
|
|
138
|
-
<ListItemText
|
|
139
|
-
primary={
|
|
140
|
-
<Stack direction="row" justifyContent="space-between" alignItems="flex-start">
|
|
141
|
-
<Typography
|
|
142
|
-
variant="body1"
|
|
143
|
-
sx={{
|
|
144
|
-
fontWeight: isUnread ? 600 : 400,
|
|
145
|
-
flex: 1,
|
|
146
|
-
pr: 1
|
|
147
|
-
}}
|
|
148
|
-
>
|
|
149
|
-
{notification.message}
|
|
150
|
-
</Typography>
|
|
151
|
-
<Stack direction="row" alignItems="center" spacing={1}>
|
|
152
|
-
{isUnread && (
|
|
153
|
-
<Chip
|
|
154
|
-
size="small"
|
|
155
|
-
label="New"
|
|
156
|
-
color="primary"
|
|
157
|
-
sx={{ height: 20, fontSize: '0.7rem' }}
|
|
158
|
-
/>
|
|
159
|
-
)}
|
|
160
|
-
<Typography variant="caption" color="textSecondary">
|
|
161
|
-
{displayDuration}
|
|
162
|
-
</Typography>
|
|
163
|
-
</Stack>
|
|
164
|
-
</Stack>
|
|
165
|
-
}
|
|
166
|
-
secondary={
|
|
167
|
-
notification.link && (
|
|
168
|
-
<Box sx={{ mt: 1 }}>
|
|
169
|
-
<IconButton
|
|
170
|
-
size="small"
|
|
171
|
-
onClick={(e) => {
|
|
172
|
-
e.stopPropagation();
|
|
173
|
-
window.open(notification.link, '_blank');
|
|
174
|
-
}}
|
|
175
|
-
sx={{ p: 0.5 }}
|
|
176
|
-
>
|
|
177
|
-
<OpenInNewIcon fontSize="small" />
|
|
178
|
-
<Typography variant="caption" sx={{ ml: 0.5 }}>
|
|
179
|
-
View Details
|
|
180
|
-
</Typography>
|
|
181
|
-
</IconButton>
|
|
182
|
-
</Box>
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
/>
|
|
186
|
-
</ListItem>
|
|
187
|
-
{index < notifications.length - 1 && <Divider variant="inset" component="li" />}
|
|
188
|
-
</React.Fragment>
|
|
189
|
-
);
|
|
190
|
-
})}
|
|
191
|
-
</List>
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return (
|
|
197
|
-
<Paper id="notifications-panel" elevation={0} sx={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
|
|
198
|
-
<Box id="notifications-header" sx={{ p: 2, borderBottom: 1, borderColor: 'divider' }}>
|
|
199
|
-
<Typography variant="h6" component="h2">
|
|
200
|
-
Notifications
|
|
201
|
-
</Typography>
|
|
202
|
-
</Box>
|
|
203
|
-
|
|
204
|
-
<Box id="notifications-content" sx={{ flex: 1, overflow: 'auto' }}>
|
|
205
|
-
{isLoading ? (
|
|
206
|
-
<Box sx={{ p: 2 }}>
|
|
207
|
-
{[...Array(3)].map((_, index) => (
|
|
208
|
-
<Box key={index} sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
|
|
209
|
-
<Skeleton variant="circular" width={48} height={48} sx={{ mr: 2 }} />
|
|
210
|
-
<Box sx={{ flex: 1 }}>
|
|
211
|
-
<Skeleton variant="text" width="80%" height={24} />
|
|
212
|
-
<Skeleton variant="text" width="40%" height={20} />
|
|
213
|
-
</Box>
|
|
214
|
-
</Box>
|
|
215
|
-
))}
|
|
216
|
-
</Box>
|
|
217
|
-
) : (
|
|
218
|
-
getNotificationList()
|
|
219
|
-
)}
|
|
220
|
-
</Box>
|
|
221
|
-
</Paper>
|
|
222
|
-
);
|
|
223
|
-
};
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useState } from "react";
|
|
4
|
+
import { ApiHelper } from "@churchapps/helpers";
|
|
5
|
+
import {
|
|
6
|
+
Box,
|
|
7
|
+
Icon,
|
|
8
|
+
Stack,
|
|
9
|
+
Typography,
|
|
10
|
+
Paper,
|
|
11
|
+
List,
|
|
12
|
+
ListItem,
|
|
13
|
+
ListItemAvatar,
|
|
14
|
+
ListItemText,
|
|
15
|
+
Avatar,
|
|
16
|
+
Chip,
|
|
17
|
+
Divider,
|
|
18
|
+
IconButton,
|
|
19
|
+
Skeleton,
|
|
20
|
+
useTheme
|
|
21
|
+
} from "@mui/material";
|
|
22
|
+
import {
|
|
23
|
+
Notifications as NotificationsIcon,
|
|
24
|
+
Task as TaskIcon,
|
|
25
|
+
Assignment as AssignmentIcon,
|
|
26
|
+
OpenInNew as OpenInNewIcon
|
|
27
|
+
} from "@mui/icons-material";
|
|
28
|
+
import { NotificationInterface, UserContextInterface } from "@churchapps/helpers";
|
|
29
|
+
import { DateHelper } from "../../helpers";
|
|
30
|
+
|
|
31
|
+
interface Props {
|
|
32
|
+
appName: string;
|
|
33
|
+
context: UserContextInterface;
|
|
34
|
+
onNavigate: (url: string) => void;
|
|
35
|
+
onUpdate: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const Notifications: React.FC<Props> = (props) => {
|
|
39
|
+
const [notifications, setNotifications] = useState<NotificationInterface[]>([]);
|
|
40
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
41
|
+
const theme = useTheme();
|
|
42
|
+
|
|
43
|
+
const loadData = async () => {
|
|
44
|
+
setIsLoading(true);
|
|
45
|
+
const n: NotificationInterface[] = await ApiHelper.get("/notifications/my", "MessagingApi");
|
|
46
|
+
setNotifications(n);
|
|
47
|
+
setIsLoading(false);
|
|
48
|
+
props.onUpdate();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
React.useEffect(() => { loadData(); }, []); //eslint-disable-line
|
|
52
|
+
|
|
53
|
+
const getAppUrl = (appName:string) => {
|
|
54
|
+
switch (appName) {
|
|
55
|
+
case props.appName.toLowerCase(): return "";
|
|
56
|
+
case "chums": return "https://app.chums.org";
|
|
57
|
+
case "b1": return "https://" + props.context.userChurch.church.subDomain + ".b1.church";
|
|
58
|
+
default: return "";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const handleClick = (notification:NotificationInterface) => {
|
|
63
|
+
let app = "";
|
|
64
|
+
let path = "";
|
|
65
|
+
switch (notification.contentType) {
|
|
66
|
+
case "task": app = "chums"; path = "/tasks/" + notification.contentId; break;
|
|
67
|
+
case "assignment": app = "b1"; path = "/my/plans/" + notification.contentId; break;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const appUrl = getAppUrl(app);
|
|
71
|
+
if (appUrl === "") {
|
|
72
|
+
props.onNavigate(path);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
window.open(appUrl + path, "_blank");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const getNotificationIcon = (contentType: string) => {
|
|
80
|
+
switch (contentType) {
|
|
81
|
+
case "task": return <TaskIcon />;
|
|
82
|
+
case "assignment": return <AssignmentIcon />;
|
|
83
|
+
default: return <NotificationsIcon />;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const getNotificationList = () => {
|
|
88
|
+
if (notifications.length === 0) {
|
|
89
|
+
return (
|
|
90
|
+
<Box id="notifications-empty" sx={{ textAlign: 'center', py: 4 }}>
|
|
91
|
+
<NotificationsIcon sx={{ fontSize: 48, color: 'grey.400', mb: 2 }} />
|
|
92
|
+
<Typography variant="h6" color="textSecondary">
|
|
93
|
+
No notifications
|
|
94
|
+
</Typography>
|
|
95
|
+
<Typography variant="body2" color="textSecondary">
|
|
96
|
+
You're all caught up!
|
|
97
|
+
</Typography>
|
|
98
|
+
</Box>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<List id="notifications-list" sx={{ width: '100%' }}>
|
|
104
|
+
{notifications.map((notification, index) => {
|
|
105
|
+
let datePosted = new Date(notification.timeSent);
|
|
106
|
+
const displayDuration = DateHelper.getDisplayDuration(datePosted);
|
|
107
|
+
const isUnread = notification.isNew;
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<React.Fragment key={notification.id}>
|
|
111
|
+
<ListItem
|
|
112
|
+
id={`notification-item-${notification.id}`}
|
|
113
|
+
component="button"
|
|
114
|
+
onClick={() => handleClick(notification)}
|
|
115
|
+
sx={{
|
|
116
|
+
alignItems: 'flex-start',
|
|
117
|
+
py: 2,
|
|
118
|
+
cursor: 'pointer',
|
|
119
|
+
bgcolor: isUnread ? 'action.hover' : 'transparent',
|
|
120
|
+
'&:hover': {
|
|
121
|
+
bgcolor: 'action.hover'
|
|
122
|
+
},
|
|
123
|
+
borderRadius: 1,
|
|
124
|
+
mb: 0.5
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
<ListItemAvatar>
|
|
128
|
+
<Avatar
|
|
129
|
+
sx={{
|
|
130
|
+
bgcolor: isUnread ? 'primary.main' : 'grey.400',
|
|
131
|
+
width: 48,
|
|
132
|
+
height: 48
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{getNotificationIcon(notification.contentType)}
|
|
136
|
+
</Avatar>
|
|
137
|
+
</ListItemAvatar>
|
|
138
|
+
<ListItemText
|
|
139
|
+
primary={
|
|
140
|
+
<Stack direction="row" justifyContent="space-between" alignItems="flex-start">
|
|
141
|
+
<Typography
|
|
142
|
+
variant="body1"
|
|
143
|
+
sx={{
|
|
144
|
+
fontWeight: isUnread ? 600 : 400,
|
|
145
|
+
flex: 1,
|
|
146
|
+
pr: 1
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
{notification.message}
|
|
150
|
+
</Typography>
|
|
151
|
+
<Stack direction="row" alignItems="center" spacing={1}>
|
|
152
|
+
{isUnread && (
|
|
153
|
+
<Chip
|
|
154
|
+
size="small"
|
|
155
|
+
label="New"
|
|
156
|
+
color="primary"
|
|
157
|
+
sx={{ height: 20, fontSize: '0.7rem' }}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
<Typography variant="caption" color="textSecondary">
|
|
161
|
+
{displayDuration}
|
|
162
|
+
</Typography>
|
|
163
|
+
</Stack>
|
|
164
|
+
</Stack>
|
|
165
|
+
}
|
|
166
|
+
secondary={
|
|
167
|
+
notification.link && (
|
|
168
|
+
<Box sx={{ mt: 1 }}>
|
|
169
|
+
<IconButton
|
|
170
|
+
size="small"
|
|
171
|
+
onClick={(e) => {
|
|
172
|
+
e.stopPropagation();
|
|
173
|
+
window.open(notification.link, '_blank');
|
|
174
|
+
}}
|
|
175
|
+
sx={{ p: 0.5 }}
|
|
176
|
+
>
|
|
177
|
+
<OpenInNewIcon fontSize="small" />
|
|
178
|
+
<Typography variant="caption" sx={{ ml: 0.5 }}>
|
|
179
|
+
View Details
|
|
180
|
+
</Typography>
|
|
181
|
+
</IconButton>
|
|
182
|
+
</Box>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
/>
|
|
186
|
+
</ListItem>
|
|
187
|
+
{index < notifications.length - 1 && <Divider variant="inset" component="li" />}
|
|
188
|
+
</React.Fragment>
|
|
189
|
+
);
|
|
190
|
+
})}
|
|
191
|
+
</List>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<Paper id="notifications-panel" elevation={0} sx={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
|
|
198
|
+
<Box id="notifications-header" sx={{ p: 2, borderBottom: 1, borderColor: 'divider' }}>
|
|
199
|
+
<Typography variant="h6" component="h2">
|
|
200
|
+
Notifications
|
|
201
|
+
</Typography>
|
|
202
|
+
</Box>
|
|
203
|
+
|
|
204
|
+
<Box id="notifications-content" sx={{ flex: 1, overflow: 'auto' }}>
|
|
205
|
+
{isLoading ? (
|
|
206
|
+
<Box sx={{ p: 2 }}>
|
|
207
|
+
{[...Array(3)].map((_, index) => (
|
|
208
|
+
<Box key={index} sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
|
|
209
|
+
<Skeleton variant="circular" width={48} height={48} sx={{ mr: 2 }} />
|
|
210
|
+
<Box sx={{ flex: 1 }}>
|
|
211
|
+
<Skeleton variant="text" width="80%" height={24} />
|
|
212
|
+
<Skeleton variant="text" width="40%" height={20} />
|
|
213
|
+
</Box>
|
|
214
|
+
</Box>
|
|
215
|
+
))}
|
|
216
|
+
</Box>
|
|
217
|
+
) : (
|
|
218
|
+
getNotificationList()
|
|
219
|
+
)}
|
|
220
|
+
</Box>
|
|
221
|
+
</Paper>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import {
|
|
5
|
-
Paper,
|
|
6
|
-
Box,
|
|
7
|
-
Typography,
|
|
8
|
-
Stack,
|
|
9
|
-
IconButton,
|
|
10
|
-
useTheme
|
|
11
|
-
} from "@mui/material";
|
|
12
|
-
import { ArrowBack as ArrowBackIcon } from "@mui/icons-material";
|
|
13
|
-
import { PrivateMessageInterface, UserContextInterface } from "@churchapps/helpers";
|
|
14
|
-
import { Notes } from "../notes/Notes";
|
|
15
|
-
import { ApiHelper, Locale, NotificationService } from "../../helpers";
|
|
16
|
-
import { PersonAvatar } from "../PersonAvatar";
|
|
17
|
-
|
|
18
|
-
interface Props {
|
|
19
|
-
context: UserContextInterface;
|
|
20
|
-
privateMessage: PrivateMessageInterface;
|
|
21
|
-
onBack: () => void
|
|
22
|
-
refreshKey: number;
|
|
23
|
-
onMessageRead?: () => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const PrivateMessageDetails: React.FC<Props> = (props) => {
|
|
27
|
-
const theme = useTheme();
|
|
28
|
-
|
|
29
|
-
// Clear notification when conversation is opened
|
|
30
|
-
React.useEffect(() => {
|
|
31
|
-
const clearNotification = async () => {
|
|
32
|
-
if (props.privateMessage.notifyPersonId === props.context.person.id) {
|
|
33
|
-
try {
|
|
34
|
-
console.log("Marking private message as read:", props.privateMessage.id);
|
|
35
|
-
|
|
36
|
-
// Clear the notification by getting the private message details
|
|
37
|
-
await ApiHelper.get(`/privateMessages/${props.privateMessage.id}`, "MessagingApi");
|
|
38
|
-
|
|
39
|
-
// Manually refresh notification counts to ensure immediate UI update
|
|
40
|
-
const notificationService = NotificationService.getInstance();
|
|
41
|
-
await notificationService.refresh();
|
|
42
|
-
|
|
43
|
-
console.log("Private message marked as read and notifications refreshed");
|
|
44
|
-
|
|
45
|
-
// Notify parent component that message was marked as read
|
|
46
|
-
if (props.onMessageRead) {
|
|
47
|
-
props.onMessageRead();
|
|
48
|
-
}
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error("Failed to clear notification:", error);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
clearNotification();
|
|
56
|
-
}, [props.privateMessage.id, props.privateMessage.notifyPersonId, props.context.person.id]);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<Paper elevation={0} sx={{
|
|
60
|
-
height: '100%',
|
|
61
|
-
display: 'flex',
|
|
62
|
-
flexDirection: 'column',
|
|
63
|
-
overflow: 'hidden',
|
|
64
|
-
position: 'relative'
|
|
65
|
-
}}>
|
|
66
|
-
{/* Fixed Header - Always visible */}
|
|
67
|
-
<Box sx={{
|
|
68
|
-
p: 2,
|
|
69
|
-
borderBottom: 1,
|
|
70
|
-
borderColor: 'divider',
|
|
71
|
-
flexShrink: 0,
|
|
72
|
-
backgroundColor: 'background.paper',
|
|
73
|
-
zIndex: 1
|
|
74
|
-
}}>
|
|
75
|
-
<Stack direction="row" alignItems="center" spacing={2}>
|
|
76
|
-
<IconButton onClick={props.onBack}>
|
|
77
|
-
<ArrowBackIcon />
|
|
78
|
-
</IconButton>
|
|
79
|
-
<Stack direction="row" spacing={2} alignItems="center" sx={{ flex: 1 }}>
|
|
80
|
-
<PersonAvatar person={props.privateMessage.person} size="small" />
|
|
81
|
-
<Box>
|
|
82
|
-
<Typography variant="h6" component="h2">
|
|
83
|
-
{props.privateMessage.person.name.display}
|
|
84
|
-
</Typography>
|
|
85
|
-
<Typography variant="caption" color="textSecondary">
|
|
86
|
-
{Locale.label("wrapper.privateConversation", "Private Conversation")}
|
|
87
|
-
</Typography>
|
|
88
|
-
</Box>
|
|
89
|
-
</Stack>
|
|
90
|
-
</Stack>
|
|
91
|
-
</Box>
|
|
92
|
-
|
|
93
|
-
{/* Chat area - Scrollable content */}
|
|
94
|
-
<Box sx={{
|
|
95
|
-
flex: 1,
|
|
96
|
-
display: 'flex',
|
|
97
|
-
flexDirection: 'column',
|
|
98
|
-
minHeight: 0,
|
|
99
|
-
overflow: 'hidden'
|
|
100
|
-
}}>
|
|
101
|
-
<Notes
|
|
102
|
-
maxHeight="100%"
|
|
103
|
-
context={props.context}
|
|
104
|
-
conversationId={props.privateMessage.conversationId}
|
|
105
|
-
noDisplayBox={true}
|
|
106
|
-
refreshKey={props.refreshKey}
|
|
107
|
-
/>
|
|
108
|
-
</Box>
|
|
109
|
-
</Paper>
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {
|
|
5
|
+
Paper,
|
|
6
|
+
Box,
|
|
7
|
+
Typography,
|
|
8
|
+
Stack,
|
|
9
|
+
IconButton,
|
|
10
|
+
useTheme
|
|
11
|
+
} from "@mui/material";
|
|
12
|
+
import { ArrowBack as ArrowBackIcon } from "@mui/icons-material";
|
|
13
|
+
import { PrivateMessageInterface, UserContextInterface } from "@churchapps/helpers";
|
|
14
|
+
import { Notes } from "../notes/Notes";
|
|
15
|
+
import { ApiHelper, Locale, NotificationService } from "../../helpers";
|
|
16
|
+
import { PersonAvatar } from "../PersonAvatar";
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
context: UserContextInterface;
|
|
20
|
+
privateMessage: PrivateMessageInterface;
|
|
21
|
+
onBack: () => void
|
|
22
|
+
refreshKey: number;
|
|
23
|
+
onMessageRead?: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const PrivateMessageDetails: React.FC<Props> = (props) => {
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
|
|
29
|
+
// Clear notification when conversation is opened
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
const clearNotification = async () => {
|
|
32
|
+
if (props.privateMessage.notifyPersonId === props.context.person.id) {
|
|
33
|
+
try {
|
|
34
|
+
console.log("Marking private message as read:", props.privateMessage.id);
|
|
35
|
+
|
|
36
|
+
// Clear the notification by getting the private message details
|
|
37
|
+
await ApiHelper.get(`/privateMessages/${props.privateMessage.id}`, "MessagingApi");
|
|
38
|
+
|
|
39
|
+
// Manually refresh notification counts to ensure immediate UI update
|
|
40
|
+
const notificationService = NotificationService.getInstance();
|
|
41
|
+
await notificationService.refresh();
|
|
42
|
+
|
|
43
|
+
console.log("Private message marked as read and notifications refreshed");
|
|
44
|
+
|
|
45
|
+
// Notify parent component that message was marked as read
|
|
46
|
+
if (props.onMessageRead) {
|
|
47
|
+
props.onMessageRead();
|
|
48
|
+
}
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error("Failed to clear notification:", error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
clearNotification();
|
|
56
|
+
}, [props.privateMessage.id, props.privateMessage.notifyPersonId, props.context.person.id]);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Paper elevation={0} sx={{
|
|
60
|
+
height: '100%',
|
|
61
|
+
display: 'flex',
|
|
62
|
+
flexDirection: 'column',
|
|
63
|
+
overflow: 'hidden',
|
|
64
|
+
position: 'relative'
|
|
65
|
+
}}>
|
|
66
|
+
{/* Fixed Header - Always visible */}
|
|
67
|
+
<Box sx={{
|
|
68
|
+
p: 2,
|
|
69
|
+
borderBottom: 1,
|
|
70
|
+
borderColor: 'divider',
|
|
71
|
+
flexShrink: 0,
|
|
72
|
+
backgroundColor: 'background.paper',
|
|
73
|
+
zIndex: 1
|
|
74
|
+
}}>
|
|
75
|
+
<Stack direction="row" alignItems="center" spacing={2}>
|
|
76
|
+
<IconButton onClick={props.onBack}>
|
|
77
|
+
<ArrowBackIcon />
|
|
78
|
+
</IconButton>
|
|
79
|
+
<Stack direction="row" spacing={2} alignItems="center" sx={{ flex: 1 }}>
|
|
80
|
+
<PersonAvatar person={props.privateMessage.person} size="small" />
|
|
81
|
+
<Box>
|
|
82
|
+
<Typography variant="h6" component="h2">
|
|
83
|
+
{props.privateMessage.person.name.display}
|
|
84
|
+
</Typography>
|
|
85
|
+
<Typography variant="caption" color="textSecondary">
|
|
86
|
+
{Locale.label("wrapper.privateConversation", "Private Conversation")}
|
|
87
|
+
</Typography>
|
|
88
|
+
</Box>
|
|
89
|
+
</Stack>
|
|
90
|
+
</Stack>
|
|
91
|
+
</Box>
|
|
92
|
+
|
|
93
|
+
{/* Chat area - Scrollable content */}
|
|
94
|
+
<Box sx={{
|
|
95
|
+
flex: 1,
|
|
96
|
+
display: 'flex',
|
|
97
|
+
flexDirection: 'column',
|
|
98
|
+
minHeight: 0,
|
|
99
|
+
overflow: 'hidden'
|
|
100
|
+
}}>
|
|
101
|
+
<Notes
|
|
102
|
+
maxHeight="100%"
|
|
103
|
+
context={props.context}
|
|
104
|
+
conversationId={props.privateMessage.conversationId}
|
|
105
|
+
noDisplayBox={true}
|
|
106
|
+
refreshKey={props.refreshKey}
|
|
107
|
+
/>
|
|
108
|
+
</Box>
|
|
109
|
+
</Paper>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|