import Link from 'next/link'; import { calculateSaju } from '@/lib/saju-calculator'; import PDFButton from '../components/PDFButton'; import Header from '@/components/Header'; import Footer from '@/components/Footer'; interface PageProps { searchParams: Promise<{ year: string; month: string; day: string; hour?: string; gender: 'male' | 'female'; calendarType: 'solar' | 'lunar'; }>; } export default async function FortunePage({ searchParams }: PageProps) { const params = await searchParams; const { year, month, day, hour, gender } = params; const yearNum = parseInt(year); const monthNum = parseInt(month); const dayNum = parseInt(day); const hourNum = hour ? parseInt(hour) : null; const sajuData = calculateSaju(yearNum, monthNum, dayNum, hourNum, gender); // 오늘 날짜 const today = new Date(); const todayYear = today.getFullYear(); const todayMonth = today.getMonth() + 1; const todayDay = today.getDate(); // 오늘의 간지 계산 (시간은 12시로 고정) const todayGanzi = calculateSaju(todayYear, todayMonth, todayDay, 12, gender); // 안전하게 stem 접근 const todayStem = todayGanzi?.day?.stem || '甲'; const todayBranch = todayGanzi?.day?.branch || '子'; const userStem = sajuData?.day?.stem || '甲'; // 운세 점수 계산 (간단한 알고리즘) const calculateFortuneScore = (category: string): number => { const seed = userStem.charCodeAt(0) + todayStem.charCodeAt(0) + category.charCodeAt(0); return 60 + (seed % 40); }; const fortuneCategories = [ { name: '종합운', icon: '⭐', score: calculateFortuneScore('종합'), color: 'bg-gradient-to-r from-[#173658] to-[#1e426a]' }, { name: '금전운', icon: '💰', score: calculateFortuneScore('금전'), color: 'bg-gradient-to-r from-green-600 to-emerald-600' }, { name: '애정운', icon: '💕', score: calculateFortuneScore('애정'), color: 'bg-gradient-to-r from-pink-600 to-rose-600' }, { name: '건강운', icon: '🏥', score: calculateFortuneScore('건강'), color: 'bg-gradient-to-r from-red-600 to-orange-600' }, { name: '직장운', icon: '💼', score: calculateFortuneScore('직장'), color: 'bg-gradient-to-r from-blue-600 to-cyan-600' }, { name: '학업운', icon: '📚', score: calculateFortuneScore('학업'), color: 'bg-gradient-to-r from-purple-600 to-indigo-600' }, ]; 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-green-600'; if (score >= 80) return 'text-blue-600'; if (score >= 70) return 'text-yellow-600'; if (score >= 60) return 'text-orange-600'; return 'text-red-600'; }; // 행운의 방향과 색깔 (일간 기준) const getLuckyDirection = (stem: string): string => { const directions: { [key: string]: string } = { '甲': '동쪽', '乙': '동쪽', '丙': '남쪽', '丁': '남쪽', '戊': '중앙', '己': '중앙', '庚': '서쪽', '辛': '서쪽', '壬': '북쪽', '癸': '북쪽', }; return directions[stem] || '동쪽'; }; const getLuckyColor = (element: string): string => { const colors: { [key: string]: string } = { '木': '녹색', '火': '빨강색', '土': '노란색', '金': '흰색', '水': '검정색', }; return colors[element] || '녹색'; }; const getLuckyNumber = (stem: string): number => { return (stem.charCodeAt(0) % 9) + 1; }; return (
{/* Content */}
{/* Header */}

오늘의 운세

{todayYear}년 {todayMonth}월 {todayDay}일 ({todayStem}{todayBranch})

{sajuData.birthDate.year}년생 {gender === 'male' ? '남성' : '여성'}의 오늘 운세

{/* 운세 점수 카드들 */}
{fortuneCategories.map((category) => (
{category.icon}

{category.name}

{category.score}점

{getScoreText(category.score)}

))}
{/* 오늘의 한마디 */}

💬 오늘의 한마디

{sajuData.day.element === '木' && '나무가 자라듯 꾸준히 노력하면 좋은 결과가 있을 것입니다. 새로운 시작에 좋은 날입니다.'} {sajuData.day.element === '火' && '활발한 기운이 가득한 날입니다. 적극적으로 행동하면 좋은 기회를 잡을 수 있습니다.'} {sajuData.day.element === '土' && '안정적인 하루가 될 것입니다. 차근차근 계획을 세우고 실행하면 좋습니다.'} {sajuData.day.element === '金' && '명확한 판단이 필요한 날입니다. 원칙을 지키며 행동하면 좋은 결과가 있을 것입니다.'} {sajuData.day.element === '水' && '유연한 사고가 도움이 되는 날입니다. 주변 사람들과의 소통을 중요하게 여기세요.'}

{/* 행운의 요소들 */}
{/* 행운의 방향 */}
🧭

행운의 방향

{getLuckyDirection(userStem)}

이 방향으로 외출하면 좋습니다

{/* 행운의 색깔 */}
🎨

행운의 색깔

{getLuckyColor(sajuData.day.element)}

이 색깔의 옷을 입으면 좋습니다

{/* 행운의 숫자 */}
🎲

행운의 숫자

{getLuckyNumber(userStem)}

오늘의 행운을 가져다 줄 숫자

{/* 주의사항 */}

⚠️ 오늘 주의할 점

  • 중요한 결정은 오전보다 오후에 하는 것이 좋습니다.
  • 감정적인 대화는 피하고 침착하게 대응하세요.
  • 건강 관리에 신경 쓰고 무리하지 마세요.
{/* 다른 메뉴 */}
📜

사주팔자

내 사주 다시 보기

💕

궁합 보기

두 사람의 궁합 확인

🎋

토정비결

한 해의 운세 보기

); }