import { calculateSaju } from '@/lib/saju-calculator'; import Link from 'next/link'; import PDFButton from '../components/PDFButton'; import ShareButtons from '../components/ShareButtons'; import Header from '@/components/Header'; import Footer from '@/components/Footer'; import { calculateDaeun, getCurrentDaeun, getDaeunDescription } from '@/lib/daeun-calculator'; import { getCurrentSolarTerm, getSolarTermName, getSolarTermMonthBranch } from '@/lib/solar-terms'; import { EARTHLY_BRANCHES_KR, FIVE_ELEMENTS_KR, FIVE_ELEMENTS } from '@/lib/saju-calculator'; import { calculateElementScore, performFullAnalysis } from '@/lib/ai-interpretation'; import AiInterpretationSection from '@/components/AiInterpretationSection'; interface PageProps { searchParams: Promise<{ year: string; month: string; day: string; hour?: string; gender: 'male' | 'female'; calendarType: 'solar' | 'lunar'; originalYear?: string; originalMonth?: string; originalDay?: string; isLeapMonth?: string; }>; } export default async function ResultPage({ searchParams }: PageProps) { const params = await searchParams; const { year, month, day, hour, gender, calendarType, originalYear, originalMonth, originalDay, isLeapMonth } = params; const yearNum = parseInt(year); const monthNum = parseInt(month); const dayNum = parseInt(day); const hourNum = hour ? parseInt(hour) : null; const inputYear = originalYear ? parseInt(originalYear) : yearNum; const inputMonth = originalMonth ? parseInt(originalMonth) : monthNum; const inputDay = originalDay ? parseInt(originalDay) : dayNum; const isLunar = calendarType === 'lunar'; const isLeap = isLeapMonth === 'true'; const sajuData = calculateSaju(yearNum, monthNum, dayNum, hourNum, gender); // 절기 정보 const solarTermIndex = getCurrentSolarTerm(yearNum, monthNum, dayNum); const solarTermName = getSolarTermName(solarTermIndex); const monthBranchIndex = getSolarTermMonthBranch(yearNum, monthNum, dayNum); const monthBranchName = EARTHLY_BRANCHES_KR[monthBranchIndex]; // 종합 분석 수행 const analysis = performFullAnalysis(sajuData); const elementScores = analysis.elementScores; // 대운 계산 const daeunList = calculateDaeun( yearNum, monthNum, dayNum, gender, sajuData.month.stem, sajuData.month.branch ); const currentYear = new Date().getFullYear(); const currentDaeun = getCurrentDaeun(daeunList, currentYear); // 오행 색상 매핑 (새 디자인) const elementColors: { [key: string]: string } = { '木': 'text-green-700', '火': 'text-red-600', '土': 'text-yellow-700', '金': 'text-[#d4af37]', '水': 'text-blue-700', }; const elementBgColors: { [key: string]: string } = { '木': 'bg-green-50 border-green-400', '火': 'bg-red-50 border-red-400', '土': 'bg-yellow-50 border-yellow-400', '金': 'bg-[#F3E7E3] border-[#d4af37]', '水': 'bg-blue-50 border-blue-400', }; // 띠 계산 const zodiacAnimals = ['쥐', '소', '호랑이', '토끼', '용', '뱀', '말', '양', '원숭이', '닭', '개', '돼지']; const zodiacIndex = (yearNum - 4) % 12; const zodiacAnimal = zodiacAnimals[zodiacIndex >= 0 ? zodiacIndex : zodiacIndex + 12]; return (
{/* 2컬럼 레이아웃 */}
{/* 사이드바 - 입력 정보 */} {/* 메인 콘텐츠 */}
{/* 페이지 헤더 */}

사주팔자 감정서

전통 명리학과 AI 기술의 만남

{/* 사주팔자 표 */}

사주팔자 (四柱八字)

{sajuData.hour && } {/* 천간 */} {sajuData.hour && ( )} {/* 지지 */} {sajuData.hour && ( )} {/* 지장간 */} {(() => { const pillars = sajuData.hour ? [analysis.hiddenStems.find(h => h.pillar === '시주'), analysis.hiddenStems.find(h => h.pillar === '일주'), analysis.hiddenStems.find(h => h.pillar === '월주'), analysis.hiddenStems.find(h => h.pillar === '년주')] : [analysis.hiddenStems.find(h => h.pillar === '일주'), analysis.hiddenStems.find(h => h.pillar === '월주'), analysis.hiddenStems.find(h => h.pillar === '년주')]; return pillars.map((h, idx) => ( )); })()} {/* 십성 */} {sajuData.hour && ( )} {/* 십이운성 */} {sajuData.hour && ( )}
구분시주일주 월주 년주
천간
{sajuData.hour.stem}
{sajuData.hour.stemKr}
{sajuData.day.stem}
{sajuData.day.stemKr}
일간
{sajuData.month.stem}
{sajuData.month.stemKr}
{sajuData.year.stem}
{sajuData.year.stemKr}
지지
{sajuData.hour.branch}
{sajuData.hour.branchKr}
{sajuData.day.branch}
{sajuData.day.branchKr}
{sajuData.month.branch}
{sajuData.month.branchKr}
{sajuData.year.branch}
{sajuData.year.branchKr}
지장간
숨은 천간
{h && (
{h.stems.map((s, si) => ( {s.stemKr} ))}
)}
십성
{sajuData.hour.tenGod}
{sajuData.day.tenGod}
{sajuData.month.tenGod}
{sajuData.year.tenGod}
십이운성
{sajuData.hour.fortune}
{sajuData.day.fortune}
{sajuData.month.fortune}
{sajuData.year.fortune}
{/* 지지 상호작용 */} {analysis.branchInteractions.length > 0 && (

지지 상호작용

{analysis.branchInteractions.map((inter, idx) => { const isPositive = inter.type.includes('합'); const isNegative = inter.type.includes('충') || inter.type.includes('형'); const colorClass = isPositive ? 'bg-emerald-50 border-emerald-400 text-emerald-800' : isNegative ? 'bg-red-50 border-red-400 text-red-800' : 'bg-amber-50 border-amber-400 text-amber-800'; return ( {inter.type} {inter.branchesKr.join('')} {inter.resultElement && ` → ${FIVE_ELEMENTS_KR[inter.resultElement as keyof typeof FIVE_ELEMENTS_KR]}`} ); })}
)} {/* 오행 균형 */}

오행 균형

{Object.entries(elementScores).map(([element, score]) => (
{element}
{FIVE_ELEMENTS_KR[element as keyof typeof FIVE_ELEMENTS_KR]}
{score}%
))}
{/* 분석 카드 그리드 */}
{/* 신강/신약 + 용신 카드 */}

일간 세력 분석

{analysis.dayMasterStrength.result} 점수: {analysis.dayMasterStrength.score}
    {analysis.dayMasterStrength.reasons.map((r, i) => (
  • - {r}
  • ))}

용신 / 희신 / 기신

용신: {analysis.yongShin.yongShinKr} 희신: {analysis.yongShin.heeShinKr} 기신: {analysis.yongShin.giShinKr}

{analysis.yongShin.explanation}

{/* 신살 + 공망 카드 */}

신살 (神煞)

{analysis.shinsal.length > 0 ? (
{analysis.shinsal.map((s, i) => (
{s.name}
{s.pillar} {s.branchKr}
{s.description}
))}
) : (

특별한 신살이 발견되지 않았습니다.

)}

공망 (空亡)

{analysis.gongmang.branchesKr.map((bk, i) => ( {bk} ))}

{analysis.gongmang.description}

{/* 세운 정보 */}

{analysis.seun.year}년 세운

{analysis.seun.stemKr}{analysis.seun.branchKr} {analysis.seun.elementKr} 기운
{analysis.seun.interactions.length > 0 && (
{analysis.seun.interactions.map((si, i) => ( {si.type} {si.branchesKr.join('')} ))}
)}
{/* AI 상세 해석 */} {/* 대운 (大運) */}

대운 (大運) - 10년 주기 운세

{currentDaeun && (

현재 대운

{currentDaeun.stem}{currentDaeun.branch}
{currentDaeun.stemKr}{currentDaeun.branchKr}
{currentDaeun.age}세 ~ {currentDaeun.age + 9}세 ({currentDaeun.startYear}년 ~ {currentDaeun.endYear}년)

{getDaeunDescription(currentDaeun, sajuData.day.stem)}

)}
{daeunList.map((daeun, index) => { const isCurrent = currentDaeun && daeun.startYear === currentDaeun.startYear && daeun.endYear === currentDaeun.endYear; return (
{daeun.stem}{daeun.branch}
{daeun.stemKr}{daeun.branchKr}
{daeun.age}세 ~ {daeun.age + 9}세
{daeun.startYear} ~ {daeun.endYear}
{isCurrent && (
현재
)}
); })}
{/* 추가 기능 버튼 */}
🌟

오늘의 운세

오늘의 운을 확인하기

💕

궁합 보기

두 사람의 궁합 확인

); }