@redneckz/wildless-cms-uni-blocks 0.14.912 → 0.14.914

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 (223) hide show
  1. package/bundle/api/LeadServiceAPI.d.ts +12 -3
  2. package/bundle/bundle.umd.js +715 -683
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
  5. package/bundle/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
  6. package/bundle/components/TariffsTable/TariffsTableCell.d.ts +1 -1
  7. package/bundle/retail/api/checkCode.d.ts +1 -9
  8. package/bundle/retail/api/sendCode.d.ts +1 -1
  9. package/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
  10. package/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
  11. package/bundle/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
  12. package/bundle/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
  13. package/bundle/utils/getTimer.d.ts +2 -0
  14. package/dist/api/LeadServiceAPI.d.ts +12 -3
  15. package/dist/api/LeadServiceAPI.js +0 -3
  16. package/dist/api/LeadServiceAPI.js.map +1 -1
  17. package/dist/components/ApplicationForm/ApplicationForm.js +1 -3
  18. package/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
  19. package/dist/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
  20. package/dist/components/ApplicationForm/VerifyPhoneDialog.js +37 -0
  21. package/dist/components/ApplicationForm/VerifyPhoneDialog.js.map +1 -0
  22. package/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
  23. package/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.js +50 -0
  24. package/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.js.map +1 -0
  25. package/dist/components/TariffsTable/TariffsTableCell.d.ts +1 -1
  26. package/dist/retail/api/checkCode.d.ts +1 -9
  27. package/dist/retail/api/checkCode.js +1 -22
  28. package/dist/retail/api/checkCode.js.map +1 -1
  29. package/dist/retail/api/sendCode.d.ts +1 -1
  30. package/dist/retail/api/sendCode.js +2 -8
  31. package/dist/retail/api/sendCode.js.map +1 -1
  32. package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
  33. package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +5 -24
  34. package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  35. package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
  36. package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +7 -10
  37. package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  38. package/dist/retail/utils/mockLocalStorage.js +2 -2
  39. package/dist/retail/utils/mockLocalStorage.js.map +1 -1
  40. package/dist/ui-kit/BaseTile/BaseTile.js +1 -1
  41. package/dist/ui-kit/BaseTile/BaseTile.js.map +1 -1
  42. package/dist/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
  43. package/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
  44. package/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js +17 -0
  45. package/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js.map +1 -0
  46. package/dist/utils/getTimer.d.ts +2 -0
  47. package/dist/utils/getTimer.js +6 -0
  48. package/dist/utils/getTimer.js.map +1 -0
  49. package/lib/api/LeadServiceAPI.d.ts +12 -3
  50. package/lib/api/LeadServiceAPI.js +0 -3
  51. package/lib/api/LeadServiceAPI.js.map +1 -1
  52. package/lib/common.css +1 -1
  53. package/lib/components/ApplicationForm/ApplicationForm.js +1 -3
  54. package/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
  55. package/lib/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
  56. package/lib/components/ApplicationForm/VerifyPhoneDialog.js +35 -0
  57. package/lib/components/ApplicationForm/VerifyPhoneDialog.js.map +1 -0
  58. package/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
  59. package/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.js +47 -0
  60. package/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.js.map +1 -0
  61. package/lib/components/Carousel/Carousel.fixture.d.ts +1 -0
  62. package/lib/components/CarouselRecommendationCard/CarouselRecommendationCard.fixture.d.ts +1 -1
  63. package/lib/components/CarouselTariffsCard/CarouselTariffsCard.fixture.d.ts +2 -0
  64. package/lib/components/TariffsTable/TariffsTableCell.d.ts +1 -1
  65. package/lib/retail/api/checkCode.d.ts +1 -9
  66. package/lib/retail/api/checkCode.js +1 -22
  67. package/lib/retail/api/checkCode.js.map +1 -1
  68. package/lib/retail/api/sendCode.d.ts +1 -1
  69. package/lib/retail/api/sendCode.js +1 -7
  70. package/lib/retail/api/sendCode.js.map +1 -1
  71. package/lib/retail/components/DraftDialog/utils.d.ts +3 -3
  72. package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
  73. package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +5 -24
  74. package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  75. package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
  76. package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -8
  77. package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  78. package/lib/retail/utils/mockLocalStorage.js +2 -2
  79. package/lib/retail/utils/mockLocalStorage.js.map +1 -1
  80. package/lib/ui-kit/BaseTile/BaseTile.js +1 -1
  81. package/lib/ui-kit/BaseTile/BaseTile.js.map +1 -1
  82. package/lib/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
  83. package/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
  84. package/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js +15 -0
  85. package/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js.map +1 -0
  86. package/lib/utils/getTimer.d.ts +2 -0
  87. package/lib/utils/getTimer.js +3 -0
  88. package/lib/utils/getTimer.js.map +1 -0
  89. package/mobile/bundle/api/LeadServiceAPI.d.ts +12 -3
  90. package/mobile/bundle/bundle.umd.js +715 -683
  91. package/mobile/bundle/bundle.umd.min.js +1 -1
  92. package/mobile/bundle/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
  93. package/mobile/bundle/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
  94. package/mobile/bundle/components/TariffsTable/TariffsTableCell.d.ts +1 -1
  95. package/mobile/bundle/retail/api/checkCode.d.ts +1 -9
  96. package/mobile/bundle/retail/api/sendCode.d.ts +1 -1
  97. package/mobile/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
  98. package/mobile/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
  99. package/mobile/bundle/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
  100. package/mobile/bundle/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
  101. package/mobile/bundle/utils/getTimer.d.ts +2 -0
  102. package/mobile/dist/api/LeadServiceAPI.d.ts +12 -3
  103. package/mobile/dist/api/LeadServiceAPI.js +0 -3
  104. package/mobile/dist/api/LeadServiceAPI.js.map +1 -1
  105. package/mobile/dist/components/ApplicationForm/ApplicationForm.js +1 -3
  106. package/mobile/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
  107. package/mobile/dist/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
  108. package/mobile/dist/components/ApplicationForm/VerifyPhoneDialog.js +37 -0
  109. package/mobile/dist/components/ApplicationForm/VerifyPhoneDialog.js.map +1 -0
  110. package/mobile/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
  111. package/mobile/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.js +50 -0
  112. package/mobile/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.js.map +1 -0
  113. package/mobile/dist/components/TariffsTable/TariffsTableCell.d.ts +1 -1
  114. package/mobile/dist/retail/api/checkCode.d.ts +1 -9
  115. package/mobile/dist/retail/api/checkCode.js +1 -22
  116. package/mobile/dist/retail/api/checkCode.js.map +1 -1
  117. package/mobile/dist/retail/api/sendCode.d.ts +1 -1
  118. package/mobile/dist/retail/api/sendCode.js +2 -8
  119. package/mobile/dist/retail/api/sendCode.js.map +1 -1
  120. package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
  121. package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +5 -24
  122. package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  123. package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
  124. package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +7 -10
  125. package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  126. package/mobile/dist/retail/utils/mockLocalStorage.js +2 -2
  127. package/mobile/dist/retail/utils/mockLocalStorage.js.map +1 -1
  128. package/mobile/dist/ui-kit/BaseTile/BaseTile.js +1 -1
  129. package/mobile/dist/ui-kit/BaseTile/BaseTile.js.map +1 -1
  130. package/mobile/dist/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
  131. package/mobile/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
  132. package/mobile/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js +17 -0
  133. package/mobile/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js.map +1 -0
  134. package/mobile/dist/utils/getTimer.d.ts +2 -0
  135. package/mobile/dist/utils/getTimer.js +6 -0
  136. package/mobile/dist/utils/getTimer.js.map +1 -0
  137. package/mobile/lib/api/LeadServiceAPI.d.ts +12 -3
  138. package/mobile/lib/api/LeadServiceAPI.js +0 -3
  139. package/mobile/lib/api/LeadServiceAPI.js.map +1 -1
  140. package/mobile/lib/common.css +1 -1
  141. package/mobile/lib/components/ApplicationForm/ApplicationForm.js +1 -3
  142. package/mobile/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
  143. package/mobile/lib/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
  144. package/mobile/lib/components/ApplicationForm/VerifyPhoneDialog.js +35 -0
  145. package/mobile/lib/components/ApplicationForm/VerifyPhoneDialog.js.map +1 -0
  146. package/mobile/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
  147. package/mobile/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.js +47 -0
  148. package/mobile/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.js.map +1 -0
  149. package/mobile/lib/components/TariffsTable/TariffsTableCell.d.ts +1 -1
  150. package/mobile/lib/retail/api/checkCode.d.ts +1 -9
  151. package/mobile/lib/retail/api/checkCode.js +1 -22
  152. package/mobile/lib/retail/api/checkCode.js.map +1 -1
  153. package/mobile/lib/retail/api/sendCode.d.ts +1 -1
  154. package/mobile/lib/retail/api/sendCode.js +1 -7
  155. package/mobile/lib/retail/api/sendCode.js.map +1 -1
  156. package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
  157. package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +5 -24
  158. package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  159. package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
  160. package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -8
  161. package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  162. package/mobile/lib/retail/utils/mockLocalStorage.js +2 -2
  163. package/mobile/lib/retail/utils/mockLocalStorage.js.map +1 -1
  164. package/mobile/lib/ui-kit/BaseTile/BaseTile.js +1 -1
  165. package/mobile/lib/ui-kit/BaseTile/BaseTile.js.map +1 -1
  166. package/mobile/lib/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
  167. package/mobile/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
  168. package/mobile/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js +15 -0
  169. package/mobile/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js.map +1 -0
  170. package/mobile/lib/utils/getTimer.d.ts +2 -0
  171. package/mobile/lib/utils/getTimer.js +3 -0
  172. package/mobile/lib/utils/getTimer.js.map +1 -0
  173. package/mobile/src/api/LeadServiceAPI.ts +13 -7
  174. package/mobile/src/components/ApplicationForm/ApplicationForm.tsx +1 -3
  175. package/mobile/src/components/ApplicationForm/VerifyPhoneDialog.tsx +73 -0
  176. package/mobile/src/components/ApplicationForm/useVerifyPhoneDialogSubmit.tsx +63 -0
  177. package/mobile/src/components/TariffsTable/TariffsTableCell.tsx +1 -1
  178. package/mobile/src/retail/api/checkCode.ts +2 -47
  179. package/mobile/src/retail/api/sendCode.ts +1 -9
  180. package/mobile/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +23 -82
  181. package/mobile/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +7 -21
  182. package/mobile/src/retail/utils/mockLocalStorage.ts +9 -15
  183. package/mobile/src/ui-kit/BaseTile/BaseTile.tsx +1 -1
  184. package/mobile/src/ui-kit/ResponseTypeDialog/ResponseTypeDialog.tsx +1 -1
  185. package/mobile/src/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.tsx +80 -0
  186. package/mobile/src/utils/getTimer.ts +4 -0
  187. package/package.json +1 -1
  188. package/src/api/LeadServiceAPI.ts +13 -7
  189. package/src/components/ApplicationForm/ApplicationForm.tsx +1 -3
  190. package/src/components/ApplicationForm/VerifyPhoneDialog.tsx +73 -0
  191. package/src/components/ApplicationForm/useVerifyPhoneDialogSubmit.tsx +63 -0
  192. package/src/components/Carousel/Carousel.fixture.mobile.tsx +16 -16
  193. package/src/components/Carousel/Carousel.fixture.tsx +42 -20
  194. package/src/components/CarouselRecommendationCard/CarouselRecommendationCard.fixture.mobile.tsx +19 -19
  195. package/src/components/CarouselRecommendationCard/CarouselRecommendationCard.fixture.tsx +44 -23
  196. package/src/components/CarouselTariffsCard/CarouselTariffsCard.fixture.tsx +12 -12
  197. package/src/components/TariffsTable/TariffsTableCell.tsx +1 -1
  198. package/src/icons/IconName.ts +4 -4
  199. package/src/retail/api/checkCode.ts +2 -47
  200. package/src/retail/api/sendCode.ts +1 -9
  201. package/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +23 -82
  202. package/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +7 -21
  203. package/src/retail/utils/mockLocalStorage.ts +9 -15
  204. package/src/ui-kit/BaseTile/BaseTile.tsx +1 -1
  205. package/src/ui-kit/ResponseTypeDialog/ResponseTypeDialog.tsx +1 -1
  206. package/src/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.tsx +80 -0
  207. package/src/utils/getTimer.ts +4 -0
  208. package/bundle/model/onClose.d.ts +0 -3
  209. package/dist/model/onClose.d.ts +0 -3
  210. package/dist/model/onClose.js +0 -2
  211. package/dist/model/onClose.js.map +0 -1
  212. package/lib/model/onClose.d.ts +0 -3
  213. package/lib/model/onClose.js +0 -2
  214. package/lib/model/onClose.js.map +0 -1
  215. package/mobile/bundle/model/onClose.d.ts +0 -3
  216. package/mobile/dist/model/onClose.d.ts +0 -3
  217. package/mobile/dist/model/onClose.js +0 -2
  218. package/mobile/dist/model/onClose.js.map +0 -1
  219. package/mobile/lib/model/onClose.d.ts +0 -3
  220. package/mobile/lib/model/onClose.js +0 -2
  221. package/mobile/lib/model/onClose.js.map +0 -1
  222. package/mobile/src/model/onClose.ts +0 -3
  223. package/src/model/onClose.ts +0 -3
