修复 sku 缺失显示问题
This commit is contained in:
@@ -5,7 +5,7 @@ import {Form} from '@/components/ui/form'
|
||||
import * as z from 'zod'
|
||||
import {zodResolver} from '@hookform/resolvers/zod'
|
||||
import {ProductItem} from '@/actions/product'
|
||||
import {parsePurchaseSkuList} from '../shared/sku'
|
||||
import {getAvailablePurchaseExpires, getAvailablePurchaseLives, parsePurchaseSkuList} from '../shared/sku'
|
||||
import {PurchaseSidePanel} from '../shared/side-panel'
|
||||
|
||||
const schema = z.object({
|
||||
@@ -19,14 +19,19 @@ const schema = z.object({
|
||||
export type Schema = z.infer<typeof schema>
|
||||
|
||||
export default function LongForm({skuList}: {skuList: ProductItem['skus']}) {
|
||||
const {priceMap, liveList, expireList} = parsePurchaseSkuList('long', skuList)
|
||||
const skuData = parsePurchaseSkuList('long', skuList)
|
||||
const defaultMode = skuData.modeList.includes('2') ? '2' : '1'
|
||||
const defaultLive = getAvailablePurchaseLives(skuData, {mode: defaultMode})[0] || ''
|
||||
const defaultExpire = defaultMode === '1'
|
||||
? getAvailablePurchaseExpires(skuData, {mode: defaultMode, live: defaultLive})[0] || '0'
|
||||
: '0'
|
||||
|
||||
const form = useForm<Schema>({
|
||||
resolver: zodResolver(schema),
|
||||
defaultValues: {
|
||||
type: '2', // 默认为包量套餐
|
||||
live: liveList[0], // 分钟
|
||||
expire: '0', // 天
|
||||
type: defaultMode,
|
||||
live: defaultLive,
|
||||
expire: defaultExpire,
|
||||
quota: 500,
|
||||
daily_limit: 100,
|
||||
pay_type: 'balance', // 余额支付
|
||||
@@ -35,7 +40,7 @@ export default function LongForm({skuList}: {skuList: ProductItem['skus']}) {
|
||||
|
||||
return (
|
||||
<Form form={form} className="flex flex-col lg:flex-row gap-4">
|
||||
<Center {...{liveList, priceMap, expireList}}/>
|
||||
<Center skuData={skuData}/>
|
||||
<PurchaseSidePanel kind="long"/>
|
||||
</Form>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user