import type { ProfileTaskCenterResponse } from '../../../packages/shared/src/contracts/runtime'; import { PlatformActionButton } from '../common/PlatformActionButton'; import { PlatformEmptyState } from '../common/PlatformEmptyState'; import { PlatformStatusMessage } from '../common/PlatformStatusMessage'; import { PlatformSubpanel } from '../common/PlatformSubpanel'; import { PlatformProfileModalShell } from './PlatformProfileModalShell'; import { buildProfileTaskProgressLabel, getProfileTaskClaimButtonLabel, getProfileTaskStatusLabel, selectProfileTaskCenterTasks, } from '../rpg-entry/rpgEntryProfileTaskViewModel'; export type PlatformProfileTaskCenterModalProps = { center: ProfileTaskCenterResponse | null; isLoading: boolean; error: string | null; success: string | null; claimingTaskId: string | null; fallbackBalance: number; onClose: () => void; onRetry: () => void; onClaim: (taskId: string) => void; }; /** * 个人中心每日任务弹窗。 * 复用任务中心 view model,保持原有任务筛选、状态文案和领取交互不变。 */ export function PlatformProfileTaskCenterModal({ center, isLoading, error, success, claimingTaskId, fallbackBalance, onClose, onRetry, onClaim, }: PlatformProfileTaskCenterModalProps) { const tasks = selectProfileTaskCenterTasks(center?.tasks ?? []); const walletBalance = center?.walletBalance ?? fallbackBalance; return ( {error ? (
{error}
重新加载
) : null} {success ? ( {success} ) : null} {isLoading ? (
{Array.from({ length: 2 }).map((_, index) => (
))}
) : tasks.length === 0 ? ( 暂无任务 ) : (
{tasks.map((task) => { const isClaimable = task.status === 'claimable'; const isClaiming = claimingTaskId === task.taskId; const progressLabel = buildProfileTaskProgressLabel(task); return (
{task.title}
{progressLabel}
+{task.rewardPoints}
{getProfileTaskStatusLabel(task.status)}
onClaim(task.taskId)} > {getProfileTaskClaimButtonLabel(task, isClaiming)}
); })}
)} ); }