import { useState, type CSSProperties } from 'react'; import type { DailyTaskResponse } from '../network/api'; interface DailyTasksProps { tasks: DailyTaskResponse[]; onClaim: (taskId: string) => void; } const buttonStyle: CSSProperties = { position: 'fixed', top: 12, right: 12, zIndex: 50, display: 'flex', alignItems: 'center', gap: 4, padding: '5px 10px', borderRadius: 8, border: '1px solid rgba(255, 215, 0, 0.2)', backgroundColor: 'rgba(0,0,0,0.55)', color: '#daa520', fontSize: 11, fontWeight: 600, cursor: 'pointer', pointerEvents: 'auto', userSelect: 'none', }; const panelStyle: CSSProperties = { position: 'fixed', top: 12, right: 12, zIndex: 50, width: 230, borderRadius: 10, border: '1px solid rgba(255, 215, 0, 0.15)', backgroundColor: 'rgba(10, 10, 20, 0.88)', backdropFilter: 'blur(6px)', overflow: 'hidden', pointerEvents: 'auto', }; const panelHeaderStyle: CSSProperties = { display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '7px 10px', borderBottom: '1px solid rgba(255,255,255,0.08)', fontSize: 12, fontWeight: 700, color: '#daa520', }; const closeButtonStyle: CSSProperties = { background: 'none', border: 'none', color: '#888', fontSize: 14, cursor: 'pointer', padding: '0 4px', lineHeight: 1, }; const taskListStyle: CSSProperties = { padding: '6px 10px 8px', }; const taskRowStyle: CSSProperties = { marginBottom: 8, }; const taskLabelStyle: CSSProperties = { display: 'flex', justifyContent: 'space-between', alignItems: 'center', fontSize: 11, color: '#ccc', marginBottom: 3, }; const progressBarBgStyle: CSSProperties = { width: '100%', height: 6, borderRadius: 3, backgroundColor: 'rgba(255,255,255,0.08)', overflow: 'hidden', }; function progressBarFillStyle(pct: number, done: boolean): CSSProperties { return { width: `${Math.min(100, pct)}%`, height: '100%', borderRadius: 3, backgroundColor: done ? '#44cc44' : '#daa520', transition: 'width 300ms ease', }; } const claimButtonStyle: CSSProperties = { marginTop: 4, padding: '2px 10px', borderRadius: 4, border: '1px solid rgba(255, 215, 0, 0.4)', backgroundColor: 'rgba(255, 215, 0, 0.15)', color: '#ffd700', fontSize: 10, fontWeight: 600, cursor: 'pointer', display: 'block', width: '100%', textAlign: 'center', }; export function DailyTasks({ tasks, onClaim }: DailyTasksProps) { const [expanded, setExpanded] = useState(false); const completedCount = tasks.filter((t) => t.completed).length; const claimableCount = tasks.filter((t) => t.completed && !t.claimed).length; if (!expanded) { return ( ); } return (
⭐ Daily Tasks
{tasks.map((task) => { const done = task.completed; const pct = (task.progress / Math.max(1, task.objectiveCount)) * 100; const canClaim = task.completed && !task.claimed; return (
{task.claimed ? '\u2705 ' : done ? '\u2714 ' : ''}{task.title} {task.progress}/{task.objectiveCount}
{task.rewardAmount > 0 && (
+{task.rewardAmount} {task.rewardType}
)} {canClaim && ( )}
); })} {tasks.length === 0 && (
No daily tasks available
)}
); }