feat: 预计最终到期时间展示
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 8m8s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 8m8s
This commit is contained in:
23
src/utils/business/expiryEstimate.ts
Normal file
23
src/utils/business/expiryEstimate.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { formatDateTime } from './format'
|
||||
|
||||
export interface ExpiryEstimate {
|
||||
estimated_final_expires_at?: string | null
|
||||
days_until_final_expiry?: number | null
|
||||
expiry_estimate_status?: string | null
|
||||
is_expiring?: boolean
|
||||
}
|
||||
|
||||
export const getExpiryEstimateText = (estimate: ExpiryEstimate): string => {
|
||||
if (estimate.expiry_estimate_status === 'exact') {
|
||||
return estimate.estimated_final_expires_at
|
||||
? formatDateTime(estimate.estimated_final_expires_at)
|
||||
: '-'
|
||||
}
|
||||
|
||||
return estimate.expiry_estimate_status ? '待激活后起算' : '-'
|
||||
}
|
||||
|
||||
export const getExpiryEstimateTooltip = (estimate: ExpiryEstimate): string => {
|
||||
if (!estimate.is_expiring || estimate.days_until_final_expiry == null) return ''
|
||||
return `剩余${estimate.days_until_final_expiry}天`
|
||||
}
|
||||
@@ -7,3 +7,4 @@ export * from './validate'
|
||||
export * from './calculate'
|
||||
export * from './voucher'
|
||||
export * from './apiRateLimit'
|
||||
export * from './expiryEstimate'
|
||||
|
||||
Reference in New Issue
Block a user