@churchapps/apphelper 0.4.29 → 0.4.31

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ImageEditor.d.ts","sourceRoot":"","sources":["../../src/components/ImageEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,8BAA8B,CAAC;AAKtC,UAAU,KAAK;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,2CAsIvC"}
1
+ {"version":3,"file":"ImageEditor.d.ts","sourceRoot":"","sources":["../../src/components/ImageEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,8BAA8B,CAAC;AAKtC,UAAU,KAAK;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,2CA2IvC"}
@@ -11,7 +11,10 @@ export function ImageEditor(props) {
11
11
  const [croppedImageDataUrl, setCroppedImageDataUrl] = useState("");
12
12
  const cropperRef = useRef(null);
13
13
  let timeout = null;
14
- const handleSave = () => props.onUpdate(croppedImageDataUrl);
14
+ const handleSave = () => {
15
+ console.log('ImageEditor handleSave called, croppedImageDataUrl:', croppedImageDataUrl ? 'Data URL available' : 'No data URL');
16
+ props.onUpdate(croppedImageDataUrl);
17
+ };
15
18
  const handleDelete = () => props.onUpdate("");
16
19
  const handleUpload = (e) => {
17
20
  e.preventDefault();
@@ -24,6 +27,7 @@ export function ImageEditor(props) {
24
27
  const reader = new FileReader();
25
28
  reader.onload = () => {
26
29
  const url = reader.result.toString();
30
+ console.log('ImageEditor file uploaded, setting photoSrc');
27
31
  setPhotoSrc(url);
28
32
  setCroppedImageDataUrl("");
29
33
  };
@@ -79,6 +83,7 @@ export function ImageEditor(props) {
79
83
  height = imageData.naturalHeight;
80
84
  }
81
85
  const url = cropper.getCroppedCanvas({ width, height }).toDataURL("image/png", 0.4);
86
+ console.log('ImageEditor handleCrop setting croppedImageDataUrl');
82
87
  setCroppedImageDataUrl(url);
83
88
  }
84
89
  }, 200);
@@ -86,7 +91,7 @@ export function ImageEditor(props) {
86
91
  useEffect(() => { setPhotoSrc(props.photoUrl); }, [props.photoUrl]);
87
92
  return (_jsx(InputBox, { id: "cropperBox", headerIcon: "", headerText: props.title, ariaLabelDelete: "deletePhoto", saveText: Locale.label("common.update"), saveFunction: handleSave, cancelFunction: props.onCancel, deleteFunction: (!props.hideDelete) && handleDelete, headerActionContent: _jsxs("div", { children: [_jsx("input", { type: "file", onChange: handleUpload, id: "fileUpload", accept: "image/*", style: { display: "none" } }), _jsx(SmallButton, { icon: "upload", text: "Upload", onClick: () => {
88
93
  document.getElementById("fileUpload").click();
89
- } })] }), children: _jsx(Suspense, { fallback: _jsx(Loading, {}), children: _jsx(Cropper, { ref: cropperRef, src: photoSrc, style: { height: 240, width: "100%" }, aspectRatio: props.aspectRatio, guides: false, crop: handleCrop, autoCropArea: 1, viewMode: 1, responsive: true, restore: false, checkOrientation: false, background: false, ready: () => {
94
+ } })] }), children: _jsx(Suspense, { fallback: _jsx(Loading, {}), children: _jsx(Cropper, { ref: cropperRef, src: photoSrc, style: { height: 240, width: "100%" }, aspectRatio: props.aspectRatio, guides: false, crop: handleCrop, autoCropArea: 1, viewMode: 0, responsive: true, restore: false, checkOrientation: false, background: false, ready: () => {
90
95
  setTimeout(selectDefaultCropZone, 100);
91
96
  } }, photoSrc) }) }));
92
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ImageEditor.js","sourceRoot":"","sources":["../../src/components/ImageEditor.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,8BAA8B,CAAC;AAEtC,kCAAkC;AAClC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAalG,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAClD,IAAI,OAAO,GAAkB,IAAI,CAAC;IAElC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IAE7D,MAAM,YAAY,GAAG,GAAG,EAAE,C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ACD,IACE,YAGR,KAAC,QAAQ,IAAC,QAAQ,EAAE,KAAC,OAAO,KAAG,YAC7B,KAAC,OAAO,IACN,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,QAAQ,EAEb,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EACrC,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,MAAM,EAAE,KAAK,EACb,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,CAAC,EACf,QAAQ,EAAE,CAAC,EACX,UAAU,EAAE,IAAI,EAChB,OAAO,EAAE,KAAK,EACd,gBAAgB,EAAE,KAAK,EACvB,UAAU,EAAE,KAAK,EACjB,KAAK,EAAE,GAAG,EAAE;oBACV,UAAU,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;gBACzC,CAAC,IAbI,QAAQ,CAcb,GACO,GACF,CACZ,CAAC;AACJ,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- interface Props {
2
+ interface TabPanelProps {
3
3
  children?: React.ReactNode;
4
4
  index: number;
5
5
  value: number;
6
6
  }
7
- export declare const TabPanel: React.FC<Props>;
7
+ export declare function TabPanel(props: TabPanelProps): import("react/jsx-runtime").JSX.Element;
8
8
  export {};
9
9
  //# sourceMappingURL=TabPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TabPanel.d.ts","sourceRoot":"","sources":["../../src/components/TabPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,UAAU,KAAK;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAwBpC,CAAA"}
1
+ {"version":3,"file":"TabPanel.d.ts","sourceRoot":"","sources":["../../src/components/TabPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAkB5C"}
@@ -1,17 +1,7 @@
1
- "use client";
2
1
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Box, styled } from "@mui/material";
4
- export const TabPanel = (props) => {
5
- const { children, value, index } = props;
6
- const StyledMenuBox = styled(Box)(({ theme }) => ({
7
- paddingTop: 10,
8
- "& .MuiListItemButton-root": { paddingLeft: 30 },
9
- "& .MuiListItemIcon-root": {
10
- color: theme.palette.primary.main
11
- },
12
- "& .MuiListItemText-root": { color: theme.palette.text.primary },
13
- "& .selected .MuiListItemText-root span": { fontWeight: "bold" }
14
- }));
15
- return (_jsx("div", { role: "tabpanel", hidden: value !== index, id: `userMenuPanel-${index}`, children: value === index && (_jsx(StyledMenuBox, { children: _jsx(Box, { children: children }) })) }));
16
- };
2
+ import { Box } from "@mui/material";
3
+ export function TabPanel(props) {
4
+ const { children, value, index, ...other } = props;
5
+ return (_jsx("div", { role: "tabpanel", hidden: value !== index, id: `simple-tabpanel-${index}`, "aria-labelledby": `simple-tab-${index}`, ...other, children: value === index && (_jsx(Box, { sx: { p: 3 }, children: children })) }));
6
+ }
17
7
  //# sourceMappingURL=TabPanel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TabPanel.js","sourceRoot":"","sources":["../../src/components/TabPanel.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAS5C,MAAM,CAAC,MAAM,QAAQ,GAAoB,CAAC,KAAY,EAAE,EAAE;IAExD,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,KAAK,C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,0 +1,9 @@
1
+ import React from "react";
2
+ interface Props {
3
+ aspectRatio: number;
4
+ onClose: () => void;
5
+ onSelect: (img: string) => void;
6
+ }
7
+ export declare const GalleryModal: React.FC<Props>;
8
+ export {};
9
+ //# sourceMappingURL=GalleryModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GalleryModal.d.ts","sourceRoot":"","sources":["../../../src/components/gallery/GalleryModal.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC,UAAU,KAAK;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2JxC,CAAC"}
@@ -0,0 +1,100 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { FileHelper } from "../../helpers/FileHelper";
4
+ import { ApiHelper } from "../../helpers";
5
+ import { Locale } from "../../helpers";
6
+ import { CommonEnvironmentHelper } from "@churchapps/helpers";
7
+ import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, Grid, IconButton, InputLabel, MenuItem, Select, Tab, Tabs, Tooltip, Icon } from "@mui/material";
8
+ import React, { useState } from "react";
9
+ import { ImageEditor } from "../ImageEditor";
10
+ import { TabPanel } from "../TabPanel";
11
+ import { StockPhotos } from "./StockPhotos";
12
+ export const GalleryModal = (props) => {
13
+ const [images, setImages] = useState([]);
14
+ const [tabIndex, setTabIndex] = React.useState(0);
15
+ const [aspectRatio, setAspectRatio] = React.useState(Math.round(props.aspectRatio * 100) / 100);
16
+ const [editorPhotoUrl, setEditorPhotoUrl] = React.useState("");
17
+ const contentRoot = CommonEnvironmentHelper.ContentRoot;
18
+ const handleTabChange = (el, newValue) => { setTabIndex(newValue); };
19
+ const loadData = () => { ApiHelper.get("/gallery/" + aspectRatio.toString(), "ContentApi").then((data) => setImages(data.images)); };
20
+ const handleImageUpdated = async (dataUrl) => {
21
+ console.log('handleImageUpdated called with dataUrl:', dataUrl ? 'Data URL received' : 'Empty dataUrl');
22
+ if (!dataUrl) {
23
+ console.warn('No dataUrl provided to handleImageUpdated');
24
+ return;
25
+ }
26
+ try {
27
+ const fileName = Math.floor(Date.now() / 1000).toString() + ".jpg";
28
+ const blob = FileHelper.dataURLtoBlob(dataUrl);
29
+ const file = new File([blob], "file_name");
30
+ const params = { folder: aspectRatio.toString(), fileName };
31
+ console.log('Attempting to upload image with params:', params);
32
+ const presigned = await ApiHelper.post("/gallery/requestUpload", params, "ContentApi");
33
+ const doUpload = presigned.key !== undefined;
34
+ if (doUpload) {
35
+ console.log('Upload successful, uploading to presigned URL');
36
+ await FileHelper.postPresignedFile(presigned, file, () => { });
37
+ console.log('Image uploaded successfully');
38
+ }
39
+ else {
40
+ console.warn('Upload failed - no presigned key received');
41
+ }
42
+ setTabIndex(0);
43
+ loadData();
44
+ }
45
+ catch (error) {
46
+ console.error('Error in handleImageUpdated:', error);
47
+ // In case of API failure, still provide feedback to user
48
+ alert('Image processing completed, but upload failed. API may not be available in this environment.');
49
+ }
50
+ };
51
+ const handleDelete = (folder, image) => {
52
+ if (window.confirm(Locale.label("gallery.confirmDelete"))) {
53
+ ApiHelper.delete("/gallery/" + folder + "/" + image, "ContentApi").then(() => { loadData(); });
54
+ }
55
+ };
56
+ React.useEffect(() => { if (aspectRatio !== props.aspectRatio)
57
+ setAspectRatio(Math.round(props.aspectRatio * 100) / 100); }, [props.aspectRatio]); //eslint-disable-line
58
+ React.useEffect(loadData, [aspectRatio]); //eslint-disable-line
59
+ const getImages = () => {
60
+ let result = [];
61
+ images.forEach((img) => {
62
+ const parts = img.split("/");
63
+ result.push(_jsx(Grid, { size: { xs: 12, md: 4 }, children: _jsxs(Box, { sx: { position: "relative", ":hover #deleteIcon": { visibility: "visible" } }, children: [_jsx("a", { href: "about:blank", onClick: (e) => { e.preventDefault(); props.onSelect(contentRoot + "/" + img); }, "aria-label": "Select image", "data-testid": "select-image", children: _jsx(Box, { component: "img", src: contentRoot + "/" + img, alt: "custom", sx: {
64
+ width: '100%',
65
+ height: 'auto',
66
+ maxWidth: '100%',
67
+ display: 'block'
68
+ } }) }), _jsx(Box, { id: "deleteIcon", sx: { position: "absolute", top: 3, right: 3, visibility: "hidden", backgroundColor: "whitesmoke", borderRadius: 5 }, children: _jsx(Tooltip, { title: "Delete", children: _jsx(IconButton, { size: "small", color: "error", onClick: () => handleDelete(parts[2], parts[3]), "aria-label": "Delete image", "data-testid": "delete-image", children: _jsx(Icon, { sx: { fontSize: "17px !important" }, children: "delete_outline" }) }) }) })] }) }));
69
+ });
70
+ return result;
71
+ };
72
+ const handleStockSelect = (url) => {
73
+ setEditorPhotoUrl(url);
74
+ setTabIndex(1);
75
+ };
76
+ const getDisplayAspect = () => {
77
+ let result = aspectRatio.toString();
78
+ if (aspectRatio === 0)
79
+ result = "Free Form";
80
+ else if (aspectRatio === 1)
81
+ result = "1:1";
82
+ else if (aspectRatio === 2)
83
+ result = "2:1";
84
+ else if (aspectRatio === 3)
85
+ result = "3:1";
86
+ else if (aspectRatio === 4)
87
+ result = "4:1";
88
+ else if (aspectRatio === 1.33)
89
+ result = "4:3";
90
+ else if (aspectRatio === 1.78)
91
+ result = "16:9";
92
+ else if (aspectRatio === 0.5)
93
+ result = "1:2";
94
+ else if (aspectRatio === 0.5625)
95
+ result = "9:16";
96
+ return result;
97
+ };
98
+ return (_jsx(_Fragment, { children: _jsxs(Dialog, { open: true, onClose: props.onClose, children: [_jsx(DialogTitle, { children: "Select a Photo" }), _jsxs(DialogContent, { style: { overflowX: "hidden" }, children: [(props.aspectRatio === 0) && (_jsxs(FormControl, { fullWidth: true, children: [_jsx(InputLabel, { children: Locale.label("gallery.aspectRatio") }), _jsxs(Select, { size: "small", label: Locale.label("gallery.aspectRatio"), name: "aspectRatio", value: aspectRatio, onChange: (e) => setAspectRatio(parseFloat(e.target.value.toString())), children: [_jsx(MenuItem, { value: "0", children: Locale.label("gallery.freeForm") }), _jsx(MenuItem, { value: "1", children: "1:1" }), _jsx(MenuItem, { value: "2", children: "2:1" }), _jsx(MenuItem, { value: "3", children: "3:1" }), _jsx(MenuItem, { value: "4", children: "4:1" }), _jsx(MenuItem, { value: "1.33", children: "4:3" }), _jsx(MenuItem, { value: "1.78", children: "16:9" }), _jsx(MenuItem, { value: "0.5", children: "1:2" }), _jsx(MenuItem, { value: "0.5625", children: "9:16" })] })] })), _jsxs(Tabs, { variant: "fullWidth", value: tabIndex, onChange: handleTabChange, children: [_jsx(Tab, { label: "Gallery" }), _jsx(Tab, { label: "Upload" }), _jsx(Tab, { label: "Stock Photos" })] }), _jsx(TabPanel, { value: tabIndex, index: 0, children: _jsx(Grid, { container: true, spacing: 3, alignItems: "center", children: getImages() }) }), _jsxs(TabPanel, { value: tabIndex, index: 1, children: [_jsxs("div", { children: [Locale.label("gallery.aspectRatio"), ": ", getDisplayAspect()] }), _jsx(ImageEditor, { onUpdate: handleImageUpdated, photoUrl: editorPhotoUrl, aspectRatio: aspectRatio, outputWidth: 1280, outputHeight: 768, hideDelete: true })] }), _jsx(TabPanel, { value: tabIndex, index: 2, children: _jsx(StockPhotos, { aspectRatio: aspectRatio, onSelect: props.onSelect, onStockSelect: handleStockSelect }) })] }), _jsx(DialogActions, { sx: { paddingX: "16px", paddingBottom: "12px" }, children: _jsx(Button, { variant: "outlined", onClick: props.onClose, children: "Close" }) })] }) }));
99
+ };
100
+ //# sourceMappingURL=GalleryModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GalleryModal.js","sourceRoot":"","sources":["../../../src/components/gallery/GalleryModal.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC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Q,EAAE,KAAK,EAAE,CAAC,YAEjC,KAAC,IAAI,IAAC,SAAS,QAAC,OAAO,EAAE,CAAC,EAAE,UAAU,EAAC,QAAQ,YAC5C,SAAS,EAAE,GACP,GACE,EACX,MAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,aACjC,0BAAM,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,QAAI,gBAAgB,EAAE,IAAO,EACtE,KAAC,WAAW,IAAC,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,GAAI,IAChJ,EACX,KAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,YACjC,KAAC,WAAW,IAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,aAAa,EAAE,iBAAiB,GAAI,GAC5F,IACG,EAChB,KAAC,aAAa,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAC5D,KAAC,MAAM,IAAC,OAAO,EAAC,UAAU,EAAC,OAAO,EAAE,KAAK,CAAC,OAAO,sBAAgB,GACnD,IACT,GACR,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface Props {
3
+ aspectRatio: number;
4
+ onSelect: (img: string) => void;
5
+ onStockSelect: (img: string) => void;
6
+ }
7
+ export declare const StockPhotos: React.FC<Props>;
8
+ export {};
9
+ //# sourceMappingURL=StockPhotos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StockPhotos.d.ts","sourceRoot":"","sources":["../../../src/components/gallery/StockPhotos.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC,UAAU,KAAK;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACrC;AAID,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAgFvC,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { Button, Grid, TextField } from "@mui/material";
4
+ import React, { useState } from "react";
5
+ import { ApiHelper } from "../../helpers";
6
+ import { Locale } from "../../helpers";
7
+ import { CommonEnvironmentHelper } from "@churchapps/helpers";
8
+ export const StockPhotos = (props) => {
9
+ const [images, setImages] = useState([]);
10
+ const [searchText, setSearchText] = useState("");
11
+ const [searchResults, setSearchResults] = useState(null);
12
+ const contentRoot = CommonEnvironmentHelper.ContentRoot;
13
+ const loadData = () => { ApiHelper.getAnonymous("/gallery/stock/" + props.aspectRatio.toString(), "ContentApi").then((data) => setImages(data.images)); };
14
+ React.useEffect(loadData, [props.aspectRatio]); //eslint-disable-line
15
+ const handleChange = (e) => { e.preventDefault(); setSearchText(e.currentTarget.value); };
16
+ const handleSearch = (e) => {
17
+ if (e !== null)
18
+ e.preventDefault();
19
+ let term = searchText.trim();
20
+ ApiHelper.post("/stock/search", { term: term }, "ContentApi").then((data) => { setSearchResults(data); });
21
+ };
22
+ const getImages = () => {
23
+ if (searchResults)
24
+ return getResults();
25
+ else
26
+ return getSuggested();
27
+ };
28
+ const getResults = () => {
29
+ let result = [];
30
+ searchResults.forEach((p) => {
31
+ result.push(_jsxs(Grid, { size: { xs: 12, md: 4 }, children: [_jsx("a", { href: "about:blank", onClick: (e) => { e.preventDefault(); props.onStockSelect(p.large); }, children: _jsx("img", { src: p.thumbnail, alt: "stock", style: {
32
+ width: '100%',
33
+ height: 'auto',
34
+ maxWidth: '100%',
35
+ display: 'block'
36
+ } }) }), _jsx("div", { children: _jsxs("i", { style: { fontSize: 12 }, children: [_jsx("a", { href: p.url, target: "_blank", rel: "noreferrer noopener", children: Locale.label("stockPhotos.photoBy") }), " ", _jsx("a", { href: p.photographerUrl, target: "_blank", rel: "noreferrer noopener", children: p.photographer })] }) })] }));
37
+ });
38
+ return result;
39
+ };
40
+ const getSuggested = () => {
41
+ let result = [];
42
+ images.forEach((img) => {
43
+ result.push(_jsx(Grid, { size: { xs: 12, md: 4 }, children: _jsx("a", { href: "about:blank", onClick: (e) => { e.preventDefault(); props.onSelect(contentRoot + "/" + img); }, children: _jsx("img", { src: contentRoot + "/" + img, alt: "stock", style: {
44
+ width: '100%',
45
+ height: 'auto',
46
+ maxWidth: '100%',
47
+ display: 'block'
48
+ } }) }) }));
49
+ });
50
+ return result;
51
+ };
52
+ return (_jsxs(_Fragment, { children: [_jsx(TextField, { fullWidth: true, name: "personAddText", label: "Search Term", value: searchText, onChange: handleChange, InputProps: { endAdornment: _jsx(Button, { variant: "contained", id: "searchButton", "data-testid": "search-button", onClick: handleSearch, children: "Search" }) } }), searchResults && _jsxs("div", { children: [Locale.label("stockPhotos.providedBy"), " ", _jsx("a", { href: "https://pexels.com", children: "Pexels" }), "."] }), _jsx(Grid, { container: true, spacing: 3, alignItems: "center", children: getImages() })] }));
53
+ };
54
+ //# sourceMappingURL=StockPhotos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StockPhotos.js","sourceRoot":"","sources":["../../../src/components/gallery/StockPhotos.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,uBAA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,EAAE,GACP,IAEN,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./GalleryModal";
2
+ export * from "./StockPhotos";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/gallery/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./GalleryModal";
2
+ export * from "./StockPhotos";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/gallery/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
@@ -13,7 +13,9 @@ export { PersonAvatar } from "./PersonAvatar";
13
13
  export { QuestionEdit } from "./QuestionEdit";
