@churchapps/apphelper 0.4.50 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 +104 -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,2 +1,2 @@
|
|
|
1
|
-
export { Banner } from "./Banner";
|
|
2
|
-
export { SiteHeader } from "./SiteHeader";
|
|
1
|
+
export { Banner } from "./Banner";
|
|
2
|
+
export { SiteHeader } from "./SiteHeader";
|
package/src/components/index.tsx
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { ErrorMessages } from "./ErrorMessages";
|
|
2
|
-
export { ExportLink } from "./ExportLink";
|
|
3
|
-
export { DisplayBox } from "./DisplayBox";
|
|
4
|
-
export { FloatingSupport } from "./FloatingSupport";
|
|
5
|
-
export { FormSubmissionEdit } from "./FormSubmissionEdit";
|
|
6
|
-
export { HelpIcon } from "./HelpIcon";
|
|
7
|
-
export { ImageEditor } from "./ImageEditor";
|
|
8
|
-
export { InputBox } from "./InputBox";
|
|
9
|
-
export { Loading } from "./Loading";
|
|
10
|
-
export { Notes } from "./notes/Notes";
|
|
11
|
-
export { PageHeader } from "./PageHeader";
|
|
12
|
-
export { PersonAvatar } from "./PersonAvatar";
|
|
13
|
-
export { QuestionEdit } from "./QuestionEdit";
|
|
14
|
-
export { SmallButton } from "./SmallButton";
|
|
15
|
-
export { SupportModal } from "./SupportModal";
|
|
16
|
-
export { TabPanel } from "./TabPanel";
|
|
17
|
-
export * from "./wrapper";
|
|
18
|
-
export * from "./notes";
|
|
19
|
-
export * from "./header";
|
|
20
|
-
export * from "./gallery";
|
|
1
|
+
export { ErrorMessages } from "./ErrorMessages";
|
|
2
|
+
export { ExportLink } from "./ExportLink";
|
|
3
|
+
export { DisplayBox } from "./DisplayBox";
|
|
4
|
+
export { FloatingSupport } from "./FloatingSupport";
|
|
5
|
+
export { FormSubmissionEdit } from "./FormSubmissionEdit";
|
|
6
|
+
export { HelpIcon } from "./HelpIcon";
|
|
7
|
+
export { ImageEditor } from "./ImageEditor";
|
|
8
|
+
export { InputBox } from "./InputBox";
|
|
9
|
+
export { Loading } from "./Loading";
|
|
10
|
+
export { Notes } from "./notes/Notes";
|
|
11
|
+
export { PageHeader } from "./PageHeader";
|
|
12
|
+
export { PersonAvatar } from "./PersonAvatar";
|
|
13
|
+
export { QuestionEdit } from "./QuestionEdit";
|
|
14
|
+
export { SmallButton } from "./SmallButton";
|
|
15
|
+
export { SupportModal } from "./SupportModal";
|
|
16
|
+
export { TabPanel } from "./TabPanel";
|
|
17
|
+
export * from "./wrapper";
|
|
18
|
+
export * from "./notes";
|
|
19
|
+
export * from "./header";
|
|
20
|
+
export * from "./gallery";
|
|
@@ -1,180 +1,180 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, { useState, useEffect } from "react"
|
|
4
|
-
import { ApiHelper, Locale, PersonHelper } from "../../helpers"
|
|
5
|
-
import { MessageInterface, UserContextInterface } from "@churchapps/helpers"
|
|
6
|
-
import {
|
|
7
|
-
Box,
|
|
8
|
-
Stack,
|
|
9
|
-
TextField,
|
|
10
|
-
IconButton,
|
|
11
|
-
Paper,
|
|
12
|
-
CircularProgress,
|
|
13
|
-
Avatar
|
|
14
|
-
} from "@mui/material"
|
|
15
|
-
import { Send as SendIcon, Delete as DeleteIcon } from "@mui/icons-material"
|
|
16
|
-
import { ErrorMessages } from "../ErrorMessages"
|
|
17
|
-
|
|
18
|
-
type Props = {
|
|
19
|
-
messageId?: string;
|
|
20
|
-
onUpdate: () => void;
|
|
21
|
-
createConversation: () => Promise<string>;
|
|
22
|
-
conversationId?: string;
|
|
23
|
-
context: UserContextInterface
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export function AddNote({ context, ...props }: Props) {
|
|
27
|
-
const [message, setMessage] = useState<MessageInterface>()
|
|
28
|
-
const [errors, setErrors] = React.useState<string[]>([]);
|
|
29
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
30
|
-
const headerText = props.messageId ? "Edit note" : "Add a note"
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (props.messageId) ApiHelper.get(`/messages/${props.messageId}`, "MessagingApi").then((n: any) => setMessage(n));
|
|
34
|
-
else setMessage({ conversationId: props.conversationId, content: "" });
|
|
35
|
-
return () => {
|
|
36
|
-
setMessage(null);
|
|
37
|
-
};
|
|
38
|
-
}, [props.messageId, props.conversationId])
|
|
39
|
-
|
|
40
|
-
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
|
|
41
|
-
setErrors([]);
|
|
42
|
-
const m = { ...message } as MessageInterface;
|
|
43
|
-
m.content = e.target.value;
|
|
44
|
-
setMessage(m);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const validate = () => {
|
|
48
|
-
const result = [];
|
|
49
|
-
if (!message.content.trim()) result.push(Locale.label("notes.validate.content", "Please enter a message"));
|
|
50
|
-
setErrors(result);
|
|
51
|
-
return result.length === 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function handleSave() {
|
|
55
|
-
if (validate()) {
|
|
56
|
-
setIsSubmitting(true);
|
|
57
|
-
let cId = props.conversationId;
|
|
58
|
-
if (!cId) cId = await props.createConversation();
|
|
59
|
-
|
|
60
|
-
const m = { ...message };
|
|
61
|
-
m.conversationId = cId;
|
|
62
|
-
ApiHelper.post("/messages", [m], "MessagingApi")
|
|
63
|
-
.then(() => {
|
|
64
|
-
props.onUpdate();
|
|
65
|
-
const m = { ...message } as MessageInterface;
|
|
66
|
-
m.content = "";
|
|
67
|
-
setMessage(m);
|
|
68
|
-
})
|
|
69
|
-
.catch((error: any) => {
|
|
70
|
-
console.error("Error saving message:", error);
|
|
71
|
-
if (error?.message === "Forbidden") {
|
|
72
|
-
setErrors(["You can't edit the message sent by others."]);
|
|
73
|
-
} else {
|
|
74
|
-
setErrors([error?.message || "Failed to save message. Please try again."]);
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
.finally(() => { setIsSubmitting(false); });
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
async function deleteNote() {
|
|
82
|
-
await ApiHelper.delete(`/messages/${props.messageId}`, "MessagingApi")
|
|
83
|
-
props.onUpdate()
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const deleteFunction = props.messageId ? deleteNote : null;
|
|
87
|
-
|
|
88
|
-
const image = PersonHelper.getPhotoUrl(context?.person)
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<Box sx={{ width: '100%' }}>
|
|
92
|
-
<ErrorMessages errors={errors} />
|
|
93
|
-
|
|
94
|
-
<Paper
|
|
95
|
-
variant="outlined"
|
|
96
|
-
sx={{
|
|
97
|
-
p: 2,
|
|
98
|
-
bgcolor: 'grey.50',
|
|
99
|
-
borderColor: 'grey.300'
|
|
100
|
-
}}
|
|
101
|
-
>
|
|
102
|
-
<Stack direction="row" spacing={2} alignItems="flex-start">
|
|
103
|
-
<Avatar
|
|
104
|
-
src={image}
|
|
105
|
-
alt={context?.person?.name?.display}
|
|
106
|
-
sx={{ width: 48, height: 48 }}
|
|
107
|
-
/>
|
|
108
|
-
|
|
109
|
-
<Box sx={{ flex: 1 }}>
|
|
110
|
-
<TextField
|
|
111
|
-
fullWidth
|
|
112
|
-
multiline
|
|
113
|
-
rows={2}
|
|
114
|
-
name="noteText"
|
|
115
|
-
aria-label={headerText}
|
|
116
|
-
placeholder={props.messageId ? "Edit your message..." : "Type a message..."}
|
|
117
|
-
variant="standard"
|
|
118
|
-
value={message?.content || ''}
|
|
119
|
-
onChange={handleChange}
|
|
120
|
-
disabled={isSubmitting}
|
|
121
|
-
InputProps={{
|
|
122
|
-
disableUnderline: true,
|
|
123
|
-
sx: {
|
|
124
|
-
fontSize: '1rem',
|
|
125
|
-
'& textarea': {
|
|
126
|
-
resize: 'vertical',
|
|
127
|
-
minHeight: '40px'
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}}
|
|
131
|
-
sx={{
|
|
132
|
-
bgcolor: 'white',
|
|
133
|
-
borderRadius: 1,
|
|
134
|
-
p: 1,
|
|
135
|
-
border: '1px solid',
|
|
136
|
-
borderColor: 'grey.300',
|
|
137
|
-
'&:hover': {
|
|
138
|
-
borderColor: 'grey.400'
|
|
139
|
-
},
|
|
140
|
-
'&.Mui-focused': {
|
|
141
|
-
borderColor: 'primary.main'
|
|
142
|
-
}
|
|
143
|
-
}}
|
|
144
|
-
/>
|
|
145
|
-
|
|
146
|
-
<Box sx={{ display: 'flex', justifyContent: 'flex-end', mt: 1, gap: 0.5 }}>
|
|
147
|
-
{deleteFunction && (
|
|
148
|
-
<IconButton
|
|
149
|
-
size="small"
|
|
150
|
-
onClick={deleteFunction}
|
|
151
|
-
disabled={isSubmitting}
|
|
152
|
-
sx={{ color: 'error.main' }}
|
|
153
|
-
>
|
|
154
|
-
<DeleteIcon fontSize="small" />
|
|
155
|
-
</IconButton>
|
|
156
|
-
)}
|
|
157
|
-
<IconButton
|
|
158
|
-
size="small"
|
|
159
|
-
color="primary"
|
|
160
|
-
onClick={handleSave}
|
|
161
|
-
disabled={isSubmitting || !message?.content?.trim()}
|
|
162
|
-
sx={{
|
|
163
|
-
bgcolor: 'primary.main',
|
|
164
|
-
color: 'white',
|
|
165
|
-
'&:hover': { bgcolor: 'primary.dark' },
|
|
166
|
-
'&:disabled': {
|
|
167
|
-
bgcolor: 'action.disabledBackground',
|
|
168
|
-
color: 'action.disabled'
|
|
169
|
-
}
|
|
170
|
-
}}
|
|
171
|
-
>
|
|
172
|
-
{isSubmitting ? <CircularProgress size={18} color="inherit" /> : <SendIcon fontSize="small" />}
|
|
173
|
-
</IconButton>
|
|
174
|
-
</Box>
|
|
175
|
-
</Box>
|
|
176
|
-
</Stack>
|
|
177
|
-
</Paper>
|
|
178
|
-
</Box>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useState, useEffect } from "react"
|
|
4
|
+
import { ApiHelper, Locale, PersonHelper } from "../../helpers"
|
|
5
|
+
import { MessageInterface, UserContextInterface } from "@churchapps/helpers"
|
|
6
|
+
import {
|
|
7
|
+
Box,
|
|
8
|
+
Stack,
|
|
9
|
+
TextField,
|
|
10
|
+
IconButton,
|
|
11
|
+
Paper,
|
|
12
|
+
CircularProgress,
|
|
13
|
+
Avatar
|
|
14
|
+
} from "@mui/material"
|
|
15
|
+
import { Send as SendIcon, Delete as DeleteIcon } from "@mui/icons-material"
|
|
16
|
+
import { ErrorMessages } from "../ErrorMessages"
|
|
17
|
+
|
|
18
|
+
type Props = {
|
|
19
|
+
messageId?: string;
|
|
20
|
+
onUpdate: () => void;
|
|
21
|
+
createConversation: () => Promise<string>;
|
|
22
|
+
conversationId?: string;
|
|
23
|
+
context: UserContextInterface
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function AddNote({ context, ...props }: Props) {
|
|
27
|
+
const [message, setMessage] = useState<MessageInterface>()
|
|
28
|
+
const [errors, setErrors] = React.useState<string[]>([]);
|
|
29
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
30
|
+
const headerText = props.messageId ? "Edit note" : "Add a note"
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (props.messageId) ApiHelper.get(`/messages/${props.messageId}`, "MessagingApi").then((n: any) => setMessage(n));
|
|
34
|
+
else setMessage({ conversationId: props.conversationId, content: "" });
|
|
35
|
+
return () => {
|
|
36
|
+
setMessage(null);
|
|
37
|
+
};
|
|
38
|
+
}, [props.messageId, props.conversationId])
|
|
39
|
+
|
|
40
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
|
|
41
|
+
setErrors([]);
|
|
42
|
+
const m = { ...message } as MessageInterface;
|
|
43
|
+
m.content = e.target.value;
|
|
44
|
+
setMessage(m);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const validate = () => {
|
|
48
|
+
const result = [];
|
|
49
|
+
if (!message.content.trim()) result.push(Locale.label("notes.validate.content", "Please enter a message"));
|
|
50
|
+
setErrors(result);
|
|
51
|
+
return result.length === 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function handleSave() {
|
|
55
|
+
if (validate()) {
|
|
56
|
+
setIsSubmitting(true);
|
|
57
|
+
let cId = props.conversationId;
|
|
58
|
+
if (!cId) cId = await props.createConversation();
|
|
59
|
+
|
|
60
|
+
const m = { ...message };
|
|
61
|
+
m.conversationId = cId;
|
|
62
|
+
ApiHelper.post("/messages", [m], "MessagingApi")
|
|
63
|
+
.then(() => {
|
|
64
|
+
props.onUpdate();
|
|
65
|
+
const m = { ...message } as MessageInterface;
|
|
66
|
+
m.content = "";
|
|
67
|
+
setMessage(m);
|
|
68
|
+
})
|
|
69
|
+
.catch((error: any) => {
|
|
70
|
+
console.error("Error saving message:", error);
|
|
71
|
+
if (error?.message === "Forbidden") {
|
|
72
|
+
setErrors(["You can't edit the message sent by others."]);
|
|
73
|
+
} else {
|
|
74
|
+
setErrors([error?.message || "Failed to save message. Please try again."]);
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
.finally(() => { setIsSubmitting(false); });
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
async function deleteNote() {
|
|
82
|
+
await ApiHelper.delete(`/messages/${props.messageId}`, "MessagingApi")
|
|
83
|
+
props.onUpdate()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const deleteFunction = props.messageId ? deleteNote : null;
|
|
87
|
+
|
|
88
|
+
const image = PersonHelper.getPhotoUrl(context?.person)
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<Box sx={{ width: '100%' }}>
|
|
92
|
+
<ErrorMessages errors={errors} />
|
|
93
|
+
|
|
94
|
+
<Paper
|
|
95
|
+
variant="outlined"
|
|
96
|
+
sx={{
|
|
97
|
+
p: 2,
|
|
98
|
+
bgcolor: 'grey.50',
|
|
99
|
+
borderColor: 'grey.300'
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
<Stack direction="row" spacing={2} alignItems="flex-start">
|
|
103
|
+
<Avatar
|
|
104
|
+
src={image}
|
|
105
|
+
alt={context?.person?.name?.display}
|
|
106
|
+
sx={{ width: 48, height: 48 }}
|
|
107
|
+
/>
|
|
108
|
+
|
|
109
|
+
<Box sx={{ flex: 1 }}>
|
|
110
|
+
<TextField
|
|
111
|
+
fullWidth
|
|
112
|
+
multiline
|
|
113
|
+
rows={2}
|
|
114
|
+
name="noteText"
|
|
115
|
+
aria-label={headerText}
|
|
116
|
+
placeholder={props.messageId ? "Edit your message..." : "Type a message..."}
|
|
117
|
+
variant="standard"
|
|
118
|
+
value={message?.content || ''}
|
|
119
|
+
onChange={handleChange}
|
|
120
|
+
disabled={isSubmitting}
|
|
121
|
+
InputProps={{
|
|
122
|
+
disableUnderline: true,
|
|
123
|
+
sx: {
|
|
124
|
+
fontSize: '1rem',
|
|
125
|
+
'& textarea': {
|
|
126
|
+
resize: 'vertical',
|
|
127
|
+
minHeight: '40px'
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}}
|
|
131
|
+
sx={{
|
|
132
|
+
bgcolor: 'white',
|
|
133
|
+
borderRadius: 1,
|
|
134
|
+
p: 1,
|
|
135
|
+
border: '1px solid',
|
|
136
|
+
borderColor: 'grey.300',
|
|
137
|
+
'&:hover': {
|
|
138
|
+
borderColor: 'grey.400'
|
|
139
|
+
},
|
|
140
|
+
'&.Mui-focused': {
|
|
141
|
+
borderColor: 'primary.main'
|
|
142
|
+
}
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
|
|
146
|
+
<Box sx={{ display: 'flex', justifyContent: 'flex-end', mt: 1, gap: 0.5 }}>
|
|
147
|
+
{deleteFunction && (
|
|
148
|
+
<IconButton
|
|
149
|
+
size="small"
|
|
150
|
+
onClick={deleteFunction}
|
|
151
|
+
disabled={isSubmitting}
|
|
152
|
+
sx={{ color: 'error.main' }}
|
|
153
|
+
>
|
|
154
|
+
<DeleteIcon fontSize="small" />
|
|
155
|
+
</IconButton>
|
|
156
|
+
)}
|
|
157
|
+
<IconButton
|
|
158
|
+
size="small"
|
|
159
|
+
color="primary"
|
|
160
|
+
onClick={handleSave}
|
|
161
|
+
disabled={isSubmitting || !message?.content?.trim()}
|
|
162
|
+
sx={{
|
|
163
|
+
bgcolor: 'primary.main',
|
|
164
|
+
color: 'white',
|
|
165
|
+
'&:hover': { bgcolor: 'primary.dark' },
|
|
166
|
+
'&:disabled': {
|
|
167
|
+
bgcolor: 'action.disabledBackground',
|
|
168
|
+
color: 'action.disabled'
|
|
169
|
+
}
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
{isSubmitting ? <CircularProgress size={18} color="inherit" /> : <SendIcon fontSize="small" />}
|
|
173
|
+
</IconButton>
|
|
174
|
+
</Box>
|
|
175
|
+
</Box>
|
|
176
|
+
</Stack>
|
|
177
|
+
</Paper>
|
|
178
|
+
</Box>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { Icon, IconButton, Stack, Box, Typography } from "@mui/material";
|
|
2
|
-
import React, { useState, useEffect } from "react";
|
|
3
|
-
import { DateHelper } from "../../helpers"
|
|
4
|
-
import { MessageInterface, UserContextInterface } from "@churchapps/helpers"
|
|
5
|
-
import { PersonAvatar } from "../PersonAvatar"
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
message: MessageInterface;
|
|
9
|
-
showEditNote: (noteId?: string) => void;
|
|
10
|
-
context: UserContextInterface;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const Note: React.FC<Props> = (props) => {
|
|
14
|
-
const [message, setMessage] = useState<MessageInterface>(null);
|
|
15
|
-
|
|
16
|
-
useEffect(() => setMessage(props.message), [props.message]);
|
|
17
|
-
|
|
18
|
-
if (message === null) return null;
|
|
19
|
-
let datePosted = new Date(message.timeUpdated || message.timeSent);
|
|
20
|
-
const displayDuration = DateHelper.getDisplayDuration(datePosted);
|
|
21
|
-
|
|
22
|
-
const isEdited = message.timeUpdated && message.timeUpdated !== message.timeSent;
|
|
23
|
-
const contents = message.content?.split("\n");
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<Box sx={{ display: 'flex', gap: 2, mb: 2, p: 1, '&:hover': { bgcolor: 'action.hover', borderRadius: 1 } }}>
|
|
27
|
-
<PersonAvatar person={message.person} size="small" />
|
|
28
|
-
<Box sx={{ flex: 1 }}>
|
|
29
|
-
<Stack direction="row" justifyContent="space-between" alignItems="flex-start">
|
|
30
|
-
<Box sx={{ flex: 1 }}>
|
|
31
|
-
<Stack direction="row" alignItems="center" spacing={1} sx={{ mb: 0.5 }}>
|
|
32
|
-
<Typography variant="subtitle2" fontWeight="bold">
|
|
33
|
-
{message.person?.name?.display}
|
|
34
|
-
</Typography>
|
|
35
|
-
<Typography variant="caption" color="text.secondary">
|
|
36
|
-
{displayDuration}
|
|
37
|
-
</Typography>
|
|
38
|
-
{isEdited && (
|
|
39
|
-
<Typography variant="caption" color="text.secondary">
|
|
40
|
-
(edited)
|
|
41
|
-
</Typography>
|
|
42
|
-
)}
|
|
43
|
-
</Stack>
|
|
44
|
-
<Box>
|
|
45
|
-
{contents.map((c, i) => c ? (
|
|
46
|
-
<Typography key={i} variant="body2" sx={{ mb: 0.5 }}>
|
|
47
|
-
{c}
|
|
48
|
-
</Typography>
|
|
49
|
-
) : (
|
|
50
|
-
<Box key={i} sx={{ height: '1em' }} />
|
|
51
|
-
))}
|
|
52
|
-
</Box>
|
|
53
|
-
</Box>
|
|
54
|
-
{(message?.id && message.personId === props.context?.person.id) && (
|
|
55
|
-
<IconButton
|
|
56
|
-
size="small"
|
|
57
|
-
aria-label="editNote"
|
|
58
|
-
onClick={() => props.showEditNote(message.id)}
|
|
59
|
-
sx={{ opacity: 0.7, '&:hover': { opacity: 1 } }}
|
|
60
|
-
>
|
|
61
|
-
<Icon fontSize="small">edit</Icon>
|
|
62
|
-
</IconButton>
|
|
63
|
-
)}
|
|
64
|
-
</Stack>
|
|
65
|
-
</Box>
|
|
66
|
-
</Box>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
1
|
+
import { Icon, IconButton, Stack, Box, Typography } from "@mui/material";
|
|
2
|
+
import React, { useState, useEffect } from "react";
|
|
3
|
+
import { DateHelper } from "../../helpers"
|
|
4
|
+
import { MessageInterface, UserContextInterface } from "@churchapps/helpers"
|
|
5
|
+
import { PersonAvatar } from "../PersonAvatar"
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
message: MessageInterface;
|
|
9
|
+
showEditNote: (noteId?: string) => void;
|
|
10
|
+
context: UserContextInterface;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Note: React.FC<Props> = (props) => {
|
|
14
|
+
const [message, setMessage] = useState<MessageInterface>(null);
|
|
15
|
+
|
|
16
|
+
useEffect(() => setMessage(props.message), [props.message]);
|
|
17
|
+
|
|
18
|
+
if (message === null) return null;
|
|
19
|
+
let datePosted = new Date(message.timeUpdated || message.timeSent);
|
|
20
|
+
const displayDuration = DateHelper.getDisplayDuration(datePosted);
|
|
21
|
+
|
|
22
|
+
const isEdited = message.timeUpdated && message.timeUpdated !== message.timeSent;
|
|
23
|
+
const contents = message.content?.split("\n");
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Box sx={{ display: 'flex', gap: 2, mb: 2, p: 1, '&:hover': { bgcolor: 'action.hover', borderRadius: 1 } }}>
|
|
27
|
+
<PersonAvatar person={message.person} size="small" />
|
|
28
|
+
<Box sx={{ flex: 1 }}>
|
|
29
|
+
<Stack direction="row" justifyContent="space-between" alignItems="flex-start">
|
|
30
|
+
<Box sx={{ flex: 1 }}>
|
|
31
|
+
<Stack direction="row" alignItems="center" spacing={1} sx={{ mb: 0.5 }}>
|
|
32
|
+
<Typography variant="subtitle2" fontWeight="bold">
|
|
33
|
+
{message.person?.name?.display}
|
|
34
|
+
</Typography>
|
|
35
|
+
<Typography variant="caption" color="text.secondary">
|
|
36
|
+
{displayDuration}
|
|
37
|
+
</Typography>
|
|
38
|
+
{isEdited && (
|
|
39
|
+
<Typography variant="caption" color="text.secondary">
|
|
40
|
+
(edited)
|
|
41
|
+
</Typography>
|
|
42
|
+
)}
|
|
43
|
+
</Stack>
|
|
44
|
+
<Box>
|
|
45
|
+
{contents.map((c, i) => c ? (
|
|
46
|
+
<Typography key={i} variant="body2" sx={{ mb: 0.5 }}>
|
|
47
|
+
{c}
|
|
48
|
+
</Typography>
|
|
49
|
+
) : (
|
|
50
|
+
<Box key={i} sx={{ height: '1em' }} />
|
|
51
|
+
))}
|
|
52
|
+
</Box>
|
|
53
|
+
</Box>
|
|
54
|
+
{(message?.id && message.personId === props.context?.person.id) && (
|
|
55
|
+
<IconButton
|
|
56
|
+
size="small"
|
|
57
|
+
aria-label="editNote"
|
|
58
|
+
onClick={() => props.showEditNote(message.id)}
|
|
59
|
+
sx={{ opacity: 0.7, '&:hover': { opacity: 1 } }}
|
|
60
|
+
>
|
|
61
|
+
<Icon fontSize="small">edit</Icon>
|
|
62
|
+
</IconButton>
|
|
63
|
+
)}
|
|
64
|
+
</Stack>
|
|
65
|
+
</Box>
|
|
66
|
+
</Box>
|
|
67
|
+
);
|
|
68
|
+
};
|