@@ -0,0 +1,73 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { LeadServiceAPI, type LeadRequest } from '../../api/LeadServiceAPI';
4
+ import type { OnCloseProps } from '../../model/OnCloseProps';
5
+ import { useCountDownTimer } from '../../ui-kit/TimerCircle/useCountDownTimer';
6
+ import { VerifyPhoneDialogLayout } from '../../ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout';
7
+ import { formatPhone } from '../../utils/formatPhone';
8
+ import { noop } from '../../utils/noop';
9
+ import { useVerifyPhoneDialogSubmit } from './useVerifyPhoneDialogSubmit';
10
+ const API = LeadServiceAPI();
11
+
12
+ const CODE_LENGTH = 4;
13
+ export const TIME_TO_RESEND = 180;
14
+
15
+ export interface VerifyPhoneDialogProps extends OnCloseProps {
16
+ phone: string;
17
+ onSuccess?: (smsCode?: string) => void;
18
+ formatData?: LeadRequest;
19
+ reqId?: string;
20
+ }
21
+
22
+ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
23
+ ({ phone, onSuccess = noop, onClose = noop, formatData = {}, reqId }) => {
24
+ const [values, setValues] = useState<string[]>(Array(CODE_LENGTH).fill('') as string[]);
25
+ const [requestId, setRequestId] = useState(reqId);
26
+
27
+ const {
28
+ handleSubmit,
29
+ hasError,
30
+ errorText,
31
+ isLoading,
32
+ timeNextReq,
33
+ isSubmitButtonDisabled,
34
+ setTimeNextReq,
35
+ setErrorText,
36
+ } = useVerifyPhoneDialogSubmit({
37
+ values,
38
+ onSuccess,
39
+ formatData,
40
+ reqId: requestId ?? '',
41
+ });
42
+
43
+ const phoneNumber = formatPhone(phone);
44
+ const restartTimer = useCountDownTimer({ seconds: timeNextReq, onTick: setTimeNextReq });
45
+
46
+ const handleSendCode = useCallback(async () => {
47
+ const response = await API.sendCode({ phone: phoneNumber });
48
+
49
+ if (response) {
50
+ setTimeNextReq(TIME_TO_RESEND);
51
+ restartTimer(TIME_TO_RESEND);
52
+ setErrorText('');
53
+ setRequestId(String(response));
54
+ }
55
+ }, [phoneNumber, restartTimer, onClose]);
56
+
57
+ return (
58
+ <VerifyPhoneDialogLayout
59
+ isSubmitButtonDisabled={isSubmitButtonDisabled}
60
+ onSubmit={handleSubmit}
61
+ onSendCode={handleSendCode}
62
+ timeNextReq={timeNextReq}
63
+ values={values}
64
+ onChange={setValues}
65
+ phone={phone}
66
+ isLoading={isLoading}
67
+ errorText={errorText}
68
+ hasError={hasError}
69
+ onClose={onClose}
70
+ />
71
+ );
72
+ },
73
+ );
@@ -0,0 +1,63 @@
1
+ import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
3
+ import { LeadServiceAPI, type LeadRequest } from '../../api/LeadServiceAPI';
4
+ import { getTimer } from '../../utils/getTimer';
5
+ const API = LeadServiceAPI();
6
+
7
+ type useVerifyPhoneDialogSubmitProps = {
8
+ values: string[];
9
+ formatData: LeadRequest;
10
+ reqId: string;
11
+ onSuccess?: (smsCode?: string) => void;
12
+ };
13
+
14
+ export const useVerifyPhoneDialogSubmit = ({
15
+ values,
16
+ onSuccess,
17
+ formatData,
18
+ reqId,
19
+ }: useVerifyPhoneDialogSubmitProps) => {
20
+ const timer = Math.max(getTimer(Date.now()), 0);
21
+
22
+ const [errorText, setErrorText] = useState('');
23
+ const [isLoading, { setTrue: startLoading, setFalse: endLoading }] = useBool(false);
24
+ const [timeNextReq, setTimeNextReq] = useState(timer);
25
+
26
+ const resetError = useCallback(() => setErrorText(''), []);
27
+
28
+ const isSubmitButtonDisabled = !values.every(Boolean);
29
+
30
+ const handleSubmit = useCallback(async () => {
31
+ try {
32
+ startLoading();
33
+ const response = await API.checkCode({
34
+ code: values.join(''),
35
+ body: formatData,
36
+ reqId,
37
+ });
38
+ if (response?.errorDesc) {
39
+ setErrorText(response?.errorDesc);
40
+
41
+ return;
42
+ }
43
+ setTimeNextReq(0);
44
+ resetError();
45
+ onSuccess?.(values.join(''));
46
+ } catch {
47
+ setErrorText('Неверный код');
48
+ } finally {
49
+ endLoading();
50
+ }
51
+ }, [values]);
52
+
53
+ return {
54
+ handleSubmit,
55
+ hasError: Boolean(errorText),
56
+ errorText,
57
+ isLoading,
58
+ timeNextReq,
59
+ isSubmitButtonDisabled,
60
+ setTimeNextReq,
61
+ setErrorText,
62
+ };
63
+ };
@@ -10,7 +10,7 @@ import { TARIFFS_CARD, TARIFFS_CARD_HIT } from '../CarouselTariffsCard/CarouselT
10
10
  import { type ProductBlockContent } from '../ProductBlock/ProductBlockContent';
