feat: Payment userid param

This commit is contained in:
IlyaDoronin 2024-04-08 11:26:51 +03:00
parent e1a93be228
commit 3074ca383e
3 changed files with 104 additions and 85 deletions

@ -189,7 +189,10 @@ const App = () => {
<Route path="/quizpayment" element={<QuizPayment />} />
<Route element={<Docs />}>
<Route path={"/docs/oferta"} element={<Oferta />} />
<Route path="/docs/ofertaQuizDevelop" element={<OfertaQuizDevelop />} />
<Route
path="/docs/ofertaQuizDevelop"
element={<OfertaQuizDevelop />}
/>
<Route path={"/docs/privacy"} element={<PrivacyPolicy />} />
</Route>
<Route path="/afterpay" element={<AfterPay />} />

@ -1,9 +1,15 @@
import { Box, Button, Typography, useTheme, useMediaQuery } from "@mui/material";
import {
Box,
Button,
Typography,
useTheme,
useMediaQuery,
} from "@mui/material";
import { payCart } from "@root/api/cart";
import { useUserStore } from "@root/stores/user";
import wallet_icon from "@root/assets/Icons/ColorWallet.svg";
import { Link } from "react-router-dom";
const MINUTE = 1000 * 60;
const { domain, pathname } = (() => {
@ -15,7 +21,9 @@ const { domain, pathname } = (() => {
if (purpose === "paycart" || from === "quiz") {
let tryCount = 0;
const payCartPendingRequestDeadline = localStorage.getItem("payCartPendingRequestDeadline");
const payCartPendingRequestDeadline = localStorage.getItem(
"payCartPendingRequestDeadline"
);
const deadline = payCartPendingRequestDeadline
? Number(payCartPendingRequestDeadline)
: Date.now() + 20 * MINUTE;
@ -41,29 +49,31 @@ const { domain, pathname } = (() => {
const host = window.location.hostname;
return {
domain: (host.includes("s") ? "s" : "") + from,
pathname: from === "hub" ? "/tariffs" : "/list"
pathname: from === "hub" ? "/tariffs" : "/list",
};
})();
export default () => {
const theme = useTheme();
const phone = useMediaQuery(theme.breakpoints.down(375));
const userId = useUserStore((state) => state.user?._id);
const redirectUrl = new URL(`https://${domain}.pena.digital${pathname}`);
redirectUrl.searchParams.append("afterpay", "true");
redirectUrl.searchParams.append("userid", userId ?? "");
return (
<Box
sx={{
width: "100vw",
height: "100vh",
p: phone ? "76px 16px" : "117px 0 0 0"
p: phone ? "76px 16px" : "117px 0 0 0",
}}
>
<Box
sx={{
display: "flex",
flexDirection: "column",
alignItems: "center"
alignItems: "center",
}}
>
<Box
@ -72,7 +82,7 @@ export default () => {
sx={{
width: phone ? "338px" : "auto",
height: phone ? "215px" : "auto",
mb: "60px"
mb: "60px",
}}
/>
<Typography
@ -81,24 +91,30 @@ export default () => {
fontWeight: 500,
lineHeight: "28.44px",
textAlign: "center",
mb: "10px"
mb: "10px",
}}
>Спасибо за оплату!</Typography>
>
Спасибо за оплату!
</Typography>
<Typography
sx={{
fontSize: "18px",
lineHeight: "21.33px",
textAlign: "center",
color: theme.palette.gray.dark,
mb: "30px"
mb: "30px",
}}
>Ваш платеж принят и в течение 10 минут товары будут зачислены</Typography>
>
Ваш платеж принят и в течение 10 минут товары будут зачислены
</Typography>
<Button
component={Link}
to={redirectUrl.toString()}
replace={true}
variant="pena-contained-dark"
>На главную</Button>
>
На главную
</Button>
</Box>
</Box>
);

@ -50,7 +50,7 @@ export default function QuizPayment() {
useEffect(
function redirectIfSignedIn() {
if (!first && user?._id === userId)
navigate(`/payment?action=${action}&dif=${dif}`, { replace: true });
navigate(`/payment?action=${action}&dif=${dif}&user=${userId}`, { replace: true });
},
[navigate, user]
);