类型(后台会员): 会员状态文案表改用命名联合类型
- membershipStatusLabels 原为 Record<string,string>,新增/改名状态时编译期无法发现漏配 - 改用 @genarrative/shared 的 ProfileMembershipStatus(normal/active),并把 AdminProfileMembershipPayload.status 的内联字面量一并替换
This commit is contained in:
@@ -2,6 +2,7 @@ import type {
|
||||
ProfileMembershipCycleKind,
|
||||
ProfileMembershipModelAccess,
|
||||
ProfileMembershipPlan,
|
||||
ProfileMembershipStatus,
|
||||
} from '@genarrative/shared';
|
||||
|
||||
export interface ApiMeta {
|
||||
@@ -392,6 +393,7 @@ export type {
|
||||
ProfileMembershipCycleKind,
|
||||
ProfileMembershipModelAccess,
|
||||
ProfileMembershipPlan,
|
||||
ProfileMembershipStatus,
|
||||
};
|
||||
export interface AdminTrackingEventListQuery {
|
||||
eventKey?: string;
|
||||
@@ -1057,7 +1059,7 @@ export interface AdminUserDetailResponse {
|
||||
export interface AdminProfileMembershipPayload {
|
||||
plan: ProfileMembershipPlan;
|
||||
/** 与后端 `RuntimeProfileMembershipStatus` 对齐:`normal` / `active`。 */
|
||||
status: 'normal' | 'active';
|
||||
status: ProfileMembershipStatus;
|
||||
cycleKind: ProfileMembershipCycleKind;
|
||||
cycleIndex: number;
|
||||
cycleCount: number;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
ProfileMembershipCycleKind,
|
||||
ProfileMembershipPlan,
|
||||
ProfileMembershipStatus,
|
||||
} from '../api/adminApiTypes';
|
||||
|
||||
/** 会员档位展示名;`normal` 即非会员。 */
|
||||
@@ -22,7 +23,7 @@ export const membershipCycleKindLabels: Record<
|
||||
};
|
||||
|
||||
/** 会员状态展示名;与后端 `RuntimeProfileMembershipStatus` 的 `normal` / `active` 对齐。 */
|
||||
export const membershipStatusLabels: Record<string, string> = {
|
||||
export const membershipStatusLabels: Record<ProfileMembershipStatus, string> = {
|
||||
normal: '非会员',
|
||||
active: '生效中',
|
||||
};
|
||||
@@ -39,5 +40,5 @@ export function formatMembershipCycleKind(kind: string): string {
|
||||
|
||||
/** 把后端的会员状态 code 映射成展示名,未知值原样返回。 */
|
||||
export function formatMembershipStatus(status: string): string {
|
||||
return membershipStatusLabels[status] ?? status;
|
||||
return membershipStatusLabels[status as ProfileMembershipStatus] ?? status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user