@selfcommunity/react-core 0.7.0-alpha.12 → 0.7.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/hooks/useFetchMenuFooter.d.ts +2 -2
- package/lib/cjs/hooks/useFetchMenuFooter.js +6 -6
- package/lib/esm/hooks/useFetchMenuFooter.d.ts +2 -2
- package/lib/esm/hooks/useFetchMenuFooter.js +7 -7
- package/lib/umd/258.js +2 -0
- package/lib/umd/react-core.js +1 -1
- package/package.json +4 -4
- package/lib/umd/440.js +0 -2
- /package/lib/umd/{440.js.LICENSE.txt → 258.js.LICENSE.txt} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SCCustomMenuType } from '@selfcommunity/types';
|
|
2
|
-
export default function useFetchMenuFooter(
|
|
1
|
+
import { SCCustomMenu, SCCustomMenuType } from '@selfcommunity/types';
|
|
2
|
+
export default function useFetchMenuFooter(id: SCCustomMenu, menu?: SCCustomMenuType | null): {
|
|
3
3
|
_menu: SCCustomMenuType;
|
|
4
4
|
loading: boolean;
|
|
5
5
|
};
|
|
@@ -4,16 +4,16 @@ const api_services_1 = require("@selfcommunity/api-services");
|
|
|
4
4
|
const utils_1 = require("@selfcommunity/utils");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const Errors_1 = require("../constants/Errors");
|
|
7
|
-
function useFetchMenuFooter(menu) {
|
|
7
|
+
function useFetchMenuFooter(id, menu = null) {
|
|
8
8
|
// STATES
|
|
9
9
|
const [_menu, setMenu] = (0, react_1.useState)(menu);
|
|
10
10
|
const [loading, setLoading] = (0, react_1.useState)(!menu);
|
|
11
11
|
/**
|
|
12
12
|
* Fetches custom pages
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
const fetchMenu = (0, react_1.useCallback)(() => {
|
|
15
15
|
setLoading(true);
|
|
16
|
-
api_services_1.CustomMenuService.
|
|
16
|
+
api_services_1.CustomMenuService.getASpecificCustomMenu(id)
|
|
17
17
|
.then((menu) => {
|
|
18
18
|
setMenu(menu);
|
|
19
19
|
})
|
|
@@ -21,16 +21,16 @@ function useFetchMenuFooter(menu) {
|
|
|
21
21
|
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, error);
|
|
22
22
|
})
|
|
23
23
|
.then(() => setLoading(false));
|
|
24
|
-
}
|
|
24
|
+
}, []);
|
|
25
25
|
/**
|
|
26
26
|
* On mount, fetches legal and custom pages
|
|
27
27
|
*/
|
|
28
28
|
(0, react_1.useEffect)(() => {
|
|
29
|
-
if (
|
|
29
|
+
if (menu) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
fetchMenu();
|
|
33
|
-
}, []);
|
|
33
|
+
}, [id]);
|
|
34
34
|
return { _menu, loading };
|
|
35
35
|
}
|
|
36
36
|
exports.default = useFetchMenuFooter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SCCustomMenuType } from '@selfcommunity/types';
|
|
2
|
-
export default function useFetchMenuFooter(
|
|
1
|
+
import { SCCustomMenu, SCCustomMenuType } from '@selfcommunity/types';
|
|
2
|
+
export default function useFetchMenuFooter(id: SCCustomMenu, menu?: SCCustomMenuType | null): {
|
|
3
3
|
_menu: SCCustomMenuType;
|
|
4
4
|
loading: boolean;
|
|
5
5
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { CustomMenuService } from '@selfcommunity/api-services';
|
|
2
2
|
import { Logger } from '@selfcommunity/utils';
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
4
|
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
5
|
-
export default function useFetchMenuFooter(menu) {
|
|
5
|
+
export default function useFetchMenuFooter(id, menu = null) {
|
|
6
6
|
// STATES
|
|
7
7
|
const [_menu, setMenu] = useState(menu);
|
|
8
8
|
const [loading, setLoading] = useState(!menu);
|
|
9
9
|
/**
|
|
10
10
|
* Fetches custom pages
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const fetchMenu = useCallback(() => {
|
|
13
13
|
setLoading(true);
|
|
14
|
-
CustomMenuService.
|
|
14
|
+
CustomMenuService.getASpecificCustomMenu(id)
|
|
15
15
|
.then((menu) => {
|
|
16
16
|
setMenu(menu);
|
|
17
17
|
})
|
|
@@ -19,15 +19,15 @@ export default function useFetchMenuFooter(menu) {
|
|
|
19
19
|
Logger.error(SCOPE_SC_CORE, error);
|
|
20
20
|
})
|
|
21
21
|
.then(() => setLoading(false));
|
|
22
|
-
}
|
|
22
|
+
}, []);
|
|
23
23
|
/**
|
|
24
24
|
* On mount, fetches legal and custom pages
|
|
25
25
|
*/
|
|
26
26
|
useEffect(() => {
|
|
27
|
-
if (
|
|
27
|
+
if (menu) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
fetchMenu();
|
|
31
|
-
}, []);
|
|
31
|
+
}, [id]);
|
|
32
32
|
return { _menu, loading };
|
|
33
33
|
}
|