From b3dbef5b48406c9fd6ca72e4c0ee642aa37991fa Mon Sep 17 00:00:00 2001 From: Zhang Minghan Date: Tue, 26 Dec 2023 00:18:18 +0800 Subject: [PATCH] feat: all in one payment method --- .../home/subscription/BuyDialog.tsx | 20 +++++++++--- app/src/dialogs/QuotaDialog.tsx | 21 +++++++------ app/src/resources/i18n/cn.json | 10 +++--- app/src/resources/i18n/en.json | 6 ++-- app/src/resources/i18n/ja.json | 6 ++-- app/src/resources/i18n/ru.json | 6 ++-- app/vite.config.ts | 1 + auth/controller.go | 4 +-- auth/payment.go | 31 +++++++++++++------ auth/quota.go | 20 ++++++++++++ auth/subscription.go | 4 +-- 11 files changed, 86 insertions(+), 43 deletions(-) diff --git a/app/src/components/home/subscription/BuyDialog.tsx b/app/src/components/home/subscription/BuyDialog.tsx index 377b47a..16ca8bf 100644 --- a/app/src/components/home/subscription/BuyDialog.tsx +++ b/app/src/components/home/subscription/BuyDialog.tsx @@ -26,6 +26,8 @@ import { Plus } from "lucide-react"; import { subscriptionPrize } from "@/conf.ts"; import { ToastAction } from "@/components/ui/toast.tsx"; import { deeptrainEndpoint, useDeeptrain } from "@/utils/env.ts"; +import { AppDispatch } from "@/store"; +import { openDialog } from "@/store/quota.ts"; function countPrize(base: number, month: number): number { const prize = subscriptionPrize[base] * month; @@ -57,6 +59,7 @@ type UpgradeProps = { async function callBuyAction( t: any, toast: any, + dispatch: AppDispatch, month: number, level: number, ): Promise { @@ -75,15 +78,22 @@ async function callBuyAction( action: ( (location.href = `${deeptrainEndpoint}/home/wallet`)} + onClick={() => + useDeeptrain + ? (location.href = `${deeptrainEndpoint}/home/wallet`) + : dispatch(openDialog()) + } > {t("buy.go")} ), }); - setTimeout(() => { - window.open(`${deeptrainEndpoint}/home/wallet`); - }, 2000); + + useDeeptrain + ? setTimeout(() => { + window.open(`${deeptrainEndpoint}/home/wallet`); + }, 2000) + : dispatch(openDialog()); } return res.status; } @@ -179,7 +189,7 @@ export function Upgrade({ base, level }: UpgradeProps) {