mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-07 01:56:53 +00:00
fix(default): correct subscription payment display
This commit is contained in:
@@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next'
|
||||
import { toast } from 'sonner'
|
||||
import { formatQuota } from '@/lib/format'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useStatus } from '@/hooks/use-status'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent, CardHeader } from '@/components/ui/card'
|
||||
import { Progress } from '@/components/ui/progress'
|
||||
@@ -52,12 +51,29 @@ function getEpayMethods(payMethods: PaymentMethod[] = []): PaymentMethod[] {
|
||||
)
|
||||
}
|
||||
|
||||
function getBillingPreferenceLabel(
|
||||
preference: string,
|
||||
t: (key: string) => string
|
||||
): string {
|
||||
switch (preference) {
|
||||
case 'subscription_first':
|
||||
return t('Subscription First')
|
||||
case 'wallet_first':
|
||||
return t('Wallet First')
|
||||
case 'subscription_only':
|
||||
return t('Subscription Only')
|
||||
case 'wallet_only':
|
||||
return t('Wallet Only')
|
||||
default:
|
||||
return preference
|
||||
}
|
||||
}
|
||||
|
||||
export function SubscriptionPlansCard({
|
||||
topupInfo,
|
||||
onAvailabilityChange,
|
||||
}: SubscriptionPlansCardProps) {
|
||||
const { t } = useTranslation()
|
||||
const { status } = useStatus()
|
||||
|
||||
const [plans, setPlans] = useState<PlanRecord[]>([])
|
||||
const [activeSubscriptions, setActiveSubscriptions] = useState<
|
||||
@@ -74,9 +90,9 @@ export function SubscriptionPlansCard({
|
||||
const [purchaseOpen, setPurchaseOpen] = useState(false)
|
||||
const [selectedPlan, setSelectedPlan] = useState<PlanRecord | null>(null)
|
||||
|
||||
const enableStripe = !!status?.enable_stripe_topup
|
||||
const enableStripe = !!topupInfo?.enable_stripe_topup
|
||||
const enableCreem = !!topupInfo?.enable_creem_topup
|
||||
const enableOnlineTopUp = !!status?.enable_online_topup
|
||||
const enableOnlineTopUp = !!topupInfo?.enable_online_topup
|
||||
const epayMethods = useMemo(
|
||||
() => getEpayMethods(topupInfo?.pay_methods),
|
||||
[topupInfo?.pay_methods]
|
||||
@@ -264,22 +280,24 @@ export function SubscriptionPlansCard({
|
||||
onValueChange={(v) => v !== null && handlePreferenceChange(v)}
|
||||
>
|
||||
<SelectTrigger className='h-8 flex-1 text-xs sm:w-[140px] sm:flex-none'>
|
||||
<SelectValue />
|
||||
<SelectValue>
|
||||
{getBillingPreferenceLabel(displayPref, t)}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='subscription_first' disabled={disablePref}>
|
||||
{t('Subscription First')}
|
||||
{getBillingPreferenceLabel('subscription_first', t)}
|
||||
{disablePref ? ` (${t('No Active')})` : ''}
|
||||
</SelectItem>
|
||||
<SelectItem value='wallet_first'>
|
||||
{t('Wallet First')}
|
||||
{getBillingPreferenceLabel('wallet_first', t)}
|
||||
</SelectItem>
|
||||
<SelectItem value='subscription_only' disabled={disablePref}>
|
||||
{t('Subscription Only')}
|
||||
{getBillingPreferenceLabel('subscription_only', t)}
|
||||
{disablePref ? ` (${t('No Active')})` : ''}
|
||||
</SelectItem>
|
||||
<SelectItem value='wallet_only'>
|
||||
{t('Wallet Only')}
|
||||
{getBillingPreferenceLabel('wallet_only', t)}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
Reference in New Issue
Block a user