11
11
  import { Carousel } from './Carousel';
12
12
 
13
- const catalogImage: Picture = {
13
+ const CATALOG_IMAGE: Picture = {
14
14
  src: 'pay-ring.png',
15
15
  format: 'webp',
16
16
  size: {
@@ -20,7 +20,7 @@ const catalogImage: Picture = {
20
20
  title: 'pay-ring',
21
21
  };
22
22
 
23
- const productBlock: ProductBlockContent = {
23
+ const PRODUCT_BLOCK: ProductBlockContent = {
24
24
  isFullWidthTitle: true,
25
25
  version: 'secondary',
26
26
  image: {
@@ -39,7 +39,7 @@ const productBlock: ProductBlockContent = {
39
39
  ],
40
40
  };
41
41
 
42
- const options = {
42
+ const OPTIONS = {
43
43
  blocksRegistry: Blocks,
44
44
  } as BlockRendererOptions;
45
45
 
@@ -53,19 +53,19 @@ export default {
53
53
  blocks: [
54
54
  {
55
55
  type: 'CarouselCatalogCard',
56
- content: { ...CATALOG_CARD, image: catalogImage },
56
+ content: { ...CATALOG_CARD, image: CATALOG_IMAGE },
57
57
  },
58
58
  {
59
59
  type: 'CarouselCatalogCard',
60
- content: { ...CATALOG_CARD_NEW, image: catalogImage },
60
+ content: { ...CATALOG_CARD_NEW, image: CATALOG_IMAGE },
61
61
  },
62
62
  {
63
63
  type: 'CarouselCatalogCard',
64
- content: { ...CATALOG_CARD, image: catalogImage },
64
+ content: { ...CATALOG_CARD, image: CATALOG_IMAGE },
65
65
  },
66
66
  ],
67
67
  }}
68
- options={options}
68
+ options={OPTIONS}
69
69
  />
70
70
  </div>
71
71
  ),
@@ -90,7 +90,7 @@ export default {
90
90
  },
91
91
  ],
92
92
  }}
93
- options={options}
93
+ options={OPTIONS}
94
94
  />
95
95
  </div>
96
96
  ),
