import Link from 'next/link'; import { calculateSaju } from '@/lib/saju-calculator'; import PDFButton from '../../components/PDFButton'; import ShareButtons from '../../components/ShareButtons'; import TojeongDetailUnlock from './TojeongDetailUnlock'; interface PageProps { searchParams: Promise<{ year: string; month: string; day: string; gender: 'male' | 'female'; targetYear: string; }>; } export default async function TojeongResultPage({ searchParams }: PageProps) { const params = await searchParams; const { year, month, day, gender, targetYear } = params; const birthYear = parseInt(year); const birthMonth = parseInt(month); const birthDay = parseInt(day); const targetYearNum = parseInt(targetYear); // 사주 계산 const sajuData = calculateSaju(birthYear, birthMonth, birthDay, null, gender); // 토정비결 점수 계산 (간단한 알고리즘) const calculateTojeongScore = (monthIndex: number): number => { const seed = sajuData.day.stem.charCodeAt(0) + sajuData.day.branch.charCodeAt(0) + targetYearNum + monthIndex; return 60 + (seed % 35); }; const months = [ '1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월' ]; const monthlyFortunes = months.map((month, index) => ({ month, score: calculateTojeongScore(index + 1), wealth: calculateTojeongScore(index + 100), health: calculateTojeongScore(index + 200), career: calculateTojeongScore(index + 300), })); const getScoreText = (score: number): string => { if (score >= 90) return '대길 (大吉)'; if (score >= 80) return '길 (吉)'; if (score >= 70) return '중길 (中吉)'; if (score >= 60) return '소길 (小吉)'; return '평 (平)'; }; const getScoreColor = (score: number): string => { if (score >= 90) return 'text-red-600'; if (score >= 80) return 'text-orange-600'; if (score >= 70) return 'text-yellow-600'; if (score >= 60) return 'text-green-600'; return 'text-gray-600'; }; const getScoreBgColor = (score: number): string => { if (score >= 90) return 'bg-red-50'; if (score >= 80) return 'bg-orange-50'; if (score >= 70) return 'bg-yellow-50'; if (score >= 60) return 'bg-green-50'; return 'bg-gray-50'; }; // 전체 운세 평균 const averageScore = Math.round( monthlyFortunes.reduce((sum, f) => sum + f.score, 0) / 12 ); return (
{/* Navigation */} {/* Content */}
{/* Header */}

🎋 {targetYear}년 토정비결

{birthYear}년 {birthMonth}월 {birthDay}일생 {gender === 'male' ? '남성' : '여성'}

일간: {sajuData.day.stem}({sajuData.day.stemKr}) | {sajuData.day.element}

{/* 연간 종합 운세 */}

📅 연간 종합 운세

{averageScore}점
{getScoreText(averageScore)}

{averageScore >= 85 && `${targetYear}년은 매우 좋은 한 해가 될 것입니다. 하고자 하는 일에 적극적으로 도전하세요.`} {averageScore >= 75 && averageScore < 85 && `${targetYear}년은 전반적으로 좋은 운이 함께합니다. 꾸준히 노력하면 좋은 결과가 있을 것입니다.`} {averageScore >= 65 && averageScore < 75 && `${targetYear}년은 안정적인 한 해입니다. 무리하지 말고 차근차근 진행하세요.`} {averageScore < 65 && `${targetYear}년은 신중함이 필요한 해입니다. 중요한 결정은 충분히 고민한 후 진행하세요.`}

{/* 분야별 연간 운세 */}

분야별 연간 운세

{/* 재물운 */}
💰

재물운

財物運

{Math.round(monthlyFortunes.reduce((sum, f) => sum + f.wealth, 0) / 12)}점

{sajuData.day.element === '金' && '금전적으로 안정된 한 해입니다. 저축과 투자에 좋습니다.'} {sajuData.day.element === '木' && '새로운 수입원이 생길 수 있습니다. 적극적으로 기회를 찾으세요.'} {sajuData.day.element === '水' && '재물의 흐름이 좋습니다. 계획적인 지출이 중요합니다.'} {sajuData.day.element === '火' && '투자보다는 안정적인 재테크가 좋습니다.'} {sajuData.day.element === '土' && '꾸준한 노력으로 재물이 쌓이는 해입니다.'}

{/* 건강운 */}
🏥

건강운

健康運

{Math.round(monthlyFortunes.reduce((sum, f) => sum + f.health, 0) / 12)}점

전반적으로 건강한 한 해입니다. 규칙적인 운동과 식습관 관리로 더욱 좋은 건강을 유지하세요.

{/* 관운 (직장/사업) */}
💼

관운

官運 (직장/사업)

{Math.round(monthlyFortunes.reduce((sum, f) => sum + f.career, 0) / 12)}점

{sajuData.day.tenGod === '정관' && '승진이나 좋은 기회가 올 수 있습니다.'} {sajuData.day.tenGod === '편관' && '새로운 도전이 기다리고 있습니다.'} {sajuData.day.tenGod === '정재' && '안정적인 직장생활이 예상됩니다.'} {sajuData.day.tenGod === '편재' && '새로운 사업 기회를 잘 살펴보세요.'} 열심히 노력하면 좋은 결과가 있을 것입니다.

{/* 애정운 */}
💕

애정운

愛情運

{Math.round((monthlyFortunes.reduce((sum, f) => sum + f.score, 0) / 12 + monthlyFortunes.reduce((sum, f) => sum + f.wealth, 0) / 12) / 2)}점

{gender === 'male' ? '좋은 인연을 만날 기회가 있습니다.' : '따뜻한 사랑이 함께하는 해입니다.'} 진심으로 상대를 대하면 좋은 관계를 유지할 수 있습니다.

{/* 월별 운세 */}

📆 월별 운세

{monthlyFortunes.map((fortune, index) => (
= 80 ? 'border-orange-200' : 'border-gray-200' }`} >

{fortune.month}

{fortune.score}
{getScoreText(fortune.score)}
💰 재물: {fortune.wealth}점
🏥 건강: {fortune.health}점
💼 직장: {fortune.career}점
))}
{/* 조언 - 토큰 잠금 영역 */}

💡 {targetYear}년 한 해를 위한 조언

  • 운이 좋은 달에는 적극적으로 새로운 일을 시작하세요.
  • 운이 낮은 달에는 무리하지 말고 현상 유지에 집중하세요.
  • 매사에 감사하는 마음을 가지고 긍정적으로 생활하세요.
  • 토정비결은 참고사항이며, 자신의 노력이 가장 중요합니다.
{/* 다른 메뉴 */}
🎋

다시 보기

다른 년도 확인하기

📜

사주 보기

내 사주 확인하기

{/* Footer */}
); }