diff --git a/VERSION b/VERSION index dfda3e0..6abaeb2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.1.0 +6.2.0 diff --git a/play-life-web/package.json b/play-life-web/package.json index b87c053..0660101 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "6.1.0", + "version": "6.2.0", "type": "module", "scripts": { "dev": "vite", diff --git a/play-life-web/src/components/CurrentWeek.jsx b/play-life-web/src/components/CurrentWeek.jsx index d9c73e9..b79d8cb 100644 --- a/play-life-web/src/components/CurrentWeek.jsx +++ b/play-life-web/src/components/CurrentWeek.jsx @@ -141,7 +141,7 @@ function MiniWishCard({ wish, onClick, pendingScoresByProject = {} }) { } // Компонент карточки желания в виде строки (для отображения 1-2 желаний) -function WishRowCard({ wish, onClick, pendingScoresByProject = {}, position }) { +function WishRowCard({ wish, onClick, pendingScoresByProject = {}, position, minGoalScore }) { const handleClick = (e) => { e.stopPropagation() if (onClick) { @@ -156,15 +156,35 @@ function WishRowCard({ wish, onClick, pendingScoresByProject = {}, position }) { const projectId = cond?.project_id const pending = (projectId != null && pendingScoresByProject[projectId] != null) ? Number(pendingScoresByProject[projectId]) : 0 const remaining = isPointsCondition ? (required - current - pending) : 0 - const weeksText = cond?.weeks_text || '' + + const formatDaysText = (days) => { + if (days < 1) return '<1 дня' + const daysRounded = Math.round(days) + const lastDigit = daysRounded % 10 + const lastTwoDigits = daysRounded % 100 + let dayWord + if (lastTwoDigits >= 11 && lastTwoDigits <= 14) { + dayWord = 'дней' + } else if (lastDigit === 1) { + dayWord = 'день' + } else if (lastDigit >= 2 && lastDigit <= 4) { + dayWord = 'дня' + } else { + dayWord = 'дней' + } + return `${daysRounded} ${dayWord}` + } const getUnlockText = () => { if (remaining <= 0) { return 'скоро' } const pointsText = `${Math.round(remaining)} баллов` - if (weeksText) { - return `${pointsText} (${weeksText})` + const safeMinGoal = Number.isFinite(minGoalScore) && minGoalScore > 0 ? minGoalScore : 0 + if (safeMinGoal > 0) { + const weeks = remaining / safeMinGoal + const days = weeks * 7 + return `${pointsText} (${formatDaysText(days)})` } return pointsText } @@ -343,6 +363,7 @@ function ProjectCard({ project, projectColor, onProjectClick, wishes = [], onWis onClick={onWishClick} pendingScoresByProject={pendingScoresByProject || {}} position={position} + minGoalScore={min_goal_score} /> ) })}