14
14
  export { SmallButton } from "./SmallButton";
15
15
  export { SupportModal } from "./SupportModal";
16
+ export { TabPanel } from "./TabPanel";
16
17
  export * from "./wrapper";
17
18
  export * from "./notes";
18
19
  export * from "./header";
20
+ export * from "./gallery";
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","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,E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AAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -13,7 +13,9 @@ export { PersonAvatar } from "./PersonAvatar";
13
13
  export { QuestionEdit } from "./QuestionEdit";
14
14
  export { SmallButton } from "./SmallButton";
15
15
  export { SupportModal } from "./SupportModal";
16
+ export { TabPanel } from "./TabPanel";
16
17
  export * from "./wrapper";
17
18
  export * from "./notes";
18
19
  export * from "./header";
20
+ export * from "./gallery";
19
21
  //# sourceMappingURL=index.js.map
@@ -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,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
+ {"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,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchapps/apphelper",
3
- "version": "0.4.29",
3
+ "version": "0.4.31",
4
4
  "description": "Library of helper functions for React and NextJS ChurchApps",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -25,7 +25,10 @@ export function ImageEditor(props: Props) {
25
25
  const cropperRef = useRef<HTMLImageElement>(null);
26
26
  let timeout: number | null = null;
27
27
 
28
- const handleSave = () => props.onUpdate(croppedImageDataUrl);
28
+ const handleSave = () => {
29
+ console.log('ImageEditor handleSave called, croppedImageDataUrl:', croppedImageDataUrl ? 'Data URL available' : 'No data URL');
30
+ props.onUpdate(croppedImageDataUrl);
31
+ };
29
32
 
30
33
  const handleDelete = () => props.onUpdate("");
31
34
 
@@ -40,6 +43,7 @@ export function ImageEditor(props: Props) {
40
43
  const reader = new FileReader();
41
44
  reader.onload = () => {
42
45
  const url = reader.result.toString();
46
+ console.log('ImageEditor file uploaded, setting photoSrc');
43
47
  setPhotoSrc(url);
44
48
  setCroppedImageDataUrl("");
45
49
  };
@@ -101,6 +105,7 @@ export function ImageEditor(props: Props) {
101
105
  }
102
106
 
103
107
  const url = cropper.getCroppedCanvas({ width, height }).toDataURL("image/png", 0.4);
108
+ console.log('ImageEditor handleCrop setting croppedImageDataUrl');
104
109
  setCroppedImageDataUrl(url);
105
110
  }
106
111
  }, 200);
