@churchapps/apphelper 0.5.1 → 0.5.3

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 (100) hide show
  1. package/dist/components/Loading.d.ts +1 -0
  2. package/dist/components/Loading.d.ts.map +1 -1
  3. package/dist/components/Loading.js +1 -45
  4. package/dist/components/Loading.js.map +1 -1
  5. package/dist/components/notes/Notes.js +27 -27
  6. package/dist/helpers/AnalyticsHelper.d.ts.map +1 -1
  7. package/dist/helpers/AnalyticsHelper.js +21 -6
  8. package/dist/helpers/AnalyticsHelper.js.map +1 -1
  9. package/dist/public/css/cropper.css +309 -309
  10. package/dist/public/css/styles.css +111 -111
  11. package/dist/public/locales/de.json +270 -0
  12. package/dist/public/locales/en.json +277 -0
  13. package/dist/public/locales/es.json +272 -0
  14. package/dist/public/locales/fr.json +270 -0
  15. package/dist/public/locales/hi.json +270 -0
  16. package/dist/public/locales/it.json +270 -0
  17. package/dist/public/locales/ko.json +270 -0
  18. package/dist/public/locales/no.json +270 -0
  19. package/dist/public/locales/pt.json +270 -0
  20. package/dist/public/locales/ru.json +270 -0
  21. package/dist/public/locales/tl.json +270 -0
  22. package/dist/public/locales/zh.json +270 -0
  23. package/package.json +72 -72
  24. package/public/css/cropper.css +309 -309
  25. package/public/css/styles.css +111 -111
  26. package/public/locales/de.json +269 -269
  27. package/public/locales/en.json +276 -276
  28. package/public/locales/es.json +272 -272
  29. package/public/locales/fr.json +269 -269
  30. package/public/locales/hi.json +269 -269
  31. package/public/locales/it.json +269 -269
  32. package/public/locales/ko.json +269 -269
  33. package/public/locales/no.json +269 -269
  34. package/public/locales/pt.json +269 -269
  35. package/public/locales/ru.json +269 -269
  36. package/public/locales/tl.json +269 -269
  37. package/public/locales/zh.json +269 -269
  38. package/src/components/DisplayBox.tsx +83 -83
  39. package/src/components/ErrorMessages.tsx +28 -28
  40. package/src/components/ExportLink.tsx +81 -81
  41. package/src/components/FloatingSupport.tsx +18 -18
  42. package/src/components/FormCardPayment.tsx +184 -184
  43. package/src/components/FormSubmissionEdit.tsx +168 -168
  44. package/src/components/HelpIcon.tsx +12 -12
  45. package/src/components/ImageEditor.tsx +161 -161
  46. package/src/components/InputBox.tsx +96 -96
  47. package/src/components/Loading.tsx +31 -77
  48. package/src/components/PageHeader.tsx +110 -110
  49. package/src/components/PersonAvatar.tsx +77 -77
  50. package/src/components/QuestionEdit.tsx +99 -99
  51. package/src/components/SmallButton.tsx +42 -42
  52. package/src/components/SupportModal.tsx +32 -32
  53. package/src/components/TabPanel.tsx +28 -28
  54. package/src/components/gallery/GalleryModal.tsx +173 -173
  55. package/src/components/gallery/StockPhotos.tsx +95 -95
  56. package/src/components/gallery/index.ts +1 -1
  57. package/src/components/header/Banner.tsx +11 -11
  58. package/src/components/header/PrimaryMenu.tsx +100 -100
  59. package/src/components/header/SecondaryMenu.tsx +23 -23
  60. package/src/components/header/SecondaryMenuAlt.tsx +40 -40
  61. package/src/components/header/SiteHeader.tsx +207 -207
  62. package/src/components/header/SupportDrawer.tsx +111 -111
  63. package/src/components/header/index.tsx +2 -2
  64. package/src/components/index.tsx +20 -20
  65. package/src/components/notes/AddNote.tsx +180 -180
  66. package/src/components/notes/Note.tsx +68 -68
  67. package/src/components/notes/Notes.tsx +208 -208
  68. package/src/components/notes/index.ts +3 -3
  69. package/src/components/wrapper/AppList.tsx +19 -19
  70. package/src/components/wrapper/ChurchList.tsx +154 -154
  71. package/src/components/wrapper/NavItem.tsx +47 -47
  72. package/src/components/wrapper/NewPrivateMessage.tsx +253 -253
  73. package/src/components/wrapper/Notifications.tsx +223 -223
  74. package/src/components/wrapper/PrivateMessageDetails.tsx +112 -112
  75. package/src/components/wrapper/PrivateMessages.tsx +576 -576
  76. package/src/components/wrapper/UserMenu.tsx +383 -383
  77. package/src/components/wrapper/index.tsx +8 -8
  78. package/src/helpers/AnalyticsHelper.ts +44 -32
  79. package/src/helpers/AppearanceHelper.ts +73 -73
  80. package/src/helpers/ArrayHelper.ts +87 -87
  81. package/src/helpers/CurrencyHelper.ts +10 -10
  82. package/src/helpers/DateHelper.ts +104 -104
  83. package/src/helpers/ErrorHelper.ts +43 -43
  84. package/src/helpers/EventHelper.ts +49 -49
  85. package/src/helpers/FileHelper.ts +31 -31
  86. package/src/helpers/Locale.ts +457 -457
  87. package/src/helpers/NotificationService.ts +296 -296
  88. package/src/helpers/PersonHelper.ts +62 -62
  89. package/src/helpers/SlugHelper.ts +37 -37
  90. package/src/helpers/SocketHelper.ts +296 -296
  91. package/src/helpers/UniqueIdHelper.ts +36 -36
  92. package/src/helpers/UserHelper.ts +107 -107
  93. package/src/helpers/createEmotionCache.ts +17 -17
  94. package/src/helpers/index.ts +58 -58
  95. package/src/hooks/index.ts +3 -3
  96. package/src/hooks/useMountedState.ts +16 -16
  97. package/src/hooks/useNotifications.ts +93 -93
  98. package/src/index.ts +2 -2
  99. package/src/types/interface-extensions.d.ts +11 -11
  100. package/tsconfig.json +31 -31
