@redneckz/wildless-cms-uni-blocks 0.14.652 → 0.14.653

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.
Files changed (68) hide show
  1. package/bundle/api/RetailAPI/updateRefreshToken.d.ts +1 -0
  2. package/bundle/bundle.umd.js +38 -7
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/hooks/useInterval.d.ts +1 -0
  5. package/dist/api/RetailAPI/doRequest.js +1 -0
  6. package/dist/api/RetailAPI/doRequest.js.map +1 -1
  7. package/dist/api/RetailAPI/updateRefreshToken.d.ts +1 -0
  8. package/dist/api/RetailAPI/updateRefreshToken.js +31 -0
  9. package/dist/api/RetailAPI/updateRefreshToken.js.map +1 -0
  10. package/dist/components/CreditForm/CreditForm.js +2 -0
  11. package/dist/components/CreditForm/CreditForm.js.map +1 -1
  12. package/dist/components/CreditForm/CreditFormStatusTracker.js +8 -6
  13. package/dist/components/CreditForm/CreditFormStatusTracker.js.map +1 -1
  14. package/dist/hooks/useInterval.d.ts +1 -0
  15. package/dist/hooks/useInterval.js +14 -0
  16. package/dist/hooks/useInterval.js.map +1 -0
  17. package/lib/api/RetailAPI/doRequest.js +1 -0
  18. package/lib/api/RetailAPI/doRequest.js.map +1 -1
  19. package/lib/api/RetailAPI/updateRefreshToken.d.ts +1 -0
  20. package/lib/api/RetailAPI/updateRefreshToken.js +28 -0
  21. package/lib/api/RetailAPI/updateRefreshToken.js.map +1 -0
  22. package/lib/components/CreditForm/CreditForm.js +3 -1
  23. package/lib/components/CreditForm/CreditForm.js.map +1 -1
  24. package/lib/components/CreditForm/CreditFormStatusTracker.js +8 -6
  25. package/lib/components/CreditForm/CreditFormStatusTracker.js.map +1 -1
  26. package/lib/hooks/useInterval.d.ts +1 -0
  27. package/lib/hooks/useInterval.js +11 -0
  28. package/lib/hooks/useInterval.js.map +1 -0
  29. package/mobile/bundle/api/RetailAPI/updateRefreshToken.d.ts +1 -0
  30. package/mobile/bundle/bundle.umd.js +38 -7
  31. package/mobile/bundle/bundle.umd.min.js +1 -1
  32. package/mobile/bundle/hooks/useInterval.d.ts +1 -0
  33. package/mobile/dist/api/RetailAPI/doRequest.js +1 -0
  34. package/mobile/dist/api/RetailAPI/doRequest.js.map +1 -1
  35. package/mobile/dist/api/RetailAPI/updateRefreshToken.d.ts +1 -0
  36. package/mobile/dist/api/RetailAPI/updateRefreshToken.js +31 -0
  37. package/mobile/dist/api/RetailAPI/updateRefreshToken.js.map +1 -0
  38. package/mobile/dist/components/CreditForm/CreditForm.js +2 -0
  39. package/mobile/dist/components/CreditForm/CreditForm.js.map +1 -1
  40. package/mobile/dist/components/CreditForm/CreditFormStatusTracker.js +8 -6
  41. package/mobile/dist/components/CreditForm/CreditFormStatusTracker.js.map +1 -1
  42. package/mobile/dist/hooks/useInterval.d.ts +1 -0
  43. package/mobile/dist/hooks/useInterval.js +14 -0
  44. package/mobile/dist/hooks/useInterval.js.map +1 -0
  45. package/mobile/lib/api/RetailAPI/doRequest.js +1 -0
  46. package/mobile/lib/api/RetailAPI/doRequest.js.map +1 -1
  47. package/mobile/lib/api/RetailAPI/updateRefreshToken.d.ts +1 -0
  48. package/mobile/lib/api/RetailAPI/updateRefreshToken.js +28 -0
  49. package/mobile/lib/api/RetailAPI/updateRefreshToken.js.map +1 -0
  50. package/mobile/lib/components/CreditForm/CreditForm.js +3 -1
  51. package/mobile/lib/components/CreditForm/CreditForm.js.map +1 -1
  52. package/mobile/lib/components/CreditForm/CreditFormStatusTracker.js +8 -6
  53. package/mobile/lib/components/CreditForm/CreditFormStatusTracker.js.map +1 -1
  54. package/mobile/lib/hooks/useInterval.d.ts +1 -0
  55. package/mobile/lib/hooks/useInterval.js +11 -0
  56. package/mobile/lib/hooks/useInterval.js.map +1 -0
  57. package/mobile/src/api/RetailAPI/doRequest.ts +1 -0
  58. package/mobile/src/api/RetailAPI/updateRefreshToken.ts +42 -0
  59. package/mobile/src/components/CreditForm/CreditForm.tsx +4 -1
  60. package/mobile/src/components/CreditForm/CreditFormStatusTracker.tsx +3 -0
  61. package/mobile/src/hooks/useInterval.ts +14 -0
  62. package/package.json +1 -1
  63. package/src/api/RetailAPI/doRequest.ts +1 -0
  64. package/src/api/RetailAPI/updateRefreshToken.ts +42 -0
  65. package/src/components/CreditForm/CreditForm.fixture.tsx +7 -0
  66. package/src/components/CreditForm/CreditForm.tsx +4 -1
  67. package/src/components/CreditForm/CreditFormStatusTracker.tsx +3 -0
  68. package/src/hooks/useInterval.ts +14 -0
