lkd-web-kit 0.7.16 → 0.7.17
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.
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const navigation = require('next/navigation');
|
|
6
|
-
const router = require('next/router');
|
|
7
6
|
const React = require('react');
|
|
8
7
|
const index = require('./index.cjs');
|
|
9
8
|
|
|
10
9
|
const QP_BACK_URL_NAME = "backUrl";
|
|
11
10
|
function useNavigationHistory() {
|
|
12
11
|
const context = React.useContext(index.NavigationHistoryContext);
|
|
13
|
-
const router
|
|
12
|
+
const router = navigation.useRouter();
|
|
14
13
|
if (!context) {
|
|
15
14
|
throw new Error("useNavigationHistory debe usarse dentro de un NavigationHistoryProvider");
|
|
16
15
|
}
|
|
@@ -19,20 +18,20 @@ function useNavigationHistory() {
|
|
|
19
18
|
const goBack = (fallback) => {
|
|
20
19
|
const returnUrl = searchParams.get(QP_BACK_URL_NAME);
|
|
21
20
|
if (returnUrl) {
|
|
22
|
-
router
|
|
21
|
+
router.push(returnUrl);
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
24
|
if (history.length <= 1) {
|
|
26
|
-
router
|
|
25
|
+
router.push(fallback ?? "/");
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
const previousRoute = history[history.length - 2];
|
|
30
29
|
const currentRoute = history[history.length - 1];
|
|
31
30
|
if (history.length >= 3 && history[history.length - 3] === currentRoute) {
|
|
32
|
-
router
|
|
31
|
+
router.push(fallback ?? "/");
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
|
-
router
|
|
34
|
+
router.push(previousRoute ?? "/");
|
|
36
35
|
};
|
|
37
36
|
return {
|
|
38
37
|
history,
|