import Link from 'next/link'; import { calculateSaju, FIVE_ELEMENTS } from '@/lib/saju-calculator'; interface PageProps { searchParams: Promise<{ year1: string; month1: string; day1: string; hour1?: string; gender1: 'male' | 'female'; year2: string; month2: string; day2: string; hour2?: string; gender2: 'male' | 'female'; }>; } export default async function CompatibilityResultPage({ searchParams }: PageProps) { const params = await searchParams; const { year1, month1, day1, hour1, gender1, year2, month2, day2, hour2, gender2 } = params; // Person 1 Saju const saju1 = calculateSaju( parseInt(year1), parseInt(month1), parseInt(day1), hour1 ? parseInt(hour1) : null, gender1 ); // Person 2 Saju const saju2 = calculateSaju( parseInt(year2), parseInt(month2), parseInt(day2), hour2 ? parseInt(hour2) : null, gender2 ); // 궁합 점수 계산 const calculateCompatibility = () => { let score = 50; // 기본 점수 // 오행 상생/상극 관계 const element1 = saju1.day.element; const element2 = saju2.day.element; const produceMap: { [key: string]: string } = { '木': '火', '火': '土', '土': '金', '金': '水', '水': '木' }; const overcomeMap: { [key: string]: string } = { '木': '土', '火': '金', '土': '水', '金': '木', '水': '火' }; // 같은 오행: 보통 if (element1 === element2) { score += 10; } // 상생 관계: 매우 좋음 else if (produceMap[element1] === element2 || produceMap[element2] === element1) { score += 25; } // 상극 관계: 주의 필요 else if (overcomeMap[element1] === element2 || overcomeMap[element2] === element1) { score -= 10; } // 지지 삼합/육합 관계 확인 const branch1 = saju1.day.branch; const branch2 = saju2.day.branch; // 육합 (六合) - 특별히 좋은 궁합 const sixHarmony: { [key: string]: string } = { '子': '丑', '丑': '子', '寅': '亥', '亥': '寅', '卯': '戌', '戌': '卯', '辰': '酉', '酉': '辰', '巳': '申', '申': '巳', '午': '未', '未': '午' }; if (sixHarmony[branch1] === branch2) { score += 20; } // 삼합 (三合) - 좋은 궁합 const threeHarmony = [ ['申', '子', '辰'], // 수국 ['寅', '午', '戌'], // 화국 ['亥', '卯', '未'], // 목국 ['巳', '酉', '丑'] // 금국 ]; for (const harmony of threeHarmony) { if (harmony.includes(branch1) && harmony.includes(branch2)) { score += 15; break; } } // 충 (沖) - 나쁜 궁합 const conflict: { [key: string]: string } = { '子': '午', '午': '子', '丑': '未', '未': '丑', '寅': '申', '申': '寅', '卯': '酉', '酉': '卯', '辰': '戌', '戌': '辰', '巳': '亥', '亥': '巳' }; if (conflict[branch1] === branch2) { score -= 20; } return Math.min(100, Math.max(0, score)); }; const compatibilityScore = calculateCompatibility(); const getScoreGrade = (score: number): string => { if (score >= 90) return 'S'; if (score >= 80) return 'A'; if (score >= 70) return 'B'; if (score >= 60) return 'C'; return 'D'; }; 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 'from-pink-500 to-red-500'; if (score >= 80) return 'from-pink-400 to-purple-400'; if (score >= 70) return 'from-purple-400 to-indigo-400'; if (score >= 60) return 'from-indigo-400 to-blue-400'; return 'from-gray-400 to-gray-500'; }; // 세부 궁합 점수 const detailedScores = [ { name: '연애운', score: compatibilityScore + Math.floor(Math.random() * 10 - 5), icon: '💑' }, { name: '결혼운', score: compatibilityScore + Math.floor(Math.random() * 10 - 5), icon: '💍' }, { name: '금전운', score: compatibilityScore + Math.floor(Math.random() * 10 - 5), icon: '💰' }, { name: '사업운', score: compatibilityScore + Math.floor(Math.random() * 10 - 5), icon: '💼' }, ].map(item => ({ ...item, score: Math.min(100, Math.max(0, item.score)) })); return (
{/* Navigation */} {/* Result Content */}
{/* Header */}

💕 궁합 결과

두 사람의 사주팔자를 비교한 결과입니다

{/* 두 사람 정보 */}
{/* Person 1 */}
👤

첫 번째 사람

{saju1.birthDate.year}년 {saju1.birthDate.month}월 {saju1.birthDate.day}일

{gender1 === 'male' ? '남성' : '여성'}

일간 (日干)

{saju1.day.stem} ({saju1.day.stemKr})

{saju1.day.element} ({['木', '火', '土', '金', '水'].indexOf(saju1.day.element) >= 0 ? ['목', '화', '토', '금', '수'][['木', '火', '土', '金', '水'].indexOf(saju1.day.element)] : ''})

{/* Person 2 */}
👤

두 번째 사람

{saju2.birthDate.year}년 {saju2.birthDate.month}월 {saju2.birthDate.day}일

{gender2 === 'male' ? '남성' : '여성'}

일간 (日干)

{saju2.day.stem} ({saju2.day.stemKr})

{saju2.day.element} ({['木', '火', '土', '金', '水'].indexOf(saju2.day.element) >= 0 ? ['목', '화', '토', '금', '수'][['木', '火', '土', '金', '水'].indexOf(saju2.day.element)] : ''})

{/* 총합 궁합 점수 */}

종합 궁합 점수

{compatibilityScore}
{getScoreGrade(compatibilityScore)}
{getScoreText(compatibilityScore)}
{/* 세부 궁합 */}

세부 궁합

{detailedScores.map((item) => (
{item.icon}

{item.name}

{item.score}점
))}
{/* 궁합 해석 */}
{/* 장점 */}

두 사람의 장점

  • 서로의 부족한 점을 잘 보완해줄 수 있습니다.
  • 대화와 소통이 원활하게 이루어질 수 있습니다.
  • 함께 있을 때 편안함을 느낄 수 있습니다.
{/* 주의점 */}

⚠️ 주의할 점

  • 서로의 가치관 차이를 이해하려는 노력이 필요합니다.
  • 감정적인 대화보다는 이성적인 대화를 나누세요.
  • 작은 문제도 소통으로 해결하려는 자세가 중요합니다.
{/* 조언 */}

💡 조언

궁합은 참고사항일 뿐입니다. 서로를 이해하고 존중하며 노력한다면 어떤 궁합이든 행복한 관계를 만들 수 있습니다. 사주는 가능성을 보여줄 뿐, 최종 결정은 두 사람의 마음과 노력에 달려있습니다.

{/* 다른 메뉴 */}
💕

다시 보기

다른 궁합 확인하기

📜

사주 보기

내 사주 확인하기

{/* Footer */}
); }