@@ -105,7 +105,7 @@ export default {
105
105
  content: CAROUSEL_RECOMMENDATION_CARD,
106
106
  }),
107
107
  }}
108
- options={options}
108
+ options={OPTIONS}
109
109
  />
110
110
  </div>
111
111
  ),
@@ -120,7 +120,7 @@ export default {
120
120
  content: { version: 'secondary', ...CAROUSEL_RECOMMENDATION_CARD },
121
121
  }),
122
122
  }}
123
- options={options}
123
+ options={OPTIONS}
124
124
  />
125
125
  </div>
126
126
  ),
@@ -137,7 +137,7 @@ export default {
137
137
  content: CAROUSEL_RECOMMENDATION_CARD_BENEFITS,
138
138
  }),
139
139
  }}
140
- options={options}
140
+ options={OPTIONS}
141
141
  />
142
142
  </div>
143
143
  ),
@@ -153,28 +153,28 @@ export default {
153
153
  block={{
154
154
  type: 'Carousel',
155
155
  blocks: [
156
- { type: 'ProductBlock', content: { ...productBlock } },
156
+ { type: 'ProductBlock', content: { ...PRODUCT_BLOCK } },
157
157
  {
158
158
  type: 'ProductBlock',
159
159
  content: {
160
- ...productBlock,
160
+ ...PRODUCT_BLOCK,
161
161
  title: 'Вклад «Доходный»',
162
162
  description: 'Получайте максимальный доход даже при небольшой сумме вклада',
163
163
  additionalDescription: 'Ставка до 16% годовых',
164
164
  },
165
165
  },
166
- { type: 'ProductBlock', content: { ...productBlock, title: 'Карта Своя' } },
166
+ { type: 'ProductBlock', content: { ...PRODUCT_BLOCK, title: 'Карта Своя' } },
167
167
  {
168
168
  type: 'ProductBlock',
169
169
  content: {
170
- ...productBlock,
170
+ ...PRODUCT_BLOCK,
171
171
  title: 'Сельская ипотека',
172
172
  additionalDescription: 'до 6 млн. ₽',
173
173
  },
174
174
  },
175
175
  ],
176
176
  }}
177
- options={options}
177
+ options={OPTIONS}
178
178
  />
179
179
  </div>
180
180
  ),
