6.2.0: Срок разблокировки в днях в карточках желаний
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m4s

This commit is contained in:
poignatov
2026-03-05 18:34:40 +03:00
parent 7c5b80b314
commit 25317997e5
3 changed files with 27 additions and 6 deletions

View File

@@ -1 +1 @@
6.1.0 6.2.0

View File

@@ -1,6 +1,6 @@
{ {
"name": "play-life-web", "name": "play-life-web",
"version": "6.1.0", "version": "6.2.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@@ -141,7 +141,7 @@ function MiniWishCard({ wish, onClick, pendingScoresByProject = {} }) {
} }
// Компонент карточки желания в виде строки (для отображения 1-2 желаний) // Компонент карточки желания в виде строки (для отображения 1-2 желаний)
function WishRowCard({ wish, onClick, pendingScoresByProject = {}, position }) { function WishRowCard({ wish, onClick, pendingScoresByProject = {}, position, minGoalScore }) {
const handleClick = (e) => { const handleClick = (e) => {
e.stopPropagation() e.stopPropagation()
if (onClick) { if (onClick) {
@@ -156,15 +156,35 @@ function WishRowCard({ wish, onClick, pendingScoresByProject = {}, position }) {
const projectId = cond?.project_id const projectId = cond?.project_id
const pending = (projectId != null && pendingScoresByProject[projectId] != null) ? Number(pendingScoresByProject[projectId]) : 0 const pending = (projectId != null && pendingScoresByProject[projectId] != null) ? Number(pendingScoresByProject[projectId]) : 0
const remaining = isPointsCondition ? (required - current - pending) : 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 = () => { const getUnlockText = () => {
if (remaining <= 0) { if (remaining <= 0) {
return 'скоро' return 'скоро'
} }
const pointsText = `${Math.round(remaining)} баллов` const pointsText = `${Math.round(remaining)} баллов`
if (weeksText) { const safeMinGoal = Number.isFinite(minGoalScore) && minGoalScore > 0 ? minGoalScore : 0
return `${pointsText} (${weeksText})` if (safeMinGoal > 0) {
const weeks = remaining / safeMinGoal
const days = weeks * 7
return `${pointsText} (${formatDaysText(days)})`
} }
return pointsText return pointsText
} }
@@ -343,6 +363,7 @@ function ProjectCard({ project, projectColor, onProjectClick, wishes = [], onWis
onClick={onWishClick} onClick={onWishClick}
pendingScoresByProject={pendingScoresByProject || {}} pendingScoresByProject={pendingScoresByProject || {}}
position={position} position={position}
minGoalScore={min_goal_score}
/> />
) )
})} })}