@bigbinary/neeto-commons-frontend 4.6.2 → 4.6.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.
- package/cjs/configs/babel.js +0 -1
- package/cjs/initializers/axiosInitializer/index.js +5 -7
- package/cjs/initializers/axiosInitializer/index.js.map +1 -1
- package/cjs/initializers/i18n.js +3 -3
- package/cjs/initializers/i18n.js.map +1 -1
- package/cjs/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js +2 -2
- package/cjs/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js.map +1 -1
- package/cjs/react-utils/PrivateRoute/PrivateRoute.js +2 -3
- package/cjs/react-utils/PrivateRoute/PrivateRoute.js.map +1 -1
- package/cjs/react-utils/metaClick/metaClick.js +2 -3
- package/cjs/react-utils/metaClick/metaClick.js.map +1 -1
- package/cjs/react-utils/useBreakpoints/index.js +2 -3
- package/cjs/react-utils/useBreakpoints/index.js.map +1 -1
- package/cjs/react-utils/useDisplayErrorPage/useDisplayErrorPage.js +2 -3
- package/cjs/react-utils/useDisplayErrorPage/useDisplayErrorPage.js.map +1 -1
- package/cjs/react-utils/useLocalStorage/useLocalStorage.js +2 -2
- package/cjs/react-utils/useLocalStorage/useLocalStorage.js.map +1 -1
- package/cjs/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js +4 -4
- package/cjs/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js.map +1 -1
- package/cjs/react-utils/usePersistedQuery/usePersistedQuery.js +3 -3
- package/cjs/react-utils/usePersistedQuery/usePersistedQuery.js.map +1 -1
- package/cjs/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js +8 -11
- package/cjs/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js.map +1 -1
- package/cjs/react-utils/useRestoreScrollPosition/useRestoreScrollPosition.js +8 -10
- package/cjs/react-utils/useRestoreScrollPosition/useRestoreScrollPosition.js.map +1 -1
- package/cjs/react-utils/withImmutableActions/withImmutableActions.js +3 -5
- package/cjs/react-utils/withImmutableActions/withImmutableActions.js.map +1 -1
- package/cjs/utils/axios.js +2 -2
- package/cjs/utils/axios.js.map +1 -1
- package/cjs/utils/buildNestedAttributesPayload.js +2 -2
- package/cjs/utils/buildNestedAttributesPayload.js.map +1 -1
- package/cjs/utils/general.js +7 -12
- package/cjs/utils/general.js.map +1 -1
- package/configs/babel.js +0 -1
- package/initializers/axiosInitializer/index.js +5 -7
- package/initializers/axiosInitializer/index.js.map +1 -1
- package/initializers/i18n.js +3 -3
- package/initializers/i18n.js.map +1 -1
- package/package.json +1 -1
- package/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js +2 -2
- package/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js.map +1 -1
- package/react-utils/PrivateRoute/PrivateRoute.js +2 -3
- package/react-utils/PrivateRoute/PrivateRoute.js.map +1 -1
- package/react-utils/metaClick/metaClick.js +2 -2
- package/react-utils/metaClick/metaClick.js.map +1 -1
- package/react-utils/useBreakpoints/index.js +2 -2
- package/react-utils/useBreakpoints/index.js.map +1 -1
- package/react-utils/useDisplayErrorPage/useDisplayErrorPage.js +2 -2
- package/react-utils/useDisplayErrorPage/useDisplayErrorPage.js.map +1 -1
- package/react-utils/useLocalStorage/useLocalStorage.js +2 -2
- package/react-utils/useLocalStorage/useLocalStorage.js.map +1 -1
- package/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js +4 -4
- package/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js.map +1 -1
- package/react-utils/usePersistedQuery/usePersistedQuery.js +3 -3
- package/react-utils/usePersistedQuery/usePersistedQuery.js.map +1 -1
- package/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js +8 -11
- package/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js.map +1 -1
- package/react-utils/useRestoreScrollPosition/useRestoreScrollPosition.js +8 -10
- package/react-utils/useRestoreScrollPosition/useRestoreScrollPosition.js.map +1 -1
- package/react-utils/withImmutableActions/withImmutableActions.js +3 -4
- package/react-utils/withImmutableActions/withImmutableActions.js.map +1 -1
- package/utils/axios.js +2 -2
- package/utils/axios.js.map +1 -1
- package/utils/buildNestedAttributesPayload.js +2 -2
- package/utils/buildNestedAttributesPayload.js.map +1 -1
- package/utils/general.js +7 -12
- package/utils/general.js.map +1 -1
package/cjs/configs/babel.js
CHANGED
|
@@ -5,15 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = initializeAxios;
|
|
8
|
-
var _omit2 = _interopRequireDefault(require("ramda/es/omit"));
|
|
9
|
-
var _evolve2 = _interopRequireDefault(require("ramda/es/evolve"));
|
|
10
|
-
var _dissoc2 = _interopRequireDefault(require("ramda/es/dissoc"));
|
|
11
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
10
|
var _axios = _interopRequireDefault(require("axios"));
|
|
14
11
|
var _i18next = _interopRequireDefault(require("i18next"));
|
|
15
12
|
var _neetoCist = require("@bigbinary/neeto-cist");
|
|
16
13
|
var _Toastr = _interopRequireDefault(require("@bigbinary/neetoui/Toastr"));
|
|
14
|
+
var _ramda = require("ramda");
|
|
17
15
|
var _reactToastify = require("react-toastify");
|
|
18
16
|
var _useDisplayErrorPage = require("../../react-utils/useDisplayErrorPage");
|
|
19
17
|
var _axios2 = require("../../utils/axios");
|
|
@@ -71,7 +69,7 @@ var showSuccessToastr = function showSuccessToastr(response) {
|
|
|
71
69
|
var errorToastId = requestErrorToasts[toastIdKey];
|
|
72
70
|
if (errorToastId) {
|
|
73
71
|
_reactToastify.toast.dismiss(errorToastId);
|
|
74
|
-
requestErrorToasts = (0,
|
|
72
|
+
requestErrorToasts = (0, _ramda.dissoc)(toastIdKey, requestErrorToasts);
|
|
75
73
|
}
|
|
76
74
|
if ((0, _neetoCist.matches)({
|
|
77
75
|
showThumbsUpToastr: true
|
|
@@ -239,15 +237,15 @@ var buildErrorResponseHandler = function buildErrorResponseHandler(skip) {
|
|
|
239
237
|
var cleanupCredentialsForCrossOrigin = function cleanupCredentialsForCrossOrigin(request) {
|
|
240
238
|
if (!request.url.includes("://")) return request;
|
|
241
239
|
if (request.url.includes(window.location.hostname)) return request;
|
|
242
|
-
return (0,
|
|
243
|
-
headers: (0,
|
|
240
|
+
return (0, _ramda.evolve)({
|
|
241
|
+
headers: (0, _ramda.omit)([_constants.HEADERS_KEYS.xCsrfToken])
|
|
244
242
|
})(request);
|
|
245
243
|
};
|
|
246
244
|
var transformDataToSnakeCase = function transformDataToSnakeCase(request) {
|
|
247
245
|
var _request$transformReq = request.transformRequestCase,
|
|
248
246
|
transformRequestCase = _request$transformReq === void 0 ? true : _request$transformReq;
|
|
249
247
|
if (!transformRequestCase) return request;
|
|
250
|
-
return (0,
|
|
248
|
+
return (0, _ramda.evolve)({
|
|
251
249
|
data: _neetoCist.serializeKeysToSnakeCase,
|
|
252
250
|
params: _neetoCist.serializeKeysToSnakeCase
|
|
253
251
|
}, request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_axios","_interopRequireDefault","require","_i18next","_neetoCist","_Toastr","_reactToastify","_useDisplayErrorPage","_axios2","_paramsSerializer","_constants","checkOnlineInterval","requestErrorToasts","shouldNot","skip","_typeof2","shouldShowToastr","response","isNotEmpty","notice","noticeCode","setAuthHeaders","_document$querySelect","axios","defaults","headers","_defineProperty2","HEADERS_KEYS","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","keysToCamelCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config","_response$config$show","showToastr","requestUrl","url","requestMethod","method","toastIdKey","concat","errorToastId","toast","dismiss","_dissoc2","matches","showThumbsUpToastr","Toastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","resetAuthTokens","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","i18next","t","dismissToastInterval","setInterval","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","MAXIMUM_OFFLINE_DURATION","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref3$show422ErrorToa","show422ErrorToastr","_ref3$url","_ref3$method","_ref4","message","code","toastrContent","skippedStatusCodes","includes","isCancel","globalProps","railsEnv","getUrlPathName","URL","_unused","handle404ErrorResponse","_error$config4","_error$response4","_ref5","_ref5$show404ErrorPag","show404ErrorPage","_ref5$show403ErrorPag","show403ErrorPage","_error$request","fullUrl","request","responseURL","useErrorDisplayStore","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","_evolve2","_omit2","transformDataToSnakeCase","_request$transformReq","transformRequestCase","serializeKeysToSnakeCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer","setParamsSerializer"],"sources":["../../../../src/initializers/axiosInitializer/index.js"],"sourcesContent":["import axios from \"axios\";\nimport i18next from \"i18next\";\nimport {\n isNotEmpty,\n keysToCamelCase,\n matches,\n serializeKeysToSnakeCase,\n} from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { dissoc, evolve, omit } from \"ramda\";\nimport { toast } from \"react-toastify\";\nimport { useErrorDisplayStore } from \"react-utils/useDisplayErrorPage\";\nimport { resetAuthTokens } from \"utils/axios\";\n\nimport setParamsSerializer from \"./paramsSerializer\";\n\nimport { HEADERS_KEYS, MAXIMUM_OFFLINE_DURATION } from \"../constants\";\n\nlet checkOnlineInterval = null;\nlet requestErrorToasts = {};\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n (typeof response === \"string\" && isNotEmpty(response)) ||\n (typeof response === \"object\" && (response?.notice || response?.noticeCode));\n\nconst setAuthHeaders = () => {\n // @ts-ignore\n axios.defaults.headers = {\n [HEADERS_KEYS.accept]: \"application/json\",\n [HEADERS_KEYS.contentType]: \"application/json\",\n [HEADERS_KEYS.xCsrfToken]: document\n .querySelector('[name=\"csrf-token\"]')\n ?.getAttribute(\"content\"),\n };\n};\n\n// pipe function from ramda doesn't accept array of functions.\n// We can't use spread operator too. So this is a workaround.\nconst createPipe = functions => data =>\n functions.reduce((acc, fn) => fn(acc), data);\n\nconst transformResponseKeysToCamelCase = response => {\n const { transformResponseCase = true } = response.config;\n\n if (response.data && transformResponseCase) {\n response.data = keysToCamelCase(response.data);\n }\n\n return response;\n};\n\nconst transformErrorKeysToCamelCase = error => {\n const { transformResponseCase = true } = error.config ?? {};\n\n if (error.response?.data && transformResponseCase) {\n error.response.data = keysToCamelCase(error.response.data);\n }\n\n return error;\n};\n\nconst showSuccessToastr = response => {\n const {\n showToastr = true,\n url: requestUrl,\n method: requestMethod,\n } = response.config;\n if (!showToastr) return response;\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) {\n toast.dismiss(errorToastId);\n requestErrorToasts = dissoc(toastIdKey, requestErrorToasts);\n }\n\n if (matches({ showThumbsUpToastr: true }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (matches({ noticeCode: \"thumbs_up\" }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (shouldShowToastr(response.data)) {\n Toastr.success(response.data);\n }\n\n return response;\n};\n\nconst pullDataFromResponse = response => {\n const { includeMetadataInResponse = false } = response.config;\n\n return includeMetadataInResponse ? response : response.data;\n};\n\nconst buildSuccessResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformResponseKeysToCamelCase);\n\n if (!skip?.showToastr) interceptors.push(showSuccessToastr);\n\n if (!skip?.pullDataFromResponse) interceptors.push(pullDataFromResponse);\n\n return createPipe(interceptors);\n};\n\nconst handleUnauthorizedErrorResponse = error => {\n if (error.response?.status !== 401) return error;\n\n resetAuthTokens();\n\n const { redirectOnError = true } = error.config ?? {};\n if (redirectOnError) {\n setTimeout(() => {\n const redirectTo =\n window.location.pathname === \"/login\"\n ? \"/login\"\n : `/login?redirect_uri=${encodeURIComponent(window.location.href)}`;\n\n // eslint-disable-next-line xss/no-location-href-assign\n window.location.href = redirectTo;\n }, 300);\n }\n\n return error;\n};\n\nconst isOnline = () => window.navigator.onLine;\n\nconst showOfflineToastr = () => {\n const toastId = Toastr.error(\n i18next.t(\"neetoCommons.toastr.error.networkError\")\n );\n\n if (toastId) {\n const dismissToastInterval = setInterval(() => {\n if (!isOnline()) return;\n\n toast.dismiss(toastId);\n clearInterval(dismissToastInterval);\n checkOnlineInterval = null;\n }, 1000);\n }\n};\n\nconst handleNetworkError = error => {\n if (checkOnlineInterval) return error;\n\n const startTime = Date.now();\n\n checkOnlineInterval = setInterval(() => {\n const elapsedTime = Date.now() - startTime;\n\n if (isOnline()) {\n clearInterval(checkOnlineInterval);\n checkOnlineInterval = null;\n } else if (elapsedTime >= MAXIMUM_OFFLINE_DURATION) {\n clearInterval(checkOnlineInterval);\n showOfflineToastr();\n }\n }, 1000);\n\n return error;\n};\n\nconst showErrorToastr = error => {\n const {\n showToastr = true,\n show422ErrorToastr = true,\n url: requestUrl = \"\",\n method: requestMethod = \"\",\n } = error.config ?? {};\n const { status } = error.response ?? {};\n\n if (!showToastr) return error;\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n let shouldShowToastr = false,\n toastrContent = error;\n\n const skippedStatusCodes = [403, 404, 520, 422];\n if (!skippedStatusCodes.includes(status) && !axios.isCancel(error)) {\n // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.\n // We handle cloudflare error differently for production and other environments.\n shouldShowToastr = true;\n }\n\n if (status === 422 && show422ErrorToastr) shouldShowToastr = true;\n\n if (status === 520) {\n shouldShowToastr = true;\n if (globalProps.railsEnv === \"production\") {\n toastrContent = i18next.t(\"generic.error\");\n }\n }\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) toast.dismiss(errorToastId);\n\n if (shouldShowToastr) {\n if (errorToastId) {\n // if there's an existing toastr with the same message, the onClose callback in the neetoUI which\n // removes the toastr from the unique list will be fired only after the toast is completely removed\n // from the UI. If there's no delay, the new toastr will be considered as duplicate and ignored.\n setTimeout(() => {\n requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }, 1200);\n } else requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }\n\n return error;\n};\n\nconst getUrlPathName = url => {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\nconst handle404ErrorResponse = error => {\n const { show404ErrorPage = true, show403ErrorPage = true } =\n error.config ?? {};\n\n const status = error.response?.status;\n if (\n (status === 404 && show404ErrorPage) ||\n (status === 403 && show403ErrorPage)\n ) {\n const fullUrl = error.request?.responseURL || error.config.url;\n useErrorDisplayStore.setState({\n showErrorPage: true,\n statusCode: status,\n failedApiUrl: fullUrl,\n failedApiPath: getUrlPathName(fullUrl),\n });\n }\n\n return error;\n};\n\nconst buildErrorResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformErrorKeysToCamelCase);\n\n if (!skip?.show404ErrorPage) interceptors.push(handle404ErrorResponse);\n\n if (!skip?.logoutOn401) interceptors.push(handleUnauthorizedErrorResponse);\n\n if (!skip?.showToastr) interceptors.push(showErrorToastr);\n\n interceptors.push(Promise.reject.bind(Promise));\n\n return createPipe(interceptors);\n};\n\nconst cleanupCredentialsForCrossOrigin = request => {\n if (!request.url.includes(\"://\")) return request;\n\n if (request.url.includes(window.location.hostname)) return request;\n\n return evolve({ headers: omit([HEADERS_KEYS.xCsrfToken]) })(request);\n};\n\nconst transformDataToSnakeCase = request => {\n const { transformRequestCase = true } = request;\n\n if (!transformRequestCase) return request;\n\n return evolve(\n { data: serializeKeysToSnakeCase, params: serializeKeysToSnakeCase },\n request\n );\n};\n\nconst addRequestInterceptors = skip => {\n if (!skip?.cleanCredentialsForCrossOrigin) {\n axios.interceptors.request.use(cleanupCredentialsForCrossOrigin);\n }\n\n if (!skip?.transformCase) {\n axios.interceptors.request.use(transformDataToSnakeCase);\n }\n};\n\nconst addResponseInterceptors = skip => {\n axios.interceptors.response.use(\n buildSuccessResponseHandler(skip),\n buildErrorResponseHandler(skip)\n );\n};\n\nconst registerIntercepts = skip => {\n if (shouldNot(skip?.request)) addRequestInterceptors(skip?.request);\n\n if (shouldNot(skip?.response)) addResponseInterceptors(skip?.response);\n};\n\nexport default function initializeAxios(skip) {\n if (!skip?.baseURL) axios.defaults.baseURL = \"/\";\n\n if (!skip?.authHeaders) setAuthHeaders();\n\n if (!skip?.paramsSerializer) setParamsSerializer();\n\n if (shouldNot(skip?.interceptors)) registerIntercepts(skip?.interceptors);\n}\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAKmB,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAGnB,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAEA,IAAAO,iBAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEA,IAAAQ,UAAA,GAAAR,OAAA;AAEA,IAAIS,mBA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AAE6D,YAAY,CAAC;AAC3E","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_axios","_interopRequireDefault","require","_i18next","_neetoCist","_Toastr","_ramda","_reactToastify","_useDisplayErrorPage","_axios2","_paramsSerializer","_constants","checkOnlineInterval","requestErrorToasts","shouldNot","skip","_typeof2","shouldShowToastr","response","isNotEmpty","notice","noticeCode","setAuthHeaders","_document$querySelect","axios","defaults","headers","_defineProperty2","HEADERS_KEYS","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","keysToCamelCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config","_response$config$show","showToastr","requestUrl","url","requestMethod","method","toastIdKey","concat","errorToastId","toast","dismiss","dissoc","matches","showThumbsUpToastr","Toastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","resetAuthTokens","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","i18next","t","dismissToastInterval","setInterval","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","MAXIMUM_OFFLINE_DURATION","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref3$show422ErrorToa","show422ErrorToastr","_ref3$url","_ref3$method","_ref4","message","code","toastrContent","skippedStatusCodes","includes","isCancel","globalProps","railsEnv","getUrlPathName","URL","_unused","handle404ErrorResponse","_error$config4","_error$response4","_ref5","_ref5$show404ErrorPag","show404ErrorPage","_ref5$show403ErrorPag","show403ErrorPage","_error$request","fullUrl","request","responseURL","useErrorDisplayStore","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","evolve","omit","transformDataToSnakeCase","_request$transformReq","transformRequestCase","serializeKeysToSnakeCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer","setParamsSerializer"],"sources":["../../../../src/initializers/axiosInitializer/index.js"],"sourcesContent":["import axios from \"axios\";\nimport i18next from \"i18next\";\nimport {\n isNotEmpty,\n keysToCamelCase,\n matches,\n serializeKeysToSnakeCase,\n} from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { dissoc, evolve, omit } from \"ramda\";\nimport { toast } from \"react-toastify\";\nimport { useErrorDisplayStore } from \"react-utils/useDisplayErrorPage\";\nimport { resetAuthTokens } from \"utils/axios\";\n\nimport setParamsSerializer from \"./paramsSerializer\";\n\nimport { HEADERS_KEYS, MAXIMUM_OFFLINE_DURATION } from \"../constants\";\n\nlet checkOnlineInterval = null;\nlet requestErrorToasts = {};\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n (typeof response === \"string\" && isNotEmpty(response)) ||\n (typeof response === \"object\" && (response?.notice || response?.noticeCode));\n\nconst setAuthHeaders = () => {\n // @ts-ignore\n axios.defaults.headers = {\n [HEADERS_KEYS.accept]: \"application/json\",\n [HEADERS_KEYS.contentType]: \"application/json\",\n [HEADERS_KEYS.xCsrfToken]: document\n .querySelector('[name=\"csrf-token\"]')\n ?.getAttribute(\"content\"),\n };\n};\n\n// pipe function from ramda doesn't accept array of functions.\n// We can't use spread operator too. So this is a workaround.\nconst createPipe = functions => data =>\n functions.reduce((acc, fn) => fn(acc), data);\n\nconst transformResponseKeysToCamelCase = response => {\n const { transformResponseCase = true } = response.config;\n\n if (response.data && transformResponseCase) {\n response.data = keysToCamelCase(response.data);\n }\n\n return response;\n};\n\nconst transformErrorKeysToCamelCase = error => {\n const { transformResponseCase = true } = error.config ?? {};\n\n if (error.response?.data && transformResponseCase) {\n error.response.data = keysToCamelCase(error.response.data);\n }\n\n return error;\n};\n\nconst showSuccessToastr = response => {\n const {\n showToastr = true,\n url: requestUrl,\n method: requestMethod,\n } = response.config;\n if (!showToastr) return response;\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) {\n toast.dismiss(errorToastId);\n requestErrorToasts = dissoc(toastIdKey, requestErrorToasts);\n }\n\n if (matches({ showThumbsUpToastr: true }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (matches({ noticeCode: \"thumbs_up\" }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (shouldShowToastr(response.data)) {\n Toastr.success(response.data);\n }\n\n return response;\n};\n\nconst pullDataFromResponse = response => {\n const { includeMetadataInResponse = false } = response.config;\n\n return includeMetadataInResponse ? response : response.data;\n};\n\nconst buildSuccessResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformResponseKeysToCamelCase);\n\n if (!skip?.showToastr) interceptors.push(showSuccessToastr);\n\n if (!skip?.pullDataFromResponse) interceptors.push(pullDataFromResponse);\n\n return createPipe(interceptors);\n};\n\nconst handleUnauthorizedErrorResponse = error => {\n if (error.response?.status !== 401) return error;\n\n resetAuthTokens();\n\n const { redirectOnError = true } = error.config ?? {};\n if (redirectOnError) {\n setTimeout(() => {\n const redirectTo =\n window.location.pathname === \"/login\"\n ? \"/login\"\n : `/login?redirect_uri=${encodeURIComponent(window.location.href)}`;\n\n // eslint-disable-next-line xss/no-location-href-assign\n window.location.href = redirectTo;\n }, 300);\n }\n\n return error;\n};\n\nconst isOnline = () => window.navigator.onLine;\n\nconst showOfflineToastr = () => {\n const toastId = Toastr.error(\n i18next.t(\"neetoCommons.toastr.error.networkError\")\n );\n\n if (toastId) {\n const dismissToastInterval = setInterval(() => {\n if (!isOnline()) return;\n\n toast.dismiss(toastId);\n clearInterval(dismissToastInterval);\n checkOnlineInterval = null;\n }, 1000);\n }\n};\n\nconst handleNetworkError = error => {\n if (checkOnlineInterval) return error;\n\n const startTime = Date.now();\n\n checkOnlineInterval = setInterval(() => {\n const elapsedTime = Date.now() - startTime;\n\n if (isOnline()) {\n clearInterval(checkOnlineInterval);\n checkOnlineInterval = null;\n } else if (elapsedTime >= MAXIMUM_OFFLINE_DURATION) {\n clearInterval(checkOnlineInterval);\n showOfflineToastr();\n }\n }, 1000);\n\n return error;\n};\n\nconst showErrorToastr = error => {\n const {\n showToastr = true,\n show422ErrorToastr = true,\n url: requestUrl = \"\",\n method: requestMethod = \"\",\n } = error.config ?? {};\n const { status } = error.response ?? {};\n\n if (!showToastr) return error;\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n let shouldShowToastr = false,\n toastrContent = error;\n\n const skippedStatusCodes = [403, 404, 520, 422];\n if (!skippedStatusCodes.includes(status) && !axios.isCancel(error)) {\n // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.\n // We handle cloudflare error differently for production and other environments.\n shouldShowToastr = true;\n }\n\n if (status === 422 && show422ErrorToastr) shouldShowToastr = true;\n\n if (status === 520) {\n shouldShowToastr = true;\n if (globalProps.railsEnv === \"production\") {\n toastrContent = i18next.t(\"generic.error\");\n }\n }\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) toast.dismiss(errorToastId);\n\n if (shouldShowToastr) {\n if (errorToastId) {\n // if there's an existing toastr with the same message, the onClose callback in the neetoUI which\n // removes the toastr from the unique list will be fired only after the toast is completely removed\n // from the UI. If there's no delay, the new toastr will be considered as duplicate and ignored.\n setTimeout(() => {\n requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }, 1200);\n } else requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }\n\n return error;\n};\n\nconst getUrlPathName = url => {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\nconst handle404ErrorResponse = error => {\n const { show404ErrorPage = true, show403ErrorPage = true } =\n error.config ?? {};\n\n const status = error.response?.status;\n if (\n (status === 404 && show404ErrorPage) ||\n (status === 403 && show403ErrorPage)\n ) {\n const fullUrl = error.request?.responseURL || error.config.url;\n useErrorDisplayStore.setState({\n showErrorPage: true,\n statusCode: status,\n failedApiUrl: fullUrl,\n failedApiPath: getUrlPathName(fullUrl),\n });\n }\n\n return error;\n};\n\nconst buildErrorResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformErrorKeysToCamelCase);\n\n if (!skip?.show404ErrorPage) interceptors.push(handle404ErrorResponse);\n\n if (!skip?.logoutOn401) interceptors.push(handleUnauthorizedErrorResponse);\n\n if (!skip?.showToastr) interceptors.push(showErrorToastr);\n\n interceptors.push(Promise.reject.bind(Promise));\n\n return createPipe(interceptors);\n};\n\nconst cleanupCredentialsForCrossOrigin = request => {\n if (!request.url.includes(\"://\")) return request;\n\n if (request.url.includes(window.location.hostname)) return request;\n\n return evolve({ headers: omit([HEADERS_KEYS.xCsrfToken]) })(request);\n};\n\nconst transformDataToSnakeCase = request => {\n const { transformRequestCase = true } = request;\n\n if (!transformRequestCase) return request;\n\n return evolve(\n { data: serializeKeysToSnakeCase, params: serializeKeysToSnakeCase },\n request\n );\n};\n\nconst addRequestInterceptors = skip => {\n if (!skip?.cleanCredentialsForCrossOrigin) {\n axios.interceptors.request.use(cleanupCredentialsForCrossOrigin);\n }\n\n if (!skip?.transformCase) {\n axios.interceptors.request.use(transformDataToSnakeCase);\n }\n};\n\nconst addResponseInterceptors = skip => {\n axios.interceptors.response.use(\n buildSuccessResponseHandler(skip),\n buildErrorResponseHandler(skip)\n );\n};\n\nconst registerIntercepts = skip => {\n if (shouldNot(skip?.request)) addRequestInterceptors(skip?.request);\n\n if (shouldNot(skip?.response)) addResponseInterceptors(skip?.response);\n};\n\nexport default function initializeAxios(skip) {\n if (!skip?.baseURL) axios.defaults.baseURL = \"/\";\n\n if (!skip?.authHeaders) setAuthHeaders();\n\n if (!skip?.paramsSerializer) setParamsSerializer();\n\n if (shouldNot(skip?.interceptors)) registerIntercepts(skip?.interceptors);\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAKmB,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEnB,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAEA,IAAAQ,iBAAA,GAAAT,sBAAA,CAAAC,OAAA;AAEA,IAAAS,UAAA,GAAAT,OAAA;AAEA,IAAIU,mBAAmB,GAAG,IAAI;AAC9B,IAAIC,kBAAkB,GAAG,CAAC,CAAC;AAE3B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,IAAI;EAAA,OAAI,IAAAC,QAAA,aAAOD,IAAI,MAAK,QAAQ,IAAI,CAACA,IAAI;AAAA;AAE3D,IAAME,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAGC,QAAQ;EAAA,OAC9B,OAAOA,QAAQ,KAAK,QAAQ,IAAI,IAAAC,qBAAU,EAACD,QAAQ,CAAC,IACpD,IAAAF,QAAA,aAAOE,QAAQ,MAAK,QAAQ,KAAK,CAAAA,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,MAAM,MAAIF,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEG,UAAU,EAAE;AAAA;AAE9E,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAA,EAAS;EAAA,IAAAC,qBAAA;EAC3B;EACAC,iBAAK,CAACC,QAAQ,CAACC,OAAO,OAAAC,gBAAA,iBAAAA,gBAAA,iBAAAA,gBAAA,iBACnBC,uB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,uBAAJA,IAAI,CAAEG,QAAQ,CAAC;AACxE,CAAC;AAEc,SAASsJ,eAAeA,CAACzJ,IAAI,EAAE;EAC5C,IAAI,EAACA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE0J,OAAO,GAAEjJ,iBAAK,CAACC,QAAQ,CAACgJ,OAAO,GAAG,GAAG;EAEhD,IAAI,EAAC1J,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE2J,WAAW,GAAEpJ,cAAc,CAAC,CAAC;EAExC,IAAI,EAACP,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE4J,gBAAgB,GAAE,IAAAC,4BAAmB,EAAC,CAAC;EAElD,IAAI9J,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6D,YAAY,CAAC,EAAE2F,kBAAkB,CAACxJ,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6D,YAAY,CAAC;AAC3E","ignoreList":[]}
|
package/cjs/initializers/i18n.js
CHANGED
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.taxonomies = exports["default"] = void 0;
|
|
8
|
-
var _mergeDeepLeft2 = _interopRequireDefault(require("ramda/es/mergeDeepLeft"));
|
|
9
8
|
var _i18next = _interopRequireDefault(require("i18next"));
|
|
10
9
|
var _i18nextBrowserLanguagedetector = _interopRequireDefault(require("i18next-browser-languagedetector"));
|
|
10
|
+
var _ramda = require("ramda");
|
|
11
11
|
var _reactI18next = require("react-i18next");
|
|
12
12
|
var _constants = require("./constants");
|
|
13
13
|
var _customFormatters = require("./utils/customFormatters");
|
|
@@ -25,7 +25,7 @@ var initializeI18n = function initializeI18n(hostTranslations) {
|
|
|
25
25
|
translation: _en["default"]
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
var resources = [hostTranslations, commonsTranslations, packageTranslations].reduce(
|
|
28
|
+
var resources = [hostTranslations, commonsTranslations, packageTranslations].reduce(_ramda.mergeDeepLeft);
|
|
29
29
|
var defaultTaxonomyKeys = Object.keys(resources.en.translation.taxonomyDefaultLabels || {});
|
|
30
30
|
var defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(function (key) {
|
|
31
31
|
return [key, {
|
|
@@ -34,7 +34,7 @@ var initializeI18n = function initializeI18n(hostTranslations) {
|
|
|
34
34
|
}];
|
|
35
35
|
}));
|
|
36
36
|
var hostTaxonomies = ((_window$globalProps = window.globalProps) === null || _window$globalProps === void 0 ? void 0 : _window$globalProps.taxonomies) || {};
|
|
37
|
-
exports.taxonomies = taxonomies = (0, _utils.replaceNullValuesWithGetter)((0,
|
|
37
|
+
exports.taxonomies = taxonomies = (0, _utils.replaceNullValuesWithGetter)((0, _ramda.mergeDeepLeft)(hostTaxonomies, defaultTaxonomies));
|
|
38
38
|
_i18next["default"].use(_i18nextBrowserLanguagedetector["default"]).use(_reactI18next.initReactI18next).use(_customPostProcessors.sentenceCaseProcessor).init({
|
|
39
39
|
resources: resources,
|
|
40
40
|
fallbackLng: "en",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":["_i18next","_interopRequireDefault","require","_i18nextBrowserLanguagedetector","_reactI18next","_constants","_customFormatters","_customPostProcessors","_utils","_en","taxonomies","exports","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","commonsTranslations","en","translation","commonsEn","resources","reduce","
|
|
1
|
+
{"version":3,"file":"i18n.js","names":["_i18next","_interopRequireDefault","require","_i18nextBrowserLanguagedetector","_ramda","_reactI18next","_constants","_customFormatters","_customPostProcessors","_utils","_en","taxonomies","exports","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","commonsTranslations","en","translation","commonsEn","resources","reduce","mergeDeepLeft","defaultTaxonomyKeys","Object","keys","taxonomyDefaultLabels","defaultTaxonomies","fromEntries","map","key","singular","plural","hostTaxonomies","window","globalProps","replaceNullValuesWithGetter","i18n","use","LanguageDetector","initReactI18next","sentenceCaseProcessor","init","fallbackLng","interpolation","defaultVariables","escapeValue","skipOnVariables","alwaysFormat","format","value","lng","options","newValue","LIST_FORMATS","includes","listFormatter","lowerCaseDynamicTextFormatter","postProcess","name","detection","order","caches","lookupQuerystring","lookupCookie","_default"],"sources":["../../../src/initializers/i18n.js"],"sourcesContent":["import i18n from \"i18next\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { initReactI18next } from \"react-i18next\";\n\nimport { LIST_FORMATS } from \"./constants\";\nimport {\n listFormatter,\n lowerCaseDynamicTextFormatter,\n} from \"./utils/customFormatters\";\nimport { sentenceCaseProcessor } from \"./utils/customPostProcessors\";\nimport { replaceNullValuesWithGetter } from \"./utils/utils\";\n\nimport commonsEn from \"../translations/en.json\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet taxonomies = {};\n\nconst initializeI18n = hostTranslations => {\n // eslint-disable-next-line no-undef\n const packageTranslations = preval.require(\n \"../configs/scripts/getPkgTranslations.js\"\n );\n\n const commonsTranslations = { en: { translation: commonsEn } };\n\n const resources = [\n hostTranslations,\n commonsTranslations,\n packageTranslations,\n ].reduce(mergeDeepLeft);\n\n const defaultTaxonomyKeys = Object.keys(\n resources.en.translation.taxonomyDefaultLabels || {}\n );\n\n const defaultTaxonomies = Object.fromEntries(\n defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }])\n );\n\n const hostTaxonomies = window.globalProps?.taxonomies || {};\n\n taxonomies = replaceNullValuesWithGetter(\n mergeDeepLeft(hostTaxonomies, defaultTaxonomies)\n );\n\n i18n\n .use(LanguageDetector)\n .use(initReactI18next)\n .use(sentenceCaseProcessor)\n .init({\n resources,\n fallbackLng: \"en\",\n interpolation: {\n defaultVariables: { taxonomies },\n escapeValue: false,\n skipOnVariables: false,\n alwaysFormat: true,\n format: (value, format, lng, options) => {\n let newValue = value;\n\n if (LIST_FORMATS.includes(format)) {\n newValue = listFormatter({ value: newValue, format, lng, options });\n\n return newValue;\n }\n\n return lowerCaseDynamicTextFormatter(newValue, format);\n },\n },\n postProcess: [sentenceCaseProcessor.name],\n detection: {\n order: [\"querystring\", \"cookie\", \"navigator\", \"path\"],\n caches: [\"cookie\"],\n lookupQuerystring: \"lang\",\n lookupCookie: \"lang\",\n },\n });\n};\n\nexport { taxonomies };\n\nexport default initializeI18n;\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,+BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAIA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAEA,IAAAQ,GAAA,GAAAT,sBAAA,CAAAC,OAAA;AAEA;AACA,IAAIS,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,CAAC,CAAC;AAEnB,IAAME,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,gBAAgB,EAAI;EAAA,IAAAC,mBAAA;EACzC;EACA,IAAMC,mBAAmB,GAAGC,MAAM,CAACf,OAAO,CACxC,0CACF,CAAC;EAED,IAAMgB,mBAAmB,GAAG;IAAEC,EAAE,EAAE;MAAEC,WAAW,EAAEC;IAAU;EAAE,CAAC;EAE9D,IAAMC,SAAS,GAAG,CAChBR,gBAAgB,EAChBI,mBAAmB,EACnBF,mBAAmB,CACpB,CAACO,MAAM,CAACC,oBAAa,CAAC;EAEvB,IAAMC,mBAAmB,GAAGC,MAAM,CAACC,IAAI,CACrCL,SAAS,CAACH,EAAE,CAACC,WAAW,CAACQ,qBAAqB,IAAI,CAAC,CACrD,CAAC;EAED,IAAMC,iBAAiB,GAAGH,MAAM,CAACI,WAAW,CAC1CL,mBAAmB,CAACM,GAAG,CAAC,UAAAC,GAAG;IAAA,OAAI,CAACA,GAAG,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AAE,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC;MACrDC,MAAM,EAAE,CAAC,QAAQ,CAAC;MAClBC,iBAAiB,EAAE,MAAM;MACzBC,YAAY,EAAE;IAChB;EACF,CAAC,CAAC;AACN,CAAC;AAAC,IAAAC,QAAA,GAAAvD,OAAA,cAIaC,cAAc","ignoreList":[]}
|
|
@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _isNil2 = _interopRequireDefault(require("ramda/es/isNil"));
|
|
11
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
11
|
var _dompurify = require("dompurify");
|
|
13
12
|
var _Button = _interopRequireDefault(require("@bigbinary/neetoui/Button"));
|
|
14
13
|
var _Typography = _interopRequireDefault(require("@bigbinary/neetoui/Typography"));
|
|
14
|
+
var _ramda = require("ramda");
|
|
15
15
|
var _reactI18next = require("react-i18next");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -55,7 +55,7 @@ var FallbackComponent = function FallbackComponent() {
|
|
|
55
55
|
(0, _react.useEffect)(function () {
|
|
56
56
|
var listener = function listener(e) {
|
|
57
57
|
var _e$target;
|
|
58
|
-
if ((0,
|
|
58
|
+
if ((0, _ramda.isNil)(e.state)) return;
|
|
59
59
|
window.location.href = (0, _dompurify.sanitize)((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.location.href);
|
|
60
60
|
};
|
|
61
61
|
window.addEventListener("popstate", listener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FallbackComponent.js","names":["_react","_interopRequireWildcard","require","_dompurify","_Button","_interopRequireDefault","_Typography","_reactI18next","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","FallbackComponentImage","props","jsxs","children","jsx","d","fill","defaultProps","width","height","viewBox","xmlns","FallbackComponent","_useTranslation","useTranslation","useEffect","listener","_e$target","
|
|
1
|
+
{"version":3,"file":"FallbackComponent.js","names":["_react","_interopRequireWildcard","require","_dompurify","_Button","_interopRequireDefault","_Typography","_ramda","_reactI18next","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","FallbackComponentImage","props","jsxs","children","jsx","d","fill","defaultProps","width","height","viewBox","xmlns","FallbackComponent","_useTranslation","useTranslation","useEffect","listener","_e$target","isNil","state","window","location","href","sanitize","target","addEventListener","removeEventListener","className","component","style","weight","Trans","i18nKey","components","reloading","onClick","reload","contactus","_window$NeetoChat","_window$NeetoChat$con","_window$NeetoChat2","_window$NeetoChat2$co","NeetoChat","contextualHelp","maximizeWidget","openWidget","_default","exports"],"sources":["../../../../src/react-utils/HoneybadgerErrorBoundary/FallbackComponent.jsx"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport FallbackComponentImage from \"assets/images/fallback-component.svg\";\nimport { sanitize } from \"dompurify\";\nimport { Button, Typography } from \"neetoui\";\nimport { isNil } from \"ramda\";\nimport { Trans, useTranslation } from \"react-i18next\";\n\nconst FallbackComponent = () => {\n const { t } = useTranslation();\n\n useEffect(() => {\n const listener = e => {\n if (isNil(e.state)) return;\n window.location.href = sanitize(e.target?.location.href);\n };\n window.addEventListener(\"popstate\", listener);\n\n return () => window.removeEventListener(\"popstate\", listener);\n }, []);\n\n return (\n <div className=\"flex h-screen w-full flex-row items-start justify-start\">\n <div className=\"m-auto text-center\">\n <div className=\"m-auto mb-8 flex items-center justify-center\">\n <FallbackComponentImage />\n </div>\n <Typography\n className=\"mb-4\"\n component=\"h2\"\n style=\"h2\"\n weight=\"semibold\"\n >\n {t(\"neetoCommons.fallbackComponent.somethingWentWrong\")}\n </Typography>\n <Typography\n className=\"neeto-ui-text-gray-600 mb-8\"\n component=\"p\"\n style=\"body1\"\n weight=\"normal\"\n >\n <Trans\n i18nKey=\"neetoCommons.fallbackComponent.description\"\n components={{\n reloading: (\n <Button style=\"link\" onClick={() => window.location.reload()} />\n ),\n contactus: (\n <Button\n style=\"link\"\n onClick={() => {\n window.NeetoChat?.contextualHelp?.maximizeWidget();\n window.NeetoChat?.contextualHelp?.openWidget();\n }}\n />\n ),\n }}\n />\n </Typography>\n </div>\n </div>\n );\n};\n\nexport default FallbackComponent;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AAAqC,IAAAE,OAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AAErC,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAAsD,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAA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exports["default"] = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _2 = _interopRequireDefault(require("ramda/es/__"));
|
|
10
|
-
var _includes2 = _interopRequireDefault(require("ramda/es/includes"));
|
|
11
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
10
|
var _ErrorPage = _interopRequireDefault(require("@bigbinary/neeto-molecules/ErrorPage"));
|
|
11
|
+
var _ramda = require("ramda");
|
|
13
12
|
var _reactRouterDom = require("react-router-dom");
|
|
14
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
14
|
var _excluded = ["condition", "redirectRoute", "errorPage", "permissions"];
|
|
@@ -27,7 +26,7 @@ var PrivateRoute = function PrivateRoute(_ref) {
|
|
|
27
26
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
28
27
|
if (condition) {
|
|
29
28
|
if (permissions) {
|
|
30
|
-
return globalProps.permissions.some((0,
|
|
29
|
+
return globalProps.permissions.some((0, _ramda.includes)(_ramda.__, permissions)) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, _objectSpread({}, props)) : errorPage || /*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorPage["default"], {
|
|
31
30
|
status: 403
|
|
32
31
|
});
|
|
33
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateRoute.js","names":["_ErrorPage","_interopRequireDefault","require","_reactRouterDom","_jsxRuntime","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","PrivateRoute","_ref","_ref$condition","condition","globalProps","authenticated","_ref$redirectRoute","redirectRoute","undefined","_ref$errorPage","errorPage","_ref$permissions","permissions","props","_objectWithoutProperties2","some","
|
|
1
|
+
{"version":3,"file":"PrivateRoute.js","names":["_ErrorPage","_interopRequireDefault","require","_ramda","_reactRouterDom","_jsxRuntime","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","PrivateRoute","_ref","_ref$condition","condition","globalProps","authenticated","_ref$redirectRoute","redirectRoute","undefined","_ref$errorPage","errorPage","_ref$permissions","permissions","props","_objectWithoutProperties2","some","includes","__","jsx","Route","status","Redirect","to","pathname","_default","exports"],"sources":["../../../../src/react-utils/PrivateRoute/PrivateRoute.jsx"],"sourcesContent":["import ErrorPage from \"neetomolecules/ErrorPage\";\nimport { __, includes } from \"ramda\";\nimport { Redirect, Route } from \"react-router-dom\";\n\nconst PrivateRoute = ({\n condition = globalProps.authenticated,\n redirectRoute = undefined,\n errorPage = undefined,\n permissions = undefined,\n ...props\n}) => {\n if (condition) {\n if (permissions) {\n return globalProps.permissions.some(includes(__, permissions)) ? (\n <Route {...props} />\n ) : (\n errorPage || <ErrorPage status={403} />\n );\n }\n\n return <Route {...props} />;\n }\n\n if (redirectRoute) {\n return <Redirect to={{ pathname: redirectRoute }} />;\n }\n\n return errorPage || <ErrorPage status={403} />;\n};\n\nexport default PrivateRoute;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAAmD,IAAAG,WAAA,GAAAH,OAAA;AAAA,IAAAI,SAAA;AAAA,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,M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A;IACpBE,KAAK,OAAAC,yBAAA,aAAAb,IAAA,EAAAvB,SAAA;EAER,IAAIyB,SAAS,EAAE;IACb,IAAIS,WAAW,EAAE;MACf,OAAOR,WAAW,CAACQ,WAAW,CAACG,IAAI,CAAC,IAAAC,eAAQ,EAACC,SAAE,EAAEL,WAAW,CAAC,CAAC,gBAC5D,IAAAnC,WAAA,CAAAyC,GAAA,EAAC1C,eAAA,CAAA2C,KAAK,EAAA3B,aAAA,KAAKqB,KAAK,CAAG,CAAC,GAEpBH,SAAS,iBAAI,IAAAjC,WAAA,CAAAyC,GAAA,EAAC9C,UAAA,WAAS;QAACgD,MAAM,EAAE;MAAI,CAAE,CACvC;IACH;IAEA,oBAAO,IAAA3C,WAAA,CAAAyC,GAAA,EAAC1C,eAAA,CAAA2C,KAAK,EAAA3B,aAAA,KAAKqB,KAAK,CAAG,CAAC;EAC7B;EAEA,IAAIN,aAAa,EAAE;IACjB,oBAAO,IAAA9B,WAAA,CAAAyC,GAAA,EAAC1C,eAAA,CAAA6C,QAAQ;MAACC,EAAE,EAAE;QAAEC,QAAQ,EAAEhB;MAAc;IAAE,CAAE,CAAC;EACtD;EAEA,OAAOG,SAAS,iBAAI,IAAAjC,WAAA,CAAAyC,GAAA,EAAC9C,UAAA,WAAS;IAACgD,MAAM,EAAE;EAAI,CAAE,CAAC;AAChD,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,cAEazB,YAAY","ignoreList":[]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.isMetaKeyPressed = exports.handleMetaClick = void 0;
|
|
8
|
-
var
|
|
9
|
-
var handleMetaClick = exports.handleMetaClick = (0,
|
|
7
|
+
var _ramda = require("ramda");
|
|
8
|
+
var handleMetaClick = exports.handleMetaClick = (0, _ramda.curry)(function (history, params, event) {
|
|
10
9
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
11
10
|
if (isMetaKeyPressed(event)) {
|
|
12
11
|
return window.open(params.pathname || params, "_blank");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metaClick.js","names":["handleMetaClick","exports","
|
|
1
|
+
{"version":3,"file":"metaClick.js","names":["_ramda","require","handleMetaClick","exports","curry","history","params","event","options","arguments","length","undefined","isMetaKeyPressed","window","open","pathname","_options$isHistoryRep","isHistoryReplace","historyMethod","replace","push","ctrlKey","metaKey"],"sources":["../../../../src/react-utils/metaClick/metaClick.js"],"sourcesContent":["import { curry } from \"ramda\";\n\nexport const handleMetaClick = curry((history, params, event, options = {}) => {\n if (isMetaKeyPressed(event)) {\n return window.open(params.pathname || params, \"_blank\");\n }\n\n const { isHistoryReplace = false } = options;\n const historyMethod = isHistoryReplace ? history.replace : history.push;\n\n return historyMethod(params);\n});\n\nexport const isMetaKeyPressed = event => !!(event?.ctrlKey || event?.metaKey);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,IAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,IAAAE,YAAK,EAAC,UAACC,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAmB;EAAA,IAAjBC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACxE,IAAIG,gBAAgB,CAACL,KAAK,CAAC,EAAE;IAC3B,OAAOM,MAAM,CAACC,IAAI,CAACR,MAAM,CAACS,QAAQ,IAAIT,MAAM,EAAE,QAAQ,CAAC;EACzD;EAEA,IAAAU,qBAAA,GAAqCR,OAAO,CAApCS,gBAAgB;IAAhBA,gBAAgB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;EAChC,IAAME,aAAa,GAAGD,gBAAgB,GAAGZ,OAAO,CAACc,OAAO,GAAGd,OAAO,CAACe,IAAI;EAEvE,OAAOF,aAAa,CAACZ,MAAM,CAAC;AAC9B,CAAC,CAAC;AAEK,IAAMM,gBAAgB,GAAAT,OAAA,CAAAS,gBAAA,GAAG,SAAnBA,gBAAgBA,CAAGL,KAAK;EAAA,OAAI,CAAC,EAAEA,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEc,OAAO,IAAId,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEe,OAAO,CAAC;AAAA","ignoreList":[]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports["default"] = void 0;
|
|
8
|
-
var _equals2 = _interopRequireDefault(require("ramda/es/equals"));
|
|
9
7
|
var _react = require("react");
|
|
8
|
+
var _ramda = require("ramda");
|
|
10
9
|
var _utils = require("./utils");
|
|
11
10
|
var useBreakpoints = function useBreakpoints(breakpointOverrides) {
|
|
12
11
|
var getSnapshot = function getSnapshot() {
|
|
@@ -15,7 +14,7 @@ var useBreakpoints = function useBreakpoints(breakpointOverrides) {
|
|
|
15
14
|
var currentSize = (0, _react.useSyncExternalStore)(_utils.subscribe, getSnapshot);
|
|
16
15
|
return {
|
|
17
16
|
currentSize: currentSize,
|
|
18
|
-
isSize: (0,
|
|
17
|
+
isSize: (0, _ramda.equals)(currentSize)
|
|
19
18
|
};
|
|
20
19
|
};
|
|
21
20
|
var _default = exports["default"] = useBreakpoints;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","require","_utils","useBreakpoints","breakpointOverrides","getSnapshot","getCurrentSize","window","currentSize","useSyncExternalStore","subscribe","isSize","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","require","_ramda","_utils","useBreakpoints","breakpointOverrides","getSnapshot","getCurrentSize","window","currentSize","useSyncExternalStore","subscribe","isSize","equals","_default","exports"],"sources":["../../../../src/react-utils/useBreakpoints/index.js"],"sourcesContent":["import { useSyncExternalStore } from \"react\";\n\nimport { equals } from \"ramda\";\n\nimport { getCurrentSize, subscribe } from \"./utils\";\n\nconst useBreakpoints = breakpointOverrides => {\n const getSnapshot = () => getCurrentSize(window, breakpointOverrides);\n const currentSize = useSyncExternalStore(subscribe, getSnapshot);\n\n return { currentSize, isSize: equals(currentSize) };\n};\n\nexport default useBreakpoints;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAMG,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,mBAAmB,EAAI;EAC5C,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAA;IAAA,OAAS,IAAAC,qBAAc,EAACC,MAAM,EAAEH,mBAAmB,CAAC;EAAA;EACrE,IAAMI,WAAW,GAAG,IAAAC,2BAAoB,EAACC,gBAAS,EAAEL,WAAW,CAAC;EAEhE,OAAO;IAAEG,WAAW,EAAXA,WAAW;IAAEG,MAAM,EAAE,IAAAC,aAAM,EAACJ,WAAW;EAAE,CAAC;AACrD,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,cAEaX,cAAc","ignoreList":[]}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.useErrorDisplayStore = exports["default"] = void 0;
|
|
8
|
-
var
|
|
7
|
+
var _ramda = require("ramda");
|
|
9
8
|
var _zustand = require("zustand");
|
|
10
9
|
var useDisplayErrorPage = function useDisplayErrorPage() {
|
|
11
|
-
return useErrorDisplayStore((0,
|
|
10
|
+
return useErrorDisplayStore((0, _ramda.prop)("showErrorPage"));
|
|
12
11
|
};
|
|
13
12
|
var useErrorDisplayStore = exports.useErrorDisplayStore = (0, _zustand.create)(function () {
|
|
14
13
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDisplayErrorPage.js","names":["
|
|
1
|
+
{"version":3,"file":"useDisplayErrorPage.js","names":["_ramda","require","_zustand","useDisplayErrorPage","useErrorDisplayStore","prop","exports","create","showErrorPage","statusCode","failedApiUrl","failedApiPath","_default"],"sources":["../../../../src/react-utils/useDisplayErrorPage/useDisplayErrorPage.js"],"sourcesContent":["import { prop } from \"ramda\";\nimport { create } from \"zustand\";\n\nconst useDisplayErrorPage = () => useErrorDisplayStore(prop(\"showErrorPage\"));\n\nexport const useErrorDisplayStore = create(() => ({\n showErrorPage: false,\n statusCode: 404,\n failedApiUrl: \"\",\n failedApiPath: \"\",\n}));\n\nexport default useDisplayErrorPage;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAME,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAA;EAAA,OAASC,oBAAoB,CAAC,IAAAC,WAAI,EAAC,eAAe,CAAC,CAAC;AAAA;AAEtE,IAAMD,oBAAoB,GAAAE,OAAA,CAAAF,oBAAA,GAAG,IAAAG,eAAM,EAAC;EAAA,OAAO;IAChDC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,GAAG;IACfC,YAAY,EAAE,EAAE;IAChBC,aAAa,EAAE;EACjB,CAAC;AAAA,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAN,OAAA,cAEWH,mBAAmB","ignoreList":[]}
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
|
-
var _isNil2 = _interopRequireDefault(require("ramda/es/isNil"));
|
|
9
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
9
|
var _react = require("react");
|
|
10
|
+
var _ramda = require("ramda");
|
|
11
11
|
var _utils = require("../../utils");
|
|
12
12
|
/* eslint-disable @bigbinary/neeto/no-local-storage */
|
|
13
13
|
|
|
@@ -30,7 +30,7 @@ var useLocalStorage = function useLocalStorage(key, defaultValue) {
|
|
|
30
30
|
var setValue = function setValue(value) {
|
|
31
31
|
return setStoredValue(function (prevStoredValue) {
|
|
32
32
|
var newValue = typeof value === "function" ? value(prevStoredValue) : value;
|
|
33
|
-
if ((0,
|
|
33
|
+
if ((0, _ramda.isNil)(newValue)) {
|
|
34
34
|
(0, _utils.removeFromLocalStorage)(key);
|
|
35
35
|
} else {
|
|
36
36
|
(0, _utils.setToLocalStorage)(key, newValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorage.js","names":["_react","require","_utils","getStorageValue","key","defaultValue","storedValue","localStorage","getItem","JSON","parse","error","logger","useLocalStorage","_useState","useState","_useState2","_slicedToArray2","setStoredValue","setValue","value","prevStoredValue","newValue","
|
|
1
|
+
{"version":3,"file":"useLocalStorage.js","names":["_react","require","_ramda","_utils","getStorageValue","key","defaultValue","storedValue","localStorage","getItem","JSON","parse","error","logger","useLocalStorage","_useState","useState","_useState2","_slicedToArray2","setStoredValue","setValue","value","prevStoredValue","newValue","isNil","removeFromLocalStorage","setToLocalStorage","_default","exports"],"sources":["../../../../src/react-utils/useLocalStorage/useLocalStorage.js"],"sourcesContent":["/* eslint-disable @bigbinary/neeto/no-local-storage */\n\nimport { useState } from \"react\";\n\nimport { isNil } from \"ramda\";\nimport { removeFromLocalStorage, setToLocalStorage } from \"utils\";\n\nconst getStorageValue = (key, defaultValue) => {\n try {\n const storedValue = localStorage.getItem(key);\n\n return storedValue ? JSON.parse(storedValue) : defaultValue;\n } catch (error) {\n logger.error(error);\n\n return defaultValue;\n }\n};\n\nconst useLocalStorage = (key, defaultValue) => {\n const [storedValue, setStoredValue] = useState(() =>\n getStorageValue(key, defaultValue)\n );\n\n const setValue = value =>\n setStoredValue(prevStoredValue => {\n const newValue =\n typeof value === \"function\" ? value(prevStoredValue) : value;\n\n if (isNil(newValue)) {\n removeFromLocalStorage(key);\n } else {\n setToLocalStorage(key, newValue);\n }\n\n return newValue;\n });\n\n return [storedValue, setValue];\n};\n\nexport default useLocalStorage;\n"],"mappings":";;;;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AALA;;AAOA,IAAMG,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,GAAG,EAAEC,YAAY,EAAK;EAC7C,IAAI;IACF,IAAMC,WAAW,GAAGC,YAAY,CAACC,OAAO,CAACJ,GAAG,CAAC;IAE7C,OAAOE,WAAW,GAAGG,IAAI,CAACC,KAAK,CAACJ,WAAW,CAAC,GAAGD,YAAY;EAC7D,CAAC,CAAC,OAAOM,KAAK,EAAE;IACdC,MAAM,CAACD,KAAK,CAACA,KAAK,CAAC;IAEnB,OAAON,YAAY;EACrB;AACF,CAAC;AAED,IAAMQ,eAAe,GAAG,SAAlBA,eAAeA,CAAIT,GAAG,EAAEC,YAAY,EAAK;EAC7C,IAAAS,SAAA,GAAsC,IAAAC,eAAQ,EAAC;MAAA,OAC7CZ,eAAe,CAACC,GAAG,EAAEC,YAAY,CAAC;IAAA,CACpC,CAAC;IAAAW,UAAA,OAAAC,eAAA,aAAAH,SAAA;IAFMR,WAAW,GAAAU,UAAA;IAAEE,cAAc,GAAAF,UAAA;EAIlC,IAAMG,QAAQ,GAAG,SAAXA,QAAQA,CAAGC,KAAK;IAAA,OACpBF,cAAc,CAAC,UAAAG,eAAe,EAAI;MAChC,IAAMC,QAAQ,GACZ,OAAOF,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACC,eAAe,CAAC,GAAGD,KAAK;MAE9D,IAAI,IAAAG,YAAK,EAACD,QAAQ,CAAC,EAAE;QACnB,IAAAE,6BAAsB,EAACpB,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,IAAAqB,wBAAiB,EAACrB,GAAG,EAAEkB,QAAQ,CAAC;MAClC;MAEA,OAAOA,QAAQ;IACjB,CAAC,CAAC;EAAA;EAEJ,OAAO,CAAChB,WAAW,EAAEa,QAAQ,CAAC;AAChC,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,cAEad,eAAe","ignoreList":[]}
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
|
-
var _type2 = _interopRequireDefault(require("ramda/es/type"));
|
|
9
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
10
|
var _reactQuery = require("@tanstack/react-query");
|
|
11
|
+
var _ramda = require("ramda");
|
|
12
12
|
var _excluded = ["keysToInvalidate"],
|
|
13
13
|
_excluded2 = ["onSuccess"];
|
|
14
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -23,10 +23,10 @@ var useMutationWithInvalidation = function useMutationWithInvalidation(mutationF
|
|
|
23
23
|
mutationFn: mutationFn,
|
|
24
24
|
onSuccess: function onSuccess(data, variables, context) {
|
|
25
25
|
keysToInvalidate.forEach(function (key) {
|
|
26
|
-
var result = (0,
|
|
27
|
-
if ((0,
|
|
26
|
+
var result = (0, _ramda.type)(key) === "Function" ? key(data, variables, context) : key;
|
|
27
|
+
if ((0, _ramda.type)(result) === "Object") {
|
|
28
28
|
queryClient.invalidateQueries(result);
|
|
29
|
-
} else if ((0,
|
|
29
|
+
} else if ((0, _ramda.type)(result) === "String") {
|
|
30
30
|
queryClient.invalidateQueries({
|
|
31
31
|
queryKey: [result]
|
|
32
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutationWithInvalidation.js","names":["_reactQuery","require","_excluded","_excluded2","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","useMutationWithInvalidation","mutationFn","_ref","keysToInvalidate","options","_objectWithoutProperties2","queryClient","useQueryClient","onSuccess","otherOptions","useMutation","data","variables","context","key","result","
|
|
1
|
+
{"version":3,"file":"useMutationWithInvalidation.js","names":["_reactQuery","require","_ramda","_excluded","_excluded2","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","useMutationWithInvalidation","mutationFn","_ref","keysToInvalidate","options","_objectWithoutProperties2","queryClient","useQueryClient","onSuccess","otherOptions","useMutation","data","variables","context","key","result","type","invalidateQueries","queryKey","_default","exports"],"sources":["../../../../src/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js"],"sourcesContent":["import { useQueryClient, useMutation } from \"@tanstack/react-query\";\nimport { type } from \"ramda\";\n\nconst useMutationWithInvalidation = (\n mutationFn,\n { keysToInvalidate, ...options }\n) => {\n const queryClient = useQueryClient();\n const { onSuccess, ...otherOptions } = options;\n\n return useMutation({\n mutationFn,\n onSuccess: (data, variables, context) => {\n keysToInvalidate.forEach(key => {\n const result =\n type(key) === \"Function\" ? key(data, variables, context) : key;\n\n if (type(result) === \"Object\") {\n queryClient.invalidateQueries(result);\n } else if (type(result) === \"String\") {\n queryClient.invalidateQueries({ queryKey: [result] });\n } else {\n queryClient.invalidateQueries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","ignoreList":[]}
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
|
-
var _isNil2 = _interopRequireDefault(require("ramda/es/isNil"));
|
|
9
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _react = require("react");
|
|
11
10
|
var _reactQuery = require("@tanstack/react-query");
|
|
11
|
+
var _ramda = require("ramda");
|
|
12
12
|
var _constants = require("../constants");
|
|
13
13
|
var _general = require("../../utils/general");
|
|
14
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -32,8 +32,8 @@ var localStorageQueryCache = {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
var isOutdated = function isOutdated(localCache, staleTime) {
|
|
35
|
-
if ((0,
|
|
36
|
-
if ((0,
|
|
35
|
+
if ((0, _ramda.isNil)(localCache)) return true;
|
|
36
|
+
if ((0, _ramda.isNil)(staleTime)) return false;
|
|
37
37
|
return localCache.modifiedAt <= Date.now() - staleTime;
|
|
38
38
|
};
|
|
39
39
|
var usePersistedQuery = function usePersistedQuery(queryKey, fetch, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePersistedQuery.js","names":["_react","require","_reactQuery","_constants","_general","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","localStorageQueryCache","set","key","data","cache","getAll","newCache","modifiedAt","Date","now","setToLocalStorage","QUERY_CACHE_NAME_SPACE","getFromLocalStorage","get","isOutdated","localCache","staleTime","
|
|
1
|
+
{"version":3,"file":"usePersistedQuery.js","names":["_react","require","_reactQuery","_ramda","_constants","_general","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","localStorageQueryCache","set","key","data","cache","getAll","newCache","modifiedAt","Date","now","setToLocalStorage","QUERY_CACHE_NAME_SPACE","getFromLocalStorage","get","isOutdated","localCache","staleTime","isNil","usePersistedQuery","queryKey","fetch","options","queryResult","useQuery","queryFn","useEffect","isSuccess","isFreshLoading","isLoading","getCache","_default","exports"],"sources":["../../../../src/react-utils/usePersistedQuery/usePersistedQuery.js"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { isNil } from \"ramda\";\nimport { QUERY_CACHE_NAME_SPACE } from \"react-utils/constants\";\nimport { getFromLocalStorage, setToLocalStorage } from \"utils/general\";\n\nconst localStorageQueryCache = {\n set: (key, data) => {\n const cache = localStorageQueryCache.getAll();\n const newCache = { ...cache, [key]: { data, modifiedAt: Date.now() } };\n setToLocalStorage(QUERY_CACHE_NAME_SPACE, newCache);\n },\n getAll: () => {\n const cache = getFromLocalStorage(QUERY_CACHE_NAME_SPACE);\n if (!cache) return {};\n\n return cache;\n },\n get: key => localStorageQueryCache.getAll()[key],\n};\n\nconst isOutdated = (localCache, staleTime) => {\n if (isNil(localCache)) return true;\n\n if (isNil(staleTime)) return false;\n\n return localCache.modifiedAt <= Date.now() - staleTime;\n};\n\nconst usePersistedQuery = (queryKey, fetch, options) => {\n const queryResult = useQuery({\n queryKey,\n queryFn: fetch,\n ...options,\n });\n const localCache = localStorageQueryCache.get(queryKey);\n\n useEffect(() => {\n if (!queryResult.isSuccess) return;\n localStorageQueryCache.set(queryKey, queryResult.data);\n }, [queryKey, queryResult.data, queryResult.isSuccess]);\n\n if (isOutdated(localCache, options?.staleTime)) {\n return { ...queryResult, isFreshLoading: queryResult.isLoading };\n }\n\n return {\n ...queryResult,\n data: queryResult.data || localCache.data,\n isFreshLoading: false,\n };\n};\n\nusePersistedQuery.getCache = localStorageQueryCache.get;\n\nexport default usePersistedQuery;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAuE,SAAAK,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,QAAAe,gBAAA,aAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,KAAAH,OAAA,CAAAI,MAAA,CAAAD,CAAA,GAAAa,OAAA,WAAAd,CAAA,IAAAE,MAAA,CAAAgB,cAAA,CAAAnB,CAAA,EAAAC,CAA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