diff --git a/apps/user/app/(main)/(content)/(user)/dashboard/content.tsx b/apps/user/app/(main)/(content)/(user)/dashboard/content.tsx index 58cc942..68d06c5 100644 --- a/apps/user/app/(main)/(content)/(user)/dashboard/content.tsx +++ b/apps/user/app/(main)/(content)/(user)/dashboard/content.tsx @@ -75,7 +75,7 @@ export default function Content() { const { data: orderData } = useQuery({ queryKey: ['orderData'], queryFn: async () => { - const { data } = await queryOrderList({ status: 5 }); + const { data } = await queryOrderList({ status: 5, page: 1, size: 10 }); return data?.[0] ?? {}; }, }); diff --git a/apps/user/app/(main)/(content)/(user)/order/components/OrderDetailDialog.tsx b/apps/user/app/(main)/(content)/(user)/order/components/OrderDetailDialog.tsx index b772209..b384a95 100644 --- a/apps/user/app/(main)/(content)/(user)/order/components/OrderDetailDialog.tsx +++ b/apps/user/app/(main)/(content)/(user)/order/components/OrderDetailDialog.tsx @@ -1,6 +1,6 @@ 'use client'; import { useQuery } from '@tanstack/react-query'; -import { Dialog, DialogContent } from '@workspace/airo-ui/components/dialog'; +import { Dialog, DialogContent, DialogTitle } from '@workspace/airo-ui/components/dialog'; import { Separator } from '@workspace/airo-ui/components/separator'; import { useTranslations } from 'next-intl'; import { useRouter } from 'next/navigation'; @@ -63,6 +63,9 @@ const OrderDetailDialog = forwardRef + +
order detail
+
{t('orderDetail')} @@ -75,7 +78,7 @@ const OrderDetailDialog = forwardRef
{t('paymentMethod')}
-
{t('walletBalance')}
+
{data?.payment?.name}
diff --git a/apps/user/app/(main)/(content)/(user)/payment/page.tsx b/apps/user/app/(main)/(content)/(user)/payment/page.tsx index 33d8ef6..46868b1 100644 --- a/apps/user/app/(main)/(content)/(user)/payment/page.tsx +++ b/apps/user/app/(main)/(content)/(user)/payment/page.tsx @@ -39,7 +39,7 @@ export default function Page() { queryFn: async () => { const { data } = await queryOrderDetail({ order_no: orderNo! }); if (data?.data?.status !== 1) { - getUserInfo(); + await getUserInfo(); setEnabled(false); } return data?.data; diff --git a/apps/user/components/main/OfferDialog/index.tsx b/apps/user/components/main/OfferDialog/index.tsx index a6c5c8d..4a3defe 100644 --- a/apps/user/components/main/OfferDialog/index.tsx +++ b/apps/user/components/main/OfferDialog/index.tsx @@ -175,7 +175,7 @@ const PlanCard = forwardRef< // 有生效套餐进行弹窗提示 const { data } = await queryUserSubscribe(); - if (data?.data?.list?.[0].status === 1) { + if (data?.data?.list?.[0]?.status === 1) { ModalRef.current.show(); return; } diff --git a/apps/user/components/subscribe/billing.tsx b/apps/user/components/subscribe/billing.tsx index e6b10c4..b268ee5 100644 --- a/apps/user/components/subscribe/billing.tsx +++ b/apps/user/components/subscribe/billing.tsx @@ -1,55 +1,3 @@ -/* -'use client'; - -import { Card, CardContent, CardHeader, CardTitle } from '@workspace/ui/components/card'; -import { Separator } from '@workspace/ui/components/separator'; -import { useTranslations } from 'next-intl'; - -export function SubscribeBilling({ order }: { order: API.Order }) { - const t = useTranslations('subscribe.billing'); - const t_c = useTranslations('components.billing'); - return ( - - - {t('billingTitle')} - - -
-
- {t('productDiscount')} - -¥ {order?.discount_amount} -
-
- {t('couponDiscount')} - -¥ {order?.coupon_discount_amount} -
-
- {t_c('planDuration')} - - {order?.quantity === 1 ? t_c('30days') : ''} - {order?.quantity === 12 ? t_c('365days') : ''} - -
-
- {t('gift')} - -¥ {order?.gift_balance_deduction_amount} -
-
- {t('fee')} - ¥ {order?.fee} -
- -
- {t('total')} - ¥ {order?.total_amount} -
-
-
-
- ); -} -*/ - 'use client'; import { Display } from '@/components/display'; @@ -81,14 +29,6 @@ export function SubscribeBilling({ order }: Readonly) { {order?.quantity === 12 ? t_c('365days') : ''} - {order?.type && [1, 2].includes(order?.type) && ( -
  • - {t('billing.duration')} - - {order?.quantity || 1} {t(order?.unit_time || 'Month')} - -
  • - )}
  • {t('billing.price')} diff --git a/apps/user/components/subscribe/payment-methods.tsx b/apps/user/components/subscribe/payment-methods.tsx index d486ed7..df64c77 100644 --- a/apps/user/components/subscribe/payment-methods.tsx +++ b/apps/user/components/subscribe/payment-methods.tsx @@ -7,64 +7,71 @@ import { RadioGroup, RadioGroupItem } from '@workspace/airo-ui/components/radio- import { cn } from '@workspace/airo-ui/lib/utils'; import { useTranslations } from 'next-intl'; import Image from 'next/image'; -import React, { memo } from 'react'; +import React, { memo, useState } from 'react'; interface PaymentMethodsProps { value: number; onChange: (value: number) => void; balance?: boolean; + titleClassName: string; } -const PaymentMethods: React.FC = ({ value, onChange, balance = true }) => { +const PaymentMethods: React.FC = ({ + value, + onChange, + balance = true, + titleClassName, +}) => { const t = useTranslations('subscribe'); - + const [methods, setMethods] = useState({}); const { data } = useQuery({ queryKey: ['getAvailablePaymentMethods', { balance }], queryFn: async () => { const { data } = await getAvailablePaymentMethods(); const list = data.data?.list || []; const methods = balance ? list : list.filter((item) => item.id !== -1); - const defaultMethod = methods.find((item) => item.id)?.id; - if (defaultMethod) onChange(defaultMethod); + const defaultMethod = methods.find((item) => item.id); + if (defaultMethod?.id) { + onChange(defaultMethod?.id); + setMethods(defaultMethod); + } return methods; }, }); return ( <> -
    {t('paymentMethod')}
    +
    + {t('paymentMethod')} + {methods.name} +
    { - console.log(val); - onChange(Number(val)); + onValueChange={(item) => { + setMethods(item); + onChange(Number(item.id)); }} > {data?.map((item) => ( -
    +
    ))} diff --git a/apps/user/components/subscribe/purchase.tsx b/apps/user/components/subscribe/purchase.tsx index f6394b7..79315d9 100644 --- a/apps/user/components/subscribe/purchase.tsx +++ b/apps/user/components/subscribe/purchase.tsx @@ -1,8 +1,8 @@ 'use client'; +import PaymentMethods from '@/components/subscribe/payment-methods'; import useGlobalStore from '@/config/use-global'; import { preCreateOrder, purchase } from '@/services/user/order'; -import { purchaseCheckout } from '@/services/user/portal'; import { useQuery } from '@tanstack/react-query'; import { Button } from '@workspace/airo-ui/components/button'; import { @@ -24,7 +24,6 @@ import { useState, useTransition, } from 'react'; -import { toast } from 'sonner'; import { SubscribeBilling } from './billing'; import { SubscribeDetail } from './detail'; @@ -109,17 +108,8 @@ const Purchase = forwardRef((props, ref) => { const response = await purchase(params as API.PurchaseOrderRequest); const orderNo = response.data.data?.order_no; if (orderNo) { - const data = await purchaseCheckout({ - orderNo: orderNo, - returnUrl: window.location.href, - }); await getUserInfo(); - if (data.data?.type === 'url' && data.data.checkout_url) { - window.open(data.data.checkout_url, '_blank'); - } else { - toast.success(t('paymentSuccess')); - router.push(`/dashboard`); - } + router.push(`/payment?order_no=${orderNo}`); } } catch (error) { /* empty */ @@ -193,10 +183,13 @@ const Purchase = forwardRef((props, ref) => { }} /> -
    -
    {t('paymentMethod')}
    -
    {t('walletBalance')}
    -
    + { + handleChange('payment', value); + }} + />