@@ -0,0 +1 @@
1
+ export declare const updateRefreshToken: () => () => void;
@@ -2261,6 +2261,7 @@
2261
2261
  credentials: 'include',
2262
2262
  body: body ? JSON.stringify(body) : null,
2263
2263
  });
2264
+ // TODO: add error handling
2264
2265
  return isJSON(response) ? response.json() : response;
2265
2266
  }
2266
2267
  // TODO: Need delete isJSON
@@ -6778,6 +6779,33 @@
6778
6779
  return (jsx(BlockWrapper, { className: style('bg-transparent', className), defaultPadding: "p-0", ...rest, children: jsxs("div", { className: "container grid grid-cols-12", children: [isFormFinished ? null : (jsx(CreditCardFormProgress, { stepsTitles: WIZARD_TITLES$1, step: step, totalSteps: WIZARD_STEPS$1 })), jsx("div", { className: "py-lg px-5xl mt-2xs bg-white col-span-12", children: jsx(CreditCardFormStep, { step: step, inputs: inputs, sections: sections, onNextStep: handleNextStep, onPrevStep: handlePrevStep, isFormFinished: isFormFinished, finishForm: setIsFormFinished }, String(step)) })] }) }));
6779
6780
  });
6780
6781
 
6782
+ const PORTAL_NATURAL_URL = '/';
6783
+ const UPDATING_INTERVAL = 60000 * 4;
6784
+ const updateRefreshToken = () => {
6785
+ const refreshToken = globalThis.sessionStorage?.getItem('refreshToken');
6786
+ const accessToken = globalThis.sessionStorage?.getItem('accessToken');
6787
+ const taskId = globalThis.localStorage.getItem('taskId');
6788
+ if (!accessToken || !refreshToken || !taskId) {
6789
+ globalThis.location.href = PORTAL_NATURAL_URL;
6790
+ return () => null;
6791
+ }
6792
+ const timer = setInterval(async () => {
6793
+ const res = await doRequest('/auth/refresh', 'POST', {
6794
+ // eslint-disable-next-line camelcase
6795
+ refresh_token: refreshToken,
6796
+ // eslint-disable-next-line camelcase
6797
+ access_token: accessToken,
6798
+ });
6799
+ if (res instanceof Response) {
6800
+ globalThis.location.href = PORTAL_NATURAL_URL;
6801
+ return;
6802
+ }
6803
+ sessionStorage.setItem('refreshToken', res.refresh_token);
6804
+ sessionStorage.setItem('accessToken', res.access_token);
6805
+ }, UPDATING_INTERVAL);
6806
+ return () => clearInterval(timer);
6807
+ };
6808
+
6781
6809
  const CreditFormProgress = JSX(({ step = 1, totalSteps = 5, stepsTitles = [] }) => {
6782
6810
  const progress = useMemo(() => (step / totalSteps) * 100, [step, totalSteps]);
6783
6811
  return (jsx("div", { className: "py-lg px-5xl bg-white col-span-12", children: jsxs("div", { children: [jsxs("span", { className: "font-bold mr-s", children: ["\u0428\u0430\u0433 ", step, " \u0438\u0437 ", totalSteps, "."] }), stepsTitles[step] || null, jsx(ProgressBar, { step: progress, showPercentage: false })] }) }));
@@ -6879,13 +6907,15 @@
6879
6907
  for (const signalType of SIGNAL_TYPES) {
6880
6908
  sendSignalToProcess({ signalType, taskId });
6881
6909
  }
6882
- const trackStatus = () => getTaskStatus({ taskId }).then((res) => {
6883
- if (res.statusCd && res.statusCd !== STATUS_TYPE.process) {
6884
- clearInterval(pullingInterval);
6885
- setStatus(res.statusCd);
6886
- }
6887
- });
6910
+ const trackStatus = () => taskId &&
6911
+ getTaskStatus({ taskId }).then((res) => {
6912
+ if (res.statusCd && res.statusCd !== STATUS_TYPE.process) {
6913
+ clearInterval(pullingInterval);
6914
+ setStatus(res.statusCd);
6915
+ }
6916
+ });
6888
6917
  const pullingInterval = setInterval(trackStatus, 30000);
6918
+ return () => clearInterval(pullingInterval);
6889
6919
  }, []);
6890
6920
  return renderStatus(status);
6891
6921
  });
@@ -7486,6 +7516,7 @@
7486
7516
  ];
7487
7517
  const CreditForm = JSX(({ className, ...rest }) => {
7488
7518
  const [step, setStep] = useState(0);
7519
+ useEffect(updateRefreshToken, []);
7489
7520
  const handleNextStep = useCallback(() => {
7490
7521
  setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
7491
7522
  }, []);
@@ -9768,7 +9799,7 @@
9768
9799
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
9769
9800
  });
9770
9801
 
9771
- const packageVersion = "0.14.651";
9802
+ const packageVersion = "0.14.652";
9772
9803
 
9773
9804
  exports.Blocks = Blocks;
9774
9805
  exports.ContentPage = ContentPage;