@churchapps/apphelper 0.4.17 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/components/DisplayBox.js +1 -1
  2. package/dist/components/DisplayBox.js.map +1 -1
  3. package/dist/components/FormCardPayment.js +2 -2
  4. package/dist/components/FormCardPayment.js.map +1 -1
  5. package/dist/components/FormSubmissionEdit.d.ts.map +1 -1
  6. package/dist/components/FormSubmissionEdit.js +4 -5
  7. package/dist/components/FormSubmissionEdit.js.map +1 -1
  8. package/dist/components/InputBox.js +1 -1
  9. package/dist/components/InputBox.js.map +1 -1
  10. package/dist/components/Loading.js +1 -1
  11. package/dist/components/Loading.js.map +1 -1
  12. package/dist/components/PageHeader.d.ts +15 -0
  13. package/dist/components/PageHeader.d.ts.map +1 -0
  14. package/dist/components/PageHeader.js +41 -0
  15. package/dist/components/PageHeader.js.map +1 -0
  16. package/dist/components/PersonAvatar.d.ts +12 -0
  17. package/dist/components/PersonAvatar.d.ts.map +1 -0
  18. package/dist/components/PersonAvatar.js +55 -0
  19. package/dist/components/PersonAvatar.js.map +1 -0
  20. package/dist/components/header/SiteHeader.d.ts +2 -1
  21. package/dist/components/header/SiteHeader.d.ts.map +1 -1
  22. package/dist/components/header/SiteHeader.js +100 -4
  23. package/dist/components/header/SiteHeader.js.map +1 -1
  24. package/dist/components/header/SupportDrawer.js.map +1 -1
  25. package/dist/components/index.d.ts +2 -0
  26. package/dist/components/index.d.ts.map +1 -1
  27. package/dist/components/index.js +2 -0
  28. package/dist/components/index.js.map +1 -1
  29. package/dist/components/notes/AddNote.d.ts.map +1 -1
  30. package/dist/components/notes/AddNote.js +45 -7
  31. package/dist/components/notes/AddNote.js.map +1 -1
  32. package/dist/components/notes/Note.d.ts.map +1 -1
  33. package/dist/components/notes/Note.js +6 -6
  34. package/dist/components/notes/Note.js.map +1 -1
  35. package/dist/components/notes/Notes.d.ts.map +1 -1
  36. package/dist/components/notes/Notes.js +120 -20
  37. package/dist/components/notes/Notes.js.map +1 -1
  38. package/dist/components/wrapper/ChurchList.d.ts.map +1 -1
  39. package/dist/components/wrapper/ChurchList.js +44 -6
  40. package/dist/components/wrapper/ChurchList.js.map +1 -1
  41. package/dist/components/wrapper/NewPrivateMessage.d.ts.map +1 -1
  42. package/dist/components/wrapper/NewPrivateMessage.js +28 -21
  43. package/dist/components/wrapper/NewPrivateMessage.js.map +1 -1
  44. package/dist/components/wrapper/Notifications.d.ts.map +1 -1
  45. package/dist/components/wrapper/Notifications.js +47 -20
  46. package/dist/components/wrapper/Notifications.js.map +1 -1
  47. package/dist/components/wrapper/PrivateMessageDetails.d.ts +1 -0
  48. package/dist/components/wrapper/PrivateMessageDetails.d.ts.map +1 -1
  49. package/dist/components/wrapper/PrivateMessageDetails.js +53 -4
  50. package/dist/components/wrapper/PrivateMessageDetails.js.map +1 -1
  51. package/dist/components/wrapper/PrivateMessages.d.ts.map +1 -1
  52. package/dist/components/wrapper/PrivateMessages.js +360 -41
  53. package/dist/components/wrapper/PrivateMessages.js.map +1 -1
  54. package/dist/components/wrapper/UserMenu.d.ts.map +1 -1
  55. package/dist/components/wrapper/UserMenu.js +164 -27
  56. package/dist/components/wrapper/UserMenu.js.map +1 -1
  57. package/dist/components/wrapper/index.d.ts +2 -1
  58. package/dist/components/wrapper/index.d.ts.map +1 -1
  59. package/dist/components/wrapper/index.js +2 -1
  60. package/dist/components/wrapper/index.js.map +1 -1
  61. package/dist/helpers/ArrayHelper.d.ts.map +1 -1
  62. package/dist/helpers/ArrayHelper.js +0 -1
  63. package/dist/helpers/ArrayHelper.js.map +1 -1
  64. package/dist/helpers/ErrorHelper.js +1 -1
  65. package/dist/helpers/ErrorHelper.js.map +1 -1
  66. package/dist/helpers/EventHelper.d.ts.map +1 -1
  67. package/dist/helpers/EventHelper.js +0 -3
  68. package/dist/helpers/EventHelper.js.map +1 -1
  69. package/dist/helpers/Locale.d.ts +1 -1
  70. package/dist/helpers/Locale.d.ts.map +1 -1
  71. package/dist/helpers/Locale.js +7 -2
  72. package/dist/helpers/Locale.js.map +1 -1
  73. package/dist/helpers/NotificationService.d.ts +56 -0
  74. package/dist/helpers/NotificationService.d.ts.map +1 -0
  75. package/dist/helpers/NotificationService.js +176 -0
  76. package/dist/helpers/NotificationService.js.map +1 -0
  77. package/dist/helpers/SocketHelper.d.ts.map +1 -1
  78. package/dist/helpers/SocketHelper.js +22 -17
  79. package/dist/helpers/SocketHelper.js.map +1 -1
  80. package/dist/helpers/UserHelper.js +2 -2
  81. package/dist/helpers/UserHelper.js.map +1 -1
  82. package/dist/helpers/index.d.ts +2 -0
  83. package/dist/helpers/index.d.ts.map +1 -1
  84. package/dist/helpers/index.js +1 -0
  85. package/dist/helpers/index.js.map +1 -1
  86. package/dist/hooks/index.d.ts +2 -0
  87. package/dist/hooks/index.d.ts.map +1 -1
  88. package/dist/hooks/index.js +1 -0
  89. package/dist/hooks/index.js.map +1 -1
  90. package/dist/hooks/useNotifications.d.ts +30 -0
  91. package/dist/hooks/useNotifications.d.ts.map +1 -0
  92. package/dist/hooks/useNotifications.js +79 -0
  93. package/dist/hooks/useNotifications.js.map +1 -0
  94. package/dist/public/css/styles.css +6 -2
  95. package/package.json +1 -1
  96. package/public/css/styles.css +6 -2
  97. package/src/components/DisplayBox.tsx +8 -8
  98. package/src/components/FormCardPayment.tsx +2 -2
  99. package/src/components/FormSubmissionEdit.tsx +5 -6
  100. package/src/components/InputBox.tsx +8 -8
  101. package/src/components/Loading.tsx +1 -1
  102. package/src/components/PageHeader.tsx +111 -0
  103. package/src/components/PersonAvatar.tsx +78 -0
  104. package/src/components/header/SiteHeader.tsx +133 -10
  105. package/src/components/header/SupportDrawer.tsx +1 -1
  106. package/src/components/index.tsx +2 -0
  107. package/src/components/notes/AddNote.tsx +105 -19
  108. package/src/components/notes/Note.tsx +43 -22
  109. package/src/components/notes/Notes.tsx +160 -21
  110. package/src/components/wrapper/ChurchList.tsx +45 -5
  111. package/src/components/wrapper/NewPrivateMessage.tsx +181 -44
  112. package/src/components/wrapper/Notifications.tsx +165 -29
  113. package/src/components/wrapper/PrivateMessageDetails.tsx +100 -13
  114. package/src/components/wrapper/PrivateMessages.tsx +539 -65
  115. package/src/components/wrapper/UserMenu.tsx +223 -38
  116. package/src/components/wrapper/index.tsx +3 -2
  117. package/src/helpers/ArrayHelper.ts +0 -1
  118. package/src/helpers/ErrorHelper.ts +1 -1
  119. package/src/helpers/EventHelper.ts +0 -3
  120. package/src/helpers/Locale.ts +7 -2
  121. package/src/helpers/NotificationService.ts +211 -0
  122. package/src/helpers/SocketHelper.ts +23 -17
  123. package/src/helpers/UserHelper.ts +2 -2
  124. package/src/helpers/index.ts +2 -0
  125. package/src/hooks/index.ts +2 -0
  126. package/src/hooks/useNotifications.ts +94 -0
  127. package/dist/components/wrapper/Drawers.d.ts +0 -5
  128. package/dist/components/wrapper/Drawers.d.ts.map +0 -1
  129. package/dist/components/wrapper/Drawers.js +0 -49
  130. package/dist/components/wrapper/Drawers.js.map +0 -1
  131. package/dist/components/wrapper/SiteWrapper.d.ts +0 -15
  132. package/dist/components/wrapper/SiteWrapper.d.ts.map +0 -1
  133. package/dist/components/wrapper/SiteWrapper.js +0 -60
  134. package/dist/components/wrapper/SiteWrapper.js.map +0 -1
  135. package/dist/components/wrapper/TabPanel.d.ts +0 -9
  136. package/dist/components/wrapper/TabPanel.d.ts.map +0 -1
  137. package/dist/components/wrapper/TabPanel.js +0 -17
  138. package/dist/components/wrapper/TabPanel.js.map +0 -1
  139. package/dist/helpers/ApiHelper.d.ts +0 -18
  140. package/dist/helpers/ApiHelper.d.ts.map +0 -1
  141. package/dist/helpers/ApiHelper.js +0 -119
  142. package/dist/helpers/ApiHelper.js.map +0 -1
  143. package/src/components/wrapper/Drawers.tsx +0 -62
  144. package/src/components/wrapper/SiteWrapper.tsx +0 -110
  145. package/src/components/wrapper/TabPanel.tsx +0 -32
  146. package/src/helpers/ApiHelper.ts +0 -127
