完善支付页面与路由的交互实现

This commit is contained in:
2025-12-09 15:25:54 +08:00
parent 5202f8190e
commit 2f61856ff6
5 changed files with 19 additions and 52 deletions

View File

@@ -1,25 +1,23 @@
'use client'
import {ReactNode, useState} from 'react'
import {ReactNode} from 'react'
import {merge} from '@/lib/utils'
import {Tabs, TabsContent, TabsList, TabsTrigger} from '@/components/ui/tabs'
import LongForm from '@/components/composites/purchase/long/form'
import ShortForm from '@/components/composites/purchase/short/form'
import {useSearchParams} from 'next/navigation'
import {usePathname, useRouter, useSearchParams} from 'next/navigation'
export type TabType = 'short' | 'long' | 'fixed' | 'custom'
type PurchaseProps = {
defaultTab: TabType
}
export default function Purchase(props: PurchaseProps) {
const [tab, setTab] = useState(props.defaultTab)
export default function Purchase() {
const router = useRouter()
const path = usePathname()
const params = useSearchParams()
const tab = params.get('type') as TabType || 'short'
const updateTab = async (tab: string) => {
setTab(tab as TabType)
const newParams = new URLSearchParams(params)
newParams.set('type', tab)
window.history.pushState({}, '', `?${newParams.toString()}`)
router.push(`${path}?${newParams.toString()}`)
}
return (