update kit
This commit is contained in:
parent
ec2b957450
commit
c9d7da58f4
@ -6,7 +6,7 @@
|
||||
"@craco/craco": "^7.0.0",
|
||||
"@emotion/react": "^11.10.5",
|
||||
"@emotion/styled": "^11.10.5",
|
||||
"@frontend/kitui": "^1.0.84",
|
||||
"@frontend/kitui": "^1.0.85",
|
||||
"@frontend/squzanswerer": "^1.0.55",
|
||||
"@mui/icons-material": "^5.10.14",
|
||||
"@mui/material": "^5.10.14",
|
||||
|
@ -21,7 +21,7 @@ import { createResult, setQuestions } from "@root/questions/actions";
|
||||
import { toggleQuizPreview } from "@root/quizPreview";
|
||||
import VisibilityIcon from "@mui/icons-material/Visibility";
|
||||
import { useDomainDefine } from "@utils/hooks/useDomainDefine";
|
||||
|
||||
// https://shub.pena.digital/quizpayment?action=squizpay&dif=9800&data=eyJhbGciOiJS
|
||||
interface Props {
|
||||
sidebar: boolean;
|
||||
header?: boolean;
|
||||
|
41
src/utils/hooks/useAutoPay.ts
Normal file
41
src/utils/hooks/useAutoPay.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { payCart } from "@root/api/cart";
|
||||
import { setSiteReadyPayCart } from "@root/stores/notEnoughMoneyAmount";
|
||||
import { useUserStore } from "@root/stores/user";
|
||||
import moment from "moment";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { useEffect } from "react";
|
||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||
|
||||
export const useAfterPay = () => {
|
||||
const navigate = useNavigate();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const paymentUserId = searchParams.get("userid");
|
||||
const userId = useUserStore(store => store.userId)
|
||||
|
||||
const purpose = searchParams.get("purpose");
|
||||
const from = searchParams.get("from") || "hub";
|
||||
const action = searchParams.get("action");
|
||||
|
||||
useEffect(() => {
|
||||
//Звёзды сошлись, будем оплачивать корзину
|
||||
if (from !== "quiz" && paymentUserId && paymentUserId === userId) {
|
||||
//Чистим url адрес от параметров. (Если нет action. Если есть - значит мы пришли из квиза)
|
||||
if (action === null) navigate(`/tariffs`, {
|
||||
replace: true,
|
||||
});
|
||||
if (purpose === "paycart") {
|
||||
(async () => {
|
||||
|
||||
//Проверяем можем ли мы оплатить корзину здесь и сейчас
|
||||
const [, payCartError] = await payCart();
|
||||
|
||||
if (payCartError) {
|
||||
//Не получилось купить корзину. Ставим флаг, что сайт в состоянии ожидания пополнения счёта для оплаты (потом проверим .isAfter)
|
||||
setSiteReadyPayCart({ [paymentUserId]: moment().add(20, 'minutes').format("x") })
|
||||
} else {
|
||||
enqueueSnackbar("Товары успешно приобретены")
|
||||
}
|
||||
})()
|
||||
}
|
||||
}
|
||||
}, [purpose, from, paymentUserId])
|
Loading…
Reference in New Issue
Block a user