修复用户未/授权购买套餐价格计算 & 发布v1.6.0版本
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
'use client'
|
||||
import {ReactNode, useEffect, useState} from 'react'
|
||||
import {ReactNode, use, useEffect, useState} 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 {usePathname, useRouter, useSearchParams} from 'next/navigation'
|
||||
import SelfDesc from '@/components/features/self-desc'
|
||||
import {listProduct, ProductItem} from '@/actions/product'
|
||||
import {listProduct, listProductHome, ProductItem} from '@/actions/product'
|
||||
import {useProfileStore} from '@/components/stores/profile'
|
||||
export type TabType = 'short' | 'long' | 'fixed' | 'custom'
|
||||
|
||||
export default function Purchase() {
|
||||
@@ -22,19 +23,21 @@ export default function Purchase() {
|
||||
newParams.set('type', tab)
|
||||
router.push(`${path}?${newParams.toString()}`)
|
||||
}
|
||||
const profile = use(useProfileStore(store => store.profile))
|
||||
|
||||
useEffect(() => {
|
||||
const fetchProducts = async () => {
|
||||
const res = await listProduct({})
|
||||
const res = profile
|
||||
? await listProduct({})
|
||||
: await listProductHome({})
|
||||
|
||||
if (res.success) {
|
||||
setProductList(res.data)
|
||||
}
|
||||
}
|
||||
fetchProducts()
|
||||
}, [])
|
||||
}, [profile])
|
||||
|
||||
const currentProduct = productList.find(item => item.code === tab)
|
||||
const currentSkuList = currentProduct?.skus || []
|
||||
const componentMap: Record<string, React.FC<{skuList: ProductItem['skus']}>> = {
|
||||
short: ShortForm,
|
||||
long: LongForm,
|
||||
|
||||
Reference in New Issue
Block a user