@@ -12,7 +12,6 @@ export class SocketHelper {
12
12
 
13
13
  static setPersonChurch = (pc: {personId:string, churchId:string}) => {
14
14
  if (pc?.personId && pc.personId && pc.churchId!==this.personIdChurchId.churchId && pc.personId!==this.personIdChurchId.personId) {
15
- //if (pc?.personId && pc.personId!==this.personIdChurchId.personId && this.socketId!==undefined && this.socketId) {
16
15
  this.personIdChurchId = pc;
17
16
  this.createAlertConnection();
18
17
  }
@@ -21,7 +20,10 @@ export class SocketHelper {
21
20
  static createAlertConnection = () => {
22
21
  if (SocketHelper.personIdChurchId.personId && SocketHelper.socketId) {
23
22
  const connection: ConnectionInterface = { conversationId: "alerts", churchId: SocketHelper.personIdChurchId.churchId, displayName: "Test", socketId: SocketHelper.socketId, personId:SocketHelper.personIdChurchId.personId }
24
- ApiHelper.postAnonymous("/connections", [connection], "MessagingApi");
23
+
24
+ ApiHelper.postAnonymous("/connections", [connection], "MessagingApi").catch((error: any) => {
25
+ console.error("❌ Failed to create alert connection:", error);
26
+ });
25
27
  }
26
28
  }
27
29
 
@@ -32,11 +34,11 @@ export class SocketHelper {
32
34
  // Reset cleanup flag
33
35
  SocketHelper.isCleanedUp = false;
34
36
 
35
- if (SocketHelper.socket !== undefined && SocketHelper.socket.readyState !== SocketHelper.socket.CLOSED) {
37
+ if (SocketHelper.socket && SocketHelper.socket.readyState !== SocketHelper.socket.CLOSED) {
36
38
  try {
37
39
  SocketHelper.socket.close();
38
40
  } catch (e) {
39
- console.log("Error closing existing socket:", e);
41
+ console.error("Error closing existing socket:", e);
40
42
  }
41
43
  }
42
44
 
@@ -45,19 +47,19 @@ export class SocketHelper {
45
47
  SocketHelper.socket = new WebSocket(CommonEnvironmentHelper.MessagingApiSocket);
46
48
 
47
49
  SocketHelper.socket.onmessage = (event) => {
48
- if (SocketHelper.isCleanedUp) return; // Don't process messages after cleanup
50
+ if (SocketHelper.isCleanedUp) return;
49
51
 
50
52
  try {
51
53
  const payload = JSON.parse(event.data);
52
54
  SocketHelper.handleMessage(payload);
53
55
  } catch (error) {
54
- console.error("Error parsing socket message:", error);
56
+ console.error("Error parsing socket message:", error);
55
57
  }
56
58
  };
57
59
 
58
60
  SocketHelper.socket.onopen = async (e) => {
59
61
  SocketHelper.reconnectAttempts = 0; // Reset reconnect attempts on successful connection
60
- SocketHelper.socket.send("getId"); //not sure this is needed. It auto-sends socketId on connect
62
+ SocketHelper.socket.send("getId"); // Request socket ID
61
63
  setTimeout(() => { resolve(null); }, 500);
62
64
  };
63
65
 
@@ -71,27 +73,31 @@ export class SocketHelper {
71
73
  // Only attempt reconnection if not manually cleaned up and within retry limits
72
74
  if (!SocketHelper.isCleanedUp && SocketHelper.reconnectAttempts < SocketHelper.maxReconnectAttempts) {
73
75
  SocketHelper.reconnectAttempts++;
74
- const backoffDelay = Math.min(1000 * Math.pow(2, SocketHelper.reconnectAttempts - 1), 30000); // Exponential backoff with max 30s
76
+ const backoffDelay = Math.min(1000 * Math.pow(2, SocketHelper.reconnectAttempts - 1), 30000);
77
+
78
+ console.log(`🔄 WebSocket reconnecting... attempt ${SocketHelper.reconnectAttempts}/${SocketHelper.maxReconnectAttempts}`);
75
79
 
76
80
  SocketHelper.reconnectTimeout = setTimeout(() => {
77
- if (!SocketHelper.isCleanedUp && SocketHelper.socket.readyState === SocketHelper.socket.CLOSED) {
81
+ if (!SocketHelper.isCleanedUp && SocketHelper.socket && SocketHelper.socket.readyState === SocketHelper.socket.CLOSED) {
78
82
  SocketHelper.init().then(() => {
79
83
  SocketHelper.handleMessage({ action: "reconnect", data: null });
80
84
  }).catch((error) => {
81
- console.error("Reconnection failed:", error);
85
+ console.error("Reconnection failed:", error);
82
86
  });
83
87
  }
84
88
  }, backoffDelay);
89
+ } else if (SocketHelper.reconnectAttempts >= SocketHelper.maxReconnectAttempts) {
90
+ console.error("❌ WebSocket max reconnection attempts reached");
85
91
  }
86
92
  };
87
93
 
88
94
  SocketHelper.socket.onerror = (error) => {
89
- console.error("WebSocket error:", error);
95
+ console.error("WebSocket connection error:", error);
90
96
  reject(error);
91
97
  };
92
98
 
93
99
  } catch (error) {
94
- console.error("Error initializing socket:", error);
100
+ console.error("Error initializing socket:", error);
95
101
  reject(error);
96
102
  }
97
103
  });
@@ -119,25 +125,25 @@ export class SocketHelper {
119
125
  }
120
126
 
121
127
  static handleMessage = (payload: SocketPayloadInterface) => {
122
- if (SocketHelper.isCleanedUp) return; // Don't handle messages after cleanup
128
+ if (SocketHelper.isCleanedUp) return;
123
129
 
124
130
  try {
125
- //console.log("MESSAGE", payload)
126
131
  if (payload.action==="socketId") {
127
132
  SocketHelper.socketId = payload.data;
128
133
  SocketHelper.createAlertConnection();
129
134
  }
130
135
  else {
131
- ArrayHelper.getAll(SocketHelper.actionHandlers, "action", payload.action).forEach((handler) => {
136
+ const matchingHandlers = ArrayHelper.getAll(SocketHelper.actionHandlers, "action", payload.action);
137
+ matchingHandlers.forEach((handler) => {
132
138
  try {
133
139
  handler.handleMessage(payload.data);
134
140
  } catch (error) {
135
- console.error(`Error in handler ${handler.id}:`, error);
141
+ console.error(`❌ Error in handler ${handler.id}:`, error);
136
142
  }
137
143
  });
138
144
  }
139
145
  } catch (error) {
140
- console.error("Error handling socket message:", error);
146
+ console.error("Error handling socket message:", error);
141
147
  }
142
148
  }
143
149
 
@@ -1,4 +1,4 @@
1
- import { ApiHelper } from "./ApiHelper"
1
+ import { ApiHelper } from "@churchapps/helpers"
2
2
  import { UserInterface, UserContextInterface, IApiPermission, PersonInterface, LoginUserChurchInterface } from "@churchapps/helpers";
3
3
 
4
4
  export class UserHelper {
@@ -44,7 +44,7 @@ export class UserHelper {
44
44
 
45
45
  let result = false;
46
46
  if (permissions !== undefined) {
47
- permissions.forEach(element => {
47
+ permissions.forEach((element: any) => {
48
48
  if (element.contentType === contentType && element.action === action) result = true;
49
49
  });
50
50
  }
@@ -46,3 +46,5 @@ export { createEmotionCache } from "./createEmotionCache";
46
46
  export { Locale } from "./Locale";
47
47
  export { SlugHelper } from "./SlugHelper";
48
48
  export { SocketHelper } from "./SocketHelper";
49
+ export { NotificationService } from "./NotificationService";
50
+ export type { NotificationCounts } from "./NotificationService";
@@ -1 +1,3 @@
1
1
  export { useMountedState } from "./useMountedState";
2
+ export { useNotifications } from "./useNotifications";
3
+ export type { UseNotificationsResult } from "./useNotifications";
@@ -0,0 +1,94 @@
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
+ import { NotificationService, NotificationCounts } from '../helpers/NotificationService';
3
+ import { UserContextInterface } from '@churchapps/helpers';
4
+
5
+ export interface UseNotificationsResult {
6
+ counts: NotificationCounts;
7
+ isLoading: boolean;
8
+ isReady: boolean;
9
+ refresh: () => Promise<void>;
10
+ error: string | null;
11
+ }
12
+
13
+ /**
14
+ * Custom hook for managing real-time notifications
15
+ *
16
+ * @param context - User context containing person and church information
17
+ * @returns Object containing notification counts and management functions
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * const { counts, isLoading, refresh } = useNotifications(context);
22
+ *
23
+ * return (
24
+ * <UserMenu
25
+ * notificationCounts={counts}
26
+ * loadCounts={refresh}
27
+ * // ... other props
28
+ * />
29
+ * );
30
+ * ```
31
+ */
32
+ export function useNotifications(context: UserContextInterface | null): UseNotificationsResult {
33
+ const [counts, setCounts] = useState<NotificationCounts>({ notificationCount: 0, pmCount: 0 });
34
+ const [isLoading, setIsLoading] = useState(true);
35
+ const [error, setError] = useState<string | null>(null);
36
+
37
+ // Get the singleton instance only once
38
+ const notificationService = React.useMemo(() => NotificationService.getInstance(), []);
39
+
40
+ // Initialize the service when context becomes available
41
+ useEffect(() => {
42
+ if (!context?.person?.id || !context?.userChurch?.church?.id) {
43
+ setIsLoading(false);
44
+ return;
45
+ }
46
+
47
+ const initializeService = async () => {
48
+ try {
49
+ setIsLoading(true);
50
+ setError(null);
51
+
52
+ await notificationService.initialize(context);
53
+ } catch (err) {
54
+ console.error("❌ useNotifications: Failed to initialize:", err);
55
+ setError(err instanceof Error ? err.message : 'Failed to initialize notifications');
56
+ } finally {
57
+ setIsLoading(false);
58
+ }
59
+ };
60
+
61
+ initializeService();
62
+ }, [context?.person?.id, context?.userChurch?.church?.id]);
63
+
64
+ // Subscribe to notification count changes
65
+ useEffect(() => {
66
+ const unsubscribe = notificationService.subscribe((newCounts) => {
67
+ setCounts(newCounts);
68
+ });
69
+
70
+ // Cleanup subscription on unmount
71
+ return () => {
72
+ unsubscribe();
73
+ };
74
+ }, [notificationService]);
75
+
76
+ // Refresh function - memoized without dependencies for stable reference
77
+ const refresh = useCallback(async () => {
78
+ try {
79
+ setError(null);
80
+ await NotificationService.getInstance().refresh();
81
+ } catch (err) {
82
+ console.error("❌ useNotifications: Refresh failed:", err);
83
+ setError(err instanceof Error ? err.message : 'Failed to refresh notifications');
84
+ }
85
+ }, []);
86
+
87
+ return {
88
+ counts,
89
+ isLoading,
90
+ isReady: notificationService.isReady(),
91
+ refresh,
92
+ error
93
+ };
94
+ }
@@ -1,5 +0,0 @@
1
- export declare const OpenDrawer: (styles: any) => import("@emotion/styled").StyledComponent<import("@mui/material").DrawerProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
2
- export declare const ClosedDrawer: (styles: any) => import("@emotion/styled").StyledComponent<import("@mui/material").DrawerProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
3
- export declare const ClosedDrawerAppBar: import("@emotion/styled").StyledComponent<import("@mui/material").AppBarOwnProps & Omit<import("@mui/material").PaperOwnProps, "classes" | "color" | "position"> & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "style" | "classes" | "className" | "color" | "children" | "elevation" | "square" | "sx" | "variant" | "position" | "enableColorOnDark"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
4
- export declare const OpenDrawerAppBar: import("@emotion/styled").StyledComponent<import("@mui/material").AppBarOwnProps & Omit<import("@mui/material").PaperOwnProps, "classes" | "color" | "position"> & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "style" | "classes" | "className" | "color" | "children" | "elevation" | "square" | "sx" | "variant" | "position" | "enableColorOnDark"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
5
- //# sourceMappingURL=Drawers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Drawers.d.ts","sourceRoot":"","sources":["../../../src/components/wrapper/Drawers.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,GAAI,QAAO,GAAG,uKAkBpC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAO,GAAG,uKActC,CAAC;AAEF,eAAO,MAAM,kBAAkB,+hBAS9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,+hBAS5B,CAAC"}
@@ -1,49 +0,0 @@
1
- "use client";
2
- import { AppBar, Drawer, styled } from "@mui/material";
3
- export const OpenDrawer = (styles) => styled(Drawer)(({ theme }) => ({
4
- "& .MuiDrawer-paper": {
5
- position: "relative",
6
- backgroundColor: styles.backgroundColor || theme.palette.primary.main,
7
- color: "#FFFFFF",
8
- whiteSpace: "nowrap",
9
- width: "100vw",
10
- zIndex: 9999,
11
- [theme.breakpoints.up("md")]: { width: 220 },
12
- transition: theme.transitions.create("width", {
13
- easing: theme.transitions.easing.sharp,
14
- duration: theme.transitions.duration.enteringScreen
15
- }),
16
- boxSizing: "border-box"
17
- },
18
- "& .MuiListItemButton-root, & .MuiListItemIcon-root": { color: "#FFFFFF" }
19
- }));
20
- export const ClosedDrawer = (styles) => styled(OpenDrawer(styles))(({ theme }) => ({
21
- overflowX: "hidden",
22
- transition: theme.transitions.create("width", {
23
- easing: theme.transitions.easing.sharp,
24
- duration: theme.transitions.duration.leavingScreen
25
- }),
26
- zIndex: 1,
27
- width: theme.spacing(7),
28
- [theme.breakpoints.up("sm")]: { width: theme.spacing(7) },
29
- "& .MuiListSubheader-root": {
30
- opacity: 0
31
- }
32
- }));
33
- export const ClosedDrawerAppBar = styled(AppBar)(({ theme }) => ({
34
- zIndex: theme.zIndex.drawer + 1,
35
- transition: theme.transitions.create(["width", "margin"], {
36
- easing: theme.transitions.easing.sharp,
37
- duration: theme.transitions.duration.leavingScreen
38
- }),
39
- "& .MuiIcon-root": { color: "#FFFFFF" }
40
- }));
41
- export const OpenDrawerAppBar = styled(ClosedDrawerAppBar)(({ theme }) => ({
42
- marginLeft: 220,
43
- width: `calc(100% - ${220}px)`,
44
- transition: theme.transitions.create(["width", "margin"], {
45
- easing: theme.transitions.easing.sharp,
46
- duration: theme.transitions.duration.enteringScreen
47
- })
48
- }));
49
- //# sourceMappingURL=Drawers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Drawers.js","sourceRoot":"","sources":["../../../src/components/wrapper/Drawers.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAU,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CACtD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACd,oBAAoB,EAAE;QACpB,QAAQ,EAAE,UAAU;QACpB,eAAe,EAAE,MAAM,CAAC,eAAe,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;QACrE,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,QAAQ;QACpB,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,IAAI;QACZ,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;QAC5C,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE;YAC5C,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK;YACtC,QAAQ,EAAE,KA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,iBAAiB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;CACxC,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CACxD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACd,UAAU,EAAE,GAAG;IACf,KAAK,EAAE,eAAe,GAAG,KAAK;IAC9B,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;QACxD,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK;QACtC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc;KACpD,CAAC;CACH,CAAC,CACH,CAAC"}
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- import { AppearanceInterface } from "../../helpers";
3
- import { UserContextInterface } from "@churchapps/helpers";
4
- interface Props {
5
- navContent: React.ReactElement;
6
- context: UserContextInterface;
7
- children: React.ReactNode;
8
- appName: string;
9
- onNavigate: (url: string) => void;
10
- appearance?: AppearanceInterface;
11
- omitOverflow?: boolean;
12
- }
13
- export declare const SiteWrapper: React.FC<Props>;
14
- export {};
15
- //# sourceMappingURL=SiteWrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SiteWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/wrapper/SiteWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8C,MAAM,OAAO,CAAC;AAEnE,OAAO,EAA8C,mBAAmB,EAAa,MAAM,eAAe,CAAC;AAE3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAK3D,UAAU,KAAK;IACb,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC;IAC/B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAwFvC,CAAC"}
@@ -1,60 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import React, { useCallback, useMemo } from "react";
4
- import { IconButton, Toolbar, Icon, Typography, Box, Container, Link } from "@mui/material";
5
- import { UserHelper, AppearanceHelper, PersonHelper, ApiHelper } from "../../helpers";
6
- import { UserMenu } from "./UserMenu";
7
- import { useMountedState } from "../../hooks/useMountedState";
8
- import { SocketHelper } from "../../helpers/SocketHelper";
9
- import { ClosedDrawer, ClosedDrawerAppBar, OpenDrawer, OpenDrawerAppBar } from "./Drawers";
10
- export const SiteWrapper = props => {
11
- const [churchLogo, setChurchLogo] = React.useState();
12
- const [open, setOpen] = React.useState(false);
13
- const [notificationCounts, setNotificationCounts] = React.useState({ notificationCount: 0, pmCount: 0 });
14
- const toggleDrawer = useCallback(() => { setOpen(!open); }, [open]);
15
- const isMounted = useMountedState();
16
- const CustomDrawer = useMemo(() => (open) ? OpenDrawer({ backgroundColor: props.appearance?.wrapperBackground }) : ClosedDrawer({ backgroundColor: props.appearance?.wrapperBackground }), [open, props.appearance?.wrapperBackground]);
17
- const CustomAppBar = useMemo(() => (open) ? OpenDrawerAppBar : ClosedDrawerAppBar, [open]);
18
- const loadCounts = useCallback(() => {
19
- ApiHelper.get("/notifications/unreadCount", "MessagingApi").then(data => {
20
- if (!notificationCounts || JSON.stringify(notificationCounts) !== JSON.stringify(data))
21
- setNotificationCounts(data);
22
- });
23
- }, [notificationCounts]);
24
- const handleNotification = useCallback(() => {
25
- loadCounts();
26
- }, [loadCounts]);
27
- React.useEffect(() => {
28
- const getChurchLogo = async () => {
29
- if (UserHelper.currentUserChurch) {
30
- setChurchLogo(AppearanceHelper.getLogoDark(props.appearance, "/images/logo-wrapper.png"));
31
- }
32
- };
33
- if (!isMounted()) {
34
- getChurchLogo();
35
- }
36
- }, [isMounted, props.appearance]);
37
- React.useEffect(() => {
38
- if (!props.context.userChurch)
39
- SocketHelper.setPersonChurch({ personId: null, churchId: null });
40
- else
41
- SocketHelper.setPersonChurch({ personId: props.context.userChurch?.person?.id, churchId: props.context.userChurch?.church?.id });
42
- }, [props.context.userChurch]);
43
- React.useEffect(() => {
44
- SocketHelper.addHandler("notification", "notificationBell", handleNotification);
45
- SocketHelper.init();
46
- loadCounts();
47
- // Cleanup function to remove handlers and disconnect socket
48
- return () => {
49
- SocketHelper.removeHandler("notificationBell");
50
- };
51
- }, [handleNotification, loadCounts]);
52
- const boxStyle = useMemo(() => {
53
- const style = { flexGrow: 1, marginTop: 8, minHeight: "90vh" };
54
- if (!props.omitOverflow)
55
- style.overflow = "auto";
56
- return style;
57
- }, [props.omitOverflow]);
58
- return _jsxs(_Fragment, { children: [_jsx(CustomAppBar, { position: "absolute", children: _jsxs(Toolbar, { sx: { pr: "24px", backgroundColor: props.appearance?.wrapperBackground }, children: [_jsx(IconButton, { edge: "start", color: "inherit", "aria-label": "open drawer", onClick: toggleDrawer, sx: { marginRight: "36px", ...(open && { display: "none" }) }, "data-testid": "open-navigation-drawer", children: _jsx(Icon, { children: "menu" }) }), _jsx(Typography, { variant: "h6", noWrap: true, children: UserHelper.currentUserChurch?.church?.name || "" }), _jsx("div", { style: { flex: 1 } }), UserHelper.user && _jsx(UserMenu, { profilePicture: PersonHelper.getPhotoUrl(props.context?.person), userName: `${UserHelper.user?.firstName} ${UserHelper.user?.lastName}`, userChurches: UserHelper.userChurches, currentUserChurch: UserHelper.currentUserChurch, context: props.context, appName: props.appName, onNavigate: props.onNavigate, loadCounts: loadCounts, notificationCounts: notificationCounts }), !UserHelper.user && _jsx(Link, { href: "/login", color: "inherit", style: { textDecoration: "none" }, children: "Login" })] }) }), _jsxs(CustomDrawer, { style: { backgroundColor: props.appearance?.wrapperBackground }, variant: "permanent", open: open, onMouseOver: useCallback(() => setOpen(true), []), onMouseLeave: useCallback(() => setOpen(false), []), children: [_jsxs(Toolbar, { sx: { display: "flex", alignItems: "center", width: "100%", px: [1] }, children: [_jsx("img", { src: churchLogo || "/images/logo-wrapper.png", alt: "logo", style: { maxWidth: 170 } }), _jsx("div", { style: { justifyContent: "flex-end", flex: 1, display: "flex" }, children: _jsx(IconButton, { onClick: toggleDrawer, "aria-label": "close navigation drawer", "data-testid": "close-navigation-drawer", children: _jsx(Icon, { style: { color: "#FFFFFF" }, children: "chevron_left" }) }) })] }), props.navContent] }), _jsx(Box, { component: "main", sx: boxStyle, children: _jsx(Container, { maxWidth: false, sx: { mt: 4, mb: 4 }, children: props.children }) })] });
59
- };
60
- //# sourceMappingURL=SiteWrapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SiteWrapper.js","sourceRoot":"","sources":["../../../src/components/wrapper/SiteWrapper.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,EAAE,EAAiB,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,YAAY,EAAuB,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAY3F,MAAM,CAAC,MAAM,WAA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K,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,YAClE,KAAC,UAAU,IAAC,OAAO,EAAE,YAAY,gBAAa,yBAAyB,iBAAa,yBAAyB,YAAC,KAAC,IAAI,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,6BAAqB,GAAa,GAC7K,IACE,EACT,KAAK,CAAC,UAAU,IACJ,EACf,KAAC,GAAG,IAAC,SAAS,EAAC,MAAM,EAAC,EAAE,EAAE,QAAQ,YAChC,KAAC,SAAS,IAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,YAC7C,KAAK,CAAC,QAAQ,GACL,GACR,IACL,CAAA;AACL,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- interface TabPanelProps {
3
- children?: React.ReactNode;
4
- index: number;
5
- value: number;
6
- }
7
- export declare function TabPanel(props: TabPanelProps): import("react/jsx-runtime").JSX.Element;
8
- export {};
9
- //# sourceMappingURL=TabPanel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabPanel.d.ts","sourceRoot":"","sources":["../../../src/components/wrapper/TabPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,aAAa;IAAG,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;CAAE;AAcrF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAY5C"}
@@ -1,17 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Box, styled } from "@mui/material";
4
- const StyledMenuBox = styled(Box)(({ theme }) => ({
5
- paddingTop: 10,
6
- "& .MuiListItemButton-root": { paddingLeft: 30 },
7
- "& .MuiListItemIcon-root": {
8
- color: theme.palette.primary.main
9
- },
10
- "& .MuiListItemText-root": { color: theme.palette.text.primary },
11
- "& .selected .MuiListItemText-root span": { fontWeight: "bold" }
12
- }));
13
- export function TabPanel(props) {
14
- const { children, value, index } = props;
15
- return (_jsx("div", { role: "tabpanel", hidden: value !== index, id: `userMenuPanel-${index}`, children: value === index && (_jsx(StyledMenuBox, { children: _jsx(Box, { children: children }) })) }));
16
- }
17
- //# sourceMappingURL=TabPanel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabPanel.js","sourceRoot":"","sources":["../../../src/components/wrapper/TabPanel.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAC/B,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACd,UAAU,EAAE,EAAE;IACd,2BAA2B,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;IAChD,yBAAyB,EAAE;QACzB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;KAClC;IACD,yBAAyB,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE;IAChE,wCAAwC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;CACjE,CAAC,CACH,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAEzC,OAAO,CACL,cAAK,IAAI,EAAC,UAAU,EAAC,MAAM,EAAE,KAAK,KAAK,KAAK,EAAE,EAAE,EAAE,iBAAiB,KAAK,EAAE,YACvE,KAAK,KAAK,KAAK,IAAI,CAClB,KAAC,aAAa,cACZ,KAAC,GAAG,cAAE,QAAQ,GAAO,GACP,CACjB,GACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,18 +0,0 @@
1
- import { ApiConfig, RolePermissionInterface, ApiListType } from "@churchapps/helpers";
2
- export declare class ApiHelper {
3
- static apiConfigs: ApiConfig[];
4
- static isAuthenticated: boolean;
5
- static getConfig(keyName: string): ApiConfig;
6
- static setDefaultPermissions(jwt: string): void;
7
- static setPermissions(keyName: string, jwt: string, permissions: RolePermissionInterface[]): void;
8
- static clearPermissions(): void;
9
- static get(path: string, apiName: ApiListType): Promise<any>;
10
- static getAnonymous(path: string, apiName: ApiListType, tags?: string[]): Promise<any>;
11
- static post(path: string, data: any[] | {}, apiName: ApiListType): Promise<any>;
12
- static patch(path: string, data: any[] | {}, apiName: ApiListType): Promise<any>;
13
- static delete(path: string, apiName: ApiListType): Promise<void>;
14
- static postAnonymous(path: string, data: any[] | {}, apiName: ApiListType): Promise<any>;
15
- static fetchWithErrorHandling(url: string, requestOptions: any): Promise<any>;
16
- private static throwApiError;
17
- }
18
- //# sourceMappingURL=ApiHelper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApiHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/ApiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGtF,qBAAa,SAAS;IAErB,MAAM,CAAC,UAAU,EAAE,SAAS,EAAE,CAAM;IACpC,MAAM,CAAC,eAAe,UAAS;IAE/B,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM;IAOhC,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE,MAAM;IAQxC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,uBAAuB,EAAE;IAU1F,MAAM,CAAC,gBAAgB;WAKV,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW;WAWtC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE;WAQhE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,WAAW;WAUzD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,WAAW;WAU1D,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW;WAczC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,WAAW;WAUlE,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG;mBAe/C,aAAa;CAUlC"}
@@ -1,119 +0,0 @@
1
- import { ErrorHelper } from "./ErrorHelper";
2
- export class ApiHelper {
3
- static getConfig(keyName) {
4
- let result;
5
- this.apiConfigs.forEach(config => { if (config.keyName === keyName)
6
- result = config; });
7
- //if (result === null) throw new Error("Unconfigured API: " + keyName);
8
- return result;
9
- }
10
- static setDefaultPermissions(jwt) {
11
- this.apiConfigs.forEach(config => {
12
- config.jwt = jwt;
13
- config.permissions = [];
14
- });
15
- this.isAuthenticated = true;
16
- }
17
- static setPermissions(keyName, jwt, permissions) {
18
- this.apiConfigs.forEach(config => {
19
- if (config.keyName === keyName) {
20
- config.jwt = jwt;
21
- config.permissions = permissions;
22
- }
23
- });
24
- this.isAuthenticated = true;
25
- }
26
- static clearPermissions() {
27
- this.apiConfigs.forEach(config => { config.jwt = ""; config.permissions = []; });
28
- this.isAuthenticated = false;
29
- }
30
- static async get(path, apiName) {
31
- const config = this.getConfig(apiName);
32
- const requestOptions = {
33
- method: "GET",
34
- headers: { Authorization: "Bearer " + config.jwt },
35
- cache: "no-store"
36
- };
37
- return await this.fetchWithErrorHandling(config.url + path, requestOptions);
38
- }
39
- static async getAnonymous(path, apiName, tags) {
40
- const config = this.getConfig(apiName);
41
- const requestOptions = { method: "GET" };
42
- if (tags?.length > 0)
43
- requestOptions.next = { tags: tags };
44
- else
45
- requestOptions.cache = "no-store";
46
- return await this.fetchWithErrorHandling(config.url + path, requestOptions);
47
- }
48
- static async post(path, data, apiName) {
49
- const config = this.getConfig(apiName);
50
- const requestOptions = {
51
- method: "POST",
52
- headers: { Authorization: "Bearer " + config.jwt, "Content-Type": "application/json" },
53
- body: JSON.stringify(data)
54
- };
55
- return await this.fetchWithErrorHandling(config.url + path, requestOptions);
56
- }
57
- static async patch(path, data, apiName) {
58
- const config = this.getConfig(apiName);
59
- const requestOptions = {
60
- method: "PATCH",
61
- headers: { Authorization: "Bearer " + config.jwt, "Content-Type": "application/json" },
62
- body: JSON.stringify(data)
63
- };
64
- return await this.fetchWithErrorHandling(config.url + path, requestOptions);
65
- }
66
- static async delete(path, apiName) {
67
- const config = this.getConfig(apiName);
68
- const requestOptions = {
69
- method: "DELETE",
70
- headers: { Authorization: "Bearer " + config.jwt }
71
- };
72
- try {
73
- const response = await fetch(config.url + path, requestOptions);
74
- if (!response.ok)
75
- await this.throwApiError(response);
76
- }
77
- catch (e) {
78
- throw (e);
79
- }
80
- }
81
- static async postAnonymous(path, data, apiName) {
82
- const config = this.getConfig(apiName);
83
- const requestOptions = {
84
- method: "POST",
85
- headers: { "Content-Type": "application/json" },
86
- body: JSON.stringify(data)
87
- };
88
- return await this.fetchWithErrorHandling(config.url + path, requestOptions);
89
- }
90
- static async fetchWithErrorHandling(url, requestOptions) {
91
- try {
92
- const response = await fetch(url, requestOptions);
93
- if (!response.ok)
94
- await this.throwApiError(response);
95
- else {
96
- if (response.status !== 204) {
97
- return response.json();
98
- }
99
- }
100
- }
101
- catch (e) {
102
- console.log("Failed to fetch from " + url);
103
- throw (e);
104
- }
105
- }
106
- static async throwApiError(response) {
107
- let msg = response.statusText;
108
- try {
109
- const json = await response.json();
110
- msg = json.errors[0];
111
- }
112
- catch { }
113
- ErrorHelper.logError(response.status.toString(), response.url, msg);
114
- throw new Error(msg || "Error");
115
- }
116
- }
117
- ApiHelper.apiConfigs = [];
118
- ApiHelper.isAuthenticated = false;
119
- //# sourceMappingURL=ApiHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApiHelper.js","sourceRoot":"","sources":["../../src/helpers/ApiHelper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,OAAO,SAAS;IAKrB,MAAM,CAAC,SAAS,CAAC,OAAe;QAC/B,IAAI,MAAiB,CAAC;QACtB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO;YAAE,MAAM,GAAG,MAAM,CAAA,CAAC,CAAC,CAAC,CAAC;QACvF,uEAAuE;QACvE,OAAO,MAAM,CAAC;IACf,CAAC;IAED,MAAM,CAAC,qBAAqB,CAAC,GAAW;QACvC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAChC,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;YACjB,MAAM,CAAC,WAAW,GAAG,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,OAAe,EAAE,GAAW,EAAE,WAAsC;QACzF,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAChC,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAChC,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;gBACjB,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;YAClC,CAAC;QACF,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,gBAAgB;QACtB,IAA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