@churchapps/apphelper 0.2.3 → 0.2.5

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.
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ type Props = {
3
+ contentDisplayName: string;
4
+ contentType: string;
5
+ contentId: string;
6
+ onClose: () => void;
7
+ };
8
+ export declare function B1ShareModal(props: Props): React.JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=B1ShareModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"B1ShareModal.d.ts","sourceRoot":"","sources":["../../src/components/B1ShareModal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,KAAK,KAAK,GAAG;IACX,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,qBAwFxC"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.B1ShareModal = void 0;
16
+ const helpers_1 = require("@churchapps/helpers");
17
+ const material_1 = require("@mui/material");
18
+ const react_1 = __importDefault(require("react"));
19
+ const react_2 = require("react");
20
+ const Loading_1 = require("./Loading");
21
+ function B1ShareModal(props) {
22
+ const [groupId, setGroupId] = (0, react_2.useState)("");
23
+ const [groups, setGroups] = (0, react_2.useState)(null);
24
+ const [comment, setComment] = (0, react_2.useState)("");
25
+ const [showSuccess, setShowSuccess] = (0, react_2.useState)(false);
26
+ const loadData = () => __awaiter(this, void 0, void 0, function* () {
27
+ const g = yield helpers_1.ApiHelper.get("/groups/my", "MembershipApi");
28
+ if (g.length > 0)
29
+ setGroupId(g[0].id);
30
+ setGroups(g);
31
+ });
32
+ const handleChange = (e) => {
33
+ e.preventDefault();
34
+ switch (e.target.name) {
35
+ case "group":
36
+ setGroupId(e.target.value);
37
+ break;
38
+ case "comment":
39
+ setComment(e.target.value);
40
+ break;
41
+ }
42
+ };
43
+ const handlePost = () => {
44
+ setShowSuccess(true);
45
+ if (groupId === "")
46
+ alert("Please select a group.");
47
+ else if (comment === "")
48
+ alert("Please add a comment.");
49
+ else {
50
+ const payload = {
51
+ groupId: groupId,
52
+ contentType: props.contentType,
53
+ contentId: props.contentId,
54
+ comment: comment,
55
+ title: props.contentDisplayName
56
+ };
57
+ helpers_1.ApiHelper.post("/conversations/start", payload, "MessagingApi").then(() => {
58
+ setShowSuccess(true);
59
+ });
60
+ }
61
+ };
62
+ (0, react_2.useEffect)(() => { loadData(); }, []);
63
+ const style = {
64
+ position: 'absolute',
65
+ top: '50%',
66
+ left: '50%',
67
+ transform: 'translate(-50%, -50%)',
68
+ width: 600,
69
+ bgcolor: 'background.paper',
70
+ border: '2px solid #000',
71
+ boxShadow: 24,
72
+ };
73
+ const getModalContent = () => {
74
+ if (!helpers_1.UserHelper.currentUserChurch)
75
+ return react_1.default.createElement("p", null, "Please log in first.");
76
+ else if (!groups)
77
+ return (react_1.default.createElement(Loading_1.Loading, null));
78
+ else if (groups.length === 0)
79
+ return (react_1.default.createElement("p", null, "You are not a currently a member of any groups on B1."));
80
+ else
81
+ return (react_1.default.createElement(react_1.default.Fragment, null,
82
+ react_1.default.createElement("h2", null,
83
+ "Sharing '",
84
+ props.contentDisplayName,
85
+ "' to B1 Group"),
86
+ react_1.default.createElement(material_1.FormControl, { fullWidth: true },
87
+ react_1.default.createElement(material_1.InputLabel, null, "Group"),
88
+ react_1.default.createElement(material_1.Select, { label: "Group", name: "group", value: groupId, onChange: handleChange }, groups.map(g => react_1.default.createElement(material_1.MenuItem, { key: g.id, value: g.id }, g.name)))),
89
+ react_1.default.createElement(material_1.TextField, { fullWidth: true, multiline: true, label: "Comment", name: "comment", value: comment, onChange: handleChange, rows: 3, placeholder: "Include a comment with your post." })));
90
+ };
91
+ if (showSuccess)
92
+ return (react_1.default.createElement(material_1.Snackbar, { open: true, anchorOrigin: { horizontal: "center", vertical: "bottom" }, autoHideDuration: 2500, onClose: () => props.onClose() },
93
+ react_1.default.createElement(material_1.Alert, { variant: "filled", severity: "success" }, "Content shared")));
94
+ else
95
+ return (react_1.default.createElement(material_1.Modal, { open: true, onClose: props.onClose },
96
+ react_1.default.createElement(material_1.Box, { sx: style },
97
+ react_1.default.createElement("div", { style: { paddingLeft: 16, paddingRight: 16 } }, getModalContent()),
98
+ react_1.default.createElement(material_1.DialogActions, { sx: { paddingX: "16px", paddingBottom: "12px" } },
99
+ react_1.default.createElement(material_1.Button, { variant: "outlined", onClick: props.onClose }, "Close"),
100
+ react_1.default.createElement(material_1.Button, { variant: "contained", onClick: handlePost }, "Post")))));
101
+ }
102
+ exports.B1ShareModal = B1ShareModal;
103
+ //# sourceMappingURL=B1ShareModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"B1ShareModal.js","sourceRoot":"","sources":["../../src/components/B1ShareModal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iDAA4E;AAC5E,4CAA4J;AAC5J,kDAA0B;AAC1B,iCAA4C;AAC5C,uCAAoC;AASpC,SAAgB,YAAY,CAAC,KAAY;IACvC,MAAM,CAAC,OAAO,EAA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AAxFD,oCAwFC"}
@@ -16,6 +16,7 @@ export { SmallButton } from "./SmallButton";
16
16
  export { SupportModal } from "./SupportModal";
17
17
  export { MarkdownEditor } from "./markdownEditor/MarkdownEditor";
18
18
  export { MarkdownPreview } from "./markdownEditor/MarkdownPreview";
19
+ export { B1ShareModal } from "./B1ShareModal";
19
20
  export * from "./wrapper";
20
21
  export * from "./gallery";
21
22
  export * from "./markdownEditor";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,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,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,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,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,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,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAA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kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MarkdownPreview = exports.MarkdownEditor = exports.SupportModal = exports.SmallButton = exports.QuestionEdit = exports.PersonAdd = exports.Notes = exports.Loading = exports.InputBox = exports.IconPicker = exports.ImageEditor = exports.HelpIcon = exports.FormSubmissionEdit = exports.FloatingSupport = exports.DisplayBox = exports.ExportLink = exports.ErrorMessages = exports.CreatePerson = void 0;
17
+ exports.B1ShareModal = exports.MarkdownPreview = exports.MarkdownEditor = exports.SupportModal = exports.SmallButton = exports.QuestionEdit = exports.PersonAdd = exports.Notes = exports.Loading = exports.InputBox = exports.IconPicker = exports.ImageEditor = exports.HelpIcon = exports.FormSubmissionEdit = exports.FloatingSupport = exports.DisplayBox = exports.ExportLink = exports.ErrorMessages = exports.CreatePerson = void 0;
18
18
  var CreatePerson_1 = require("./CreatePerson");
19
19
  Object.defineProperty(exports, "CreatePerson", { enumerable: true, get: function () { return CreatePerson_1.CreatePerson; } });
20
20
  var ErrorMessages_1 = require("./ErrorMessages");
@@ -51,6 +51,8 @@ var MarkdownEditor_1 = require("./markdownEditor/MarkdownEditor");
51
51
  Object.defineProperty(exports, "MarkdownEditor", { enumerable: true, get: function () { return MarkdownEditor_1.MarkdownEditor; } });
52
52
  var MarkdownPreview_1 = require("./markdownEditor/MarkdownPreview");
53
53
  Object.defineProperty(exports, "MarkdownPreview", { enumerable: true, get: function () { return MarkdownPreview_1.MarkdownPreview; } });
54
+ var B1ShareModal_1 = require("./B1ShareModal");
55
+ Object.defineProperty(exports, "B1ShareModal", { enumerable: true, get: function () { return B1ShareModal_1.B1ShareModal; } });
54
56
  __exportStar(require("./wrapper"), exports);
55
57
  __exportStar(require("./gallery"), exports);
56
58
  __exportStar(require("./markdownEditor"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,sDAAqD;AAA5C,wGAAA,UAAU,OAAA;AACnB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AACvB,oEAAmE;AAA1D,kHAAA,eAAe,OAAA;AAExB,4CAA0B;AAC1B,4CAA0B;AAC1B,mDAAiC;AACjC,0CAAwB;AACxB,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,sDAAqD;AAA5C,wGAAA,UAAU,OAAA;AACnB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AACvB,oEAAmE;AAA1D,kHAAA,eAAe,OAAA;AACxB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAErB,4CAA0B;AAC1B,4CAA0B;AAC1B,mDAAiC;AACjC,0CAAwB;AACxB,8CAA4B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchapps/apphelper",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Library of helper functions for React and NextJS ChurchApps",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,102 @@
1
+ import { GroupInterface, ApiHelper, UserHelper } from "@churchapps/helpers";
2
+ import { Modal, Box, FormControl, InputLabel, MenuItem, Select, TextField, SelectChangeEvent, Button, DialogActions, Alert, Snackbar } from "@mui/material";
3
+ import React from "react";
4
+ import { useEffect, useState } from "react";
5
+ import { Loading } from "./Loading";
6
+
7
+ type Props = {
8
+ contentDisplayName: string;
9
+ contentType: string;
10
+ contentId: string;
11
+ onClose: () => void;
12
+ };
13
+
14
+ export function B1ShareModal(props: Props) {
15
+ const [groupId, setGroupId] = useState("");
16
+ const [groups, setGroups] = useState<GroupInterface[]>(null);
17
+ const [comment, setComment] = useState("");
18
+ const [showSuccess, setShowSuccess] = useState(false);
19
+
20
+ const loadData = async () => {
21
+ const g = await ApiHelper.get("/groups/my", "MembershipApi");
22
+ if (g.length > 0) setGroupId(g[0].id);
23
+ setGroups(g);
24
+ }
25
+
26
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement> | SelectChangeEvent<string>) => {
27
+ e.preventDefault();
28
+ switch (e.target.name) {
29
+ case "group":
30
+ setGroupId(e.target.value as string);
31
+ break;
32
+ case "comment":
33
+ setComment(e.target.value as string);
34
+ break;
35
+ }
36
+ }
37
+
38
+ const handlePost = () => {
39
+ setShowSuccess(true);
40
+ if (groupId === "") alert("Please select a group.");
41
+ else if (comment === "") alert("Please add a comment.");
42
+ else {
43
+ const payload = {
44
+ groupId: groupId,
45
+ contentType: props.contentType,
46
+ contentId: props.contentId,
47
+ comment: comment,
48
+ title: props.contentDisplayName
49
+ }
50
+ ApiHelper.post("/conversations/start", payload, "MessagingApi").then(() => {
51
+ setShowSuccess(true);
52
+ });
53
+ }
54
+ }
55
+
56
+ useEffect(() => { loadData(); }, []);
57
+
58
+ const style = {
59
+ position: 'absolute' as 'absolute',
60
+ top: '50%',
61
+ left: '50%',
62
+ transform: 'translate(-50%, -50%)',
63
+ width: 600,
64
+ bgcolor: 'background.paper',
65
+ border: '2px solid #000',
66
+ boxShadow: 24,
67
+ };
68
+
69
+ const getModalContent = () => {
70
+ if (!UserHelper.currentUserChurch) return <p>Please log in first.</p>
71
+ else if (!groups) return (<Loading />);
72
+ else if (groups.length === 0) return (<p>You are not a currently a member of any groups on B1.</p>);
73
+ else return (<>
74
+ <h2>Sharing '{props.contentDisplayName}' to B1 Group</h2>
75
+ <FormControl fullWidth>
76
+ <InputLabel>Group</InputLabel>
77
+ <Select label="Group" name="group" value={groupId} onChange={handleChange}>
78
+ {groups.map(g => <MenuItem key={g.id} value={g.id}>{g.name}</MenuItem>)}
79
+ </Select>
80
+ </FormControl>
81
+ <TextField fullWidth multiline label="Comment" name="comment" value={comment} onChange={handleChange} rows={3} placeholder="Include a comment with your post." />
82
+ </>);
83
+ }
84
+
85
+
86
+ if (showSuccess) return (<Snackbar open={true} anchorOrigin={{ horizontal: "center", vertical: "bottom" }} autoHideDuration={2500} onClose={() => props.onClose()}>
87
+ <Alert variant="filled" severity="success">Content shared</Alert>
88
+ </Snackbar>)
89
+ else return (<Modal open={true} onClose={props.onClose}>
90
+ <Box sx={style}>
91
+ <div style={{paddingLeft:16, paddingRight:16}}>
92
+ {getModalContent()}
93
+ </div>
94
+ <DialogActions sx={{ paddingX: "16px", paddingBottom: "12px" }}>
95
+ <Button variant="outlined" onClick={props.onClose}>Close</Button>
96
+ <Button variant="contained" onClick={handlePost}>Post</Button>
97
+ </DialogActions>
98
+ </Box>
99
+
100
+ </Modal>);
101
+
102
+ }
@@ -16,6 +16,7 @@ export { SmallButton } from "./SmallButton";
16
16
  export { SupportModal } from "./SupportModal";
17
17
  export { MarkdownEditor } from "./markdownEditor/MarkdownEditor";
18
18
  export { MarkdownPreview } from "./markdownEditor/MarkdownPreview";
19
+ export { B1ShareModal } from "./B1ShareModal";
19
20
 
20
21
  export * from "./wrapper";
21
22
  export * from "./gallery";