@churchapps/apphelper 0.5.11 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ErrorMessages.js +1 -1
- package/dist/components/ErrorMessages.js.map +1 -1
- package/dist/components/FormCardPayment.js +2 -2
- package/dist/components/FormCardPayment.js.map +1 -1
- package/dist/components/ImageEditor.d.ts.map +1 -1
- package/dist/components/ImageEditor.js +13 -8
- package/dist/components/ImageEditor.js.map +1 -1
- package/dist/components/PageHeader.js +1 -1
- package/dist/components/PageHeader.js.map +1 -1
- package/dist/components/QuestionEdit.js +2 -2
- package/dist/components/QuestionEdit.js.map +1 -1
- package/dist/components/SmallButton.js +1 -1
- package/dist/components/SmallButton.js.map +1 -1
- package/dist/components/gallery/GalleryModal.d.ts.map +1 -1
- package/dist/components/gallery/GalleryModal.js +2 -6
- package/dist/components/gallery/GalleryModal.js.map +1 -1
- package/dist/components/header/SecondaryMenu.js +2 -2
- package/dist/components/header/SecondaryMenu.js.map +1 -1
- package/dist/components/header/SiteHeader.d.ts.map +1 -1
- package/dist/components/header/SiteHeader.js +0 -3
- package/dist/components/header/SiteHeader.js.map +1 -1
- package/dist/components/notes/Note.js +1 -1
- package/dist/components/notes/Note.js.map +1 -1
- package/dist/components/wrapper/ChurchList.d.ts.map +1 -1
- package/dist/components/wrapper/ChurchList.js +0 -7
- package/dist/components/wrapper/ChurchList.js.map +1 -1
- package/dist/components/wrapper/NewPrivateMessage.d.ts.map +1 -1
- package/dist/components/wrapper/NewPrivateMessage.js +1 -2
- package/dist/components/wrapper/NewPrivateMessage.js.map +1 -1
- package/dist/components/wrapper/Notifications.js +1 -1
- package/dist/components/wrapper/Notifications.js.map +1 -1
- package/dist/components/wrapper/PrivateMessageDetails.d.ts.map +1 -1
- package/dist/components/wrapper/PrivateMessageDetails.js +0 -2
- package/dist/components/wrapper/PrivateMessageDetails.js.map +1 -1
- package/dist/components/wrapper/PrivateMessages.js +1 -1
- package/dist/components/wrapper/PrivateMessages.js.map +1 -1
- package/dist/components/wrapper/UserMenu.d.ts.map +1 -1
- package/dist/components/wrapper/UserMenu.js +0 -13
- package/dist/components/wrapper/UserMenu.js.map +1 -1
- package/dist/helpers/ErrorHelper.d.ts.map +1 -1
- package/dist/helpers/ErrorHelper.js +0 -2
- package/dist/helpers/ErrorHelper.js.map +1 -1
- package/dist/helpers/NotificationService.d.ts +0 -18
- package/dist/helpers/NotificationService.d.ts.map +1 -1
- package/dist/helpers/NotificationService.js +0 -65
- package/dist/helpers/NotificationService.js.map +1 -1
- package/dist/helpers/SocketHelper.d.ts.map +1 -1
- package/dist/helpers/SocketHelper.js +1 -53
- package/dist/helpers/SocketHelper.js.map +1 -1
- package/dist/helpers/UserHelper.d.ts.map +1 -1
- package/dist/helpers/UserHelper.js +0 -4
- package/dist/helpers/UserHelper.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ErrorMessages.tsx +1 -1
- package/src/components/FormCardPayment.tsx +1 -1
- package/src/components/ImageEditor.tsx +167 -161
- package/src/components/PageHeader.tsx +2 -2
- package/src/components/QuestionEdit.tsx +2 -2
- package/src/components/SmallButton.tsx +1 -1
- package/src/components/gallery/GalleryModal.tsx +169 -173
- package/src/components/header/SecondaryMenu.tsx +2 -2
- package/src/components/header/SiteHeader.tsx +204 -207
- package/src/components/notes/Note.tsx +2 -2
- package/src/components/wrapper/ChurchList.tsx +145 -154
- package/src/components/wrapper/NewPrivateMessage.tsx +1 -2
- package/src/components/wrapper/Notifications.tsx +1 -1
- package/src/components/wrapper/PrivateMessageDetails.tsx +2 -6
- package/src/components/wrapper/PrivateMessages.tsx +1 -1
- package/src/components/wrapper/UserMenu.tsx +3 -17
- package/src/helpers/ErrorHelper.ts +41 -43
- package/src/helpers/NotificationService.ts +232 -296
- package/src/helpers/SocketHelper.ts +247 -296
- package/src/helpers/UserHelper.ts +2 -6
|
@@ -1,161 +1,167 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, { useState, useEffect, useRef, Suspense, lazy } from "react";
|
|
4
|
-
import { InputBox, SmallButton, Loading } from ".";
|
|
5
|
-
import { Locale } from "../helpers";
|
|
6
|
-
import "../../public/css/cropper.css";
|
|
7
|
-
|
|
8
|
-
// Lazy load the Cropper component
|
|
9
|
-
const Cropper = lazy(() => import("react-cropper").then(module => ({ default: module.default })));
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
title?: string;
|
|
13
|
-
photoUrl: string;
|
|
14
|
-
aspectRatio: number;
|
|
15
|
-
onUpdate: (dataUrl?: string) => void;
|
|
16
|
-
onCancel?: () => void;
|
|
17
|
-
outputWidth?: number;
|
|
18
|
-
outputHeight?: number;
|
|
19
|
-
hideDelete?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function ImageEditor(props: Props) {
|
|
23
|
-
const [photoSrc, setPhotoSrc] = useState<string>("");
|
|
24
|
-
const [croppedImageDataUrl, setCroppedImageDataUrl] = useState<string>("");
|
|
25
|
-
const cropperRef = useRef<HTMLImageElement>(null);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
let
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useState, useEffect, useRef, Suspense, lazy } from "react";
|
|
4
|
+
import { InputBox, SmallButton, Loading } from ".";
|
|
5
|
+
import { Locale } from "../helpers";
|
|
6
|
+
import "../../public/css/cropper.css";
|
|
7
|
+
|
|
8
|
+
// Lazy load the Cropper component
|
|
9
|
+
const Cropper = lazy(() => import("react-cropper").then(module => ({ default: module.default })));
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
title?: string;
|
|
13
|
+
photoUrl: string;
|
|
14
|
+
aspectRatio: number;
|
|
15
|
+
onUpdate: (dataUrl?: string) => void;
|
|
16
|
+
onCancel?: () => void;
|
|
17
|
+
outputWidth?: number;
|
|
18
|
+
outputHeight?: number;
|
|
19
|
+
hideDelete?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function ImageEditor(props: Props) {
|
|
23
|
+
const [photoSrc, setPhotoSrc] = useState<string>("");
|
|
24
|
+
const [croppedImageDataUrl, setCroppedImageDataUrl] = useState<string>("");
|
|
25
|
+
const cropperRef = useRef<HTMLImageElement>(null);
|
|
26
|
+
const timeoutRef = useRef<number | null>(null);
|
|
27
|
+
|
|
28
|
+
// Cleanup timeout on unmount
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
return () => {
|
|
31
|
+
if (timeoutRef.current !== null) {
|
|
32
|
+
window.clearTimeout(timeoutRef.current);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
const handleSave = () => {
|
|
38
|
+
props.onUpdate(croppedImageDataUrl);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const handleDelete = () => props.onUpdate("");
|
|
42
|
+
|
|
43
|
+
const handleUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
let files;
|
|
46
|
+
if (e.target) {
|
|
47
|
+
files = e.target.files;
|
|
48
|
+
}
|
|
49
|
+
if (!files || files.length === 0) return;
|
|
50
|
+
|
|
51
|
+
const reader = new FileReader();
|
|
52
|
+
reader.onload = () => {
|
|
53
|
+
const url = reader.result.toString();
|
|
54
|
+
setPhotoSrc(url);
|
|
55
|
+
setCroppedImageDataUrl("");
|
|
56
|
+
};
|
|
57
|
+
reader.readAsDataURL(files[0]);
|
|
58
|
+
|
|
59
|
+
// Clear the input value to allow re-uploading the same file
|
|
60
|
+
e.target.value = "";
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const selectDefaultCropZone = () => {
|
|
64
|
+
const imageElement: any = cropperRef?.current;
|
|
65
|
+
let cropper: any = imageElement?.cropper;
|
|
66
|
+
if (props.aspectRatio===0)
|
|
67
|
+
{
|
|
68
|
+
let containerData = cropper.getContainerData();
|
|
69
|
+
const imgWidth = cropper.getImageData().width;
|
|
70
|
+
const imgHeight = cropper.getImageData().height;
|
|
71
|
+
const effectiveWidth = (containerData.width > imgWidth) ? imgWidth : containerData.width;
|
|
72
|
+
const effectiveHeight = (containerData.height > imgHeight) ? imgHeight : containerData.height;
|
|
73
|
+
cropper.setCropBoxData({ width: effectiveWidth, height: effectiveHeight, left: (containerData.width - effectiveWidth) / 2.0 , top: (containerData.height - effectiveHeight) / 2.0 });
|
|
74
|
+
} else {
|
|
75
|
+
let desiredAspect = props.aspectRatio;
|
|
76
|
+
let containerData = cropper.getContainerData();
|
|
77
|
+
let imgAspect = cropper.getImageData().aspectRatio;
|
|
78
|
+
let scale = imgAspect / desiredAspect;
|
|
79
|
+
if (scale < 1) {
|
|
80
|
+
const imgWidth = cropper.getImageData().width;
|
|
81
|
+
let l = (containerData.width - imgWidth) / 2.0;
|
|
82
|
+
let t = (containerData.height - (containerData.height * scale)) / 2.0;
|
|
83
|
+
cropper.setCropBoxData({ width: imgWidth, height: imgWidth / desiredAspect, left: l, top: t });
|
|
84
|
+
} else {
|
|
85
|
+
const imgHeight = cropper.getImageData().height;
|
|
86
|
+
let l = (containerData.width - (imgHeight * desiredAspect)) / 2.0;
|
|
87
|
+
let t = cropper.canvasData.top;
|
|
88
|
+
cropper.setCropBoxData({ width: imgHeight * desiredAspect, height: imgHeight, left: l, top: t });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const handleCrop = () => {
|
|
95
|
+
if (timeoutRef.current !== null) {
|
|
96
|
+
window.clearTimeout(timeoutRef.current);
|
|
97
|
+
timeoutRef.current = null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
101
|
+
if (cropperRef.current !== null) {
|
|
102
|
+
const imageElement: any = cropperRef?.current;
|
|
103
|
+
const cropper: any = imageElement?.cropper;
|
|
104
|
+
|
|
105
|
+
//Do not enlarge if less
|
|
106
|
+
const imageData = cropper.getImageData();
|
|
107
|
+
let width = props.outputWidth || 400;
|
|
108
|
+
let height = props.outputHeight || 300;
|
|
109
|
+
if (imageData.naturalWidth < width && imageData.naturalHeight < height) {
|
|
110
|
+
width = imageData.naturalWidth;
|
|
111
|
+
height = imageData.naturalHeight;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const url = cropper.getCroppedCanvas({ width, height }).toDataURL("image/png", 0.4);
|
|
115
|
+
setCroppedImageDataUrl(url);
|
|
116
|
+
}
|
|
117
|
+
}, 200);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
useEffect(() => { setPhotoSrc(props.photoUrl); }, [props.photoUrl]);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<InputBox
|
|
124
|
+
id="cropperBox"
|
|
125
|
+
headerIcon=""
|
|
126
|
+
headerText={props.title}
|
|
127
|
+
ariaLabelDelete="deletePhoto"
|
|
128
|
+
saveText={Locale.label("common.update")}
|
|
129
|
+
saveFunction={handleSave}
|
|
130
|
+
cancelFunction={props.onCancel}
|
|
131
|
+
deleteFunction={(!props.hideDelete) && handleDelete}
|
|
132
|
+
headerActionContent={
|
|
133
|
+
<div>
|
|
134
|
+
<input type="file" onChange={handleUpload} id="fileUpload" accept="image/*" style={{ display: "none" }} />
|
|
135
|
+
<SmallButton
|
|
136
|
+
icon="upload"
|
|
137
|
+
text="Upload"
|
|
138
|
+
onClick={() => {
|
|
139
|
+
document.getElementById("fileUpload").click();
|
|
140
|
+
}}
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
}
|
|
144
|
+
>
|
|
145
|
+
<Suspense fallback={<Loading />}>
|
|
146
|
+
<Cropper
|
|
147
|
+
ref={cropperRef}
|
|
148
|
+
src={photoSrc}
|
|
149
|
+
key={photoSrc}
|
|
150
|
+
style={{ height: 240, width: "100%" }}
|
|
151
|
+
aspectRatio={props.aspectRatio}
|
|
152
|
+
guides={false}
|
|
153
|
+
crop={handleCrop}
|
|
154
|
+
autoCropArea={1}
|
|
155
|
+
viewMode={0}
|
|
156
|
+
responsive={true}
|
|
157
|
+
restore={false}
|
|
158
|
+
checkOrientation={false}
|
|
159
|
+
background={false}
|
|
160
|
+
ready={() => {
|
|
161
|
+
setTimeout(selectDefaultCropZone, 100);
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
</Suspense>
|
|
165
|
+
</InputBox>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
@@ -92,8 +92,8 @@ export const PageHeader: React.FC<PageHeaderProps> = ({ icon, title, subtitle, c
|
|
|
92
92
|
{/* Statistics row */}
|
|
93
93
|
{statistics && statistics.length > 0 && (
|
|
94
94
|
<Stack id="page-header-statistics" direction={{ xs: "column", sm: "row" }} spacing={3} sx={{ mt: 3 }}>
|
|
95
|
-
{statistics.map((stat
|
|
96
|
-
<Stack key={
|
|
95
|
+
{statistics.map((stat) => (
|
|
96
|
+
<Stack key={stat.label} direction="row" spacing={1} alignItems="center">
|
|
97
97
|
{React.cloneElement(stat.icon as React.ReactElement<any>, { sx: { color: "#FFF", fontSize: 20 } })}
|
|
98
98
|
<Typography variant="h6" sx={{ color: "#FFF", fontWeight: 600, mr: 1 }}>
|
|
99
99
|
{stat.value}
|
|
@@ -42,9 +42,9 @@ export const QuestionEdit = React.forwardRef<any, Props>(({noBackground = false,
|
|
|
42
42
|
let choiceOptions = [];
|
|
43
43
|
if (q.choices !== undefined && q.choices !== null) {
|
|
44
44
|
if (q.fieldType === "Multiple Choice") {
|
|
45
|
-
for (let i = 0; i < q.choices.length; i++) choiceOptions.push(<MenuItem key={i} value={q.choices[i].value}>{q.choices[i].text}</MenuItem>);
|
|
45
|
+
for (let i = 0; i < q.choices.length; i++) choiceOptions.push(<MenuItem key={q.choices[i].value} value={q.choices[i].value}>{q.choices[i].text}</MenuItem>);
|
|
46
46
|
} else if (q.fieldType === "Checkbox") {
|
|
47
|
-
for (let i = 0; i < q.choices.length; i++) choiceOptions.push(<FormControlLabel key={i} label={q.choices[i].text} control={<Checkbox onChange={handleCheck} name={q.choices[i].value} />} />);
|
|
47
|
+
for (let i = 0; i < q.choices.length; i++) choiceOptions.push(<FormControlLabel key={q.choices[i].value} label={q.choices[i].text} control={<Checkbox onChange={handleCheck} name={q.choices[i].value} />} />);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -22,7 +22,7 @@ export const SmallButton = React.forwardRef<HTMLDivElement, Props>((props, ref)
|
|
|
22
22
|
const handleClick = (e: React.MouseEvent) => {
|
|
23
23
|
e.preventDefault();
|
|
24
24
|
if (props.href) setRedirectUrl(props.href);
|
|
25
|
-
else props.onClick(e);
|
|
25
|
+
else if (props.onClick) props.onClick(e);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const style = (props.text)
|