Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHXzpsZQxKG9hQmNRfZjRS
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
/* 실매물 판정 tier / 금액 포맷 순수 헬퍼 */
|
|
const C = { green: '#34d399', yellow: '#f59e0b', red: '#f87171', gray: '#94a3b8' };
|
|
|
|
export const SAFETY_TIER_META = Object.freeze({
|
|
'안전': { emoji: '🟢', color: C.green },
|
|
'주의': { emoji: '🟡', color: C.yellow },
|
|
'위험': { emoji: '🔴', color: C.red },
|
|
'보류': { emoji: '⚪', color: C.gray },
|
|
});
|
|
|
|
export const VALUATION_TIER_META = Object.freeze({
|
|
'저평가': { emoji: '🟢', color: C.green },
|
|
'시세': { emoji: '🟡', color: C.yellow },
|
|
'고가': { emoji: '🔴', color: C.red },
|
|
'보류': { emoji: '⚪', color: C.gray },
|
|
});
|
|
|
|
export const tierMeta = (kind, tier) => {
|
|
const map = kind === 'valuation' ? VALUATION_TIER_META : SAFETY_TIER_META;
|
|
if (Object.hasOwn(map, tier)) return { ...map[tier], label: tier };
|
|
return { emoji: '⚪', color: C.gray, label: tier ?? '' };
|
|
};
|
|
|
|
export const formatMoney = (manwon) => {
|
|
if (manwon == null || manwon === '') return '-';
|
|
const n = Number(manwon);
|
|
if (Number.isNaN(n)) return '-';
|
|
const eok = Math.floor(n / 10000);
|
|
const rest = n % 10000;
|
|
if (eok > 0 && rest > 0) return `${eok}억 ${rest.toLocaleString('ko-KR')}만`;
|
|
if (eok > 0) return `${eok}억`;
|
|
return `${n.toLocaleString('ko-KR')}만`;
|
|
};
|
|
|
|
export const formatRatio = (ratio) => {
|
|
if (ratio == null) return '-';
|
|
const n = Number(ratio);
|
|
if (Number.isNaN(n)) return '-';
|
|
return `${(n * 100).toFixed(1)}%`;
|
|
};
|