@redneckz/wildless-cms-uni-blocks 0.14.865 → 0.14.866
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 +43 -26
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +7 -2
- package/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -2
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +7 -2
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +19 -10
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -2
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +21 -10
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +7 -2
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +18 -9
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -2
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +21 -10
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +43 -26
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +7 -2
- package/mobile/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -2
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +7 -2
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +19 -10
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -2
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +21 -10
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +7 -2
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +18 -9
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -2
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +21 -10
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +31 -27
- package/mobile/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +22 -10
- package/package.json +1 -1
- package/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +31 -27
- package/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +22 -10
package/bundle/bundle.umd.js
CHANGED
|
@@ -5034,6 +5034,12 @@
|
|
|
5034
5034
|
|
|
5035
5035
|
const updateUserTask = (body) => doRequest('/user-data/updateUserTask', 'PUT', body);
|
|
5036
5036
|
|
|
5037
|
+
const sessionStore = new Store(); // sessionStorage cache
|
|
5038
|
+
replicate(sessionStore, new StorageAdapter(globalThis?.sessionStorage));
|
|
5039
|
+
function useSessionStore() {
|
|
5040
|
+
return useStore(sessionStore);
|
|
5041
|
+
}
|
|
5042
|
+
|
|
5037
5043
|
const Timer = JSX(({ className, seconds }) => (jsx("span", { className: className, children: formatTimer(seconds) })));
|
|
5038
5044
|
const formatTimer = (seconds) => {
|
|
5039
5045
|
const minutes = Math.floor(seconds / 60);
|
|
@@ -5192,25 +5198,29 @@
|
|
|
5192
5198
|
};
|
|
5193
5199
|
|
|
5194
5200
|
const useVerifyPhoneDialogSubmit = ({ values, onSuccess, }) => {
|
|
5201
|
+
const sessionStore = useSessionStore();
|
|
5202
|
+
const attempts = sessionStore.smsCode?.attempts || 0;
|
|
5203
|
+
const timer = Math.max(getTimer(sessionStore.smsCode?.sendTime || Date.now()), 0);
|
|
5195
5204
|
const [errorText, setErrorText] = useState('');
|
|
5196
5205
|
const [isLoading, { setTrue: startLoading, setFalse: endLoading }] = useBool(false);
|
|
5197
|
-
const [timeNextReq, setTimeNextReq] = useState(
|
|
5198
|
-
const [isTimerStarted, setIsTimerStarted] = useState(false);
|
|
5199
|
-
const [attempts, setAttempts] = useState(0);
|
|
5206
|
+
const [timeNextReq, setTimeNextReq] = useState(timer);
|
|
5200
5207
|
const resetError = useCallback(() => setErrorText(''), []);
|
|
5201
|
-
const isTimeExpired = Boolean(timeNextReq === 0 &&
|
|
5208
|
+
const isTimeExpired = Boolean(timeNextReq === 0 && sessionStore.smsCode?.sendTime);
|
|
5202
5209
|
const isSubmitButtonDisabled = attempts > 2 || isTimeExpired || !values.every(Boolean);
|
|
5203
5210
|
const handleSubmit = useCallback(async () => {
|
|
5204
5211
|
try {
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5212
|
+
sessionStore.smsCode = {
|
|
5213
|
+
...sessionStore.smsCode,
|
|
5214
|
+
attempts: attempts + 1,
|
|
5215
|
+
};
|
|
5208
5216
|
startLoading();
|
|
5209
5217
|
await checkCode({
|
|
5210
5218
|
smsText: values.join(''),
|
|
5211
5219
|
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
5212
5220
|
});
|
|
5221
|
+
setTimeNextReq(0);
|
|
5213
5222
|
resetError();
|
|
5223
|
+
sessionStore.smsCode = null;
|
|
5214
5224
|
await onSuccess?.(values.join(''));
|
|
5215
5225
|
}
|
|
5216
5226
|
catch {
|
|
@@ -5221,7 +5231,12 @@
|
|
|
5221
5231
|
}
|
|
5222
5232
|
}, [values, attempts]);
|
|
5223
5233
|
useEffect(() => {
|
|
5224
|
-
|
|
5234
|
+
if (isTimeExpired) {
|
|
5235
|
+
setErrorText('Код просрочен');
|
|
5236
|
+
}
|
|
5237
|
+
else if (attempts > 2) {
|
|
5238
|
+
setErrorText('Исчерпан лимит ввода смс-кода');
|
|
5239
|
+
}
|
|
5225
5240
|
}, [isTimeExpired]);
|
|
5226
5241
|
return {
|
|
5227
5242
|
handleSubmit,
|
|
@@ -5231,14 +5246,17 @@
|
|
|
5231
5246
|
timeNextReq,
|
|
5232
5247
|
isSubmitButtonDisabled,
|
|
5233
5248
|
setTimeNextReq,
|
|
5234
|
-
|
|
5235
|
-
setAttempts,
|
|
5249
|
+
setErrorText,
|
|
5236
5250
|
};
|
|
5237
5251
|
};
|
|
5252
|
+
const getTimer = (sendTime) => TIME_TO_RESEND - Math.floor((Date.now() - sendTime) / 1000);
|
|
5238
5253
|
|
|
5239
|
-
const
|
|
5240
|
-
|
|
5241
|
-
|
|
5254
|
+
const TIME_TO_RESEND = 180;
|
|
5255
|
+
const CODE_LENGTH = 4;
|
|
5256
|
+
const VerifyPhoneDialog = JSX(({ phone, withDescription = true, consents, onSuccess = noop, onClose = noop }) => {
|
|
5257
|
+
const [values, setValues] = useState(Array(CODE_LENGTH).fill(''));
|
|
5258
|
+
const sessionStore = useSessionStore();
|
|
5259
|
+
const { handleSubmit, hasError, errorText, isLoading, timeNextReq, isSubmitButtonDisabled, setTimeNextReq, setErrorText, } = useVerifyPhoneDialogSubmit({ values, onSuccess });
|
|
5242
5260
|
const captchaDialog = useDialog(CaptchaDialog);
|
|
5243
5261
|
const phoneNumber = formatPhone(phone);
|
|
5244
5262
|
const restartTimer = useCountDownTimer({ seconds: timeNextReq, onTick: setTimeNextReq });
|
|
@@ -5248,19 +5266,24 @@
|
|
|
5248
5266
|
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
5249
5267
|
});
|
|
5250
5268
|
if (isSuccessSendCode) {
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5269
|
+
setTimeNextReq(TIME_TO_RESEND);
|
|
5270
|
+
restartTimer(TIME_TO_RESEND);
|
|
5271
|
+
setErrorText('');
|
|
5272
|
+
sessionStore.smsCode = {
|
|
5273
|
+
sendTime: Date.now(),
|
|
5274
|
+
attempts: 0,
|
|
5275
|
+
};
|
|
5255
5276
|
}
|
|
5256
5277
|
else {
|
|
5257
5278
|
captchaDialog.open({ phoneNumber, sendCode: handleSendCode });
|
|
5258
5279
|
}
|
|
5259
5280
|
}, [phoneNumber, restartTimer, onClose]);
|
|
5260
5281
|
useEffect(() => {
|
|
5261
|
-
|
|
5282
|
+
if (!sessionStore.smsCode?.sendTime) {
|
|
5283
|
+
handleSendCode();
|
|
5284
|
+
}
|
|
5262
5285
|
}, []);
|
|
5263
|
-
return (jsx(Dialog, { className: "my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-xl p-m", onClose: onClose, children: jsxs("div", { className: "flex flex-col gap-xl items-center rounded-md", children: [jsx(Headline, { className: "w-full", title: "\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u043D\u043E\u043C\u0435\u0440 \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0430", description: `Мы отправили код на ${phone}`, headlineVersion: "XS", isEmbedded: true, as: "h6" }),
|
|
5286
|
+
return (jsx(Dialog, { className: "my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-xl p-m", onClose: onClose, children: jsxs("div", { className: "flex flex-col gap-xl items-center rounded-md", children: [jsx(Headline, { className: "w-full", title: "\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u043D\u043E\u043C\u0435\u0440 \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0430", description: `Мы отправили код на ${phone}`, headlineVersion: "XS", isEmbedded: true, as: "h6" }), jsx(InputCode, { values: values, setValues: setValues, errorText: errorText, hasError: hasError }), renderText$1(timeNextReq, handleSendCode), withDescription ? (jsxs(RichText, { itemSize: "list-s", children: [jsx("span", { children: "\u0412\u0432\u043E\u0434\u044F \u043A\u043E\u0434, \u044F \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044E, \u0447\u0442\u043E \u043E\u0437\u043D\u0430\u043A\u043E\u043C\u043B\u0435\u043D \u0438 \u043F\u043E\u0434\u043F\u0438\u0441\u044B\u0432\u0430\u044E: " }), jsx("ul", { children: consents?.map((_, i) => (jsx("li", { children: _ }, `${_}-${i}`))) })] })) : null, renderNextButton(isSubmitButtonDisabled, handleSubmit), isLoading ? jsx(Loader, { blur: false }) : null] }) }));
|
|
5264
5287
|
});
|
|
5265
5288
|
const renderNextButton = (disabled, onClick) => (jsx(SubmitButton, { text: "\u0414\u0430\u043B\u0435\u0435", disabled: disabled, onClick: onClick }));
|
|
5266
5289
|
const renderText$1 = (timeNextReq, handleSendCode) => timeNextReq ? (jsxs("div", { className: "flex flex-row text-l font-light text-base", children: ["\u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u043D\u043E\u0432\u044B\u0439 \u043A\u043E\u0434 \u043C\u043E\u0436\u043D\u043E \u0447\u0435\u0440\u0435\u0437", jsx(Timer, { className: "pl-2xs", seconds: timeNextReq })] })) : (jsx(Button, { embedded: true, onClick: handleSendCode, children: jsx(ButtonTitle, { children: "\u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u043D\u043E\u0432\u044B\u0439 \u043A\u043E\u0434" }) }));
|
|
@@ -7347,12 +7370,6 @@
|
|
|
7347
7370
|
|
|
7348
7371
|
const CurrencyInput = JSX((props) => (jsx(NumberInput, { ...props, fractionDigits: 2, children: jsx("div", { className: "absolute right-4 bottom-4", children: jsx(Text, { size: "text-xl", font: "font-light", children: "\u20BD" }) }) })));
|
|
7349
7372
|
|
|
7350
|
-
const sessionStore = new Store(); // sessionStorage cache
|
|
7351
|
-
replicate(sessionStore, new StorageAdapter(globalThis?.sessionStorage));
|
|
7352
|
-
function useSessionStore() {
|
|
7353
|
-
return useStore(sessionStore);
|
|
7354
|
-
}
|
|
7355
|
-
|
|
7356
7373
|
const paymentURLMap = {
|
|
7357
7374
|
private: 'p2p/registerP2P',
|
|
7358
7375
|
business: 'b2c/registerB2C',
|
|
@@ -10996,7 +11013,7 @@
|
|
|
10996
11013
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
10997
11014
|
});
|
|
10998
11015
|
|
|
10999
|
-
const packageVersion = "0.14.
|
|
11016
|
+
const packageVersion = "0.14.865";
|
|
11000
11017
|
|
|
11001
11018
|
exports.Blocks = Blocks;
|
|
11002
11019
|
exports.ContentPage = ContentPage;
|