From 8349a631c0d45c965b1fe87164d0a93512235fae Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 20 Mar 2024 03:36:53 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D1=81=D1=82=D1=80=20=D1=81=D0=BF=D1=81=20?= =?UTF-8?q?=D0=B7=D0=B0=20=D0=B4=D0=B5=D0=BD=D0=B5=D0=B6=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/Icons/ColorWallet.svg | 50 +++++++++++++++++++++++++++++ src/index.tsx | 2 ++ src/pages/AfterPay/index.tsx | 55 ++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 src/assets/Icons/ColorWallet.svg create mode 100644 src/pages/AfterPay/index.tsx diff --git a/src/assets/Icons/ColorWallet.svg b/src/assets/Icons/ColorWallet.svg new file mode 100644 index 0000000..f19fe45 --- /dev/null +++ b/src/assets/Icons/ColorWallet.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/index.tsx b/src/index.tsx index 21a1420..942342f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -35,6 +35,7 @@ import PrivacyPolicy from "@root/docs/content/PrivacyPolicy" import RecoverPassword from "@root/pages/auth/RecoverPassword" import OutdatedLink from "@root/pages/auth/OutdatedLink" import { verify } from "./pages/AccountSettings/helper" +import AfterPay from "./pages/AfterPay" pdfjs.GlobalWorkerOptions.workerSrc = new URL("pdfjs-dist/build/pdf.worker.min.js", import.meta.url).toString() @@ -116,6 +117,7 @@ const App = () => { } /> } /> + } /> }/> } /> diff --git a/src/pages/AfterPay/index.tsx b/src/pages/AfterPay/index.tsx new file mode 100644 index 0000000..d17c2fe --- /dev/null +++ b/src/pages/AfterPay/index.tsx @@ -0,0 +1,55 @@ +import { Box, Button, Typography, useTheme, useMediaQuery } from "@mui/material" +import wallet_icon from "@root/assets/Icons/ColorWallet.svg" + +export default () => { + const theme = useTheme(); + const phone = useMediaQuery(theme.breakpoints.down(375)); + return ( + + + + Спасибо за оплату! + Ваш платеж принят и в течение 10 минут товары будут зачислены + + + + ) +} \ No newline at end of file From 3ffa3418c0d1051f2f98666ca8c73d51035ac511 Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 20 Mar 2024 05:04:27 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BD=D1=8B=D0=B9=20=D1=83=D1=80=D0=BB=20=D0=BF=D0=BB=D0=B0?= =?UTF-8?q?=D1=82=D1=91=D0=B6=D0=BA=D0=B8=20=D0=B2=D0=B5=D0=B4=D1=91=D1=82?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D1=83=20=D1=81=D0=BF=D0=B0=D1=81=D0=B8=D0=B1=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/wallet.ts | 48 +++++++++++++++++------------- src/index.tsx | 12 ++++---- src/pages/AfterPay/index.tsx | 15 ++++++++++ src/pages/Payment/Payment.tsx | 16 ++-------- src/utils/hooks/useDomainDefine.ts | 13 ++++++++ 5 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 src/utils/hooks/useDomainDefine.ts diff --git a/src/api/wallet.ts b/src/api/wallet.ts index 9017930..f3d812f 100644 --- a/src/api/wallet.ts +++ b/src/api/wallet.ts @@ -2,32 +2,25 @@ import { makeRequest } from "@frontend/kitui"; import { SendPaymentRequest, SendPaymentResponse } from "@root/model/wallet"; import { parseAxiosError } from "@root/utils/parse-error"; +const isStaging = (() => { + const host = window.location.hostname; + return host.includes("s") ? "s" : ""; +})(); + const apiUrl = process.env.REACT_APP_DOMAIN + "/customer"; -const testPaymentBody: SendPaymentRequest = { - type: "bankCard", - amount: 15020, - currency: "RUB", - bankCard: { - number: "RUB", - expiryYear: "2021", - expiryMonth: "05", - csc: "05", - cardholder: "IVAN IVANOV", - }, - phoneNumber: "79000000000", - login: "login_test", - returnUrl: window.location.origin + "/wallet", -}; +interface PaymentBody { + type: string; + amount: number; +} export async function sendPayment({ - body = testPaymentBody, - fromSquiz = false, + body, + fromSquiz }: { - body?: SendPaymentRequest; + body: PaymentBody; fromSquiz: boolean; }): Promise<[SendPaymentResponse | null, string?]> { - if (fromSquiz) body.returnUrl = "squiz.pena.digital/list?action=fromhub"; try { const sendPaymentResponse = await makeRequest< SendPaymentRequest, @@ -38,7 +31,20 @@ export async function sendPayment({ method: "POST", useToken: true, withCredentials: false, - body, + body: { + currency: "RUB", + bankCard: { + number: "RUB", + expiryYear: "2021", + expiryMonth: "05", + csc: "05", + cardholder: "IVAN IVANOV", + }, + phoneNumber: "79000000000", + login: "login_test", + returnUrl: `https://${isStaging}hub.pena.digital/afterpay?from=${fromSquiz ? "quiz" : "hub"}`, + ...body + } }); return [sendPaymentResponse]; @@ -55,7 +61,7 @@ export const sendRSPayment = async (money: number): Promise => { url: apiUrl + "/wallet/rspay", method: "POST", useToken: true, - body: {money: money}, + body: { money: money }, withCredentials: false, }); diff --git a/src/index.tsx b/src/index.tsx index 942342f..026dbcf 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -99,7 +99,7 @@ const App = () => { } /> } /> } /> - + } /> }> }> @@ -117,14 +117,14 @@ const App = () => { } /> } /> - } /> - }/> - } /> + } /> + } /> }> - }/> - }/> + } /> + } /> + } /> ) diff --git a/src/pages/AfterPay/index.tsx b/src/pages/AfterPay/index.tsx index d17c2fe..e196ec8 100644 --- a/src/pages/AfterPay/index.tsx +++ b/src/pages/AfterPay/index.tsx @@ -1,9 +1,22 @@ import { Box, Button, Typography, useTheme, useMediaQuery } from "@mui/material" import wallet_icon from "@root/assets/Icons/ColorWallet.svg" +import { Link } from "react-router-dom"; +//Привет :) +const { domain, pathname } = (() => { + const params = new URLSearchParams(window.location.search); + const from = params.get("from") || "hub"; + if (window.location.pathname.includes("afterpay")) history.pushState(null, document.title, "/afterpay"); + const host = window.location.hostname; + return { + domain: (host.includes("s") ? "s" : "") + from, + pathname: from === "hub" ? "/wallet" : "" + } +})(); export default () => { const theme = useTheme(); const phone = useMediaQuery(theme.breakpoints.down(375)); + return ( { }} >Ваш платеж принят и в течение 10 минут товары будут зачислены diff --git a/src/pages/Payment/Payment.tsx b/src/pages/Payment/Payment.tsx index 3ca0f6f..1c26153 100644 --- a/src/pages/Payment/Payment.tsx +++ b/src/pages/Payment/Payment.tsx @@ -22,7 +22,7 @@ import { sendPayment, sendRSPayment } from "@root/api/wallet"; import { getMessageFromFetchError } from "@frontend/kitui"; import { enqueueSnackbar } from "notistack"; import { currencyFormatter } from "@root/utils/currencyFormatter"; -import { useLocation, useNavigate } from "react-router-dom"; +import { Link, useLocation, useNavigate } from "react-router-dom"; import { useHistoryTracker } from "@root/utils/hooks/useHistoryTracker"; import { useUserStore } from "@root/stores/user"; import { VerificationStatus } from "@root/model/account"; @@ -62,6 +62,7 @@ export default function Payment() { const location = useLocation(); const verificationStatus = useUserStore((state) => state.verificationStatus); const navigate = useNavigate(); + const handleCustomBackNavigation = useHistoryTracker(); const notEnoughMoneyAmount = (location.state?.notEnoughMoneyAmount as number) ?? 0; @@ -86,6 +87,7 @@ export default function Payment() { async function handleChoosePaymentClick() { if (!selectedPaymentMethod) { + enqueueSnackbar("Введите метод оплаты") return; } @@ -100,17 +102,6 @@ export default function Payment() { body: { type: selectedPaymentMethod, amount: Number(paymentValueField) * 100, - currency: "RUB", - bankCard: { - number: "RUB", - expiryYear: "2021", - expiryMonth: "05", - csc: "05", - cardholder: "IVAN IVANOV", - }, - phoneNumber: "79000000000", - login: "login_test", - returnUrl: window.location.origin + "/wallet", }, }); @@ -178,7 +169,6 @@ export default function Payment() { } - const handleCustomBackNavigation = useHistoryTracker(); return ( (false); + + useEffect(() => { + const host = window.location.hostname; + let isTest = host.includes("s"); + setIsTestServer(isTest); + }, []); + + return { isTestServer }; +}