@redneckz/wildless-cms-uni-blocks 0.14.713 → 0.14.715
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/bundle/bundle.umd.js +47 -36
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
- package/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
- package/bundle/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
- package/bundle/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
- package/bundle/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
- package/bundle/components/CreditForm/useCreditFormAPI.d.ts +1 -1
- package/bundle/hooks/useAsyncEffect.d.ts +1 -0
- package/bundle/services/retail/mockLocalStorage.d.ts +1 -0
- package/bundle/ui-kit/Button/Button.d.ts +1 -0
- package/bundle/ui-kit/Loader/Loader.d.ts +1 -0
- package/dist/api/RetailAPI/sendCode.js +3 -4
- package/dist/api/RetailAPI/sendCode.js.map +1 -1
- package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +2 -2
- package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/dist/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
- package/dist/components/ApplicationLeadForm/renderSubmitButton.js +1 -1
- package/dist/components/ApplicationLeadForm/renderSubmitButton.js.map +1 -1
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +10 -7
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/dist/components/CreditCardForm/CreditCardFormStep.js +2 -2
- package/dist/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
- package/dist/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
- package/dist/components/CreditCardForm/StepsNavigationButtons.js +2 -2
- package/dist/components/CreditCardForm/StepsNavigationButtons.js.map +1 -1
- package/dist/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
- package/dist/components/CreditCardForm/useCreditCardFormAPI.js +7 -1
- package/dist/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
- package/dist/components/CreditForm/CreditFormStep.js +2 -2
- package/dist/components/CreditForm/CreditFormStep.js.map +1 -1
- package/dist/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
- package/dist/components/CreditForm/StepsNavigationButtons.js +2 -2
- package/dist/components/CreditForm/StepsNavigationButtons.js.map +1 -1
- package/dist/components/CreditForm/useCreditFormAPI.d.ts +1 -1
- package/dist/components/CreditForm/useCreditFormAPI.js +7 -1
- package/dist/components/CreditForm/useCreditFormAPI.js.map +1 -1
- package/dist/hooks/useAsyncEffect.d.ts +1 -0
- package/dist/hooks/useAsyncEffect.js +15 -0
- package/dist/hooks/useAsyncEffect.js.map +1 -0
- package/dist/services/retail/mockLocalStorage.d.ts +1 -0
- package/dist/services/retail/mockLocalStorage.js +35 -0
- package/dist/services/retail/mockLocalStorage.js.map +1 -0
- package/dist/setup-fixture.js +11 -0
- package/dist/setup-fixture.js.map +1 -1
- package/dist/ui-kit/Button/Button.d.ts +1 -0
- package/dist/ui-kit/Button/Button.js +6 -5
- package/dist/ui-kit/Button/Button.js.map +1 -1
- package/dist/ui-kit/Loader/Loader.d.ts +1 -0
- package/dist/ui-kit/Loader/Loader.js +2 -2
- package/dist/ui-kit/Loader/Loader.js.map +1 -1
- package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -4
- package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/lib/api/RetailAPI/sendCode.js +4 -5
- package/lib/api/RetailAPI/sendCode.js.map +1 -1
- package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +2 -2
- package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/lib/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
- package/lib/components/ApplicationLeadForm/renderSubmitButton.js +1 -1
- package/lib/components/ApplicationLeadForm/renderSubmitButton.js.map +1 -1
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +10 -7
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/lib/components/CreditCardForm/CreditCardForm.fixture.d.ts +1 -1
- package/lib/components/CreditCardForm/CreditCardForm.fixture.mobile.d.ts +1 -1
- package/lib/components/CreditCardForm/CreditCardFormStep.js +2 -2
- package/lib/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
- package/lib/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
- package/lib/components/CreditCardForm/StepsNavigationButtons.js +2 -2
- package/lib/components/CreditCardForm/StepsNavigationButtons.js.map +1 -1
- package/lib/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
- package/lib/components/CreditCardForm/useCreditCardFormAPI.js +7 -1
- package/lib/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
- package/lib/components/CreditForm/CreditForm.fixture.d.ts +1 -1
- package/lib/components/CreditForm/CreditForm.fixture.mobile.d.ts +1 -1
- package/lib/components/CreditForm/CreditFormStep.js +2 -2
- package/lib/components/CreditForm/CreditFormStep.js.map +1 -1
- package/lib/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
- package/lib/components/CreditForm/StepsNavigationButtons.js +2 -2
- package/lib/components/CreditForm/StepsNavigationButtons.js.map +1 -1
- package/lib/components/CreditForm/useCreditFormAPI.d.ts +1 -1
- package/lib/components/CreditForm/useCreditFormAPI.js +7 -1
- package/lib/components/CreditForm/useCreditFormAPI.js.map +1 -1
- package/lib/hooks/useAsyncEffect.d.ts +1 -0
- package/lib/hooks/useAsyncEffect.js +12 -0
- package/lib/hooks/useAsyncEffect.js.map +1 -0
- package/lib/services/retail/mockLocalStorage.d.ts +1 -0
- package/lib/services/retail/mockLocalStorage.js +32 -0
- package/lib/services/retail/mockLocalStorage.js.map +1 -0
- package/lib/setup-fixture.js +11 -0
- package/lib/setup-fixture.js.map +1 -1
- package/lib/ui-kit/Button/Button.d.ts +1 -0
- package/lib/ui-kit/Button/Button.js +7 -6
- package/lib/ui-kit/Button/Button.js.map +1 -1
- package/lib/ui-kit/Loader/Loader.d.ts +1 -0
- package/lib/ui-kit/Loader/Loader.js +2 -2
- package/lib/ui-kit/Loader/Loader.js.map +1 -1
- package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -4
- package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +47 -36
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
- package/mobile/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
- package/mobile/bundle/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
- package/mobile/bundle/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
- package/mobile/bundle/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
- package/mobile/bundle/components/CreditForm/useCreditFormAPI.d.ts +1 -1
- package/mobile/bundle/hooks/useAsyncEffect.d.ts +1 -0
- package/mobile/bundle/services/retail/mockLocalStorage.d.ts +1 -0
- package/mobile/bundle/ui-kit/Button/Button.d.ts +1 -0
- package/mobile/bundle/ui-kit/Loader/Loader.d.ts +1 -0
- package/mobile/dist/api/RetailAPI/sendCode.js +3 -4
- package/mobile/dist/api/RetailAPI/sendCode.js.map +1 -1
- package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +2 -2
- package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/mobile/dist/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
- package/mobile/dist/components/ApplicationLeadForm/renderSubmitButton.js +1 -1
- package/mobile/dist/components/ApplicationLeadForm/renderSubmitButton.js.map +1 -1
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +10 -7
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/mobile/dist/components/CreditCardForm/CreditCardFormStep.js +2 -2
- package/mobile/dist/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
- package/mobile/dist/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
- package/mobile/dist/components/CreditCardForm/StepsNavigationButtons.js +2 -2
- package/mobile/dist/components/CreditCardForm/StepsNavigationButtons.js.map +1 -1
- package/mobile/dist/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
- package/mobile/dist/components/CreditCardForm/useCreditCardFormAPI.js +7 -1
- package/mobile/dist/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
- package/mobile/dist/components/CreditForm/CreditFormStep.js +2 -2
- package/mobile/dist/components/CreditForm/CreditFormStep.js.map +1 -1
- package/mobile/dist/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
- package/mobile/dist/components/CreditForm/StepsNavigationButtons.js +2 -2
- package/mobile/dist/components/CreditForm/StepsNavigationButtons.js.map +1 -1
- package/mobile/dist/components/CreditForm/useCreditFormAPI.d.ts +1 -1
- package/mobile/dist/components/CreditForm/useCreditFormAPI.js +7 -1
- package/mobile/dist/components/CreditForm/useCreditFormAPI.js.map +1 -1
- package/mobile/dist/hooks/useAsyncEffect.d.ts +1 -0
- package/mobile/dist/hooks/useAsyncEffect.js +15 -0
- package/mobile/dist/hooks/useAsyncEffect.js.map +1 -0
- package/mobile/dist/services/retail/mockLocalStorage.d.ts +1 -0
- package/mobile/dist/services/retail/mockLocalStorage.js +35 -0
- package/mobile/dist/services/retail/mockLocalStorage.js.map +1 -0
- package/mobile/dist/setup-fixture.js +11 -0
- package/mobile/dist/setup-fixture.js.map +1 -1
- package/mobile/dist/ui-kit/Button/Button.d.ts +1 -0
- package/mobile/dist/ui-kit/Button/Button.js +6 -5
- package/mobile/dist/ui-kit/Button/Button.js.map +1 -1
- package/mobile/dist/ui-kit/Loader/Loader.d.ts +1 -0
- package/mobile/dist/ui-kit/Loader/Loader.js +2 -2
- package/mobile/dist/ui-kit/Loader/Loader.js.map +1 -1
- package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -4
- package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/lib/api/RetailAPI/sendCode.js +4 -5
- package/mobile/lib/api/RetailAPI/sendCode.js.map +1 -1
- package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +2 -2
- package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/mobile/lib/components/ApplicationLeadForm/renderSubmitButton.d.ts +1 -1
- package/mobile/lib/components/ApplicationLeadForm/renderSubmitButton.js +1 -1
- package/mobile/lib/components/ApplicationLeadForm/renderSubmitButton.js.map +1 -1
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +1 -0
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +10 -7
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/mobile/lib/components/CreditCardForm/CreditCardFormStep.js +2 -2
- package/mobile/lib/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
- package/mobile/lib/components/CreditCardForm/StepsNavigationButtons.d.ts +1 -0
- package/mobile/lib/components/CreditCardForm/StepsNavigationButtons.js +2 -2
- package/mobile/lib/components/CreditCardForm/StepsNavigationButtons.js.map +1 -1
- package/mobile/lib/components/CreditCardForm/useCreditCardFormAPI.d.ts +1 -1
- package/mobile/lib/components/CreditCardForm/useCreditCardFormAPI.js +7 -1
- package/mobile/lib/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
- package/mobile/lib/components/CreditForm/CreditFormStep.js +2 -2
- package/mobile/lib/components/CreditForm/CreditFormStep.js.map +1 -1
- package/mobile/lib/components/CreditForm/StepsNavigationButtons.d.ts +1 -0
- package/mobile/lib/components/CreditForm/StepsNavigationButtons.js +2 -2
- package/mobile/lib/components/CreditForm/StepsNavigationButtons.js.map +1 -1
- package/mobile/lib/components/CreditForm/useCreditFormAPI.d.ts +1 -1
- package/mobile/lib/components/CreditForm/useCreditFormAPI.js +7 -1
- package/mobile/lib/components/CreditForm/useCreditFormAPI.js.map +1 -1
- package/mobile/lib/hooks/useAsyncEffect.d.ts +1 -0
- package/mobile/lib/hooks/useAsyncEffect.js +12 -0
- package/mobile/lib/hooks/useAsyncEffect.js.map +1 -0
- package/mobile/lib/services/retail/mockLocalStorage.d.ts +1 -0
- package/mobile/lib/services/retail/mockLocalStorage.js +32 -0
- package/mobile/lib/services/retail/mockLocalStorage.js.map +1 -0
- package/mobile/lib/setup-fixture.js +11 -0
- package/mobile/lib/setup-fixture.js.map +1 -1
- package/mobile/lib/ui-kit/Button/Button.d.ts +1 -0
- package/mobile/lib/ui-kit/Button/Button.js +7 -6
- package/mobile/lib/ui-kit/Button/Button.js.map +1 -1
- package/mobile/lib/ui-kit/Loader/Loader.d.ts +1 -0
- package/mobile/lib/ui-kit/Loader/Loader.js +2 -2
- package/mobile/lib/ui-kit/Loader/Loader.js.map +1 -1
- package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -4
- package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/src/api/RetailAPI/sendCode.ts +4 -15
- package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +2 -2
- package/mobile/src/components/ApplicationLeadForm/renderSubmitButton.tsx +2 -2
- package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +12 -7
- package/mobile/src/components/CreditCardForm/CreditCardFormStep.tsx +2 -2
- package/mobile/src/components/CreditCardForm/StepsNavigationButtons.tsx +17 -12
- package/mobile/src/components/CreditCardForm/useCreditCardFormAPI.tsx +7 -2
- package/mobile/src/components/CreditForm/CreditFormStep.tsx +2 -2
- package/mobile/src/components/CreditForm/StepsNavigationButtons.tsx +17 -12
- package/mobile/src/components/CreditForm/useCreditFormAPI.tsx +7 -2
- package/mobile/src/hooks/useAsyncEffect.ts +16 -0
- package/mobile/src/services/retail/mockLocalStorage.ts +40 -0
- package/mobile/src/setup-fixture.ts +12 -0
- package/mobile/src/ui-kit/Button/Button.tsx +7 -3
- package/mobile/src/ui-kit/Loader/Loader.tsx +5 -3
- package/mobile/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +5 -4
- package/package.json +1 -1
- package/src/api/RetailAPI/sendCode.ts +4 -15
- package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +2 -2
- package/src/components/ApplicationLeadForm/renderSubmitButton.tsx +2 -2
- package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +12 -7
- package/src/components/CreditCardForm/CreditCardForm.fixture.mobile.tsx +14 -18
- package/src/components/CreditCardForm/CreditCardForm.fixture.tsx +14 -18
- package/src/components/CreditCardForm/CreditCardFormStep.tsx +2 -2
- package/src/components/CreditCardForm/StepsNavigationButtons.tsx +17 -12
- package/src/components/CreditCardForm/useCreditCardFormAPI.tsx +7 -2
- package/src/components/CreditForm/CreditForm.fixture.mobile.tsx +19 -23
- package/src/components/CreditForm/CreditForm.fixture.tsx +19 -23
- package/src/components/CreditForm/CreditFormStep.tsx +2 -2
- package/src/components/CreditForm/StepsNavigationButtons.tsx +17 -12
- package/src/components/CreditForm/useCreditFormAPI.tsx +7 -2
- package/src/hooks/useAsyncEffect.ts +16 -0
- package/src/services/retail/mockLocalStorage.ts +40 -0
- package/src/setup-fixture.ts +12 -0
- package/src/ui-kit/Button/Button.tsx +7 -3
- package/src/ui-kit/Loader/Loader.tsx +5 -3
- package/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +5 -4
|
@@ -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,
|
|
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
|
-
|
|
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
|
-
|
|
40
|
+
endLoading();
|
|
40
41
|
}
|
|
41
42
|
}, [values, attempts]);
|
|
42
43
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type StatusType } from './StatusType';
|
|
1
|
+
import { doRequest } from './doRequest';
|
|
3
2
|
|
|
4
3
|
export type SendCodeBody = {
|
|
5
4
|
phoneNumber: string;
|
|
@@ -8,17 +7,7 @@ export type SendCodeBody = {
|
|
|
8
7
|
};
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
type SendCodeErrorResult = { errorMessage: string };
|
|
12
|
-
|
|
13
10
|
export const sendCode = (body: SendCodeBody) =>
|
|
14
|
-
|
|
15
|
-
(res) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const isErrorResult = (
|
|
19
|
-
res: StatusType | SendCodeErrorResult | null,
|
|
20
|
-
phoneNumber: string,
|
|
21
|
-
): res is SendCodeErrorResult =>
|
|
22
|
-
Boolean(res) &&
|
|
23
|
-
typeof res !== 'string' &&
|
|
24
|
-
Boolean(res?.errorMessage?.startsWith(`Too many request for phoneNumber [${phoneNumber}]`));
|
|
11
|
+
doRequest('/sms/sendCode', 'POST', body)
|
|
12
|
+
.then((res) => res.text())
|
|
13
|
+
.then((text) => text === 'OK');
|
|
@@ -26,7 +26,7 @@ export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
|
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
const [initialFormState, { isLoading }] = useInitApplicationLead(inputs, nextStepLink);
|
|
29
|
-
const { handleSubmit, responseStatus } = useApplicationLeadApi({
|
|
29
|
+
const { handleSubmit, responseStatus, isSending } = useApplicationLeadApi({
|
|
30
30
|
inputs,
|
|
31
31
|
programId,
|
|
32
32
|
nextStepLink,
|
|
@@ -58,7 +58,7 @@ export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
|
|
|
58
58
|
{renderInputs({ field, inputs: _?.inputs })}
|
|
59
59
|
</div>
|
|
60
60
|
))}
|
|
61
|
-
{renderSubmitButton(button)}
|
|
61
|
+
{renderSubmitButton(button, isSending)}
|
|
62
62
|
</form>
|
|
63
63
|
</ApplicationFormLayout>
|
|
64
64
|
);
|
|
@@ -2,8 +2,8 @@ import { Button } from '../../ui-kit/Button/Button';
|
|
|
2
2
|
import { style } from '../../utils/style';
|
|
3
3
|
import { type SubmitButtonProps } from './ApplicationLeadFormContent';
|
|
4
4
|
|
|
5
|
-
export const renderSubmitButton = (button?: SubmitButtonProps,
|
|
6
|
-
<Button className={style('w-full @xl:w-auto'
|
|
5
|
+
export const renderSubmitButton = (button?: SubmitButtonProps, isSending?: boolean) => (
|
|
6
|
+
<Button className={style('w-full @xl:w-auto')} type="submit" isLoading={isSending}>
|
|
7
7
|
{button?.text ? button.text : 'Отправить заявку'}
|
|
8
8
|
</Button>
|
|
9
9
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
|
|
2
3
|
import { createDraftTask } from '../../api/RetailAPI/createDraftTask';
|
|
3
4
|
import { createUserProfile } from '../../api/RetailAPI/createUserProfile';
|
|
4
5
|
import { getLastTaskStatus } from '../../api/RetailAPI/getLastTaskStatus';
|
|
@@ -33,6 +34,7 @@ export const useApplicationLeadApi = ({
|
|
|
33
34
|
nextStepLink,
|
|
34
35
|
}: ApplicationLeadApiProps) => {
|
|
35
36
|
const [responseStatus, setResponseStatus] = useState<'OK' | 'Fail' | ''>('');
|
|
37
|
+
const [isSending, { setTrue: startSending, setFalse: endSending }] = useBool(false);
|
|
36
38
|
const saveUserData = useSaveUserData();
|
|
37
39
|
|
|
38
40
|
const openEsiaLoginDialog = useEsiaLoginDialog(nextStepLink);
|
|
@@ -47,6 +49,7 @@ export const useApplicationLeadApi = ({
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
try {
|
|
52
|
+
startSending();
|
|
50
53
|
const profileId = await createUserProfile({
|
|
51
54
|
profile: { phone: formatPhone(formData.phone as string) },
|
|
52
55
|
});
|
|
@@ -64,10 +67,7 @@ export const useApplicationLeadApi = ({
|
|
|
64
67
|
};
|
|
65
68
|
const handleSuccessVerify = async () => {
|
|
66
69
|
try {
|
|
67
|
-
const lastTaskId = await getLastTaskStatus({
|
|
68
|
-
profileId,
|
|
69
|
-
programId,
|
|
70
|
-
});
|
|
70
|
+
const lastTaskId = await getLastTaskStatus({ profileId, programId });
|
|
71
71
|
|
|
72
72
|
if (lastTaskId) {
|
|
73
73
|
const task = await getTaskById({ taskId: lastTaskId });
|
|
@@ -85,15 +85,14 @@ export const useApplicationLeadApi = ({
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
const acceptedConsents
|
|
89
|
-
.filter((_) => formData[_])
|
|
90
|
-
.map((_) => CONSENTS[_]?.text);
|
|
88
|
+
const acceptedConsents = getAcceptedConsents(formData);
|
|
91
89
|
|
|
92
90
|
verifyPhoneDialog.open({
|
|
93
91
|
phone: formData?.phone,
|
|
94
92
|
consents: acceptedConsents,
|
|
95
93
|
onSuccess: handleSuccessVerify,
|
|
96
94
|
});
|
|
95
|
+
endSending();
|
|
97
96
|
}
|
|
98
97
|
} catch {
|
|
99
98
|
setResponseStatus('Fail');
|
|
@@ -103,9 +102,15 @@ export const useApplicationLeadApi = ({
|
|
|
103
102
|
return {
|
|
104
103
|
handleSubmit,
|
|
105
104
|
responseStatus,
|
|
105
|
+
isSending,
|
|
106
106
|
};
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
+
const getAcceptedConsents = (formData: LeadFormState): string[] =>
|
|
110
|
+
Object.keys(CONSENTS)
|
|
111
|
+
.filter((_) => formData[_])
|
|
112
|
+
.map((_) => CONSENTS[_]?.text);
|
|
113
|
+
|
|
109
114
|
const updateUserData = async ({
|
|
110
115
|
programId,
|
|
111
116
|
profileId,
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useAsyncEffect } from '../../hooks/useAsyncEffect';
|
|
3
|
+
import { mockLocalStorage } from '../../services/retail/mockLocalStorage';
|
|
1
4
|
import '../../setup-fixture';
|
|
2
5
|
import { DialogManager } from '../../ui-kit/DialogManager/DialogManager';
|
|
3
6
|
import { PopupManager } from '../../ui-kit/PopupManager/PopupManager';
|
|
4
7
|
import { CreditCardForm } from './CreditCardForm';
|
|
5
8
|
|
|
6
|
-
const MOCK_TOKEN = 'mock-key';
|
|
7
|
-
const MOCK_TASK_ID = '111111';
|
|
8
|
-
|
|
9
|
-
const refreshToken = globalThis.sessionStorage?.getItem('refreshToken');
|
|
10
|
-
const accessToken = globalThis.sessionStorage?.getItem('accessToken');
|
|
11
|
-
const taskId = globalThis.localStorage.getItem('taskId');
|
|
12
|
-
|
|
13
|
-
!refreshToken && globalThis.sessionStorage?.setItem('refreshToken', MOCK_TOKEN);
|
|
14
|
-
!accessToken && globalThis.sessionStorage?.setItem('accessToken', MOCK_TOKEN);
|
|
15
|
-
!taskId && globalThis.localStorage.setItem('taskId', MOCK_TASK_ID);
|
|
16
|
-
|
|
17
9
|
export default {
|
|
18
|
-
default: (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
default: JSX(() => {
|
|
11
|
+
useAsyncEffect(async () => await mockLocalStorage(), []);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<CreditCardForm className="col-span-12" />
|
|
16
|
+
<PopupManager />
|
|
17
|
+
<DialogManager />
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}),
|
|
25
21
|
};
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useAsyncEffect } from '../../hooks/useAsyncEffect';
|
|
3
|
+
import { mockLocalStorage } from '../../services/retail/mockLocalStorage';
|
|
1
4
|
import '../../setup-fixture';
|
|
2
5
|
import { DialogManager } from '../../ui-kit/DialogManager/DialogManager';
|
|
3
6
|
import { PopupManager } from '../../ui-kit/PopupManager/PopupManager';
|
|
4
7
|
import { CreditCardForm } from './CreditCardForm';
|
|
5
8
|
|
|
6
|
-
const MOCK_TOKEN = 'mock-key';
|
|
7
|
-
const MOCK_TASK_ID = '111111';
|
|
8
|
-
|
|
9
|
-
const refreshToken = globalThis.sessionStorage?.getItem('refreshToken');
|
|
10
|
-
const accessToken = globalThis.sessionStorage?.getItem('accessToken');
|
|
11
|
-
const taskId = globalThis.localStorage.getItem('taskId');
|
|
12
|
-
|
|
13
|
-
!refreshToken && globalThis.sessionStorage?.setItem('refreshToken', MOCK_TOKEN);
|
|
14
|
-
!accessToken && globalThis.sessionStorage?.setItem('accessToken', MOCK_TOKEN);
|
|
15
|
-
!taskId && globalThis.localStorage.setItem('taskId', MOCK_TASK_ID);
|
|
16
|
-
|
|
17
9
|
export default {
|
|
18
|
-
default: (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
default: JSX(() => {
|
|
11
|
+
useAsyncEffect(async () => await mockLocalStorage(), []);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<CreditCardForm className="col-span-12" />
|
|
16
|
+
<PopupManager />
|
|
17
|
+
<DialogManager />
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}),
|
|
25
21
|
};
|
|
@@ -24,7 +24,7 @@ export const CreditCardFormStep = JSX<CreditCardFormStepProps>(
|
|
|
24
24
|
[sections],
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
-
const [initialState, onSubmit] = useCreditCardFormAPI({
|
|
27
|
+
const [initialState, onSubmit, isSending] = useCreditCardFormAPI({
|
|
28
28
|
step,
|
|
29
29
|
inputs,
|
|
30
30
|
onNextStep,
|
|
@@ -38,7 +38,7 @@ export const CreditCardFormStep = JSX<CreditCardFormStepProps>(
|
|
|
38
38
|
) : (
|
|
39
39
|
<form onSubmit={handleSubmit} className="space-y-m">
|
|
40
40
|
{renderStep({ sections, field, step })}
|
|
41
|
-
<StepsNavigationButtons step={step} onPrevStep={onPrevStep} />
|
|
41
|
+
<StepsNavigationButtons isSending={isSending} step={step} onPrevStep={onPrevStep} />
|
|
42
42
|
</form>
|
|
43
43
|
);
|
|
44
44
|
},
|
|
@@ -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>(
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export const StepsNavigationButtons = JSX<StepsNavigationButtonsProps>(
|
|
11
|
+
({ step, isSending, onPrevStep }) => {
|
|
12
|
+
const isFirstStep = step === 0;
|
|
13
|
+
const isFinalStep = step === 5;
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 isLoading={isSending} type="submit">
|
|
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 { 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 =
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useAsyncEffect } from '../../hooks/useAsyncEffect';
|
|
3
|
+
import { mockLocalStorage } from '../../services/retail/mockLocalStorage';
|
|
1
4
|
import '../../setup-fixture';
|
|
2
5
|
import { DialogManager } from '../../ui-kit/DialogManager/DialogManager';
|
|
3
6
|
import { PopupManager } from '../../ui-kit/PopupManager/PopupManager';
|
|
4
7
|
import { CreditForm } from './CreditForm';
|
|
5
8
|
|
|
6
|
-
const MOCK_TOKEN = 'mock-key';
|
|
7
|
-
const MOCK_TASK_ID = '111111';
|
|
8
|
-
|
|
9
|
-
const refreshToken = globalThis.sessionStorage?.getItem('refreshToken');
|
|
10
|
-
const accessToken = globalThis.sessionStorage?.getItem('accessToken');
|
|
11
|
-
const taskId = globalThis.localStorage.getItem('taskId');
|
|
12
|
-
|
|
13
|
-
!refreshToken && globalThis.sessionStorage?.setItem('refreshToken', MOCK_TOKEN);
|
|
14
|
-
!accessToken && globalThis.sessionStorage?.setItem('accessToken', MOCK_TOKEN);
|
|
15
|
-
!taskId && globalThis.localStorage.setItem('taskId', MOCK_TASK_ID);
|
|
16
|
-
|
|
17
9
|
export default {
|
|
18
|
-
default: (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
default: JSX(() => {
|
|
11
|
+
useAsyncEffect(async () => await mockLocalStorage(), []);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<CreditForm
|
|
16
|
+
className="col-span-12"
|
|
17
|
+
programsSource={{
|
|
18
|
+
$ref: '/wcms-resources/products-credit-calc-data.json',
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
<PopupManager />
|
|
22
|
+
<DialogManager />
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}),
|
|
30
26
|
};
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useAsyncEffect } from '../../hooks/useAsyncEffect';
|
|
3
|
+
import { mockLocalStorage } from '../../services/retail/mockLocalStorage';
|
|
1
4
|
import '../../setup-fixture';
|
|
2
5
|
import { DialogManager } from '../../ui-kit/DialogManager/DialogManager';
|
|
3
6
|
import { PopupManager } from '../../ui-kit/PopupManager/PopupManager';
|
|
4
7
|
import { CreditForm } from './CreditForm';
|
|
5
8
|
|
|
6
|
-
const MOCK_TOKEN = 'mock-key';
|
|
7
|
-
const MOCK_TASK_ID = '111111';
|
|
8
|
-
|
|
9
|
-
const refreshToken = globalThis.sessionStorage?.getItem('refreshToken');
|
|
10
|
-
const accessToken = globalThis.sessionStorage?.getItem('accessToken');
|
|
11
|
-
const taskId = globalThis.localStorage.getItem('taskId');
|
|
12
|
-
|
|
13
|
-
!refreshToken && globalThis.sessionStorage?.setItem('refreshToken', MOCK_TOKEN);
|
|
14
|
-
!accessToken && globalThis.sessionStorage?.setItem('accessToken', MOCK_TOKEN);
|
|
15
|
-
!taskId && globalThis.localStorage.setItem('taskId', MOCK_TASK_ID);
|
|
16
|
-
|
|
17
9
|
export default {
|
|
18
|
-
default: (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
default: JSX(() => {
|
|
11
|
+
useAsyncEffect(async () => await mockLocalStorage(), []);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<CreditForm
|
|
16
|
+
className="col-span-12"
|
|
17
|
+
programsSource={{
|
|
18
|
+
$ref: '/wcms-resources/products-credit-calc-data.json',
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
<PopupManager />
|
|
22
|
+
<DialogManager />
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}),
|
|
30
26
|
};
|
|
@@ -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>(
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export const StepsNavigationButtons = JSX<StepsNavigationButtonsProps>(
|
|
11
|
+
({ step, onPrevStep, isSending }) => {
|
|
12
|
+
const isFirstStep = step === 0;
|
|
13
|
+
const isFinalStep = step === 5;
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 =
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
|
|
3
|
+
export function useAsyncEffect<Deps extends any[], R>(
|
|
4
|
+
effect: () => Promise<R | (() => void)>,
|
|
5
|
+
deps: Deps,
|
|
6
|
+
): void {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const free = effect();
|
|
9
|
+
|
|
10
|
+
return () => {
|
|
11
|
+
free.then((_) => {
|
|
12
|
+
_ instanceof Function && _();
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
}, deps);
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { checkCode } from '../../api/RetailAPI/checkCode';
|
|
2
|
+
import { createDraftTask } from '../../api/RetailAPI/createDraftTask';
|
|
3
|
+
import { createUserProfile } from '../../api/RetailAPI/createUserProfile';
|
|
4
|
+
import { sendCode } from '../../api/RetailAPI/sendCode';
|
|
5
|
+
|
|
6
|
+
const PHONE = '+11111111111';
|
|
7
|
+
const PROGRAM_ID = '13';
|
|
8
|
+
|
|
9
|
+
export const mockLocalStorage = async () => {
|
|
10
|
+
const programId = globalThis.localStorage.getItem('programId') ?? PROGRAM_ID;
|
|
11
|
+
|
|
12
|
+
const profileId =
|
|
13
|
+
globalThis.localStorage.getItem('profileId') ??
|
|
14
|
+
(await createUserProfile({ profile: { phone: PHONE } }));
|
|
15
|
+
|
|
16
|
+
await sendCode({
|
|
17
|
+
phoneNumber: PHONE,
|
|
18
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await checkCode({
|
|
22
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
23
|
+
smsText: '1234',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const task = {
|
|
27
|
+
taskId: globalThis.localStorage.getItem('taskId'),
|
|
28
|
+
participantId: globalThis.localStorage.getItem('participantId'),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (!task.taskId || !task.participantId) {
|
|
32
|
+
const draft = await createDraftTask({ profileId: Number(profileId), programId });
|
|
33
|
+
Object.assign(task, draft);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
globalThis.localStorage.setItem('programId', programId);
|
|
37
|
+
globalThis.localStorage.setItem('profileId', String(profileId));
|
|
38
|
+
globalThis.localStorage.setItem('taskId', String(task.taskId));
|
|
39
|
+
globalThis.localStorage.setItem('participantId', String(task.participantId));
|
|
40
|
+
};
|
package/src/setup-fixture.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import '@redneckz/uni-jsx/lib/setup.react';
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { handlerDecorator } from './external/handlerDecorator';
|
|
4
|
+
import { locationNavigator } from './external/locationNavigator';
|
|
4
5
|
import { useRouter } from './external/useRouter';
|
|
5
6
|
import { projectSettings } from './ProjectSettings';
|
|
7
|
+
import { noop } from './utils/noop';
|
|
6
8
|
import { joinPath } from './utils/url';
|
|
7
9
|
import wlc from './wlc.json';
|
|
8
10
|
|
|
@@ -49,3 +51,13 @@ handlerDecorator.setup((handler): any => (ev) => {
|
|
|
49
51
|
|
|
50
52
|
handler(ev);
|
|
51
53
|
});
|
|
54
|
+
|
|
55
|
+
locationNavigator.setup(() => ({
|
|
56
|
+
assign: noop,
|
|
57
|
+
get href() {
|
|
58
|
+
return globalThis.location.href;
|
|
59
|
+
},
|
|
60
|
+
get origin() {
|
|
61
|
+
return globalThis.location.origin;
|
|
62
|
+
},
|
|
63
|
+
}));
|