@@ -5,6 +5,7 @@ import '../../setup-fixture';
5
5
  import { Blocks } from '../Blocks';
6
6
  import { CATALOG_CARD, CATALOG_CARD_NEW } from '../CarouselCatalogCard/CarouselCatalogCard.fixture';
7
7
  import {
8
+ CAROUSEL_RECOMMENDATION_CARD_AS_TARIFF,
8
9
  CAROUSEL_RECOMMENDATION_CARD_BENEFITS,
9
10
  CAROUSEL_RECOMMENDATION_CARD_SECONDARY,
10
11
  CAROUSEL_RECOMMENDATION_CARD_WITHOUT_LIST,
@@ -14,7 +15,7 @@ import { type ProductBlockContent } from '../ProductBlock/ProductBlockContent';
14
15
  import { RICH_CARD } from '../RichTextBlock/RichTextBlock.fixture';
15
16
  import { Carousel } from './Carousel';
16
17
 
17
- const cardsListHtml =
18
+ const CARDS_LIST_HTML =
18
19
  '<p><strong>IR</strong>cтрана эмитента</p><p><strong>RU</strong>страна риска</p><p><strong>09.03.2022</strong>дата погашения</p><p><strong>Ba3</strong>рейтинг MOODY’S</p>';
19
20
 
20
21
  const five: Picture = {
@@ -29,11 +30,11 @@ const five: Picture = {
29
30
  const INVESTMENT_CARD_WITH_SINGLE_COLUMN: ProductBlockContent = {
30
31
  title: 'Borets Finance DAC 17/09/26',
31
32
  description: 'Краткосрочная',
32
- __html: cardsListHtml,
33
+ __html: CARDS_LIST_HTML,
33
34
  image: five,
34
35
  };
35
36
 
36
- const catalogImage: Picture = {
37
+ const CATALOG_IMAGE: Picture = {
37
38
  src: 'pay-ring.png',
38
39
  format: 'webp',
39
40
  size: {
@@ -43,7 +44,7 @@ const catalogImage: Picture = {
43
44
  title: 'pay-ring',
44
45
  };
45
46
 
46
- const productBlock: ProductBlockContent = {
47
+ const PRODUCT_BLOCK: ProductBlockContent = {
47
48
  isFullWidthTitle: true,
48
49
  version: 'secondary',
49
50
  image: {
@@ -62,7 +63,7 @@ const productBlock: ProductBlockContent = {
62
63
  ],
63
64
  };
64
65
 
65
- const options = {
66
+ const OPTIONS = {
66
67
  blocksRegistry: Blocks,
67
68
  } as BlockRendererOptions;
68
69
 
@@ -77,19 +78,19 @@ export default {
77
78
  blocks: [
78
79
  {
79
80
  type: 'CarouselCatalogCard',
80
- content: { ...CATALOG_CARD, image: catalogImage },
81
+ content: { ...CATALOG_CARD, image: CATALOG_IMAGE },
81
82
  },
82
83
  {
83
84
  type: 'CarouselCatalogCard',
84
- content: { ...CATALOG_CARD_NEW, image: catalogImage },
85
+ content: { ...CATALOG_CARD_NEW, image: CATALOG_IMAGE },
85
86
  },
86
87
  {
87
88
  type: 'CarouselCatalogCard',
88
- content: { ...CATALOG_CARD, image: catalogImage },
89
+ content: { ...CATALOG_CARD, image: CATALOG_IMAGE },
89
90
  },
90
91
  ],
91
92
  }}
92
- options={options}
93
+ options={OPTIONS}
93
94
  />
94
95
  </div>
95
96
  ),
@@ -108,7 +109,28 @@ export default {
108
109
  })
109
110
  .map((_, i) => (i === 1 ? { ..._, content: TARIFFS_CARD_HIT } : _)),
110
111
  }}
111
- options={options}
112
+ options={OPTIONS}
113
+ />
114
+ </div>
115
+ ),
116
+ 'tariffs (via recommendation card)': (
117
+ <div className="container grid grid-cols-12">
118
+ <Carousel
119
+ className="col-span-12"
120
+ visibleItemCount={0}
121
+ isGap={false}
122
+ block={{
123
+ type: 'Carousel',
124
+ blocks: Array.from<BlockDef>({ length: 6 })
125
+ .fill({
126
+ type: 'CarouselRecommendationCard',
127
+ content: CAROUSEL_RECOMMENDATION_CARD_AS_TARIFF,
128
+ })
129
+ .map((_, i) =>
130
+ i === 1 ? { ..._, content: { ..._.content, isHighlighting: true } } : _,
131
+ ),
132
+ }}
133
+ options={OPTIONS}
112
134
  />
113
135
  </div>
114
136
  ),
@@ -124,7 +146,7 @@ export default {
124
146
  content: INVESTMENT_CARD_WITH_SINGLE_COLUMN,
125
147
  }),
126
148
  }}
