6.2.0: Срок разблокировки в днях в карточках желаний
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m4s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m4s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "play-life-web",
|
||||
"version": "6.1.0",
|
||||
"version": "6.2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user