@redneckz/wildless-cms-uni-blocks 0.14.714 → 0.14.716

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 (193) hide show
  1. package/bundle/bundle.umd.js +68 -51
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
  4. package/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
  5. package/bundle/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
  6. package/bundle/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
  7. package/bundle/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
  8. package/bundle/components/CreditForm/useCreditFormAPI.d.ts +1 -1
  9. package/bundle/ui-kit/Button/Button.d.ts +1 -0
  10. package/bundle/ui-kit/Loader/Loader.d.ts +1 -0
  11. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +2 -2
  12. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  13. package/dist/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
  14. package/dist/components/ApplicationLeadForm/renderSubmitButton.js +1 -1
  15. package/dist/components/ApplicationLeadForm/renderSubmitButton.js.map +1 -1
  16. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
  17. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +10 -7
  18. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  19. package/dist/components/CreditCardForm/CreditCardFormStep.js +2 -2
  20. package/dist/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
  21. package/dist/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
  22. package/dist/components/CreditCardForm/StepsNavigationButtons.js +2 -2
  23. package/dist/components/CreditCardForm/StepsNavigationButtons.js.map +1 -1
  24. package/dist/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
  25. package/dist/components/CreditCardForm/useCreditCardFormAPI.js +7 -1
  26. package/dist/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
  27. package/dist/components/CreditForm/CreditFormStep.js +2 -2
  28. package/dist/components/CreditForm/CreditFormStep.js.map +1 -1
  29. package/dist/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
  30. package/dist/components/CreditForm/StepsNavigationButtons.js +2 -2
  31. package/dist/components/CreditForm/StepsNavigationButtons.js.map +1 -1
  32. package/dist/components/CreditForm/useCreditFormAPI.d.ts +1 -1
  33. package/dist/components/CreditForm/useCreditFormAPI.js +7 -1
  34. package/dist/components/CreditForm/useCreditFormAPI.js.map +1 -1
  35. package/dist/ui-kit/Button/Button.d.ts +1 -0
  36. package/dist/ui-kit/Button/Button.js +6 -5
  37. package/dist/ui-kit/Button/Button.js.map +1 -1
  38. package/dist/ui-kit/FormField/Fields/Experience5YearsField.js +9 -1
  39. package/dist/ui-kit/FormField/Fields/Experience5YearsField.js.map +1 -1
  40. package/dist/ui-kit/FormField/Fields/PartInBusinessField.js +3 -3
  41. package/dist/ui-kit/FormField/Fields/PartInBusinessField.js.map +1 -1
  42. package/dist/ui-kit/Loader/Loader.d.ts +1 -0
  43. package/dist/ui-kit/Loader/Loader.js +2 -2
  44. package/dist/ui-kit/Loader/Loader.js.map +1 -1
  45. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -4
  46. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  47. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +2 -2
  48. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  49. package/lib/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
  50. package/lib/components/ApplicationLeadForm/renderSubmitButton.js +1 -1
  51. package/lib/components/ApplicationLeadForm/renderSubmitButton.js.map +1 -1
  52. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
  53. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +10 -7
  54. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  55. package/lib/components/CreditCardForm/CreditCardFormStep.js +2 -2
  56. package/lib/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
  57. package/lib/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
  58. package/lib/components/CreditCardForm/StepsNavigationButtons.js +2 -2
  59. package/lib/components/CreditCardForm/StepsNavigationButtons.js.map +1 -1
  60. package/lib/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
  61. package/lib/components/CreditCardForm/useCreditCardFormAPI.js +7 -1
  62. package/lib/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
  63. package/lib/components/CreditForm/CreditFormStep.js +2 -2
  64. package/lib/components/CreditForm/CreditFormStep.js.map +1 -1
  65. package/lib/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
  66. package/lib/components/CreditForm/StepsNavigationButtons.js +2 -2
  67. package/lib/components/CreditForm/StepsNavigationButtons.js.map +1 -1
  68. package/lib/components/CreditForm/useCreditFormAPI.d.ts +1 -1
  69. package/lib/components/CreditForm/useCreditFormAPI.js +7 -1
  70. package/lib/components/CreditForm/useCreditFormAPI.js.map +1 -1
  71. package/lib/ui-kit/Button/Button.d.ts +1 -0
  72. package/lib/ui-kit/Button/Button.js +7 -6
  73. package/lib/ui-kit/Button/Button.js.map +1 -1
  74. package/lib/ui-kit/FormField/Fields/Experience5YearsField.js +9 -1
  75. package/lib/ui-kit/FormField/Fields/Experience5YearsField.js.map +1 -1
  76. package/lib/ui-kit/FormField/Fields/PartInBusinessField.js +3 -3
  77. package/lib/ui-kit/FormField/Fields/PartInBusinessField.js.map +1 -1
  78. package/lib/ui-kit/Loader/Loader.d.ts +1 -0
  79. package/lib/ui-kit/Loader/Loader.js +2 -2
  80. package/lib/ui-kit/Loader/Loader.js.map +1 -1
  81. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -4
  82. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  83. package/mobile/bundle/bundle.umd.js +68 -51
  84. package/mobile/bundle/bundle.umd.min.js +1 -1
  85. package/mobile/bundle/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
  86. package/mobile/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
  87. package/mobile/bundle/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
  88. package/mobile/bundle/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
  89. package/mobile/bundle/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
  90. package/mobile/bundle/components/CreditForm/useCreditFormAPI.d.ts +1 -1
  91. package/mobile/bundle/ui-kit/Button/Button.d.ts +1 -0
  92. package/mobile/bundle/ui-kit/Loader/Loader.d.ts +1 -0
  93. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +2 -2
  94. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  95. package/mobile/dist/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
  96. package/mobile/dist/components/ApplicationLeadForm/renderSubmitButton.js +1 -1
  97. package/mobile/dist/components/ApplicationLeadForm/renderSubmitButton.js.map +1 -1
  98. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
  99. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +10 -7
  100. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  101. package/mobile/dist/components/CreditCardForm/CreditCardFormStep.js +2 -2
  102. package/mobile/dist/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
  103. package/mobile/dist/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
  104. package/mobile/dist/components/CreditCardForm/StepsNavigationButtons.js +2 -2
  105. package/mobile/dist/components/CreditCardForm/StepsNavigationButtons.js.map +1 -1
  106. package/mobile/dist/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
  107. package/mobile/dist/components/CreditCardForm/useCreditCardFormAPI.js +7 -1
  108. package/mobile/dist/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
  109. package/mobile/dist/components/CreditForm/CreditFormStep.js +2 -2
  110. package/mobile/dist/components/CreditForm/CreditFormStep.js.map +1 -1
  111. package/mobile/dist/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
  112. package/mobile/dist/components/CreditForm/StepsNavigationButtons.js +2 -2
  113. package/mobile/dist/components/CreditForm/StepsNavigationButtons.js.map +1 -1
  114. package/mobile/dist/components/CreditForm/useCreditFormAPI.d.ts +1 -1
  115. package/mobile/dist/components/CreditForm/useCreditFormAPI.js +7 -1
  116. package/mobile/dist/components/CreditForm/useCreditFormAPI.js.map +1 -1
  117. package/mobile/dist/ui-kit/Button/Button.d.ts +1 -0
  118. package/mobile/dist/ui-kit/Button/Button.js +6 -5
  119. package/mobile/dist/ui-kit/Button/Button.js.map +1 -1
  120. package/mobile/dist/ui-kit/FormField/Fields/Experience5YearsField.js +9 -1
  121. package/mobile/dist/ui-kit/FormField/Fields/Experience5YearsField.js.map +1 -1
  122. package/mobile/dist/ui-kit/FormField/Fields/PartInBusinessField.js +3 -3
  123. package/mobile/dist/ui-kit/FormField/Fields/PartInBusinessField.js.map +1 -1
  124. package/mobile/dist/ui-kit/Loader/Loader.d.ts +1 -0
  125. package/mobile/dist/ui-kit/Loader/Loader.js +2 -2
  126. package/mobile/dist/ui-kit/Loader/Loader.js.map +1 -1
  127. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -4
  128. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  129. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +2 -2
  130. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  131. package/mobile/lib/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
  132. package/mobile/lib/components/ApplicationLeadForm/renderSubmitButton.js +1 -1
  133. package/mobile/lib/components/ApplicationLeadForm/renderSubmitButton.js.map +1 -1
  134. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
  135. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +10 -7
  136. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  137. package/mobile/lib/components/CreditCardForm/CreditCardFormStep.js +2 -2
  138. package/mobile/lib/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
  139. package/mobile/lib/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
  140. package/mobile/lib/components/CreditCardForm/StepsNavigationButtons.js +2 -2
  141. package/mobile/lib/components/CreditCardForm/StepsNavigationButtons.js.map +1 -1
  142. package/mobile/lib/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
  143. package/mobile/lib/components/CreditCardForm/useCreditCardFormAPI.js +7 -1
  144. package/mobile/lib/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
  145. package/mobile/lib/components/CreditForm/CreditFormStep.js +2 -2
  146. package/mobile/lib/components/CreditForm/CreditFormStep.js.map +1 -1
  147. package/mobile/lib/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
  148. package/mobile/lib/components/CreditForm/StepsNavigationButtons.js +2 -2
  149. package/mobile/lib/components/CreditForm/StepsNavigationButtons.js.map +1 -1
  150. package/mobile/lib/components/CreditForm/useCreditFormAPI.d.ts +1 -1
  151. package/mobile/lib/components/CreditForm/useCreditFormAPI.js +7 -1
  152. package/mobile/lib/components/CreditForm/useCreditFormAPI.js.map +1 -1
  153. package/mobile/lib/ui-kit/Button/Button.d.ts +1 -0
  154. package/mobile/lib/ui-kit/Button/Button.js +7 -6
  155. package/mobile/lib/ui-kit/Button/Button.js.map +1 -1
  156. package/mobile/lib/ui-kit/FormField/Fields/Experience5YearsField.js +9 -1
  157. package/mobile/lib/ui-kit/FormField/Fields/Experience5YearsField.js.map +1 -1
  158. package/mobile/lib/ui-kit/FormField/Fields/PartInBusinessField.js +3 -3
  159. package/mobile/lib/ui-kit/FormField/Fields/PartInBusinessField.js.map +1 -1
  160. package/mobile/lib/ui-kit/Loader/Loader.d.ts +1 -0
  161. package/mobile/lib/ui-kit/Loader/Loader.js +2 -2
  162. package/mobile/lib/ui-kit/Loader/Loader.js.map +1 -1
  163. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -4
  164. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  165. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +2 -2
  166. package/mobile/src/components/ApplicationLeadForm/renderSubmitButton.tsx +2 -2
  167. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +12 -7
  168. package/mobile/src/components/CreditCardForm/CreditCardFormStep.tsx +2 -2
  169. package/mobile/src/components/CreditCardForm/StepsNavigationButtons.tsx +17 -12
  170. package/mobile/src/components/CreditCardForm/useCreditCardFormAPI.tsx +7 -2
  171. package/mobile/src/components/CreditForm/CreditFormStep.tsx +2 -2
  172. package/mobile/src/components/CreditForm/StepsNavigationButtons.tsx +17 -12
  173. package/mobile/src/components/CreditForm/useCreditFormAPI.tsx +7 -2
  174. package/mobile/src/ui-kit/Button/Button.tsx +7 -3
  175. package/mobile/src/ui-kit/FormField/Fields/Experience5YearsField.tsx +24 -10
  176. package/mobile/src/ui-kit/FormField/Fields/PartInBusinessField.tsx +7 -5
  177. package/mobile/src/ui-kit/Loader/Loader.tsx +5 -3
  178. package/mobile/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +5 -4
  179. package/package.json +1 -1
  180. package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +2 -2
  181. package/src/components/ApplicationLeadForm/renderSubmitButton.tsx +2 -2
  182. package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +12 -7
  183. package/src/components/CreditCardForm/CreditCardFormStep.tsx +2 -2
  184. package/src/components/CreditCardForm/StepsNavigationButtons.tsx +17 -12
  185. package/src/components/CreditCardForm/useCreditCardFormAPI.tsx +7 -2
  186. package/src/components/CreditForm/CreditFormStep.tsx +2 -2
  187. package/src/components/CreditForm/StepsNavigationButtons.tsx +17 -12
  188. package/src/components/CreditForm/useCreditFormAPI.tsx +7 -2
  189. package/src/ui-kit/Button/Button.tsx +7 -3
  190. package/src/ui-kit/FormField/Fields/Experience5YearsField.tsx +24 -10
  191. package/src/ui-kit/FormField/Fields/PartInBusinessField.tsx +7 -5
  192. package/src/ui-kit/Loader/Loader.tsx +5 -3
  193. package/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +5 -4
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useMemo } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
2
3
  import { updateUserTask } from '../../api/RetailAPI/updateUserTask';