127
- options={options}
149
+ options={OPTIONS}
128
150
  />
129
151
  </div>
130
152
  ),
@@ -141,7 +163,7 @@ export default {
141
163
  content: CAROUSEL_RECOMMENDATION_CARD_WITHOUT_LIST,
142
164
  }),
143
165
  }}
144
- options={options}
166
+ options={OPTIONS}
145
167
  />
146
168
  </div>
147
169
  ),
@@ -158,7 +180,7 @@ export default {
158
180
  content: CAROUSEL_RECOMMENDATION_CARD_SECONDARY,
159
181
  }),
160
182
  }}
161
- options={options}
183
+ options={OPTIONS}
162
184
  />
163
185
  </div>
164
186
  ),
@@ -175,7 +197,7 @@ export default {
175
197
  content: CAROUSEL_RECOMMENDATION_CARD_BENEFITS,
176
198
  }),
177
199
  }}
178
- options={options}
200
+ options={OPTIONS}
179
201
  />
180
202
  </div>
181
203
  ),
@@ -191,7 +213,7 @@ export default {
191
213
  content: RICH_CARD,
192
214
  }),
193
215
  }}
194
- options={options}
216
+ options={OPTIONS}
195
217
  />
196
218
  </div>
197
219
  ),
@@ -207,28 +229,28 @@ export default {
207
229
  block={{
208
230
  type: 'Carousel',
209
231
  blocks: [
210
- { type: 'ProductBlock', content: { ...productBlock } },
232
+ { type: 'ProductBlock', content: { ...PRODUCT_BLOCK } },
211
233
  {
212
234
  type: 'ProductBlock',
213
235
  content: {
214
- ...productBlock,
236
+ ...PRODUCT_BLOCK,
215
237
  title: 'Вклад «Доходный»',
216
238
  description: 'Получайте максимальный доход даже при небольшой сумме вклада',
217
239
  additionalDescription: 'Ставка до 16% годовых',
218
240
  },
219
241
  },
220
- { type: 'ProductBlock', content: { ...productBlock, title: 'Карта Своя' } },
242
+ { type: 'ProductBlock', content: { ...PRODUCT_BLOCK, title: 'Карта Своя' } },
221
243
  {
222
244
  type: 'ProductBlock',
223
245
  content: {
224
- ...productBlock,
246
+ ...PRODUCT_BLOCK,
225
247
  title: 'Сельская ипотека',
226
248
  additionalDescription: 'до 6 млн. ₽',
227
249
  },
228
250
  },
229
251
  ],
230
252
  }}
231
- options={options}
253
+ options={OPTIONS}
232
254
  />
233
255
  </div>
234
256
  ),
