1223.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. "use strict";
  2. exports.id = 1223;
  3. exports.ids = [1223];
  4. exports.modules = {
  5. /***/ 966:
  6. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  7. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  8. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  10. /* harmony export */ });
  11. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  12. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  13. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  14. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  15. /* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(71853);
  16. /* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(next_router__WEBPACK_IMPORTED_MODULE_2__);
  17. /* harmony import */ var _utils_navigation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(57933);
  18. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_utils_navigation__WEBPACK_IMPORTED_MODULE_3__]);
  19. _utils_navigation__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  20. const RedirectToLoginPage = ()=>{
  21. const router = (0,next_router__WEBPACK_IMPORTED_MODULE_2__.useRouter)();
  22. (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{
  23. const { asPath } = router;
  24. router.replace((0,_utils_navigation__WEBPACK_IMPORTED_MODULE_3__/* .getLoginNavigationUrl */ .gk)(asPath));
  25. }, [
  26. router
  27. ]);
  28. return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {});
  29. };
  30. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (RedirectToLoginPage);
  31. __webpack_async_result__();
  32. } catch(e) { __webpack_async_result__(e); } });
  33. /***/ }),
  34. /***/ 1223:
  35. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  36. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  37. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  38. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  39. /* harmony export */ });
  40. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  41. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  42. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  43. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  44. /* harmony import */ var _RedirectToLoginPage__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(966);
  45. /* harmony import */ var _utils_auth_login__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(22197);
  46. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_RedirectToLoginPage__WEBPACK_IMPORTED_MODULE_2__, _utils_auth_login__WEBPACK_IMPORTED_MODULE_3__]);
  47. ([_RedirectToLoginPage__WEBPACK_IMPORTED_MODULE_2__, _utils_auth_login__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  48. /**
  49. * withAuth is a Higher-Order Component (HOC) that wraps a component and checks if the user is authenticated.
  50. * If the user is authenticated, it renders the wrapped component.
  51. * If the user is not authenticated, it redirects the user to the login page.
  52. *
  53. * @param {React.ComponentType} WrappedComponent - The component to wrap and protect with authentication check.
  54. *
  55. * @returns {React.ComponentType} If the user is authenticated, returns the WrappedComponent.
  56. * If not, returns RedirectToLoginPage component.
  57. *
  58. * @example
  59. * const ProtectedComponent = withAuth(MyComponent);
  60. */ const withAuth = (WrappedComponent)=>{
  61. const WithAuth = (props)=>{
  62. const { 0: isReady , 1: setIsReady } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
  63. /**
  64. * we need to wait for the initial render to check if the user is authenticated
  65. * because when it's server-side rendered, the user is not authenticated yet
  66. */ (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{
  67. setIsReady(true);
  68. }, []);
  69. if (!isReady) {
  70. return null; // or return a loading spinner
  71. }
  72. return (0,_utils_auth_login__WEBPACK_IMPORTED_MODULE_3__/* .isLoggedIn */ .jl)() ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(WrappedComponent, {
  73. ...props
  74. }) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_RedirectToLoginPage__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {});
  75. };
  76. return WithAuth;
  77. };
  78. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (withAuth);
  79. __webpack_async_result__();
  80. } catch(e) { __webpack_async_result__(e); } });
  81. /***/ })
  82. };
  83. ;
  84. //# sourceMappingURL=1223.js.map