3
4
  import { useRetailFormStore } from '../../hooks/useRetailFormStore';
4
5
  import { getObjectValidator } from '../../ui-kit/FormField/getObjectValidator';
@@ -22,7 +23,8 @@ export const useCreditCardFormAPI = ({
22
23
  inputs,
23
24
  onNextStep,
24
25
  onFinish,
25
- }: CreditFormApiProps): [LeadFormState, (formData: LeadFormState) => void] => {
26
+ }: CreditFormApiProps): [LeadFormState, (formData: LeadFormState) => void, boolean] => {
27
+ const [isSending, { setTrue: startSending, setFalse: endSending }] = useBool(false);
26
28
  const isFinalStep = step === 5;
27
29
 
28
30
  const retailFormStore = useRetailFormStore();
@@ -61,6 +63,7 @@ export const useCreditCardFormAPI = ({
61
63
  return;
62
64
  }
63
65
 
66
+ startSending();
64
67
  retailFormStore.leadForm = formData;
65
68
 
66
69
  try {
@@ -84,12 +87,14 @@ export const useCreditCardFormAPI = ({
84
87
  }
85
88
  } catch (ex) {
86
89
  // Do nothing
90
+ } finally {
91
+ endSending();
87
92
  }
88
93
  },
89
94
  [isFinalStep, resetForm],
90
95
  );
91
96
 
92
- return [initialState, handleSubmit];
97
+ return [initialState, handleSubmit, isSending];
93
98
  };
