@churchapps/apphelper 0.4.17 → 0.4.19
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/DisplayBox.js +1 -1
- package/dist/components/DisplayBox.js.map +1 -1
- package/dist/components/FormCardPayment.js +2 -2
- package/dist/components/FormCardPayment.js.map +1 -1
- package/dist/components/FormSubmissionEdit.d.ts.map +1 -1
- package/dist/components/FormSubmissionEdit.js +4 -5
- package/dist/components/FormSubmissionEdit.js.map +1 -1
- package/dist/components/InputBox.js +1 -1
- package/dist/components/InputBox.js.map +1 -1
- package/dist/components/Loading.js +1 -1
- package/dist/components/Loading.js.map +1 -1
- package/dist/components/PageHeader.d.ts +15 -0
- package/dist/components/PageHeader.d.ts.map +1 -0
- package/dist/components/PageHeader.js +41 -0
- package/dist/components/PageHeader.js.map +1 -0
- package/dist/components/PersonAvatar.d.ts +12 -0
- package/dist/components/PersonAvatar.d.ts.map +1 -0
- package/dist/components/PersonAvatar.js +55 -0
- package/dist/components/PersonAvatar.js.map +1 -0
- package/dist/components/header/SiteHeader.d.ts +2 -1
- package/dist/components/header/SiteHeader.d.ts.map +1 -1
- package/dist/components/header/SiteHeader.js +100 -4
- package/dist/components/header/SiteHeader.js.map +1 -1
- package/dist/components/header/SupportDrawer.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/notes/AddNote.d.ts.map +1 -1
- package/dist/components/notes/AddNote.js +45 -7
- package/dist/components/notes/AddNote.js.map +1 -1
- package/dist/components/notes/Note.d.ts.map +1 -1
- package/dist/components/notes/Note.js +6 -6
- package/dist/components/notes/Note.js.map +1 -1
- package/dist/components/notes/Notes.d.ts.map +1 -1
- package/dist/components/notes/Notes.js +120 -20
- package/dist/components/notes/Notes.js.map +1 -1
- package/dist/components/wrapper/ChurchList.d.ts.map +1 -1
- package/dist/components/wrapper/ChurchList.js +44 -6
- 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 +28 -21
- package/dist/components/wrapper/NewPrivateMessage.js.map +1 -1
- package/dist/components/wrapper/Notifications.d.ts.map +1 -1
- package/dist/components/wrapper/Notifications.js +47 -20
- package/dist/components/wrapper/Notifications.js.map +1 -1
- package/dist/components/wrapper/PrivateMessageDetails.d.ts +1 -0
- package/dist/components/wrapper/PrivateMessageDetails.d.ts.map +1 -1
- package/dist/components/wrapper/PrivateMessageDetails.js +53 -4
- package/dist/components/wrapper/PrivateMessageDetails.js.map +1 -1
- package/dist/components/wrapper/PrivateMessages.d.ts.map +1 -1
- package/dist/components/wrapper/PrivateMessages.js +360 -41
- 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 +164 -27
- package/dist/components/wrapper/UserMenu.js.map +1 -1
- package/dist/components/wrapper/index.d.ts +2 -1
- package/dist/components/wrapper/index.d.ts.map +1 -1
- package/dist/components/wrapper/index.js +2 -1
- package/dist/components/wrapper/index.js.map +1 -1
- package/dist/helpers/ArrayHelper.d.ts.map +1 -1
- package/dist/helpers/ArrayHelper.js +0 -1
- package/dist/helpers/ArrayHelper.js.map +1 -1
- package/dist/helpers/ErrorHelper.js +1 -1
- package/dist/helpers/ErrorHelper.js.map +1 -1
- package/dist/helpers/EventHelper.d.ts.map +1 -1
- package/dist/helpers/EventHelper.js +0 -3
- package/dist/helpers/EventHelper.js.map +1 -1
- package/dist/helpers/Locale.d.ts +1 -1
- package/dist/helpers/Locale.d.ts.map +1 -1
- package/dist/helpers/Locale.js +7 -2
- package/dist/helpers/Locale.js.map +1 -1
- package/dist/helpers/NotificationService.d.ts +56 -0
- package/dist/helpers/NotificationService.d.ts.map +1 -0
- package/dist/helpers/NotificationService.js +176 -0
- package/dist/helpers/NotificationService.js.map +1 -0
- package/dist/helpers/SocketHelper.d.ts.map +1 -1
- package/dist/helpers/SocketHelper.js +22 -17
- package/dist/helpers/SocketHelper.js.map +1 -1
- package/dist/helpers/UserHelper.js +2 -2
- package/dist/helpers/UserHelper.js.map +1 -1
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useNotifications.d.ts +30 -0
- package/dist/hooks/useNotifications.d.ts.map +1 -0
- package/dist/hooks/useNotifications.js +79 -0
- package/dist/hooks/useNotifications.js.map +1 -0
- package/dist/public/css/styles.css +6 -2
- package/package.json +1 -1
- package/public/css/styles.css +6 -2
- package/src/components/DisplayBox.tsx +8 -8
- package/src/components/FormCardPayment.tsx +2 -2
- package/src/components/FormSubmissionEdit.tsx +5 -6
- package/src/components/InputBox.tsx +8 -8
- package/src/components/Loading.tsx +1 -1
- package/src/components/PageHeader.tsx +111 -0
- package/src/components/PersonAvatar.tsx +78 -0
- package/src/components/header/SiteHeader.tsx +133 -10
- package/src/components/header/SupportDrawer.tsx +1 -1
- package/src/components/index.tsx +2 -0
- package/src/components/notes/AddNote.tsx +105 -19
- package/src/components/notes/Note.tsx +43 -22
- package/src/components/notes/Notes.tsx +160 -21
- package/src/components/wrapper/ChurchList.tsx +45 -5
- package/src/components/wrapper/NewPrivateMessage.tsx +181 -44
- package/src/components/wrapper/Notifications.tsx +165 -29
- package/src/components/wrapper/PrivateMessageDetails.tsx +100 -13
- package/src/components/wrapper/PrivateMessages.tsx +539 -65
- package/src/components/wrapper/UserMenu.tsx +223 -38
- package/src/components/wrapper/index.tsx +3 -2
- package/src/helpers/ArrayHelper.ts +0 -1
- package/src/helpers/ErrorHelper.ts +1 -1
- package/src/helpers/EventHelper.ts +0 -3
- package/src/helpers/Locale.ts +7 -2
- package/src/helpers/NotificationService.ts +211 -0
- package/src/helpers/SocketHelper.ts +23 -17
- package/src/helpers/UserHelper.ts +2 -2
- package/src/helpers/index.ts +2 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useNotifications.ts +94 -0
- package/dist/components/wrapper/Drawers.d.ts +0 -5
- package/dist/components/wrapper/Drawers.d.ts.map +0 -1
- package/dist/components/wrapper/Drawers.js +0 -49
- package/dist/components/wrapper/Drawers.js.map +0 -1
- package/dist/components/wrapper/SiteWrapper.d.ts +0 -15
- package/dist/components/wrapper/SiteWrapper.d.ts.map +0 -1
- package/dist/components/wrapper/SiteWrapper.js +0 -60
- package/dist/components/wrapper/SiteWrapper.js.map +0 -1
- package/dist/components/wrapper/TabPanel.d.ts +0 -9
- package/dist/components/wrapper/TabPanel.d.ts.map +0 -1
- package/dist/components/wrapper/TabPanel.js +0 -17
- package/dist/components/wrapper/TabPanel.js.map +0 -1
- package/dist/helpers/ApiHelper.d.ts +0 -18
- package/dist/helpers/ApiHelper.d.ts.map +0 -1
- package/dist/helpers/ApiHelper.js +0 -119
- package/dist/helpers/ApiHelper.js.map +0 -1
- package/src/components/wrapper/Drawers.tsx +0 -62
- package/src/components/wrapper/SiteWrapper.tsx +0 -110
- package/src/components/wrapper/TabPanel.tsx +0 -32
- package/src/helpers/ApiHelper.ts +0 -127
package/dist/components/index.js
CHANGED
|
@@ -8,6 +8,8 @@ export { ImageEditor } from "./ImageEditor";
|
|
|
8
8
|
export { InputBox } from "./InputBox";
|
|
9
9
|
export { Loading } from "./Loading";
|
|
10
10
|
export { Notes } from "./notes/Notes";
|
|
11
|
+
export { PageHeader } from "./PageHeader";
|
|
12
|
+
export { PersonAvatar } from "./PersonAvatar";
|
|
11
13
|
export { QuestionEdit } from "./QuestionEdit";
|
|
12
14
|
export { SmallButton } from "./SmallButton";
|
|
13
15
|
export { SupportModal } from "./SupportModal";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNote.d.ts","sourceRoot":"","sources":["../../../src/components/notes/AddNote.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAoB,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"AddNote.d.ts","sourceRoot":"","sources":["../../../src/components/notes/AddNote.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAoB,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAc5E,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,kBAAkB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,oBAAoB,CAAA;CAC9B,CAAC;AAEF,wBAAgB,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,2CA0JnD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import React, { useState, useEffect } from "react";
|
|
4
4
|
import { ApiHelper, Locale, PersonHelper } from "../../helpers";
|
|
5
|
-
import {
|
|
5
|
+
import { Box, Stack, TextField, IconButton, Paper, CircularProgress, Avatar } from "@mui/material";
|
|
6
|
+
import { Send as SendIcon, Delete as DeleteIcon } from "@mui/icons-material";
|
|
6
7
|
import { ErrorMessages } from "../ErrorMessages";
|
|
7
|
-
import { SmallButton } from "../SmallButton";
|
|
8
8
|
export function AddNote({ context, ...props }) {
|
|
9
9
|
const [message, setMessage] = useState();
|
|
10
10
|
const [errors, setErrors] = React.useState([]);
|
|
@@ -12,7 +12,7 @@ export function AddNote({ context, ...props }) {
|
|
|
12
12
|
const headerText = props.messageId ? "Edit note" : "Add a note";
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (props.messageId)
|
|
15
|
-
ApiHelper.get(`/messages/${props.messageId}`, "MessagingApi").then(n => setMessage(n));
|
|
15
|
+
ApiHelper.get(`/messages/${props.messageId}`, "MessagingApi").then((n) => setMessage(n));
|
|
16
16
|
else
|
|
17
17
|
setMessage({ conversationId: props.conversationId, content: "" });
|
|
18
18
|
return () => {
|
|
@@ -28,7 +28,7 @@ export function AddNote({ context, ...props }) {
|
|
|
28
28
|
const validate = () => {
|
|
29
29
|
const result = [];
|
|
30
30
|
if (!message.content.trim())
|
|
31
|
-
result.push(Locale.label("notes.validate.content"));
|
|
31
|
+
result.push(Locale.label("notes.validate.content", "Please enter a message"));
|
|
32
32
|
setErrors(result);
|
|
33
33
|
return result.length === 0;
|
|
34
34
|
};
|
|
@@ -48,8 +48,13 @@ export function AddNote({ context, ...props }) {
|
|
|
48
48
|
setMessage(m);
|
|
49
49
|
})
|
|
50
50
|
.catch((error) => {
|
|
51
|
-
|
|
51
|
+
console.error("Error saving message:", error);
|
|
52
|
+
if (error?.message === "Forbidden") {
|
|
52
53
|
setErrors(["You can't edit the message sent by others."]);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
setErrors([error?.message || "Failed to save message. Please try again."]);
|
|
57
|
+
}
|
|
53
58
|
})
|
|
54
59
|
.finally(() => { setIsSubmitting(false); });
|
|
55
60
|
}
|
|
@@ -61,6 +66,39 @@ export function AddNote({ context, ...props }) {
|
|
|
61
66
|
}
|
|
62
67
|
const deleteFunction = props.messageId ? deleteNote : null;
|
|
63
68
|
const image = PersonHelper.getPhotoUrl(context?.person);
|
|
64
|
-
return (_jsxs(
|
|
69
|
+
return (_jsxs(Box, { sx: { width: '100%' }, children: [_jsx(ErrorMessages, { errors: errors }), _jsx(Paper, { variant: "outlined", sx: {
|
|
70
|
+
p: 2,
|
|
71
|
+
bgcolor: 'grey.50',
|
|
72
|
+
borderColor: 'grey.300'
|
|
73
|
+
}, children: _jsxs(Stack, { direction: "row", spacing: 2, alignItems: "flex-start", children: [_jsx(Avatar, { src: image, alt: context?.person?.name?.display, sx: { width: 48, height: 48 } }), _jsxs(Box, { sx: { flex: 1 }, children: [_jsx(TextField, { fullWidth: true, multiline: true, rows: 2, name: "noteText", "aria-label": headerText, placeholder: props.messageId ? "Edit your message..." : "Type a message...", variant: "standard", value: message?.content || '', onChange: handleChange, disabled: isSubmitting, InputProps: {
|
|
74
|
+
disableUnderline: true,
|
|
75
|
+
sx: {
|
|
76
|
+
fontSize: '1rem',
|
|
77
|
+
'& textarea': {
|
|
78
|
+
resize: 'vertical',
|
|
79
|
+
minHeight: '40px'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, sx: {
|
|
83
|
+
bgcolor: 'white',
|
|
84
|
+
borderRadius: 1,
|
|
85
|
+
p: 1,
|
|
86
|
+
border: '1px solid',
|
|
87
|
+
borderColor: 'grey.300',
|
|
88
|
+
'&:hover': {
|
|
89
|
+
borderColor: 'grey.400'
|
|
90
|
+
},
|
|
91
|
+
'&.Mui-focused': {
|
|
92
|
+
borderColor: 'primary.main'
|
|
93
|
+
}
|
|
94
|
+
} }), _jsxs(Box, { sx: { display: 'flex', justifyContent: 'flex-end', mt: 1, gap: 0.5 }, children: [deleteFunction && (_jsx(IconButton, { size: "small", onClick: deleteFunction, disabled: isSubmitting, sx: { color: 'error.main' }, children: _jsx(DeleteIcon, { fontSize: "small" }) })), _jsx(IconButton, { size: "small", color: "primary", onClick: handleSave, disabled: isSubmitting || !message?.content?.trim(), sx: {
|
|
95
|
+
bgcolor: 'primary.main',
|
|
96
|
+
color: 'white',
|
|
97
|
+
'&:hover': { bgcolor: 'primary.dark' },
|
|
98
|
+
'&:disabled': {
|
|
99
|
+
bgcolor: 'action.disabledBackground',
|
|
100
|
+
color: 'action.disabled'
|
|
101
|
+
}
|
|
102
|
+
}, children: isSubmitting ? _jsx(CircularProgress, { size: 18, color: "inherit" }) : _jsx(SendIcon, { fontSize: "small" }) })] })] })] }) })] }));
|
|
65
103
|
}
|
|
66
104
|
//# sourceMappingURL=AddNote.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNote.js","sourceRoot":"","sources":["../../../src/components/notes/AddNote.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE/D,OAAO,
|
|
1
|
+
{"version":3,"file":"AddNote.js","sourceRoot":"","sources":["../../../src/components/notes/AddNote.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE/D,OAAO,EACL,GAAG,EACH,KAAK,EACL,SAAS,EACT,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,MAAM,EACP,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MA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ACvB,KAAK,EAAE,OAAO;gDACd,SAAS,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;gDACtC,YAAY,EAAE;oDACZ,OAAO,EAAE,2BAA2B;oDACpC,KAAK,EAAE,iBAAiB;iDACzB;6CACF,YAEA,YAAY,CAAC,CAAC,CAAC,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAC,SAAS,GAAG,CAAC,CAAC,CAAC,KAAC,QAAQ,IAAC,QAAQ,EAAC,OAAO,GAAG,GACnF,IACT,IACF,IACA,GACF,IACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Note.d.ts","sourceRoot":"","sources":["../../../src/components/notes/Note.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"Note.d.ts","sourceRoot":"","sources":["../../../src/components/notes/Note.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAG5E,UAAU,KAAK;IACb,OAAO,EAAE,gBAAgB,CAAC;IAC1B,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAuDhC,CAAC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Icon, IconButton, Stack, Box } from "@mui/material";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon, IconButton, Stack, Box, Typography } from "@mui/material";
|
|
3
3
|
import { useState, useEffect } from "react";
|
|
4
|
-
import { DateHelper
|
|
4
|
+
import { DateHelper } from "../../helpers";
|
|
5
|
+
import { PersonAvatar } from "../PersonAvatar";
|
|
5
6
|
export const Note = (props) => {
|
|
6
7
|
const [message, setMessage] = useState(null);
|
|
7
8
|
useEffect(() => setMessage(props.message), [props.message]);
|
|
8
9
|
if (message === null)
|
|
9
10
|
return null;
|
|
10
|
-
const photoUrl = PersonHelper.getPhotoUrl(message.person);
|
|
11
11
|
let datePosted = new Date(message.timeUpdated || message.timeSent);
|
|
12
12
|
const displayDuration = DateHelper.getDisplayDuration(datePosted);
|
|
13
|
-
const isEdited = message.timeUpdated && message.timeUpdated !== message.timeSent
|
|
13
|
+
const isEdited = message.timeUpdated && message.timeUpdated !== message.timeSent;
|
|
14
14
|
const contents = message.content?.split("\n");
|
|
15
|
-
return (_jsxs(
|
|
15
|
+
return (_jsxs(Box, { sx: { display: 'flex', gap: 2, mb: 2, p: 1, '&:hover': { bgcolor: 'action.hover', borderRadius: 1 } }, children: [_jsx(PersonAvatar, { person: message.person, size: "small" }), _jsx(Box, { sx: { flex: 1 }, children: _jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "flex-start", children: [_jsxs(Box, { sx: { flex: 1 }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 0.5 }, children: [_jsx(Typography, { variant: "subtitle2", fontWeight: "bold", children: message.person?.name?.display }), _jsx(Typography, { variant: "caption", color: "text.secondary", children: displayDuration }), isEdited && (_jsx(Typography, { variant: "caption", color: "text.secondary", children: "(edited)" }))] }), _jsx(Box, { children: contents.map((c, i) => c ? (_jsx(Typography, { variant: "body2", sx: { mb: 0.5 }, children: c }, i)) : (_jsx(Box, { sx: { height: '1em' } }, i))) })] }), (message?.id && message.personId === props.context?.person.id) && (_jsx(IconButton, { size: "small", "aria-label": "editNote", onClick: () => props.showEditNote(message.id), sx: { opacity: 0.7, '&:hover': { opacity: 1 } }, children: _jsx(Icon, { fontSize: "small", children: "edit" }) }))] }) })] }));
|
|
16
16
|
};
|
|
17
17
|
//# sourceMappingURL=Note.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Note.js","sourceRoot":"","sources":["../../../src/components/notes/Note.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Note.js","sourceRoot":"","sources":["../../../src/components/notes/Note.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACzE,OAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,UAAU,EAAgB,MAAM,eAAe,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAQ9C,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,KAAK,EAAE,EAAE;IAC7C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAmB,IAAI,CAAC,CAAC;IAE/D,SAAS,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE5D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAClC,IAAI,UAAU,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnE,MAAM,eAAe,GAAG,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAElE,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC;IACjF,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC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,CACd,CAAC,CAAC,CAAC,CACF,KAAC,GAAG,IAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAxB,CAAC,CAA2B,CACvC,CAAC,GACE,IACF,EACL,CAAC,OAAO,EAAE,EAAE,IAAI,OAAO,CAAC,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CACjE,KAAC,UAAU,IACT,IAAI,EAAC,OAAO,gBACD,UAAU,EACrB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,EAC7C,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,YAE/C,KAAC,IAAI,IAAC,QAAQ,EAAC,OAAO,qBAAY,GACvB,CACd,IACK,GACJ,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notes.d.ts","sourceRoot":"","sources":["../../../src/components/notes/Notes.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAoB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,UAAU,KAAK;IAEb,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"Notes.d.ts","sourceRoot":"","sources":["../../../src/components/notes/Notes.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAoB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,UAAU,KAAK;IAEb,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,2CA8LjC"}
|
|
@@ -7,17 +7,70 @@ import { ApiHelper, ArrayHelper, Locale } from "../../helpers";
|
|
|
7
7
|
export function Notes(props) {
|
|
8
8
|
const [messages, setMessages] = React.useState(null);
|
|
9
9
|
const [editMessageId, setEditMessageId] = React.useState(null);
|
|
10
|
+
const [isInitialLoad, setIsInitialLoad] = React.useState(true);
|
|
11
|
+
const [previousMessageCount, setPreviousMessageCount] = React.useState(0);
|
|
12
|
+
// Add CSS for custom scrollbar styling
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
const styleId = 'notes-scrollbar-styles';
|
|
15
|
+
if (!document.getElementById(styleId)) {
|
|
16
|
+
const style = document.createElement('style');
|
|
17
|
+
style.id = styleId;
|
|
18
|
+
style.textContent = `
|
|
19
|
+
.notes-scroll-container {
|
|
20
|
+
scrollbar-width: thin;
|
|
21
|
+
scrollbar-color: rgba(0, 0, 0, 0.3) rgba(0, 0, 0, 0.1);
|
|
22
|
+
}
|
|
23
|
+
.notes-scroll-container::-webkit-scrollbar {
|
|
24
|
+
width: 12px;
|
|
25
|
+
background: transparent;
|
|
26
|
+
}
|
|
27
|
+
.notes-scroll-container::-webkit-scrollbar-track {
|
|
28
|
+
background: rgba(0, 0, 0, 0.1);
|
|
29
|
+
border-radius: 6px;
|
|
30
|
+
margin: 4px;
|
|
31
|
+
}
|
|
32
|
+
.notes-scroll-container::-webkit-scrollbar-thumb {
|
|
33
|
+
background: rgba(0, 0, 0, 0.3);
|
|
34
|
+
border-radius: 6px;
|
|
35
|
+
border: 2px solid transparent;
|
|
36
|
+
background-clip: content-box;
|
|
37
|
+
}
|
|
38
|
+
.notes-scroll-container::-webkit-scrollbar-thumb:hover {
|
|
39
|
+
background: rgba(0, 0, 0, 0.5);
|
|
40
|
+
background-clip: content-box;
|
|
41
|
+
}
|
|
42
|
+
.notes-scroll-container::-webkit-scrollbar-corner {
|
|
43
|
+
background: transparent;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
document.head.appendChild(style);
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
10
49
|
const loadNotes = async () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
50
|
+
try {
|
|
51
|
+
const messages = (props.conversationId) ? await ApiHelper.get("/messages/conversation/" + props.conversationId, "MessagingApi") : [];
|
|
52
|
+
if (messages.length > 0) {
|
|
53
|
+
const peopleIds = ArrayHelper.getIds(messages, "personId");
|
|
54
|
+
const people = await ApiHelper.get("/people/basic?ids=" + peopleIds.join(","), "MembershipApi");
|
|
55
|
+
messages.forEach(n => {
|
|
56
|
+
n.person = ArrayHelper.getOne(people, "id", n.personId);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
setMessages(messages);
|
|
60
|
+
setEditMessageId(null);
|
|
61
|
+
// Mark as no longer initial load after first load
|
|
62
|
+
if (isInitialLoad) {
|
|
63
|
+
setIsInitialLoad(false);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error("❌ Failed to load messages for conversation:", props.conversationId, error);
|
|
68
|
+
// Don't clear messages on error - keep showing existing messages
|
|
69
|
+
// Only set isInitialLoad to false if this was the first load attempt
|
|
70
|
+
if (isInitialLoad) {
|
|
71
|
+
setIsInitialLoad(false);
|
|
72
|
+
}
|
|
18
73
|
}
|
|
19
|
-
setMessages(messages);
|
|
20
|
-
setEditMessageId(null);
|
|
21
74
|
};
|
|
22
75
|
const getNotes = () => {
|
|
23
76
|
if (!messages)
|
|
@@ -33,26 +86,73 @@ export function Notes(props) {
|
|
|
33
86
|
};
|
|
34
87
|
const getNotesWrapper = () => {
|
|
35
88
|
const notes = getNotes();
|
|
36
|
-
if (props.maxHeight)
|
|
37
|
-
return _jsx("div", { id: "notesScroll", style: {
|
|
89
|
+
if (props.maxHeight) {
|
|
90
|
+
return (_jsx("div", { id: "notesScroll", style: {
|
|
91
|
+
flex: 1,
|
|
92
|
+
minHeight: 0,
|
|
93
|
+
overflowY: "auto",
|
|
94
|
+
overflowX: "hidden",
|
|
95
|
+
padding: "8px 12px",
|
|
96
|
+
scrollBehavior: "smooth",
|
|
97
|
+
height: "100%"
|
|
98
|
+
}, className: "notes-scroll-container", "data-testid": "message-scroll-area", children: _jsx("div", { style: {
|
|
99
|
+
display: "flex",
|
|
100
|
+
flexDirection: "column",
|
|
101
|
+
gap: "8px",
|
|
102
|
+
minHeight: "min-content"
|
|
103
|
+
}, children: notes }) }));
|
|
104
|
+
}
|
|
38
105
|
else
|
|
39
106
|
return notes;
|
|
40
107
|
};
|
|
41
108
|
React.useEffect(() => { loadNotes(); }, [props.conversationId, props.refreshKey]); //eslint-disable-line
|
|
109
|
+
// Simply reload notes when refreshKey changes
|
|
110
|
+
// This is triggered by the parent component when WebSocket messages arrive
|
|
111
|
+
// Auto-scroll to bottom only when new messages are added (not on initial load)
|
|
42
112
|
React.useEffect(() => {
|
|
43
|
-
if (props.maxHeight && messages?.length > 0) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
113
|
+
if (props.maxHeight && messages?.length > 0 && !isInitialLoad) {
|
|
114
|
+
const currentMessageCount = messages.length;
|
|
115
|
+
// Only auto-scroll if messages were added
|
|
116
|
+
if (currentMessageCount > previousMessageCount) {
|
|
117
|
+
// Use requestAnimationFrame for smoother scrolling
|
|
118
|
+
requestAnimationFrame(() => {
|
|
119
|
+
const element = window?.document?.getElementById("notesScroll");
|
|
120
|
+
if (element) {
|
|
121
|
+
element.scrollTop = element.scrollHeight;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
setPreviousMessageCount(currentMessageCount);
|
|
126
|
+
}
|
|
127
|
+
else if (messages?.length > 0 && isInitialLoad) {
|
|
128
|
+
// On initial load, just set the previous count without scrolling
|
|
129
|
+
setPreviousMessageCount(messages.length);
|
|
49
130
|
}
|
|
50
|
-
}, [messages, props.maxHeight]);
|
|
51
|
-
let result =
|
|
131
|
+
}, [messages, props.maxHeight, isInitialLoad, previousMessageCount]);
|
|
132
|
+
let result = props.maxHeight ? (_jsxs("div", { style: {
|
|
133
|
+
height: "100%",
|
|
134
|
+
display: "flex",
|
|
135
|
+
flexDirection: "column",
|
|
136
|
+
overflow: "hidden",
|
|
137
|
+
minHeight: 0
|
|
138
|
+
}, children: [_jsx("div", { style: {
|
|
139
|
+
flex: 1,
|
|
140
|
+
minHeight: 0,
|
|
141
|
+
display: "flex",
|
|
142
|
+
flexDirection: "column",
|
|
143
|
+
overflow: "hidden"
|
|
144
|
+
}, children: getNotesWrapper() }), messages && (_jsx("div", { style: {
|
|
145
|
+
flexShrink: 0,
|
|
146
|
+
borderTop: "1px solid #e0e0e0",
|
|
147
|
+
backgroundColor: "#fafafa",
|
|
148
|
+
padding: "12px",
|
|
149
|
+
minHeight: "auto",
|
|
150
|
+
maxHeight: "200px"
|
|
151
|
+
}, children: _jsx(AddNote, { context: props.context, conversationId: props.conversationId, onUpdate: loadNotes, createConversation: props.createConversation, messageId: editMessageId }) }))] })) : (_jsxs(_Fragment, { children: [getNotesWrapper(), messages && (_jsx(AddNote, { context: props.context, conversationId: props.conversationId, onUpdate: loadNotes, createConversation: props.createConversation, messageId: editMessageId }))] }));
|
|
52
152
|
if (props.noDisplayBox)
|
|
53
153
|
return result;
|
|
54
154
|
else
|
|
55
|
-
return (_jsx(DisplayBox, { id: "notesBox", "data-testid": "notes-box", headerIcon: "sticky_note_2", headerText: Locale.label("notes.notes"), children: result }));
|
|
155
|
+
return (_jsx(DisplayBox, { id: "notesBox", "data-testid": "notes-box", headerIcon: "sticky_note_2", headerText: Locale.label("notes.notes", "Notes"), children: result }));
|
|
56
156
|
}
|
|
57
157
|
;
|
|
58
158
|
//# sourceMappingURL=Notes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notes.js","sourceRoot":"","sources":["../../../src/components/notes/Notes.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAa/D,MAAM,UAAU,KAAK,CAAC,KAAY;IAEhC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,IAAI,CAAC,CAAA;IACxE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"Notes.js","sourceRoot":"","sources":["../../../src/components/notes/Notes.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAa/D,MAAM,UAAU,KAAK,CAAC,KAAY;IAEhC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAA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,CACP,IACG,CACP,CAAC,CAAC,CAAC,CACF,8BACG,eAAe,EAAE,EACjB,QAAQ,IAAI,CAAC,KAAC,OAAO,IAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE,SAAS,EAAE,aAAa,GAAI,CAAC,IACpL,CACJ,CAAC;IAEF,IAAI,KAAK,CAAC,YAAY;QAAE,OAAO,MAAM,CAAC;;QACjC,OAAO,CAAC,KAAC,UAAU,IAAC,EAAE,EAAC,UAAU,iBAAa,WAAW,EAAC,UAAU,EAAC,eAAe,EAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,YAAG,MAAM,GAAc,CAAC,CAAC;AACrK,CAAC;AAAA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChurchList.d.ts","sourceRoot":"","sources":["../../../src/components/wrapper/ChurchList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAe,MAAM,qBAAqB,CAAC;AAMlG,MAAM,WAAW,KAAK;IAAG,YAAY,EAAE,wBAAwB,EAAE,CAAC;IAAC,iBAAiB,EAAE,wBAAwB,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE;AAEtK,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"ChurchList.d.ts","sourceRoot":"","sources":["../../../src/components/wrapper/ChurchList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAe,MAAM,qBAAqB,CAAC;AAMlG,MAAM,WAAW,KAAK;IAAG,YAAY,EAAE,wBAAwB,EAAE,CAAC;IAAC,iBAAiB,EAAE,wBAAwB,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE;AAEtK,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAwEtC,CAAC"}
|
|
@@ -1,16 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import React, { useState } from "react";
|
|
4
4
|
import { ArrayHelper } from "@churchapps/helpers";
|
|
5
|
-
import { ApiHelper } from "
|
|
5
|
+
import { ApiHelper } from "@churchapps/helpers";
|
|
6
6
|
import { UserHelper } from "../../helpers/UserHelper";
|
|
7
7
|
import { NavItem } from "./NavItem";
|
|
8
8
|
import { Locale } from "../../helpers";
|
|
9
9
|
export const ChurchList = props => {
|
|
10
|
-
const [userChurches, setUserChurches] = useState(
|
|
10
|
+
const [userChurches, setUserChurches] = useState(() => {
|
|
11
|
+
try {
|
|
12
|
+
// Handle both array and single object cases
|
|
13
|
+
let churches = props.userChurches;
|
|
14
|
+
if (!Array.isArray(churches)) {
|
|
15
|
+
churches = churches ? [churches] : [];
|
|
16
|
+
}
|
|
17
|
+
return churches.filter(uc => uc && uc.apis && uc.apis.length > 0);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error('Error filtering userChurches:', error);
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
// Update local state when props change
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
try {
|
|
27
|
+
// Handle both array and single object cases
|
|
28
|
+
let churches = props.userChurches;
|
|
29
|
+
if (!Array.isArray(churches)) {
|
|
30
|
+
churches = churches ? [churches] : [];
|
|
31
|
+
}
|
|
32
|
+
setUserChurches(churches.filter(uc => uc && uc.apis && uc.apis.length > 0));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error('Error updating userChurches:', error);
|
|
36
|
+
setUserChurches([]);
|
|
37
|
+
}
|
|
38
|
+
}, [props.userChurches]);
|
|
11
39
|
const handleDelete = async (uc) => {
|
|
12
|
-
|
|
13
|
-
|
|
40
|
+
// Helper function to get label with fallback
|
|
41
|
+
const getLabel = (key, fallback) => {
|
|
42
|
+
const label = Locale.label(key);
|
|
43
|
+
return label && label !== key ? label : fallback;
|
|
44
|
+
};
|
|
45
|
+
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());
|
|
46
|
+
if (window.confirm(confirmMessage)) {
|
|
14
47
|
await ApiHelper.delete(`/userchurch/record/${props.context.user.id}/${uc.church.id}/${uc.person.id}`, "MembershipApi");
|
|
15
48
|
await ApiHelper.delete(`/rolemembers/self/${uc.church.id}/${props.context.user.id}`, "MembershipApi");
|
|
16
49
|
// remove the same from userChurches
|
|
@@ -20,11 +53,16 @@ export const ChurchList = props => {
|
|
|
20
53
|
props?.onDelete();
|
|
21
54
|
}
|
|
22
55
|
};
|
|
56
|
+
// Helper function to get label with fallback
|
|
57
|
+
const getLabel = (key, fallback) => {
|
|
58
|
+
const label = Locale.label(key);
|
|
59
|
+
return label && label !== key ? label : fallback;
|
|
60
|
+
};
|
|
23
61
|
let result = [];
|
|
24
62
|
userChurches.forEach(uc => {
|
|
25
63
|
const userChurch = uc;
|
|
26
64
|
const churchName = uc.church.name;
|
|
27
|
-
result.push(_jsx(NavItem, { selected: (uc.church.id === props.currentUserChurch.church.id) && true, onClick: () => UserHelper.selectChurch(props.context, userChurch.church.id, null), label: churchName || "Unknown", icon: "church", deleteIcon: uc.church.id !== props.currentUserChurch.church.id ? "delete" : null, deleteLabel:
|
|
65
|
+
result.push(_jsx(NavItem, { selected: (uc.church.id === props.currentUserChurch.church.id) && true, onClick: () => UserHelper.selectChurch(props.context, userChurch.church.id, null), label: churchName || "Unknown", icon: "church", deleteIcon: uc.church.id !== props.currentUserChurch.church.id ? "delete" : null, deleteLabel: getLabel("wrapper.deleteChurch", "Delete"), deleteFunction: () => { handleDelete(uc); } }, userChurch.church.id));
|
|
28
66
|
});
|
|
29
67
|
return _jsx(_Fragment, { children: result });
|
|
30
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChurchList.js","sourceRoot":"","sources":["../../../src/components/wrapper/ChurchList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,
|
|
1
|
+
{"version":3,"file":"ChurchList.js","sourceRoot":"","sources":["../../../src/components/wrapper/ChurchList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAkD,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvC,MAAM,CAAC,MAAM,UAAU,GAAoB,KAAK,CAAC,EAAE;IAElD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE;QACrD,IAAI,CAAC;YACJ,4CAA4C;YAC5C,IAAI,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9B,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACvC,CAAC;YACD,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC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,OAAO,CAAC,EAAE,CAAC,EAAE;QACzB,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,MAAM,UAAU,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,KAAC,OAAO,IAEnB,QAAQ,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,EACtE,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,EACjF,KAAK,EAAE,UAAU,IAAI,SAAS,EAC9B,IAAI,EAAC,QAAQ,EACb,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAChF,WAAW,EAAE,QAAQ,CAAC,sBAAsB,EAAE,QAAQ,CAAC,EACvD,cAAc,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAPtC,UAAU,CAAC,MAAM,CAAC,EAAE,CAQxB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,4BAAG,MAAM,GAAI,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NewPrivateMessage.d.ts","sourceRoot":"","sources":["../../../src/components/wrapper/NewPrivateMessage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NewPrivateMessage.d.ts","sourceRoot":"","sources":["../../../src/components/wrapper/NewPrivateMessage.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAyB,eAAe,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAI5H,UAAU,KAAK;IACb,OAAO,EAAE,oBAAoB,CAAC;IAC9B,eAAe,EAAE,CAAC,EAAE,EAAE,uBAAuB,KAAK,IAAI,CAAA;IACtD,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,cAAc,CAAC,EAAE,eAAe,CAAA;CACjC;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAuN7C,CAAA"}
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button, TextField,
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
3
|
+
import { Button, TextField, Paper, Box, Typography, Stack, IconButton, List, ListItemAvatar, ListItemText, ListItemButton, InputAdornment, Divider, Skeleton, useTheme } from "@mui/material";
|
|
4
|
+
import { ArrowBack as ArrowBackIcon, PersonSearch as PersonSearchIcon } from "@mui/icons-material";
|
|
5
|
+
import React, { useEffect, useState } from "react";
|
|
6
|
+
import { ApiHelper, Locale } from "../../helpers";
|
|
6
7
|
import { AddNote } from "../notes/AddNote";
|
|
7
|
-
import {
|
|
8
|
+
import { PersonAvatar } from "../PersonAvatar";
|
|
8
9
|
export const NewPrivateMessage = (props) => {
|
|
9
10
|
const [searchText, setSearchText] = React.useState("");
|
|
10
11
|
const [searchResults, setSearchResults] = React.useState([]);
|
|
11
12
|
const [selectedPerson, setSelectedPerson] = React.useState(null);
|
|
12
|
-
const handleSubmit = (e) => {
|
|
13
|
-
if (e !== null)
|
|
14
|
-
e.preventDefault();
|
|
15
|
-
let term = escape(searchText.trim());
|
|
16
|
-
ApiHelper.get("/people/search?term=" + term, "MembershipApi").then(data => setSearchResults(data));
|
|
17
|
-
};
|
|
18
13
|
const handleChange = (e) => {
|
|
19
14
|
setSearchText(e.currentTarget.value);
|
|
20
15
|
};
|
|
@@ -38,19 +33,11 @@ export const NewPrivateMessage = (props) => {
|
|
|
38
33
|
}
|
|
39
34
|
setSelectedPerson(person);
|
|
40
35
|
};
|
|
41
|
-
const getPeople = () => {
|
|
42
|
-
let result = [];
|
|
43
|
-
for (let i = 0; i < searchResults.length; i++) {
|
|
44
|
-
const p = searchResults[i];
|
|
45
|
-
result.push(_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsx("img", { src: PersonHelper.getPhotoUrl(p), alt: "avatar" }) }), _jsx(TableCell, { children: _jsx("a", { href: "about:blank", onClick: (e) => { e.preventDefault(); handlePersonSelected(p); }, children: p.name.display }) })] }, p.id));
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
36
|
const handleNoteAdded = () => {
|
|
50
37
|
handlePersonSelected(selectedPerson);
|
|
51
38
|
};
|
|
52
39
|
const createConversation = async () => {
|
|
53
|
-
const conv = { allowAnonymousPosts: false, contentType: "privateMessage", contentId: props.context.person.id, title: props.context.person.name.display + " " + Locale.label("wrapper.privateMessage"), visibility: "hidden" };
|
|
40
|
+
const conv = { allowAnonymousPosts: false, contentType: "privateMessage", contentId: props.context.person.id, title: props.context.person.name.display + " " + Locale.label("wrapper.privateMessage", "Private Message"), visibility: "hidden" };
|
|
54
41
|
const result = await ApiHelper.post("/conversations", [conv], "MessagingApi");
|
|
55
42
|
const pm = {
|
|
56
43
|
fromPersonId: props.context.person.id,
|
|
@@ -64,10 +51,30 @@ export const NewPrivateMessage = (props) => {
|
|
|
64
51
|
if (props.selectedPerson)
|
|
65
52
|
handlePersonSelected(props.selectedPerson);
|
|
66
53
|
}, [props.selectedPerson]);
|
|
54
|
+
const theme = useTheme();
|
|
55
|
+
const [isSearching, setIsSearching] = useState(false);
|
|
56
|
+
const handleSearchSubmit = async (e) => {
|
|
57
|
+
if (e !== null)
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
if (!searchText.trim())
|
|
60
|
+
return;
|
|
61
|
+
setIsSearching(true);
|
|
62
|
+
let term = escape(searchText.trim());
|
|
63
|
+
const data = await ApiHelper.get("/people/search?term=" + term, "MembershipApi");
|
|
64
|
+
setSearchResults(data);
|
|
65
|
+
setIsSearching(false);
|
|
66
|
+
};
|
|
67
67
|
if (!selectedPerson)
|
|
68
|
-
return (_jsxs(
|
|
68
|
+
return (_jsxs(Paper, { elevation: 0, sx: { height: '100%', display: 'flex', flexDirection: 'column' }, children: [_jsx(Box, { sx: { p: 2, borderBottom: 1, borderColor: 'divider' }, children: _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 2, children: [_jsx(IconButton, { onClick: props.onBack, children: _jsx(ArrowBackIcon, {}) }), _jsx(Typography, { variant: "h6", component: "h2", children: Locale.label("wrapper.newPrivateMessage", "New Private Message") })] }) }), _jsx(Box, { sx: { p: 3 }, children: _jsxs(Stack, { spacing: 3, children: [_jsxs(Box, { children: [_jsx(Typography, { variant: "body1", color: "textSecondary", gutterBottom: true, children: Locale.label("wrapper.searchForPerson", "Search for a person to message") }), _jsx(TextField, { fullWidth: true, placeholder: "Search by name...", id: "searchText", "data-testid": "search-input", value: searchText, onChange: handleChange, onKeyDown: (e) => {
|
|
69
|
+
e.stopPropagation();
|
|
70
|
+
if (e.key === 'Enter')
|
|
71
|
+
handleSearchSubmit(null);
|
|
72
|
+
}, InputProps: {
|
|
73
|
+
startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(PersonSearchIcon, { color: "action" }) })),
|
|
74
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(Button, { variant: "contained", size: "small", onClick: handleSearchSubmit, disabled: !searchText.trim() || isSearching, children: Locale.label("common.search", "Search") }) }))
|
|
75
|
+
}, sx: { mt: 1 } })] }), isSearching && (_jsx(Box, { children: [...Array(3)].map((_, index) => (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', mb: 2 }, children: [_jsx(Skeleton, { variant: "circular", width: 48, height: 48, sx: { mr: 2 } }), _jsx(Skeleton, { variant: "text", width: "60%", height: 24 })] }, index))) })), !isSearching && searchResults.length > 0 && (_jsxs(Box, { children: [_jsxs(Typography, { variant: "subtitle2", color: "textSecondary", gutterBottom: true, children: [searchResults.length, " ", searchResults.length === 1 ? 'person' : 'people', " found"] }), _jsx(List, { sx: { bgcolor: 'background.paper', borderRadius: 1 }, children: searchResults.map((person, index) => (_jsxs(React.Fragment, { children: [_jsxs(ListItemButton, { onClick: () => handlePersonSelected(person), sx: { py: 2 }, children: [_jsx(ListItemAvatar, { children: _jsx(PersonAvatar, { person: person, size: "small" }) }), _jsx(ListItemText, { primary: person.name.display, secondary: person.contactInfo?.email || '' })] }), index < searchResults.length - 1 && _jsx(Divider, {})] }, person.id))) })] })), !isSearching && searchText && searchResults.length === 0 && (_jsxs(Box, { sx: { textAlign: 'center', py: 4 }, children: [_jsx(PersonSearchIcon, { sx: { fontSize: 48, color: 'grey.400', mb: 2 } }), _jsx(Typography, { variant: "h6", color: "textSecondary", children: "No people found" }), _jsx(Typography, { variant: "body2", color: "textSecondary", children: "Try searching with a different name" })] }))] }) })] }));
|
|
69
76
|
else {
|
|
70
|
-
return (_jsxs(
|
|
77
|
+
return (_jsxs(Paper, { elevation: 0, sx: { height: '100%', display: 'flex', flexDirection: 'column' }, children: [_jsx(Box, { sx: { p: 2, borderBottom: 1, borderColor: 'divider' }, children: _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 2, children: [_jsx(IconButton, { onClick: props.onBack, children: _jsx(ArrowBackIcon, {}) }), _jsx(Typography, { variant: "h6", component: "h2", children: Locale.label("wrapper.newPrivateMessage", "New Private Message") })] }) }), _jsxs(Box, { sx: { p: 3 }, children: [_jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", sx: { mb: 3 }, children: [_jsx(PersonAvatar, { person: selectedPerson, size: "medium" }), _jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle1", fontWeight: "medium", children: selectedPerson.name.display }), selectedPerson.contactInfo?.email && (_jsx(Typography, { variant: "body2", color: "textSecondary", children: selectedPerson.contactInfo.email }))] })] }), _jsx(Divider, { sx: { mb: 3 } }), _jsx(AddNote, { context: props.context, conversationId: null, onUpdate: handleNoteAdded, createConversation: createConversation })] })] }));
|
|
71
78
|
}
|
|
72
79
|
};
|
|
73
80
|
//# sourceMappingURL=NewPrivateMessage.js.map
|