개체 상세페이지 수정

This commit is contained in:
2025-12-12 17:03:30 +09:00
parent feb795ea91
commit b9117f231b
3 changed files with 47 additions and 11 deletions

View File

@@ -6,6 +6,9 @@ import { Card, CardContent } from "@/components/ui/card"
// 기본 7개 형질
const DEFAULT_TRAITS = ['도체중', '등심단면적', '등지방두께', '근내지방도', '체장', '체고', '등심weight']
// 낮을수록 좋은 형질 (부호 반전 색상 적용)
const NEGATIVE_TRAITS = ['등지방두께']
// 형질명 표시 (전체 이름)
const TRAIT_SHORT_NAMES: Record<string, string> = {
'도체중': '도체중',
@@ -82,12 +85,17 @@ function TraitListView({ traits, cowName }: { traits: Array<{ name: string; shor
</td>
<td className="px-3 sm:px-5 py-4 text-left">
<div className="flex items-center gap-2">
<span className={`text-base sm:text-xl font-bold ${(trait.actualValue ?? 0) > 0
? 'text-green-600'
: (trait.actualValue ?? 0) < 0
? 'text-red-600'
: 'text-muted-foreground'
}`}>
<span className={`text-base sm:text-xl font-bold ${(() => {
const value = trait.actualValue ?? 0
const isNegativeTrait = NEGATIVE_TRAITS.includes(trait.name)
// 등지방두께: 음수가 좋음(녹색), 양수가 나쁨(빨간색)
// 나머지: 양수가 좋음(녹색), 음수가 나쁨(빨간색)
if (value === 0) return 'text-muted-foreground'
if (isNegativeTrait) {
return value < 0 ? 'text-green-600' : 'text-red-600'
}
return value > 0 ? 'text-green-600' : 'text-red-600'
})()}`}>
{trait.actualValue !== undefined ? (
<>{trait.actualValue > 0 ? '+' : ''}{trait.actualValue.toFixed(1)}</>
) : '-'}