94
99
 
95
100
  const getValue =
@@ -30,7 +30,7 @@ export const CreditFormStep = JSX<CreditFormStepProps>(
30
30
  [sections],
31
31
  );
32
32
 
33
- const [initialState, onSubmit] = useCreditFormAPI({
33
+ const [initialState, onSubmit, isSending] = useCreditFormAPI({
34
34
  step,
35
35
  inputs,
36
36
  onNextStep,
@@ -44,7 +44,7 @@ export const CreditFormStep = JSX<CreditFormStepProps>(
44
44
  ) : (
45
45
  <form onSubmit={handleSubmit} className="space-y-m">
46
46
  {renderStep({ sections, field, step, params: { calcData } })}
47
- <StepsNavigationButtons step={step} onPrevStep={onPrevStep} />
47
+ <StepsNavigationButtons step={step} isSending={isSending} onPrevStep={onPrevStep} />
48
48
  </form>
49
49
  );
50
50
  },
@@ -3,19 +3,24 @@ import { Button } from '../../ui-kit/Button/Button';
3
3
 
4
4
  export interface StepsNavigationButtonsProps {
5
5
  step: number;
6
+ isSending: boolean;
6
7
  onPrevStep?: () => void;
7
8
  }
8
9
 
9
- export const StepsNavigationButtons = JSX<StepsNavigationButtonsProps>(({ step, onPrevStep }) => {
10
- const isFirstStep = step === 0;
11
- const isFinalStep = step === 5;
10
+ export const StepsNavigationButtons = JSX<StepsNavigationButtonsProps>(
11
+ ({ step, onPrevStep, isSending }) => {
12
+ const isFirstStep = step === 0;
13
+ const isFinalStep = step === 5;
12
14
 
13
- return (
14
- <div className={'flex justify-between gap-m'}>
15
- <Button onClick={onPrevStep} type="button" version="secondary" disabled={isFirstStep}>
16
- Назад
17
- </Button>
18
- <Button type="submit">{isFinalStep ? 'Отправить заявку' : 'Далее'}</Button>
19
- </div>
20
- );
21
- });
15
+ return (
16
+ <div className={'flex justify-between gap-m'}>
17
+ <Button onClick={onPrevStep} type="button" version="secondary" disabled={isFirstStep}>
18
+ Назад
19
+ </Button>
20
+ <Button type="submit" isLoading={isSending}>
21
+ {isFinalStep ? 'Отправить заявку' : 'Далее'}
22
+ </Button>
23
+ </div>
24
+ );
25
+ },
26
+ );
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useMemo } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
2
3
  import { updateUserTask } from '../../api/RetailAPI/updateUserTask';
3
4
  import { useRetailFormStore } from '../../hooks/useRetailFormStore';
4
5
  import { getCreditFormTaskData } from '../../services/retail/adaptors/getCreditFormTaskData';
@@ -22,7 +23,8 @@ export const useCreditFormAPI = ({
22
23
  inputs,
23
24
  onNextStep,
24
25
  onFinish,
25
- }: CreditFormApiProps): [LeadFormState, (formData: LeadFormState) => void] => {
26
+ }: CreditFormApiProps): [LeadFormState, (formData: LeadFormState) => void, boolean] => {
27
+ const [isSending, { setTrue: startSending, setFalse: endSending }] = useBool(false);
26
28
  const isFinalStep = step === 5;
27
29
 
28
30
  const retailFormStore = useRetailFormStore();
@@ -62,6 +64,7 @@ export const useCreditFormAPI = ({
62
64
  return;
63
65
  }
64
66
 
67
+ startSending();
65
68
  retailFormStore.leadForm = formData;
66
69
 
67
70
  try {
@@ -85,12 +88,14 @@ export const useCreditFormAPI = ({
85
88
  }
86
89
  } catch (ex) {
87
90
  // Do nothing
91
+ } finally {
92
+ endSending();
88
93
  }
89
94
  },
90
95
  [isFinalStep, resetForm],
91
96
  );
92
97
 
93
- return [initialState, handleSubmit];
98
+ return [initialState, handleSubmit, isSending];
94
99
  };
95
100
 
96
101
  const getValue =
@@ -3,6 +3,7 @@ import { type ButtonVersion } from '../../model/ButtonVersion';
3
3
  import { style } from '../../utils/style';
4
4
  import { type ARIAProps } from '../ARIAProps';
5
5
  import { type ControlStateProps } from '../ControlStateProps';
6
+ import { Loader } from '../Loader/Loader';
6
7
  import { type PreventableEvent } from '../PreventableEvent';
7
8
  import { useButton } from './useButton';
8
9
 
@@ -30,6 +31,7 @@ export interface ButtonProps extends ControlStateProps, ARIAProps {
30
31
  version?: ButtonVersion;
31
32
  type?: 'button' | 'submit' | 'reset';
32
33
  rounded?: boolean;
34
+ isLoading?: boolean;
33
35
  role?: string;
34
36
  onClick?: (ev?: PreventableEvent) => void;
35
37
  }
@@ -42,6 +44,7 @@ export const Button = JSX<ButtonProps>(({ children, ...props }) => {
42
44
  version = 'primary',
43
45
  active,
44
46
  disabled,
47
+ isLoading,
45
48
  type = 'button',
46
49
  rounded = true,
47
50
  role,
@@ -52,13 +55,13 @@ export const Button = JSX<ButtonProps>(({ children, ...props }) => {
52
55
  <button
53
56
  className={style(
54
57
  'font-sans px-9 py-4',
55
- 'flex justify-center items-center gap-xs',
58
+ 'flex justify-center items-center gap-xs relative',
56
59
  {
57
60
  'text-white bg-primary-active': active,
58
- 'bg-main-gray text-main-disabled cursor-not-allowed': disabled,
61
+ 'bg-main-gray text-main-disabled cursor-not-allowed': disabled || isLoading,
59
62
  'rounded-md': rounded,
60
63
  },
61
- !active && !disabled
64
+ !active && !disabled && !isLoading
62
65
  ? style(buttonStyleMap[version], secondaryButtonStyleMap[version])
63
66
  : '',
64
67
  className,
@@ -67,6 +70,7 @@ export const Button = JSX<ButtonProps>(({ children, ...props }) => {
67
70
  role={role}
68
71
  onClick={onClick}
69
72
  >
73
+ {isLoading ? <Loader blur={true} size="small" /> : null}
70
74
  {children}
71
75
  </button>
72
76
  );
@@ -1,16 +1,30 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { clamp } from '../../../utils/clamp';
2
4
  import { InputControl } from '../../Input/InputControl';
3
5
  import { type CustomFieldProps } from '../CustomFieldProps';
4
6
  import { validatorObj } from '../getObjectValidator';
5
7
  import { getValidation } from '../getValidation';
6
8
 
7
- export const Experience5YearsField = JSX<CustomFieldProps>(({ field, input }) => (
8
- <InputControl
9
- label="Стаж"
10
- placeholder="За последние 5 лет"
11
- type="number"
12
- maxLength={2}
13
- {...getValidation(field('experience5Years'), validatorObj.experience5Years, input?.required)}
14
- {...input}
15
- />
16
- ));
9
+ const FIELD_NAME = 'experience5Years';
10
+ const MAX_YEARS = 5;
11
+ const MIN_YEARS = 0;
12
+
13
+ export const Experience5YearsField = JSX<CustomFieldProps>(({ field, input }) => {
14
+ const onChange = useCallback(
15
+ (value: string) =>
16
+ field(FIELD_NAME)?.onChange?.(String(clamp(Number(value), MIN_YEARS, MAX_YEARS))),
17
+ [],
18
+ );
19
+
20
+ return (
21
+ <InputControl
22
+ label="Стаж"
23
+ placeholder="За последние 5 лет"
24
+ type="number"
25
+ {...getValidation(field(FIELD_NAME), validatorObj[FIELD_NAME], input?.required)}
26
+ {...input}
27
+ onChange={onChange}
28
+ />
29
+ );
30
+ });
@@ -1,19 +1,21 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
2
  import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { clamp } from '../../../utils/clamp';
3
4
  import { InputControl } from '../../Input/InputControl';
4
5
  import { type CustomFieldProps } from '../CustomFieldProps';
5
6
  import { validatorObj } from '../getObjectValidator';
6
7
  import { getValidation } from '../getValidation';
7
8
 
8
9
  const MAX_PART = 100;
10
+ const MIN_PART = 0;
9
11
  const FIELD_NAME = 'partInBusiness';
10
12
 
11
13
  export const PartInBusinessField = JSX<CustomFieldProps>(({ field, input }) => {
12
- const onChange = useCallback((value: string) => {
13
- field(FIELD_NAME)?.onChange?.(
14
- String(Number(value) > MAX_PART ? MAX_PART : Number(value) || ''),
15
- );
16
- }, []);
14
+ const onChange = useCallback(
15
+ (value: string) =>
16
+ field(FIELD_NAME)?.onChange?.(String(clamp(Number(value), MIN_PART, MAX_PART))),
17
+ [],
18
+ );
17
19
 
18
20
  return (
19
21
  <InputControl
@@ -6,10 +6,11 @@ interface LoaderProps {
6
6
  color?: TextColor;
7
7
  position?: 'static' | 'absolute';
8
8
  blur?: boolean;
9
+ size?: 'small' | 'big';
9
10
  }
10
11
 
11
12
  export const Loader = JSX<LoaderProps>(
12
- ({ color = 'text-primary-main', position = 'absolute', blur = true }) => (
13
+ ({ color = 'text-primary-main', position = 'absolute', blur = true, size = 'big' }) => (
13
14
  <div
14
15
  className={style('flex justify-center items-center h-full w-full z-50', position, {
15
16
  'backdrop-blur': blur,
@@ -17,10 +18,11 @@ export const Loader = JSX<LoaderProps>(
17
18
  >
18
19
  <div
19
20
  className={style(
20
- 'inline-block h-28 w-28',
21
+ 'inline-block ',
21
22
  'animate-spin rounded-full',
22
- 'border-8 border-solid border-current',
23
+ 'border-solid border-current',
23
24
  'border-r-transparent',
25
+ size === 'small' ? 'border-4 h-8 w-8' : 'border-8 h-28 w-28',
24
26
  color,
25
27
  )}
26
28
  role="status"
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
2
3
  import { checkCode } from '../../api/RetailAPI/checkCode';
3
4
 
4
5
  type useVerifyPhoneDialogSubmitProps = {
@@ -11,7 +12,7 @@ export const useVerifyPhoneDialogSubmit = ({
11
12
  onSuccess,
12
13
  }: useVerifyPhoneDialogSubmitProps) => {
13
14
  const [errorText, setErrorText] = useState('');
14
- const [isLoading, setIsLoading] = useState(false);
15
+ const [isLoading, { setTrue: startLoading, setFalse: endLoading }] = useBool(false);
15
16
  const [timeNextReq, setTimeNextReq] = useState(0);
16
17
  const [isTimerStarted, setIsTimerStarted] = useState(false);
17
18
  const [attempts, setAttempts] = useState(0);
@@ -26,17 +27,17 @@ export const useVerifyPhoneDialogSubmit = ({
26
27
  setIsTimerStarted(false);
27
28
  setTimeNextReq(0);
28
29
  setAttempts((_) => _ + 1);
29
- setIsLoading(true);
30
+ startLoading();
30
31
  await checkCode({
31
32
  smsText: values.join(''),
32
33
  smsCodesSetName: { key: 'AUTHENTICATION' },
33
34
  });
34
35
  resetError();
35
- onSuccess?.(values.join(''));
36
+ await onSuccess?.(values.join(''));
36
37
  } catch {
37
38
  setErrorText(attempts > 1 ? 'Исчерпан лимит ввода смс-кода' : 'Неверный код');
38
39
  } finally {
39
- setIsLoading(false);
40
+ endLoading();
40
41
  }
41
42
  }, [values, attempts]);
42
43