12951.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. exports.id = 12951;
  2. exports.ids = [12951];
  3. exports.modules = {
  4. /***/ 22817:
  5. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6. "use strict";
  7. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  8. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  9. /* harmony export */ });
  10. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16689);
  11. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  12. var _path;
  13. function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
  14. var SvgRetry = function SvgRetry(props) {
  15. return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
  16. width: 15,
  17. height: 15,
  18. viewBox: "0 0 15 15",
  19. fill: "none",
  20. xmlns: "http://www.w3.org/2000/svg"
  21. }, props), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
  22. d: "M1.85 7.5c0-2.835 2.21-5.65 5.65-5.65 2.778 0 4.152 2.056 4.737 3.15H10.5a.5.5 0 0 0 0 1h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-1 0v1.813C12.296 3.071 10.666.85 7.5.85 3.437.85.85 4.185.85 7.5c0 3.315 2.587 6.65 6.65 6.65 1.944 0 3.562-.77 4.714-1.942a6.77 6.77 0 0 0 1.428-2.167.5.5 0 1 0-.925-.38 5.77 5.77 0 0 1-1.216 1.846c-.971.99-2.336 1.643-4.001 1.643-3.44 0-5.65-2.815-5.65-5.65Z",
  23. fill: "currentColor",
  24. fillRule: "evenodd",
  25. clipRule: "evenodd"
  26. })));
  27. };
  28. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SvgRetry);
  29. /***/ }),
  30. /***/ 23769:
  31. /***/ ((module) => {
  32. // Exports
  33. module.exports = {
  34. "container": "Error_container__1m9XV",
  35. "text": "Error_text__yg4kD"
  36. };
  37. /***/ }),
  38. /***/ 12951:
  39. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  40. "use strict";
  41. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  42. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  43. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  44. /* harmony export */ });
  45. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  46. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  47. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  48. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  49. /* harmony import */ var swr_immutable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(79847);
  50. /* harmony import */ var _components_Error__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4233);
  51. /* harmony import */ var _dls_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7190);
  52. /* harmony import */ var src_api__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(92684);
  53. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([swr_immutable__WEBPACK_IMPORTED_MODULE_2__, _components_Error__WEBPACK_IMPORTED_MODULE_3__]);
  54. ([swr_immutable__WEBPACK_IMPORTED_MODULE_2__, _components_Error__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  55. /**
  56. * Data fetcher is a dynamic component that serves as a container for a component
  57. * that depends on data from a remote API to render. This component handles:
  58. * 1. Calling the API.
  59. * 2. Caching the response (due to using useSwr).
  60. * 3. Handling errors if any by showing an error message.
  61. * 4. Handling when the user is offline while trying to fetch the API response.
  62. * 5. Dynamically passing the response data through render-props to the parent.
  63. *
  64. * @param {Props} props
  65. * @returns {JSX.Element}
  66. */ const DataFetcher = ({ queryKey , render , renderError , initialData , loading =()=>/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_dls_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {}) , fetcher: dataFetcher = src_api__WEBPACK_IMPORTED_MODULE_5__/* .fetcher */ ._i , showSpinnerOnRevalidate =true , onFetchSuccess })=>{
  67. const { data , error , isValidating , mutate } = (0,swr_immutable__WEBPACK_IMPORTED_MODULE_2__["default"])(queryKey, ()=>dataFetcher(queryKey).then((res)=>{
  68. onFetchSuccess?.(res);
  69. return Promise.resolve(res);
  70. }).catch((err)=>Promise.reject(err)), {
  71. fallbackData: initialData
  72. });
  73. // if showSpinnerOnRevalidate is true, we should show the spinner if we are revalidating the data.
  74. // otherwise, we should only show the spinner on initial loads.
  75. if (showSpinnerOnRevalidate ? isValidating : isValidating && !data) {
  76. return loading();
  77. }
  78. const onRetryClicked = ()=>{
  79. mutate();
  80. };
  81. /**
  82. * if we haven't fetched the data yet and the device is not online (because we don't want to show an offline message if the data already exists).
  83. * or if we had an error when calling the API.
  84. */ if (error) {
  85. // if there is a custom error renderer, use it.
  86. if (renderError) {
  87. const errorComponent = renderError(error);
  88. // if the custom error renderer returns false, it means that it doesn't want to render anything special.
  89. if (typeof errorComponent !== "undefined") {
  90. return errorComponent;
  91. }
  92. }
  93. return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_Error__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {
  94. onRetryClicked: onRetryClicked,
  95. error: error
  96. });
  97. }
  98. return render(data);
  99. };
  100. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_1__.memo)(DataFetcher));
  101. __webpack_async_result__();
  102. } catch(e) { __webpack_async_result__(e); } });
  103. /***/ }),
  104. /***/ 4233:
  105. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  106. "use strict";
  107. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  108. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  109. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  110. /* harmony export */ });
  111. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  112. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  113. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  114. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  115. /* harmony import */ var next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(60866);
  116. /* harmony import */ var next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_2__);
  117. /* harmony import */ var _Error_module_scss__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(23769);
  118. /* harmony import */ var _Error_module_scss__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_Error_module_scss__WEBPACK_IMPORTED_MODULE_6__);
  119. /* harmony import */ var _dls_Button_Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(50497);
  120. /* harmony import */ var _icons_retry_svg__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(22817);
  121. /* harmony import */ var src_api__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(92684);
  122. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_dls_Button_Button__WEBPACK_IMPORTED_MODULE_3__]);
  123. _dls_Button_Button__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  124. const Error = ({ onRetryClicked , error })=>{
  125. const { t } = next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_2___default()("common");
  126. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
  127. className: (_Error_module_scss__WEBPACK_IMPORTED_MODULE_6___default().container),
  128. children: [
  129. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
  130. className: (_Error_module_scss__WEBPACK_IMPORTED_MODULE_6___default().text),
  131. children: error.message !== src_api__WEBPACK_IMPORTED_MODULE_5__/* .OFFLINE_ERROR */ .yH ? t("error.general") : t("error.offline")
  132. }),
  133. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_dls_Button_Button__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .ZP, {
  134. prefix: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_icons_retry_svg__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {}),
  135. size: _dls_Button_Button__WEBPACK_IMPORTED_MODULE_3__/* .ButtonSize.Small */ .qE.Small,
  136. type: _dls_Button_Button__WEBPACK_IMPORTED_MODULE_3__/* .ButtonType.Secondary */ .L$.Secondary,
  137. onClick: onRetryClicked,
  138. children: t("retry")
  139. })
  140. ]
  141. });
  142. };
  143. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Error);
  144. __webpack_async_result__();
  145. } catch(e) { __webpack_async_result__(e); } });
  146. /***/ })
  147. };
  148. ;
  149. //# sourceMappingURL=12951.js.map