From 710947209aeba74ac4c07a42da05cae7acdca06b Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Tue, 11 Mar 2025 20:06:12 +0700 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(payment):=20Recon?= =?UTF-8?q?struct=20the=20payment=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/app/dashboard/payment/alipayf2f.tsx | 256 ----------- apps/admin/app/dashboard/payment/epay.tsx | 221 ---------- apps/admin/app/dashboard/payment/page.tsx | 29 +- .../app/dashboard/payment/payment-form.tsx | 396 ++++++++++++++++++ .../app/dashboard/payment/payment-table.tsx | 226 ++++++++++ .../app/dashboard/payment/stripe-alipay.tsx | 232 ---------- .../dashboard/payment/stripe-wechat-pay.tsx | 232 ---------- apps/admin/locales/cs-CZ/payment.json | 81 ++-- apps/admin/locales/de-DE/payment.json | 81 ++-- apps/admin/locales/en-US/payment.json | 85 ++-- apps/admin/locales/es-ES/payment.json | 81 ++-- apps/admin/locales/es-MX/payment.json | 81 ++-- apps/admin/locales/fa-IR/payment.json | 81 ++-- apps/admin/locales/fi-FI/payment.json | 81 ++-- apps/admin/locales/fr-FR/payment.json | 81 ++-- apps/admin/locales/hi-IN/payment.json | 81 ++-- apps/admin/locales/hu-HU/payment.json | 81 ++-- apps/admin/locales/ja-JP/payment.json | 81 ++-- apps/admin/locales/ko-KR/payment.json | 81 ++-- apps/admin/locales/no-NO/payment.json | 81 ++-- apps/admin/locales/pl-PL/payment.json | 81 ++-- apps/admin/locales/pt-BR/payment.json | 81 ++-- apps/admin/locales/ro-RO/payment.json | 81 ++-- apps/admin/locales/ru-RU/payment.json | 81 ++-- apps/admin/locales/th-TH/payment.json | 81 ++-- apps/admin/locales/tr-TR/payment.json | 81 ++-- apps/admin/locales/uk-UA/payment.json | 81 ++-- apps/admin/locales/vi-VN/payment.json | 81 ++-- apps/admin/locales/zh-CN/payment.json | 85 ++-- apps/admin/locales/zh-HK/payment.json | 81 ++-- apps/admin/services/admin/payment.ts | 131 +++--- apps/admin/services/admin/typings.d.ts | 149 ++++--- apps/admin/services/common/common.ts | 15 + apps/admin/services/common/typings.d.ts | 68 ++- 34 files changed, 1826 insertions(+), 2000 deletions(-) delete mode 100644 apps/admin/app/dashboard/payment/alipayf2f.tsx delete mode 100644 apps/admin/app/dashboard/payment/epay.tsx create mode 100644 apps/admin/app/dashboard/payment/payment-form.tsx create mode 100644 apps/admin/app/dashboard/payment/payment-table.tsx delete mode 100644 apps/admin/app/dashboard/payment/stripe-alipay.tsx delete mode 100644 apps/admin/app/dashboard/payment/stripe-wechat-pay.tsx diff --git a/apps/admin/app/dashboard/payment/alipayf2f.tsx b/apps/admin/app/dashboard/payment/alipayf2f.tsx deleted file mode 100644 index 51c5849..0000000 --- a/apps/admin/app/dashboard/payment/alipayf2f.tsx +++ /dev/null @@ -1,256 +0,0 @@ -'use client'; - -import { getAlipayF2FPaymentConfig, updateAlipayF2FPaymentConfig } from '@/services/admin/payment'; -import { useQuery } from '@tanstack/react-query'; -import { Label } from '@workspace/ui/components/label'; -import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectTrigger, - SelectValue, -} from '@workspace/ui/components/select'; -import { Switch } from '@workspace/ui/components/switch'; -import { Table, TableBody, TableCell, TableRow } from '@workspace/ui/components/table'; -import { Textarea } from '@workspace/ui/components/textarea'; -import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input'; -import { unitConversion } from '@workspace/ui/utils'; -import { useTranslations } from 'next-intl'; -import { toast } from 'sonner'; - -export default function AlipayF2F() { - const t = useTranslations('payment'); - - const { data, refetch } = useQuery({ - queryKey: ['getAlipayF2FPaymentConfig'], - queryFn: async () => { - const { data } = await getAlipayF2FPaymentConfig(); - - return data.data; - }, - }); - - async function updateConfig(key: string, value: unknown) { - if (data?.[key] === value) return; - try { - await updateAlipayF2FPaymentConfig({ - ...data, - [key]: value, - } as API.UpdateAlipayF2fRequest); - toast.success(t('saveSuccess')); - refetch(); - } catch (error) { - /* empty */ - } - } - - return ( - - - - - -

{t('enableDescription')}

-
- - { - updateConfig('enable', checked); - }} - /> - -
- - - -

{t('alipayf2f.sandboxDescription')}

-
- - { - updateConfig('config', { - ...data?.config, - sandbox: checked, - }); - }} - /> - -
- - - -

{t('showNameDescription')}

-
- - updateConfig('name', value)} - /> - -
- - - -

{t('iconUrlDescription')}

-
- - updateConfig('icon', value)} - /> - -
- - - -

{t('notifyUrlDescription')}

-
- - updateConfig('domain', value)} - /> - -
- - - -

{t('feeModeDescription')}

-
- - - -
- - - -

{t('feePercentDescription')}

-
- - updateConfig('fee_percent', value)} - suffix='%' - /> - -
- - - -

{t('fixedFeeDescription')}

-
- - unitConversion('centsToDollars', value)} - formatOutput={(value) => unitConversion('dollarsToCents', value)} - onValueBlur={(value) => updateConfig('fee_amount', value)} - /> - -
- - - -

- - - - updateConfig('config', { - ...data?.config, - app_id: value, - }) - } - /> - - - - - -

- - -