@@ -5,7 +5,7 @@ import { type LinkButtonContent } from '../../ui-kit/LinkButton/LinkButtonConten
5
5
  import { CarouselRecommendationCard } from './CarouselRecommendationCard';
6
6
  import { type CarouselRecommendationCardContent } from './CarouselRecommendationCardContent';
7
7
 
8
- const icon: Picture = {
8
+ const ICON: Picture = {
9
9
  src: 'product-basket.png',
10
10
  format: 'webp',
11
11
  size: {
@@ -15,7 +15,7 @@ const icon: Picture = {
15
15
  title: 'product-basket',
16
16
  };
17
17
 
18
- const iconCoin: Picture = {
18
+ const ICON_COIN: Picture = {
19
19
  src: 'coin.png',
20
20
  format: 'webp',
21
21
  size: {
@@ -24,7 +24,7 @@ const iconCoin: Picture = {
24
24
  title: 'money',
25
25
  };
26
26
 
27
- const benefits: BenefitItemContent[] = [
27
+ const BENEFITS: BenefitItemContent[] = [
28
28
  {
29
29
  label: 'От 16 до 81',
30
30
  description: 'платежей',
@@ -35,7 +35,7 @@ const benefits: BenefitItemContent[] = [
35
35
  },
36
36
  ];
37
37
 
38
- const socialMediaWithText: LinkButtonContent[] = [
38
+ const SOCIAL_MEDIA_WITH_TEXT: LinkButtonContent[] = [
39
39
  {
40
40
  href: 'https://t.me',
41
41
  text: 'Telegram',
@@ -50,7 +50,7 @@ const socialMediaWithText: LinkButtonContent[] = [
50
50
  },
51
51
  ];
52
52
 
53
- const socialMediaWithoutText: LinkButtonContent[] = [
53
+ const SOCIAL_MEDIA_WITHOUT_TEXT: LinkButtonContent[] = [
54
54
  {
55
55
  href: 'https://t.me',
56
56
  },
@@ -62,7 +62,7 @@ const socialMediaWithoutText: LinkButtonContent[] = [
62
62
  },
63
63
  ];
64
64
 
65
- const __html = `
65
+ const HTML = `
66
66
  <ul>
67
67
  <li>Бесплатное подключение и обслуживание</li>
68
68
  <li>Вход и подписание документов по биометрии</li>
@@ -73,38 +73,38 @@ const __html = `
73
73
  export const CAROUSEL_RECOMMENDATION_CARD: CarouselRecommendationCardContent = {
74
74
  title: 'Подключаем мобильный банк для управления бизнесом',
75
75
  description: 'Все возможности банка для бизнеса в вашем смартфоне',
76
- __html,
77
- icon,
78
- socialMedia: socialMediaWithText,
76
+ __html: HTML,
77
+ icon: ICON,
78
+ socialMedia: SOCIAL_MEDIA_WITH_TEXT,
79
79
  };
80
80
 
81
81
  export const CAROUSEL_RECOMMENDATION_CARD_SIMPLE: CarouselRecommendationCardContent = {
82
82
  title: 'Подключаем мобильный банк для управления бизнесом',
83
83
  description: 'Все возможности банка для бизнеса в вашем смартфоне',
84
- __html,
85
- icon,
86
- socialMedia: socialMediaWithoutText,
84
+ __html: HTML,
85
+ icon: ICON,
86
+ socialMedia: SOCIAL_MEDIA_WITHOUT_TEXT,
87
87
  };
88
88
  export const CAROUSEL_RECOMMENDATION_CARD_WITHOUT_LIST: CarouselRecommendationCardContent = {
89
89
  title: 'Подключаем мобильный банк для управления бизнесом',
90
90
  description: 'Все возможности банка для бизнеса в вашем смартфоне',
91
- icon,
92
- socialMedia: socialMediaWithoutText,
91
+ icon: ICON,
92
+ socialMedia: SOCIAL_MEDIA_WITHOUT_TEXT,
93
93
  };
94
94
 
95
95
  export const CAROUSEL_RECOMMENDATION_CARD_SECONDARY: CarouselRecommendationCardContent = {
96
96
  title: 'Россельхозбанк',
97
97
  description: 'Описание',
98
98
  align: 'text-left',
99
- icon,
99
+ icon: ICON,
100
100
  __html: `
101
101
  <ul>
102
102
  <li>Свежие новости</li>
103
- <li>Акции и предложения</li>
103
+ <li>Акции и предложения</li>
104
104
  <li>Ставки и катировки</li>
105
105
  </ul>`,
106
106
  version: 'secondary',
107
- socialMedia: socialMediaWithoutText,
107
+ socialMedia: SOCIAL_MEDIA_WITHOUT_TEXT,
108
108
  };
109
109
 
110
110
  export const CAROUSEL_RECOMMENDATION_CARD_BENEFITS: CarouselRecommendationCardContent = {
@@ -112,8 +112,8 @@ export const CAROUSEL_RECOMMENDATION_CARD_BENEFITS: CarouselRecommendationCardCo
112
112
  imageOptions: {
113
113
  directionRight: false,
114
114
  },
115
- icon: iconCoin,
116
- benefits: benefits,
115
+ icon: ICON_COIN,
116
+ benefits: BENEFITS,
117
117
  };
118
118
 
119
119
  export default {