@@ -1,96 +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
- </>);
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
96
  };
@@ -1,2 +1,2 @@
1
- export * from "./GalleryModal";
1
+ export * from "./GalleryModal";
2
2
  export * from "./StockPhotos";
@@ -1,11 +1,11 @@
1
- import React from "react";
2
-
3
- interface Props {
4
- children: React.ReactNode
5
- }
6
-
7
- export const Banner = (props:Props) => {
8
- return (<div id="banner">
9
- {props.children}
10
- </div>);
11
- }
1
+ import React from "react";
2
+
3
+ interface Props {
4
+ children: React.ReactNode
5
+ }
6
+
7
+ export const Banner = (props:Props) => {
8
+ return (<div id="banner">
9
+ {props.children}
10
+ </div>);
11
+ }
@@ -1,100 +1,100 @@
1
- import React, { useState, useRef } from "react";
2
- import { Box, Button, Icon, Paper, Popper, Grow, ClickAwayListener } from "@mui/material";
3
- import { NavItem } from "../wrapper/NavItem";
4
-
5
- interface Props {
6
- label: string;
7
- menuItems: { url: string; icon: string; label: string }[];
8
- onNavigate: (url: string) => void;
9
- }
10
-
11
- export const PrimaryMenu = (props: Props) => {
12
- const [open, setOpen] = useState(false);
13
- const anchorRef = useRef<HTMLButtonElement>(null);
14
-
15
- const handleToggle = () => {
16
- setOpen((prevOpen) => !prevOpen);
17
- };
18
-
19
- const handleClose = (event: Event | React.SyntheticEvent) => {
20
- if (
21
- anchorRef.current &&
22
- anchorRef.current.contains(event.target as HTMLElement)
23
- ) {
24
- return;
25
- }
26
- setOpen(false);
27
- };
28
-
29
- const handleItemClick = (url: string) => {
30
- setOpen(false);
31
- props.onNavigate(url);
32
- };
33
-
34
- const getNavItems = () => {
35
- let result: React.ReactElement[] = [];
36
- props.menuItems.forEach((item) => {
37
- result.push(
38
- <NavItem
39
- url={item.url}
40
- label={item.label.toUpperCase()}
41
- icon={item.icon}
42
- key={item.url}
43
- onNavigate={handleItemClick}
44
- />
45
- );
46
- });
47
- return result;
48
- };
49
-
50
- return (
51
- <>
52
- <Button
53
- ref={anchorRef}
54
- onClick={handleToggle}
55
- color="inherit"
56
- endIcon={<Icon>expand_more</Icon>}
57
- id="primaryNavButton"
58
- >
59
- <img src="/images/logo-icon.png" alt="Primary Menu" />
60
- <h2>{props.label}</h2>
61
- </Button>
62
-
63
- <Popper
64
- open={open}
65
- anchorEl={anchorRef.current}
66
- role={undefined}
67
- placement="bottom-end"
68
- transition
69
- disablePortal={true}
70
- style={{ zIndex: 1300, color: "#FFF" }}
71
- >
72
- {({ TransitionProps }) => (
73
- <Grow {...TransitionProps}>
74
- <Paper
75
- elevation={3}
76
- sx={{
77
- backgroundColor: "var(--c1)",
78
- color: "#FFF",
79
- minWidth: 300,
80
- paddingY: "10px",
81
- filter: "drop-shadow(0px 2px 8px rgba(0,0,0,0.32))",
82
- }}
83
- >
84
- <ClickAwayListener onClickAway={handleClose}>
85
- <Box
86
- sx={{
87
- "& a": { color: "#FFF", textDecoration: "none" },
88
- "& a:hover": { color: "#DDD" },
89
- }}
90
- >
91
- {getNavItems()}
92
- </Box>
93
- </ClickAwayListener>
94
- </Paper>
95
- </Grow>
96
- )}
97
- </Popper>
98
- </>
99
- );
100
- };
1
+ import React, { useState, useRef } from "react";
2
+ import { Box, Button, Icon, Paper, Popper, Grow, ClickAwayListener } from "@mui/material";
3
+ import { NavItem } from "../wrapper/NavItem";
4
+
5
+ interface Props {
6
+ label: string;
7
+ menuItems: { url: string; icon: string; label: string }[];
8
+ onNavigate: (url: string) => void;
9
+ }
10
+
11
+ export const PrimaryMenu = (props: Props) => {
12
+ const [open, setOpen] = useState(false);
13
+ const anchorRef = useRef<HTMLButtonElement>(null);
14
+
15
+ const handleToggle = () => {
16
+ setOpen((prevOpen) => !prevOpen);
17
+ };
18
+
19
+ const handleClose = (event: Event | React.SyntheticEvent) => {
20
+ if (
21
+ anchorRef.current &&
22
+ anchorRef.current.contains(event.target as HTMLElement)
23
+ ) {
24
+ return;
25
+ }
26
+ setOpen(false);
27
+ };
28
+
29
+ const handleItemClick = (url: string) => {
30
+ setOpen(false);
31
+ props.onNavigate(url);
32
+ };
33
+
34
+ const getNavItems = () => {
35
+ let result: React.ReactElement[] = [];
36
+ props.menuItems.forEach((item) => {
37
+ result.push(
38
+ <NavItem
39
+ url={item.url}
40
+ label={item.label.toUpperCase()}
41
+ icon={item.icon}
42
+ key={item.url}
43
+ onNavigate={handleItemClick}
44
+ />
45
+ );
46
+ });
47
+ return result;
48
+ };
49
+
50
+ return (
51
+ <>
52
+ <Button
53
+ ref={anchorRef}
54
+ onClick={handleToggle}
55
+ color="inherit"
56
+ endIcon={<Icon>expand_more</Icon>}
57
+ id="primaryNavButton"
58
+ >
59
+ <img src="/images/logo-icon.png" alt="Primary Menu" />
60
+ <h2>{props.label}</h2>
61
+ </Button>
62
+
63
+ <Popper
64
+ open={open}
65
+ anchorEl={anchorRef.current}
66
+ role={undefined}
67
+ placement="bottom-end"
68
+ transition
69
+ disablePortal={true}
70
+ style={{ zIndex: 1300, color: "#FFF" }}
71
+ >
72
+ {({ TransitionProps }) => (
73
+ <Grow {...TransitionProps}>
74
+ <Paper
75
+ elevation={3}
76
+ sx={{
77
+ backgroundColor: "var(--c1)",
78
+ color: "#FFF",
79
+ minWidth: 300,
80
+ paddingY: "10px",
81
+ filter: "drop-shadow(0px 2px 8px rgba(0,0,0,0.32))",
82
+ }}
83
+ >
84
+ <ClickAwayListener onClickAway={handleClose}>
85
+ <Box
86
+ sx={{
87
+ "& a": { color: "#FFF", textDecoration: "none" },
88
+ "& a:hover": { color: "#DDD" },
89
+ }}
90
+ >
91
+ {getNavItems()}
92
+ </Box>
93
+ </ClickAwayListener>
94
+ </Paper>
95
+ </Grow>
96
+ )}
97
+ </Popper>
98
+ </>
99
+ );
100
+ };
@@ -1,23 +1,23 @@
1
- import { Chip } from "@mui/material";
2
-
3
- interface Props {
4
- label: string,
5
- menuItems: { url: string, label: string }[]
6
- onNavigate: (url: string) => void;
7
- }
8
-
9
- export const SecondaryMenu= (props:Props) => {
10
-
11
- const getItems = () => {
12
- const result:any[] = [];
13
- props.menuItems.forEach((item, index) => {
14
- if (item.label === props.label) result.push(<Chip key={index} onClick={() => props.onNavigate(item.url)} label={item.label} component="a" variant="filled" clickable style={{backgroundColor:"var(--c1d2)", color:"#FFF", fontSize:16}} />);
15
- else result.push(<a key={index} href="about:blank" onClick={(e) => { e.preventDefault(); props.onNavigate(item.url) }} style={{ color:"#FFF", textDecoration: "none", marginLeft:10, marginRight:10}}>{item.label}</a>);
16
- });
17
- return result;
18
- }
19
-
20
- return (<div id="secondaryMenu">
21
- {getItems()}
22
- </div>)
23
- }
1
+ import { Chip } from "@mui/material";
2
+
3
+ interface Props {
4
+ label: string,
5
+ menuItems: { url: string, label: string }[]
6
+ onNavigate: (url: string) => void;
7
+ }
8
+
9
+ export const SecondaryMenu= (props:Props) => {
10
+
11
+ const getItems = () => {
12
+ const result:any[] = [];
13
+ props.menuItems.forEach((item, index) => {
14
+ if (item.label === props.label) result.push(<Chip key={index} onClick={() => props.onNavigate(item.url)} label={item.label} component="a" variant="filled" clickable style={{backgroundColor:"var(--c1d2)", color:"#FFF", fontSize:16}} />);
15
+ else result.push(<a key={index} href="about:blank" onClick={(e) => { e.preventDefault(); props.onNavigate(item.url) }} style={{ color:"#FFF", textDecoration: "none", marginLeft:10, marginRight:10}}>{item.label}</a>);
16
+ });
17
+ return result;
18
+ }
19
+
20
+ return (<div id="secondaryMenu">
21
+ {getItems()}
22
+ </div>)
23
+ }
@@ -1,40 +1,40 @@
1
- import React from "react";
2
- import { Box, Button, Icon, Menu } from "@mui/material";
3
- import { NavItem } from "../wrapper/NavItem";
4
-
5
- interface Props {
6
- label: string,
7
- menuItems: { url: string, label: string }[]
8
- onNavigate: (url: string) => void;
9
- }
10
-
11
- export const SecondaryMenuAlt = (props:Props) => {
12
- const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
13
- const handleClose = () => { setAnchorEl(null); };
14
- const open = Boolean(anchorEl);
15
-
16
- const handleClick = (e: React.MouseEvent<HTMLElement>) => {
17
- e.preventDefault();
18
- setAnchorEl(e.currentTarget);
19
- };
20
-
21
- const getItems = () => {
22
- const result:any[] = [];
23
- props.menuItems.forEach(item => {
24
- result.push(<NavItem url={item.url} label={item.label} key={item.url} onNavigate={props.onNavigate} icon="people" />);
25
- });
26
- return result;
27
- }
28
-
29
- return (
30
- <div id="secondaryMenuAlt">
31
- <Button onClick={handleClick} color="inherit" aria-controls={open ? "account-menu" : undefined} aria-haspopup="true" aria-expanded={open ? "true" : undefined} endIcon={<Icon>expand_more</Icon>} id="secondaryMenuButton">
32
- <h3 style={{lineHeight:1}}>{props.label}</h3>
33
- </Button>
34
- <Menu anchorEl={anchorEl} id="account-menu" open={anchorEl!==null} onClose={handleClose} transformOrigin={{ horizontal: "right", vertical: "top" }} anchorOrigin={{ horizontal: "right", vertical: "bottom" }} sx={{ "& .MuiBox-root": { borderBottom: 0 } }}>
35
- <Box sx={{ borderBottom: 1, borderColor: "divider" }}>
36
- {getItems()}
37
- </Box>
38
- </Menu>
39
- </div>)
40
- }
1
+ import React from "react";
2
+ import { Box, Button, Icon, Menu } from "@mui/material";
3
+ import { NavItem } from "../wrapper/NavItem";
4
+
5
+ interface Props {
6
+ label: string,
7
+ menuItems: { url: string, label: string }[]
8
+ onNavigate: (url: string) => void;
9
+ }
10
+
11
+ export const SecondaryMenuAlt = (props:Props) => {
12
+ const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
13
+ const handleClose = () => { setAnchorEl(null); };
14
+ const open = Boolean(anchorEl);
15
+
16
+ const handleClick = (e: React.MouseEvent<HTMLElement>) => {
17
+ e.preventDefault();
18
+ setAnchorEl(e.currentTarget);
19
+ };
20
+
21
+ const getItems = () => {
22
+ const result:any[] = [];
23
+ props.menuItems.forEach(item => {
24
+ result.push(<NavItem url={item.url} label={item.label} key={item.url} onNavigate={props.onNavigate} icon="people" />);
25
+ });
26
+ return result;
27
+ }
28
+
29
+ return (
30
+ <div id="secondaryMenuAlt">
31
+ <Button onClick={handleClick} color="inherit" aria-controls={open ? "account-menu" : undefined} aria-haspopup="true" aria-expanded={open ? "true" : undefined} endIcon={<Icon>expand_more</Icon>} id="secondaryMenuButton">
32
+ <h3 style={{lineHeight:1}}>{props.label}</h3>
33
+ </Button>
34
+ <Menu anchorEl={anchorEl} id="account-menu" open={anchorEl!==null} onClose={handleClose} transformOrigin={{ horizontal: "right", vertical: "top" }} anchorOrigin={{ horizontal: "right", vertical: "bottom" }} sx={{ "& .MuiBox-root": { borderBottom: 0 } }}>
35
+ <Box sx={{ borderBottom: 1, borderColor: "divider" }}>
36
+ {getItems()}
37
+ </Box>
38
+ </Menu>
39
+ </div>)
40
+ }