@@ -141,7 +146,7 @@ export function ImageEditor(props: Props) {
141
146
  guides={false}
142
147
  crop={handleCrop}
143
148
  autoCropArea={1}
144
- viewMode={1}
149
+ viewMode={0}
145
150
  responsive={true}
146
151
  restore={false}
147
152
  checkOrientation={false}
@@ -1,35 +1,27 @@
1
- "use client";
1
+ import React from "react";
2
+ import { Box } from "@mui/material";
2
3
 
3
- import { Box, styled } from "@mui/material";
4
- import React from "react"
5
-
6
- interface Props {
4
+ interface TabPanelProps {
7
5
  children?: React.ReactNode;
8
6
  index: number;
9
7
  value: number;
10
8
  }
11
9
 
12
- export const TabPanel: React.FC<Props> = (props: Props) => {
13
-
14
- const { children, value, index } = props;
15
- const StyledMenuBox = styled(Box)(
16
- ({ theme }) => ({
17
- paddingTop: 10,
18
- "& .MuiListItemButton-root": { paddingLeft: 30 },
19
- "& .MuiListItemIcon-root": {
20
- color: theme.palette.primary.main
21
- },
22
- "& .MuiListItemText-root": { color: theme.palette.text.primary },
23
- "& .selected .MuiListItemText-root span": { fontWeight: "bold" }
24
- })
25
- );
10
+ export function TabPanel(props: TabPanelProps) {
11
+ const { children, value, index, ...other } = props;
26
12
 
27
13
  return (
28
- <div role="tabpanel" hidden={value !== index} id={`userMenuPanel-${index}`}>
14
+ <div
15
+ role="tabpanel"
16
+ hidden={value !== index}
17
+ id={`simple-tabpanel-${index}`}
18
+ aria-labelledby={`simple-tab-${index}`}
19
+ {...other}
20
+ >
29
21
  {value === index && (
30
- <StyledMenuBox>
31
- <Box>{children}</Box>
32
- </StyledMenuBox>
22
+ <Box sx={{ p: 3 }}>
23
+ {children}
24
+ </Box>
33
25
  )}
34
26
  </div>
35
27
  );
@@ -0,0 +1,174 @@
1
+ "use client";
2
+
3
+ import { FileHelper } from "../../helpers/FileHelper";
4
+ import { ApiHelper } from "../../helpers";
5
+ import { Locale } from "../../helpers";
6
+ import { CommonEnvironmentHelper } from "@churchapps/helpers";
7
+ import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, Grid, IconButton, InputLabel, MenuItem, Select, Tab, Tabs, Tooltip, Icon } from "@mui/material";
8
+ import React, { useState } from "react";
9
+ import { ImageEditor } from "../ImageEditor";
10
+ import { TabPanel } from "../TabPanel";
11
+ import { StockPhotos } from "./StockPhotos";
12
+
13
+ interface Props {
14
+ aspectRatio: number,
15
+ onClose: () => void,
16
+ onSelect: (img: string) => void
17
+ }
18
+
19
+ export const GalleryModal: React.FC<Props> = (props: Props) => {
20
+ const [images, setImages] = useState<string[]>([]);
21
+ const [tabIndex, setTabIndex] = React.useState(0);
22
+ const [aspectRatio, setAspectRatio] = React.useState(Math.round(props.aspectRatio * 100) / 100);
23
+ const [editorPhotoUrl, setEditorPhotoUrl] = React.useState("");
24
+
25
+ const contentRoot = CommonEnvironmentHelper.ContentRoot;
26
+
27
+ const handleTabChange = (el: any, newValue: any) => { setTabIndex(newValue); }
28
+
29
+ const loadData = () => { ApiHelper.get("/gallery/" + aspectRatio.toString(), "ContentApi").then((data: any) => setImages(data.images)); }
30
+
31
+ const handleImageUpdated = async (dataUrl: string) => {
32
+ console.log('handleImageUpdated called with dataUrl:', dataUrl ? 'Data URL received' : 'Empty dataUrl');
33
+
34
+ if (!dataUrl) {
35
+ console.warn('No dataUrl provided to handleImageUpdated');
36
+ return;
37
+ }
38
+
39
+ try {
40
+ const fileName = Math.floor(Date.now() / 1000).toString() + ".jpg"
41
+ const blob = FileHelper.dataURLtoBlob(dataUrl);
42
+ const file = new File([blob], "file_name");
43
+
44
+ const params = { folder: aspectRatio.toString(), fileName };
45
+ console.log('Attempting to upload image with params:', params);
46
+
47
+ const presigned = await ApiHelper.post("/gallery/requestUpload", params, "ContentApi");
48
+ const doUpload = presigned.key !== undefined;
49
+
50
+ if (doUpload) {
51
+ console.log('Upload successful, uploading to presigned URL');
52
+ await FileHelper.postPresignedFile(presigned, file, () => { });
53
+ console.log('Image uploaded successfully');
54
+ } else {
55
+ console.warn('Upload failed - no presigned key received');
56
+ }
57
+
58
+ setTabIndex(0);
59
+ loadData();
60
+ } catch (error) {
61
+ console.error('Error in handleImageUpdated:', error);
62
+ // In case of API failure, still provide feedback to user
63
+ alert('Image processing completed, but upload failed. API may not be available in this environment.');
64
+ }
65
+ };
66
+
67
+ const handleDelete = (folder: string, image: string) => {
68
+ if (window.confirm(Locale.label("gallery.confirmDelete"))) {
69
+ ApiHelper.delete("/gallery/" + folder + "/" + image, "ContentApi").then(() => { loadData(); });
70
+ }
71
+ }
72
+
73
+ React.useEffect(() => { if (aspectRatio !== props.aspectRatio) setAspectRatio(Math.round(props.aspectRatio * 100) / 100) }, [props.aspectRatio]); //eslint-disable-line
74
+ React.useEffect(loadData, [aspectRatio]); //eslint-disable-line
75
+
76
+ const getImages = () => {
77
+ let result: React.ReactElement[] = [];
78
+ images.forEach((img: any) => {
79
+ const parts = img.split("/");
80
+
81
+ result.push(<Grid size={{ xs: 12, md: 4 }}>
82
+ <Box sx={{ position: "relative", ":hover #deleteIcon": { visibility: "visible" } }}>
83
+ <a href="about:blank" onClick={(e) => { e.preventDefault(); props.onSelect(contentRoot + "/" + img) }} aria-label="Select image" data-testid="select-image">
84
+ <Box
85
+ component="img"
86
+ src={contentRoot + "/" + img}
87
+ alt="custom"
88
+ sx={{
89
+ width: '100%',
90
+ height: 'auto',
91
+ maxWidth: '100%',
92
+ display: 'block'
93
+ }}
94
+ />
95
+ </a>
96
+ <Box id="deleteIcon" sx={{ position: "absolute", top: 3, right: 3, visibility: "hidden", backgroundColor: "whitesmoke", borderRadius: 5 }}>
97
+ <Tooltip title="Delete">
98
+ <IconButton size="small" color="error" onClick={() => handleDelete(parts[2], parts[3])} aria-label="Delete image" data-testid="delete-image">
99
+ <Icon sx={{ fontSize: "17px !important" }}>delete_outline</Icon>
100
+ </IconButton>
101
+ </Tooltip>
102
+ </Box>
103
+ </Box>
104
+ </Grid>);
105
+ })
106
+ return result;
107
+ }
108
+
109
+ const handleStockSelect = (url: string) => {
110
+ setEditorPhotoUrl(url);
111
+ setTabIndex(1);
112
+ }
113
+
114
+ const getDisplayAspect = () => {
115
+ let result = aspectRatio.toString();
116
+ if (aspectRatio === 0) result = "Free Form";
117
+ else if (aspectRatio === 1) result = "1:1";
118
+ else if (aspectRatio === 2) result = "2:1";
119
+ else if (aspectRatio === 3) result = "3:1";
120
+ else if (aspectRatio === 4) result = "4:1";
121
+ else if (aspectRatio === 1.33) result = "4:3";
122
+ else if (aspectRatio === 1.78) result = "16:9";
123
+ else if (aspectRatio === 0.5) result = "1:2";
124
+ else if (aspectRatio === 0.5625) result = "9:16";
125
+ return result;
126
+ }
127
+
128
+ return (<>
129
+ <Dialog open={true} onClose={props.onClose}>
130
+ <DialogTitle>Select a Photo</DialogTitle>
131
+ <DialogContent style={{ overflowX: "hidden" }}>
132
+
133
+ {(props.aspectRatio === 0) && (
134
+ <FormControl fullWidth>
135
+ <InputLabel>{Locale.label("gallery.aspectRatio")}</InputLabel>
136
+ <Select size="small" label={Locale.label("gallery.aspectRatio")} name="aspectRatio" value={aspectRatio} onChange={(e) => setAspectRatio(parseFloat(e.target.value.toString()))}>
137
+ <MenuItem value="0">{Locale.label("gallery.freeForm")}</MenuItem>
138
+ <MenuItem value="1">1:1</MenuItem>
139
+ <MenuItem value="2">2:1</MenuItem>
140
+ <MenuItem value="3">3:1</MenuItem>
141
+ <MenuItem value="4">4:1</MenuItem>
142
+ <MenuItem value="1.33">4:3</MenuItem>
143
+ <MenuItem value="1.78">16:9</MenuItem>
144
+ <MenuItem value="0.5">1:2</MenuItem>
145
+ <MenuItem value="0.5625">9:16</MenuItem>
146
+ </Select>
147
+ </FormControl>
148
+ )}
149
+
150
+ <Tabs variant="fullWidth" value={tabIndex} onChange={handleTabChange}>
151
+ <Tab label="Gallery" />
152
+ <Tab label="Upload" />
153
+ <Tab label="Stock Photos" />
154
+ </Tabs>
155
+ <TabPanel value={tabIndex} index={0}>
156
+
157
+ <Grid container spacing={3} alignItems="center">
158
+ {getImages()}
159
+ </Grid>
160
+ </TabPanel>
161
+ <TabPanel value={tabIndex} index={1}>
162
+ <div>{Locale.label("gallery.aspectRatio")}: {getDisplayAspect()}</div>
163
+ <ImageEditor onUpdate={handleImageUpdated} photoUrl={editorPhotoUrl} aspectRatio={aspectRatio} outputWidth={1280} outputHeight={768} hideDelete={true} />
164
+ </TabPanel>
165
+ <TabPanel value={tabIndex} index={2}>
166
+ <StockPhotos aspectRatio={aspectRatio} onSelect={props.onSelect} onStockSelect={handleStockSelect} />
167
+ </TabPanel>
168
+ </DialogContent>
169
+ <DialogActions sx={{ paddingX: "16px", paddingBottom: "12px" }}>
170
+ <Button variant="outlined" onClick={props.onClose}>Close</Button>
171
+ </DialogActions>
172
+ </Dialog>
173
+ </>);
174
+ };
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import { Button, Grid, TextField } from "@mui/material";
3
+ import React, { useState } from "react";
4
+ import { ApiHelper } from "../../helpers";
5
+ import { Locale } from "../../helpers";
6
+ import { CommonEnvironmentHelper } from "@churchapps/helpers";
7
+
8
+ interface Props {
9
+ aspectRatio: number,
10
+ onSelect: (img: string) => void,
11
+ onStockSelect: (img: string) => void
12
+ }
13
+
14
+ interface SearchResult { description: string, url: string, photographer: string, photographerUrl: string, large: string, thumbnail: string }
15
+
16
+ export const StockPhotos: React.FC<Props> = (props: Props) => {
17
+ const [images, setImages] = useState<string[]>([]);
18
+ const [searchText, setSearchText] = useState("");
19
+ const [searchResults, setSearchResults] = useState<SearchResult[]>(null);
20
+
21
+ const contentRoot = CommonEnvironmentHelper.ContentRoot;
22
+
23
+ const loadData = () => { ApiHelper.getAnonymous("/gallery/stock/" + props.aspectRatio.toString(), "ContentApi").then((data: any) => setImages(data.images)); }
24
+
25
+ React.useEffect(loadData, [props.aspectRatio]); //eslint-disable-line
26
+
27
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { e.preventDefault(); setSearchText(e.currentTarget.value); }
28
+
29
+ const handleSearch = (e: React.MouseEvent) => {
30
+ if (e !== null) e.preventDefault();
31
+ let term = searchText.trim();
32
+ ApiHelper.post("/stock/search", { term: term }, "ContentApi").then((data: SearchResult[]) => { setSearchResults(data) });
33
+ }
34
+
35
+ const getImages = () => {
36
+ if (searchResults) return getResults();
37
+ else return getSuggested();
38
+ }
39
+
40
+ const getResults = () => {
41
+ let result: React.ReactElement[] = [];
42
+ searchResults.forEach((p: any) => {
43
+ result.push(<Grid size={{ xs: 12, md: 4 }}>
44
+ <a href="about:blank" onClick={(e) => { e.preventDefault(); props.onStockSelect(p.large) }}>
45
+ <img
46
+ src={p.thumbnail}
47
+ alt="stock"
48
+ style={{
49
+ width: '100%',
50
+ height: 'auto',
51
+ maxWidth: '100%',
52
+ display: 'block'
53
+ }}
54
+ />
55
+ </a>
56
+ <div>
57
+ <i style={{ fontSize: 12 }}>
58
+ <a href={p.url} target="_blank" rel="noreferrer noopener">{Locale.label("stockPhotos.photoBy")}</a> <a href={p.photographerUrl} target="_blank" rel="noreferrer noopener">{p.photographer}</a></i>
59
+ </div>
60
+ </Grid>);
61
+ })
62
+ return result;
63
+ }
64
+
65
+ const getSuggested = () => {
66
+ let result: React.ReactElement[] = [];
67
+ images.forEach((img: any) => {
68
+ result.push(<Grid size={{ xs: 12, md: 4 }}>
69
+ <a href="about:blank" onClick={(e) => { e.preventDefault(); props.onSelect(contentRoot + "/" + img) }}>
70
+ <img
71
+ src={contentRoot + "/" + img}
72
+ alt="stock"
73
+ style={{
74
+ width: '100%',
75
+ height: 'auto',
76
+ maxWidth: '100%',
77
+ display: 'block'
78
+ }}
79
+ />
80
+ </a>
81
+ </Grid>);
82
+ })
83
+ return result;
84
+ }
85
+
86
+ return (<>
87
+ <TextField fullWidth name="personAddText" label="Search Term" value={searchText} onChange={handleChange}
88
+ InputProps={{ endAdornment: <Button variant="contained" id="searchButton" data-testid="search-button" onClick={handleSearch}>Search</Button> }}
89
+ />
90
+ {searchResults && <div>{Locale.label("stockPhotos.providedBy")} <a href="https://pexels.com">Pexels</a>.</div>}
91
+ <Grid container spacing={3} alignItems="center">
92
+ {getImages()}
93
+ </Grid>
94
+
95
+ </>);
96
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./GalleryModal";
2
+ export * from "./StockPhotos";
@@ -13,6 +13,8 @@ export { PersonAvatar } from "./PersonAvatar";
13
13
  export { QuestionEdit } from "./QuestionEdit";
14
14
  export { SmallButton } from "./SmallButton";
15
15
  export { SupportModal } from "./SupportModal";
16
+ export { TabPanel } from "./TabPanel";
16
17
  export * from "./wrapper";
17
18
  export * from "./notes";
18
19
  export * from "./header";
20
+ export * from "./gallery";