套餐管理添加IP检查状态字段 &修复套餐提取和购买的数量显示问题
This commit is contained in:
@@ -230,6 +230,17 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
header: 'IP检查状态',
|
||||||
|
cell: ({row}) => {
|
||||||
|
const checkip = row.original.checkip
|
||||||
|
return (
|
||||||
|
<span className={checkip ? 'text-green-500' : 'text-red-500'}>
|
||||||
|
{checkip ? '启用IP检查' : '停用IP检查'}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// 短效资源增加到期时间列
|
// 短效资源增加到期时间列
|
||||||
|
|||||||
@@ -29,36 +29,32 @@ export default function Center({skuData}: {
|
|||||||
const currentCountMin = useMemo(() => {
|
const currentCountMin = useMemo(() => {
|
||||||
if (!type || !live) return 0
|
if (!type || !live) return 0
|
||||||
const expireValue = type === '1' ? expire : '0'
|
const expireValue = type === '1' ? expire : '0'
|
||||||
return getPurchaseSkuCountMin(skuData, {mode: type, live, expire: expireValue})
|
const countMin = getPurchaseSkuCountMin(skuData, {
|
||||||
|
mode: type,
|
||||||
|
live,
|
||||||
|
expire: expireValue,
|
||||||
|
})
|
||||||
|
return countMin
|
||||||
}, [type, live, expire, skuData])
|
}, [type, live, expire, skuData])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (type === '1') {
|
if (currentCountMin <= 0) return
|
||||||
const current = getValues('daily_limit')
|
const targetField = type === '1' ? 'daily_limit' : 'quota'
|
||||||
if (current < currentCountMin) {
|
const currentValue = getValues(targetField)
|
||||||
setValue('daily_limit', currentCountMin)
|
if (currentValue !== currentCountMin) {
|
||||||
}
|
setValue(targetField, currentCountMin, {shouldValidate: true})
|
||||||
}
|
|
||||||
else {
|
|
||||||
const current = getValues('quota')
|
|
||||||
if (current < currentCountMin) {
|
|
||||||
setValue('quota', currentCountMin)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [currentCountMin, type, setValue, getValues])
|
}, [currentCountMin, type, setValue, getValues])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const nextType = modeList.includes(type) ? type : modeList[0]
|
const nextType = modeList.includes(type) ? type : modeList[0]
|
||||||
|
|
||||||
if (!nextType) {
|
if (!nextType) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextType !== type) {
|
if (nextType !== type) {
|
||||||
setValue('type', nextType)
|
setValue('type', nextType)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextLiveList = nextType === '1'
|
const nextLiveList = nextType === '1'
|
||||||
? getAvailablePurchaseLives(skuData, {mode: nextType, expire})
|
? getAvailablePurchaseLives(skuData, {mode: nextType, expire})
|
||||||
: getAvailablePurchaseLives(skuData, {mode: nextType})
|
: getAvailablePurchaseLives(skuData, {mode: nextType})
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function BillingMethodField(props: {
|
|||||||
modeList: PurchaseMode[]
|
modeList: PurchaseMode[]
|
||||||
timeDailyLimit: number
|
timeDailyLimit: number
|
||||||
}) {
|
}) {
|
||||||
const {setValue} = useFormContext<PurchaseFormValues>()
|
const {setValue, getValues} = useFormContext<PurchaseFormValues>()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormField<PurchaseFormValues, 'type'>
|
<FormField<PurchaseFormValues, 'type'>
|
||||||
@@ -30,8 +30,7 @@ export function BillingMethodField(props: {
|
|||||||
setValue('expire', '0')
|
setValue('expire', '0')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
setValue('expire', getValues('expire') || '0')
|
||||||
setValue('daily_limit', props.timeDailyLimit)
|
|
||||||
}}
|
}}
|
||||||
className="flex gap-4 max-md:flex-col"
|
className="flex gap-4 max-md:flex-col"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -36,9 +36,11 @@ export default function Center({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentCountMin <= 0) return
|
if (currentCountMin <= 0) return
|
||||||
|
|
||||||
const targetField = type === '1' ? 'daily_limit' : 'quota'
|
const targetField = type === '1' ? 'daily_limit' : 'quota'
|
||||||
const currentValue = getValues(targetField)
|
const currentValue = getValues(targetField)
|
||||||
if (currentValue < currentCountMin) {
|
|
||||||
|
if (currentValue !== currentCountMin) {
|
||||||
setValue(targetField, currentCountMin, {shouldValidate: true})
|
setValue(targetField, currentCountMin, {shouldValidate: true})
|
||||||
}
|
}
|
||||||
}, [currentCountMin, type, setValue, getValues])
|
}, [currentCountMin, type, setValue, getValues])
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export type Resource<T extends 1 | 2 = 1 | 2> = {
|
|||||||
active: boolean
|
active: boolean
|
||||||
created_at: Date
|
created_at: Date
|
||||||
updated_at: Date
|
updated_at: Date
|
||||||
|
checkip: boolean
|
||||||
} & (
|
} & (
|
||||||
T extends 1 ? {
|
T extends 1 ? {
|
||||||
type: 1
|
type: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user